annotate lisp/w3/w3-parse.el @ 110:fe104dbd9147 r20-1b7

Import from CVS: tag r20-1b7
author cvs
date Mon, 13 Aug 2007 09:19:45 +0200
parents 360340f9fd5f
children 8619ce7e4c50
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1 ;; Created by: Joe Wells, jbw@cs.bu.edu
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Created on: Sat Sep 30 17:25:40 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Filename: w3-parse.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Purpose: Parse HTML and/or SGML for Emacs W3 browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
6 ;; Copyright © 1995, 1996, 1997 Joseph Brian Wells
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
7 ;; Copyright © 1993, 1994, 1995 by William M. Perry (wmperry@cs.indiana.edu)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2 of the License, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
22 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; On November 13, 1995, the license was available at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; <URL:ftp://prep.ai.mit.edu/pub/gnu/COPYING-2.0>. It may still be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; obtainable via that URL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Trying to make the best of an evil speed hack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; Explanation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; Basically, this file provides one big function (w3-parse-buffer) and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; some data structures. However, to avoid code redundancy, I have broken
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; out some common subexpressions of w3-parse-buffer into separate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; functions. I have declared these separate functions with "defsubst" so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; they will be inlined into w3-parse-buffer. Also, I have defined them
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; within eval-when-compile forms, so no definitions will be emitted into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; the .elc file for these separate functions. (They will work normally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; when the uncompiled file is loaded.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; Each of these subfunctions use some scratch variables in a purely local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; fashion. In good software design, I would declare these variables as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; close to their use as possible with "let". However, "let"-binding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; variables is *SLOW* in Emacs Lisp, even when compiled. Since each of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; these functions is executed one or more time during each iteration of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; the main loop, I deemed this too expensive. So the main function does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; the "let"-binding of these variables. However, I still want to declare
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; them close to their use, partially to keep the compiler from crying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; "Wolf!" when there is no danger (well, maybe a little danger :-), so I
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; define some macros for this purpose.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; Also, there are some variables which are updated throughout the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; (remember this is really all one function). Some of the code which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; updates them is located inside the subfunctions. So that the compiler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; will not complain, these variables are defined with defvar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (require 'w3-vars)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
61 (require 'mule-sysdp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defconst w3-p-s-var-list nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 "A list of the scratch variables used by functions called by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 w3-parse-buffer which it is w3-parse-buffer's responsibility to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 \"let\"-bind.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; *** This is unused and does not belong right here anyway.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (defmacro w3-resolve-numeric-entity (ent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 "Return a string representing the numeric entity ENT (&#ENT;)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (` (if (< (, ent) 256)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (char-to-string (, ent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (format "[Too large character: %s]" (, ent)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (defmacro w3-p-s-var-def (var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 "Declare VAR as a scratch variable which w3-parse-buffer must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 \"let\"-bind."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (` (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (defvar (, var))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (or (memq '(, var) w3-p-s-var-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (setq w3-p-s-var-list (cons '(, var) w3-p-s-var-list))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (defmacro w3-p-s-let-bindings (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 "\"let\"-bind all of the variables in w3-p-s-var-list in BODY."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (` (let (, w3-p-s-var-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (,@ body))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (put 'w3-p-s-let-bindings 'lisp-indent-function 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (put 'w3-p-s-let-bindings 'edebug-form-spec t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (defvar w3-p-d-current-element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (put 'w3-p-d-current-element 'variable-documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 "Information structure for the current open element.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (defvar w3-p-d-exceptions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (put 'w3-p-d-exceptions 'variable-documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 "Alist specifying elements (dis)allowed because of an (ex|in)clusion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 exception of some containing element (not necessarily the immediately
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 containing element). Each item specifies a transition for an element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 which overrides that specified by the current element's content model.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 Each item is of the form (TAG ACTION *same ERRORP).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (defvar w3-p-d-in-parsed-marked-section)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (put 'w3-p-d-in-parsed-marked-section 'variable-documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 "Are we in a parsed marked section so that we have to scan for \"]]>\"?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defvar w3-p-d-non-markup-chars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (put 'w3-p-d-non-markup-chars 'variable-documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "The characters that do not indicate the start of markup, in the format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 for an argument to skip-chars-forward.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (defvar w3-p-d-null-end-tag-enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (put 'w3-p-d-null-end-tag-enabled 'variable-documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 "Is the null end tag (\"/\") enabled?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (defvar w3-p-d-open-element-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (put 'w3-p-d-open-element-stack 'variable-documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 "A stack of the currently open elements, with the innermost enclosing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 element on top and the outermost on bottom.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defvar w3-p-d-shortrefs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (put 'w3-p-d-shortrefs 'variable-documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 "An alist of the magic entity reference strings in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 between-tags region and their replacements. Each item is of the format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 \(REGEXP . REPLACEMENT-STRING\). Although in SGML shortrefs normally name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 entities whose value should be used as the replacement, we have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 preexpanded the entities for speed. We have also regexp-quoted the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 strings to be replaced, so they can be used with looking-at. This should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 never be in an element's overrides field unless
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 w3-p-d-shortref-chars is also in the field.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (defvar w3-p-d-shortref-chars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (put 'w3-p-d-shortref-chars 'variable-documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 "A string of the characters which can start shortrefs in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 between-tags region. This must be in a form which can be passed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 skip-chars-forward and must contain exactly the characters which start the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 entries in w3-p-d-shortrefs. If this variable is mentioned in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 overrides field of an element, its handling is magical in that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 variable w3-p-d-non-markup-chars is saved to the element's undo-list and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 updated at the same time. This should never be in an element's overrides
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 field unless w3-p-d-shortrefs is also in the field.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (defvar w3-p-d-tag-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (put 'w3-p-d-tag-name 'variable-documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 "Name of tag we are looking at, as an Emacs Lisp symbol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 Only non-nil when we are looking at a tag.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (defvar w3-p-d-end-tag-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (put 'w3-p-d-end-tag-p 'variable-documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 "Is the tag we are looking at an end tag?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 Only non-nil when we are looking at a tag.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;;; HTML syntax error messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (defvar w3-p-d-debug-url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (put 'w3-p-d-debug-url 'variable-documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 "Whether to print the URL being parsed before an error messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 Only true for the first error message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; The level parameter indicates whether the error is (1) very
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; serious, must be displayed to all users, (2) invalid HTML, but the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; user should only be told if the user has indicated interest, or (3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;; valid HTML which is bad because it appears to rely on the way certain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;; browsers will display it, which should only be displayed to the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;; if they have really asked for it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (defmacro w3-debug-html (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 "Emit a warning message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 These keywords may be used at the beginning of the arguments:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 :mandatory-if sexp -- force printing if sexp evaluates non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 :bad-style -- do not print unless w3-debug-html is 'style.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 :outer -- do not include the current element in the element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 context we report.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 :nocontext -- do not include context where error detected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 The remaining parameters are treated as the body of a progn, the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 which must be a string to use as the error message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (let (mandatory-if bad-style outer nocontext condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (while (memq (car body) '(:mandatory-if :bad-style :outer :nocontext))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (cond ((eq ':mandatory-if (car body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (setq mandatory-if (car (cdr body)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (setq body (cdr (cdr body))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ((eq ':bad-style (car body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (setq bad-style t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (setq body (cdr body)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ((eq ':nocontext (car body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (setq nocontext t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (setq body (cdr body)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ((eq ':outer (car body))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (setq outer t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (setq body (cdr body)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (setq condition (if bad-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 '(eq 'style w3-debug-html)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 'w3-debug-html))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (if mandatory-if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (setq condition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (` (or (, mandatory-if)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (, condition)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (` (if (, condition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (let ((message (progn (,@ body))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (if message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (w3-debug-html-aux message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (,@ (if nocontext
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (list outer nocontext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (if outer '(t)))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;; This is unsatisfactory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (put 'w3-debug-html 'lisp-indent-function 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (put 'w3-debug-html 'edebug-form-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 '([&rest &or ":nocontext" ":outer" [":mandatory-if" form] ":bad-style"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 &rest form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defun w3-debug-html-aux (message &optional outer nocontext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;; We have already determined whether the user should see the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;; message, so don't let w3-warn suppress it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (w3-debug-html t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;; Print the URL before the first error message for a document.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (cond (w3-p-d-debug-url
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (let ((url (url-view-url t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (w3-warn 'html
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (if (or (null url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (string-equal "" url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (format "HTML errors for buffer %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (format "HTML errors for <URL:%s>" url))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (setq w3-p-d-debug-url nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (w3-warn 'html
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (if nocontext
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (concat message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;; Display context information for each error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;; message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 "\n Containing elements: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (w3-open-elements-string (if outer 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 "\n Text around error: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (insert "*ERROR*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (w3-quote-for-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (max (- (point) 27) (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (min (+ (point) 20) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (delete-char -7))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (defun w3-quote-for-string (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (set-buffer (get-buffer-create " w3-quote-whitespace"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (insert string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (insert "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (skip-chars-forward "^\"\\\t\n\r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (not (eobp)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
267 (insert "\\" (cdr (assq (following-char) '((?\" . "\"")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
268 (?\\ . "\\")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
269 (?\t . "t")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
270 (?\n . "n")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
271 (?\r . "r")))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (delete-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (insert "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (buffer-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;;; General entity references and numeric character references.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;; *** MULE conversion?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;; *** I18N HTML support?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (let ((html-entities w3-html-entities))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (while html-entities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (put (car (car html-entities)) 'html-entity-expansion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (cons 'CDATA (if (integerp (cdr (car html-entities)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
288 (char-to-string
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
289 (mule-make-iso-character (cdr (car html-entities))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (cdr (car html-entities)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (setq html-entities (cdr html-entities))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; These are handled differently than the normal HTML entities because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;; we need to define the entities with 'nil instead of 'CDATA so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ;; that they are correctly scanned for new markup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;; from jbw@cs.bu.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;;> Of course, this differs from the specification a bit. The W3C tech
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;;> report defines all of these as SYSTEM entities. This potentially means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;;> that they can be used in more contexts. The method I outlined above
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ;;> means "&smiley;" can only be used in contexts where IMG is a valid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;;> element. I am not sure exactly where it is okay to use a SYSTEM entity.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;;> I think anywhere that data characters are accepted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;; I find this acceptable, as just what the hell are you supposed to do with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;; &computer; as part of a value of a form input when you display it and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ;; submit it?!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (let ((html-entities w3-graphic-entities)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (cur nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (while html-entities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (setq cur (car html-entities)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 html-entities (cdr html-entities))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (put (nth 0 cur) 'html-entity-expansion
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
316 (cons 'nil (format "<img src=\"%s/%s%s\" alt=\"%s\">"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 w3-icon-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (nth 1 cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (if w3-icon-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (concat "." (symbol-name w3-icon-format))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (or (nth 3 cur) (nth 2 cur)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ;; These are the general entities in HTML 3.0 in terms of which the math
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ;; shortrefs are defined:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;; <!ENTITY REF1 STARTTAG "SUP">
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 ;; <!ENTITY REF2 ENDTAG "SUP">
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ;; <!ENTITY REF3 STARTTAG "SUB">
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;; <!ENTITY REF4 ENDTAG "SUB">
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; <!ENTITY REF5 STARTTAG "BOX">
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; <!ENTITY REF6 ENDTAG "BOX">
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;; We're ignoring them because these names should really be local to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ;; DTD and not visible in the document. They might change at any time in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; future HTML standards.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ;; <!--Entities for language-dependent presentation (BIDI and contextual analysis) -->
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;; <!ENTITY zwnj CDATA "&#8204;"-- zero width non-joiner-->
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;; <!ENTITY zwj CDATA "&#8205;"-- zero width joiner-->
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 ;; <!ENTITY lrm CDATA "&#8206;"-- left-to-right mark-->
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ;; <!ENTITY rlm CDATA "&#8207;"-- right-to-left mark-->
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ;; Entity names are case sensitive!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;; & should only be recognized when followed by letter or # and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ;; digit or # and letter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (w3-p-s-var-def w3-p-s-entity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (w3-p-s-var-def w3-p-s-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (w3-p-s-var-def w3-p-s-num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 ;; Destroys free variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ;; w3-p-s-entity, w3-p-s-pos, w3-p-s-num
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 ;; Depends on case-fold-search being t.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (defsubst w3-expand-entity-at-point-maybe ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 ;; We are looking at a &.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 ;; Only &A or &#1 or &#A syntax is special.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ((and (looking-at "&\\([a-z][-a-z0-9.]*\\)[\ ;\n]?") ; \n should be \r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ;; We are looking at a general entity reference, maybe undefined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (setq w3-p-s-entity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (intern (buffer-substring (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 'html-entity-expansion)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ;; If the reference was undefined, then for SGML, we should really
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ;; issue a warning and delete the reference. However, the HTML
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 ;; standard (contradicting the SGML standard) says to leave the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 ;; undefined reference in the text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 ;; We are looking at a defined general entity reference.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (replace-match "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (cond ((eq 'CDATA (car w3-p-s-entity))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;; Leave point after expansion so we don't rescan it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (insert (cdr w3-p-s-entity)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 ((memq (car w3-p-s-entity) '(nil STARTTAG ENDTAG MS MD))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 ;; nil is how I mark ordinary entities.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 ;; The replacement text gets rescanned for all of these.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (setq w3-p-s-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (insert (cdr (assq (car w3-p-s-entity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 '((nil . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (STARTTAG . "<")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (ENDTAG . "</")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (MS . "<![")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (MD . "<!"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (cdr w3-p-s-entity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (cdr (assq (car w3-p-s-entity)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 '((nil . "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (STARTTAG . ">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (ENDTAG . ">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (MS . "]]>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (MD . ">")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (goto-char w3-p-s-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;; *** Strictly speaking, if we parse anything from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ;; replacement text, it must end before the end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ;; replacement text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ((eq 'SDATA (car w3-p-s-entity))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (insert "[Unimplemented SDATA \"%s\"]" (cdr w3-p-s-entity)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 ((eq 'PI (car w3-p-s-entity))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 ;; We are currently ignoring processing instructions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;; *** Strictly speaking, we should issue a warning if this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;; occurs in a attribute value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 ;; *** We don't handle external entities yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (error "[Unimplemented entity: \"%s\"]" w3-p-s-entity))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 ((looking-at "&#[0-9][0-9]*\\([\ ;\n]?\\)") ; \n should be \r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;; We are looking at a numeric character reference.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 ;; Ensure the number is already terminated by a semicolon or carriage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ;; return so we can use "read" to get it as a number quickly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (cond ((= (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 ;; This is very uncommon, so we don't have to be quick here but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ;; rather correct.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (goto-char (match-end 0)) ; same as match-end 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (insert ?\;))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 ;; Set up the match data properly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (looking-at "&#[0-9][0-9]*;")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (forward-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (setq w3-p-s-num (read (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 ;; Always leave point after the expansion of a numeric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ;; character reference, like it were a CDATA entity.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (replace-match "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ;; char-to-string will hopefully do something useful with characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 ;; larger than 255. I think in MULE it does. Is this true?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;; Bill wants to call w3-resolve-numeric-entity here, but I think
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 ;; that functionality belongs in char-to-string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 ;; The largest valid character in the I18N version of HTML is 65533.
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
433 ;; ftp://ds.internic.net/internet-drafts/draft-ietf-html-i18n-01.txt
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
434 ;; wrongo! Apparently, mule doesn't do sane things with char-to-string
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
435 ;; -wmp 7/9/96
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
436 (insert (char-to-string
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
437 (mule-make-iso-character w3-p-s-num))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ((looking-at "&#\\(re\\|rs\\|space\\|tab\\)[\ ;\n]?") ; \n should be \r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (replace-match (assq (upcase (char-after (+ 3 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 '(;; *** Strictly speaking, record end should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 ;; carriage return.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (?E . "\n") ; RE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ;; *** And record start should be line feed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (?S . "") ; RS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (?P . " ") ; SPACE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (?A . "\t")))) ; TAB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;; Leave point after the expansion of a character reference, so it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ;; doesn't get rescanned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 ;; *** Strictly speaking, we should issue a warning for &#foo; if foo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 ;; is not a function character in the SGML declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
453 ((eq ?& (following-char))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ;; We are either looking at an undefined reference or a & that does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ;; not start a reference (in which case we should not have been called).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ;; Skip over the &.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ;; What is the code doing calling us if we're not looking at a "&"?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (error "this should never happen"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;;; Syntax table used in markup declarations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (defvar w3-sgml-md-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (let ((table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (items '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (0 "." 255) ; clear everything
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (?\r " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (?\t " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (?\n " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (32 " ") ; space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (?< "\(>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (?> "\)<")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (?\( "\(\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (?\) "\)\(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (?\[ "\(\]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (?\] "\)\[")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (?\" "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (?\' "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (?a "w" ?z)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (?A "w" ?Z)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (?0 "w" ?9)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (?. "w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ;; "-" can be a character in a NAME, but it is also used in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;; "--" as both a comment start and end within SGML
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;; declarations ("<!" ... ">"). In HTML, it is only used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ;; as a NAME character in the parameter entities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;; Content-Type, HTTP-Method, and style-notations and in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ;; the attribute name http-equiv and in the notation names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;; dsssl-lite and w3c-style. We would like to be able to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 ;; train Emacs to skip over these kinds of comments with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ;; forward-sexp and backward-sexp. Is there any way to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; teach Emacs how to do this? It doesn't seem to be the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ;; case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (?- "w")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (while items
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (let* ((item (car items))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (char (car item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (syntax (car (cdr item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (bound (or (car-safe (cdr-safe (cdr item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (while (<= char bound)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (modify-syntax-entry char syntax table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (setq char (1+ char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (setq items (cdr items)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 "A syntax table for parsing SGML markup declarations.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ;;; Element information data type.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 ;; The element information data type is used in two ways:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 ;; * To store the DTD, there is one element record for each element in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ;; the DTD.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 ;; * To store information for open elements in the current parse tree.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ;; Each such element is initialized by copying the element record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 ;; from the DTD. This means that values in the fields can not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 ;; destructively altered, although of course the fields can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;; changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 ;; The cells in this vector are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 ;; name: the element's name (a generic identifier).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 ;; end-tag-name: a symbol whose name should be the result of prefixing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 ;; the generic-identifier with a slash. This is a convenience value for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ;; interfacing with the display engine which expects a stream of start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 ;; and end tags in this format rather than a tree.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 ;; content-model: a data structure describing what elements or character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 ;; data we expect to find within this element. This is either a symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 ;; listed here:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 ;; EMPTY: no content, no end-tag allowed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ;; CDATA: all data characters until "</[a-z]" is seen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 ;; XCDATA: special non-SGML-standard mode which includes all data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 ;; characters until "</foo" is seen where "foo" is the name of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 ;; element. (for XMP and LISTING)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 ;; XXCDATA: special non-SGML-standard mode which includes all data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 ;; until end-of-entity (end-of-buffer for us). (for PLAINTEXT)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 ;; RCDATA: all data characters until "</[a-z]" is seen, except that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 ;; entities are expanded first, although the expansions are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 ;; scanned for end-tags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 ;; XINHERIT: special non-SGML-standard mode which means to use the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 ;; content model of the containing element instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 ;; or a vector of this structure:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 ;; [(INCLUDES INCSPACEP (((TAG ...) . TRANSITION) ...) DEFAULT) ...]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 ;; where INCLUDES is of the format:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 ;; (TAG ...)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 ;; where each TRANSITION is one of these:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;; (ACTION NEW-STATE ERRORP)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 ;; (ACTION NEW-STATE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 ;; (ACTION)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 ;; where DEFAULT is one of these:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 ;; nil or TRANSITION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 ;; where the meaning of the components is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 ;; INCLUDES is a list of tags for which the transition (*include *same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 ;; nil) applies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 ;; DEFAULT if non-nil is a transition that should be taken when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ;; matching any possibility not explicitly listed in another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 ;; TRANSITION, except for data characters containing only whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 ;; INCSPACEP specifies how to handle data characters which include
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 ;; only whitespace characters. The value is non-nil to indicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;; (*include *same nil) or nil to indicate (*discard *same nil).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 ;; TAG is a symbol corresponding to the start-tag we are looking at,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;; or *data when seeing character data that includes at least one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ;; non-space character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ;; ACTION is one of:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 ;; *close: Close this element and try again using content model of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ;; enclosing element. (Note that this does not apply to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 ;; case of an element being closed by its own end-tag.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ;; *include: Process new element as subelement of this one or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 ;; include data characters directly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 ;; *discard: Discard a start-tag or data characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 ;; *retry: Try again after processing NEW-STATE and ERRORP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 ;; ELEMENT: Open ELEMENT (with default attributes), then try again
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ;; using its content model.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 ;; NEW-STATE (optional, default *same) is the index of the state to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 ;; move to after processing the element or one of these:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ;; *same: no state change occurs.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
607 ;; *next: change the current state + 1.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ;; The initial state is 0. NEW-STATE does not matter if ACTION is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 ;; *close.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 ;; ERRORP (optional, default nil) if non-nil indicates this transition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ;; represents an error. The error message includes this value if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ;; is a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 ;; If no matching transition is found, the default transition is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 ;; (*discard *same "not allowed here").
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ;; overrides: An alist of pairs of the form (VAR REPLACEP . VALUE).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 ;; When this element is opened, the old value of VAR is saved in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 ;; undo-list. If REPLACEP is non-nil, then VAR gets value VALUE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;; otherwise VAR gets value (append VALUE (symbol-value VAR)). Useful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 ;; values for VAR are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ;; w3-p-d-exceptions: See doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ;; w3-p-d-shortrefs: See doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ;; w3-p-d-shortref-chars: See doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;; end-tag-omissible: Whether it is legal to omit the end-tag of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;; element. If an end-tag is inferred for an element whose end tag is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;; not omissible, an error message is given.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;; state: The current state in the content model. Preset to the initial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ;; state of 0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ;; undo-list: an alist of of former values of local variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 ;; of w3-parse-buffer to restore upon closing this element. Each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ;; item on the list is of the format (VAR . VALUE-TO-RESTORE).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;; attributes: an alist of attributes and values. Each item on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 ;; this list is of the format (ATTRIBUTE-NAME . VALUE). Each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 ;; ATTRIBUTE-NAME is a symbol and each attribute value is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 ;; string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ;; content: a list of the accumulated content of the element. While the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 ;; element is open, the list is in order from latest to earliest,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ;; otherwise it is in order from earliest to latest. Each member is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ;; either a string of data characters or a list of the form (NAME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ;; ATTRIBUTES CONTENT), where NAME is the subelement's name, ATTRIBUTES
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 ;; is an alist of the subelement's attribute names (lowercase symbols)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ;; and their values (strings), and CONTENT is the subelement's content.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (defconst w3-element-fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 '(name end-tag-name content-model state overrides undo-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 content attributes end-tag-omissible deprecated))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (let* ((fields w3-element-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (index (1- (length fields))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (while fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (let* ((field (symbol-name (car fields)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (get-sym (intern (concat "w3-element-" field)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (set-sym (intern (concat "w3-set-element-" field))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (eval (` (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (defmacro (, get-sym) (element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (list 'aref element (, index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (defmacro (, set-sym) (element value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (list 'aset element (, index) value))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (setq fields (cdr fields))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (setq index (1- index))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (defmacro w3-make-element ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (list 'make-vector (length w3-element-fields) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 ;; *** move this to be with DTD declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (defmacro w3-fresh-element-for-tag (tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (` (copy-sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (or (get (, tag) 'html-element-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (error "unimplemented element %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (w3-sgml-name-to-string (, tag)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 ;; *** move this to be with DTD declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (defmacro w3-known-element-p (tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (` (get (, tag) 'html-element-info)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (defsubst w3-sgml-name-to-string (sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (upcase (symbol-name sym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 ;;; Parse tree manipulation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 ;; ;; Find the name of the previous element or a substring of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 ;; ;; preceding data characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 ;; (let ((content (w3-element-content (car stack))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 ;; (while content
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 ;; (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 ;; ((and (stringp (car content))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 ;; (not (string-match "\\`[ \t\n\r]*\\'" (car content))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 ;; (setq prior-item (car content))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 ;; ;; Trim trailing whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 ;; (if (string-match "\\(.*[^ \t\n\r]\\)[ \t\n\r]*\\'" prior-item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 ;; (setq prior-item (substring prior-item 0 (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 ;; (if (> (length prior-item) 8)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 ;; (setq prior-item (concat "..." (substring prior-item -8))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 ;; (setq prior-item (w3-quote-for-string prior-item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 ;; (setq prior-item (concat "\(after " prior-item "\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 ;; (setq content nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 ;; ((and (consp (car content))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 ;; (symbolp (car (car content))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 ;; (setq prior-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 ;; (concat "\(after "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 ;; (w3-sgml-name-to-string (car (car content)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 ;; "\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 ;; (setq content nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 ;; (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 ;; (setq content (cdr content))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 ;; Only used for HTML debugging.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (defun w3-open-elements-string (&optional skip-count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (let* ((stack (nthcdr (or skip-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (cons w3-p-d-current-element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 w3-p-d-open-element-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 ;;(prior-item "(at start)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 ;; Accumulate the names of the enclosing elements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (while stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (let ((element (w3-element-name (car stack))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (if (eq '*holder element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 ;; Only include *DOCUMENT if there are no other elements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (if (or (not (eq '*document element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (null result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (setq result (cons (w3-sgml-name-to-string element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 result)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (setq stack (cdr stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (setq result (mapconcat 'identity result ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (if result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 ;;(concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 ;; prior-item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 "[nowhere!]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 ;; *** This doesn't really belong here, but where?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (defmacro w3-invalid-sgml-chars ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 "Characters not allowed in an SGML document using the reference
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 concrete syntax (i.e. HTML). Returns a string in the format expected by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 skip-chars-forward."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 "\000-\010\013\014\016-\037\177-\237"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 ;; Uses:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 ;; w3-p-d-null-end-tag-enabled, w3-p-d-in-parsed-marked-section,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 ;; w3-p-d-shortref-chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 ;; Modifies free variable:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 ;; w3-p-d-non-markup-chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (defsubst w3-update-non-markup-chars ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (setq w3-p-d-non-markup-chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (concat "^&<"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (w3-invalid-sgml-chars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (if w3-p-d-null-end-tag-enabled "/" "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (if w3-p-d-in-parsed-marked-section "]" "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (or w3-p-d-shortref-chars ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (w3-p-s-var-def w3-p-s-overrides)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (w3-p-s-var-def w3-p-s-undo-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (w3-p-s-var-def w3-p-s-var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 ;; Uses free variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 ;; w3-p-d-non-markup-chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 ;; Modifies free variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 ;; w3-p-d-current-element, w3-p-d-open-element-stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 ;; Destroys free variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 ;; w3-p-s-overrides, w3-p-s-undo-list, w3-p-s-var
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (defsubst w3-open-element (tag attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 ;; Push new element on stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (setq w3-p-d-open-element-stack (cons w3-p-d-current-element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 w3-p-d-open-element-stack))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (setq w3-p-d-current-element (w3-fresh-element-for-tag tag))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 ;; Warn if deprecated or obsolete.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (if (w3-element-deprecated w3-p-d-current-element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (w3-debug-html :outer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (format "%s element %s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (if (eq 'obsolete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (w3-element-deprecated w3-p-d-current-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 "Obsolete"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 "Deprecated")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (w3-sgml-name-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (w3-element-name w3-p-d-current-element)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 ;; Store attributes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 ;; *** we are not handling #CURRENT attributes (HTML has none).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (w3-set-element-attributes w3-p-d-current-element attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 ;; *** Handle default attribute values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 ;; *** Fix the attribute name for unnamed values. Right now they will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 ;; be in the attribute list as items of the format (VALUE . VALUE) where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 ;; both occurrences of VALUE are the same. The first one needs to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 ;; changed to the proper attribute name by consulting the DTD.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 ;; ********************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 ;; Handle syntax/semantics overrides of new current element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (cond ((w3-element-overrides w3-p-d-current-element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (setq w3-p-s-overrides
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (w3-element-overrides w3-p-d-current-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (setq w3-p-s-undo-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (while w3-p-s-overrides
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (setq w3-p-s-var (car (car w3-p-s-overrides)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (setq w3-p-s-undo-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (cons (cons w3-p-s-var
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (symbol-value w3-p-s-var))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 w3-p-s-undo-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (set w3-p-s-var (if (car (cdr (car w3-p-s-overrides)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (cdr (cdr (car w3-p-s-overrides)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (append (cdr (cdr (car w3-p-s-overrides)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (symbol-value w3-p-s-var))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 ;; *** HACK HACK.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 ;; Magic handling of w3-p-d-shortref-chars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (cond ((eq 'w3-p-d-shortref-chars w3-p-s-var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (setq w3-p-s-undo-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (cons (cons 'w3-p-d-non-markup-chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 w3-p-d-non-markup-chars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 w3-p-s-undo-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (w3-update-non-markup-chars)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (setq w3-p-s-overrides (cdr w3-p-s-overrides)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (w3-set-element-undo-list w3-p-d-current-element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 w3-p-s-undo-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 ;; Handle content-model inheritance. (Very non-SGML!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (if (eq 'XINHERIT (w3-element-content-model w3-p-d-current-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (w3-set-element-content-model
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 w3-p-d-current-element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (w3-element-content-model (car w3-p-d-open-element-stack))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
843 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 ;; The protocol for handing items to the display engine is as follows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 ;; For an element, send (START-TAG . ATTS), each member of the content,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ;; and (END-TAG . nil) if the element is allowed to have an end tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 ;; For data characters, send (text . DATA-CHARACTERS).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 ;; Exceptions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ;; For PLAINTEXT, STYLE, XMP, TEXTAREA send:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 ;; (START-TAG . ((data . DATA-CHARACTERS) . ATTS)).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 ;; *** This requires somehow eliminating any subelements of the TEXTAREA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 ;; element. TEXTAREA can contain subelements in HTML 3.0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 ;; For LISTING, send (text . DATA-CHARACTERS). (Is this really correct or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 ;; is this perhaps a bug in the old parser?) I'm ignoring this for now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (w3-p-s-var-def w3-p-s-undo-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (w3-p-s-var-def w3-p-s-content)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (w3-p-s-var-def w3-p-s-end-tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 ;; Modifies free variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 ;; w3-p-d-current-element, w3-p-d-open-element-stack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 ;; Accesses free variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 ;; w3-p-d-tag-name, w3-p-d-end-tag-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 ;; Destroys free variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 ;; w3-p-s-undo-list, w3-p-s-content, w3-p-s-end-tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (defsubst w3-close-element (&optional inferred)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 ;; inferred: non-nil if the end-tag of the current element is being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 ;; inferred due to the presence of content not allowed in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ;; element. If t, then the tag causing this is in w3-p-d-tag-name and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 ;; w3-p-d-end-tag-p.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 ;; (OLD: ... otherwise it is a symbol indicating the start-tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 ;; of an element or *data or *space indicating data characters.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (cond ((and inferred
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (not (w3-element-end-tag-omissible w3-p-d-current-element)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (w3-debug-html
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (format "</%s> end-tag not omissible (required due to %s)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (w3-sgml-name-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (w3-element-name w3-p-d-current-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (cond ((eq t inferred)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (format (if w3-p-d-end-tag-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 "</%s> end-tag"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 "start-tag for %s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (w3-sgml-name-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 w3-p-d-tag-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 ;; *** Delete this functionality?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 ((memq inferred '(*space *data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 "data characters")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 ((symbolp inferred)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (format "start-tag for %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (w3-sgml-name-to-string inferred)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 ;; Undo any variable bindings of this element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (cond ((w3-element-undo-list w3-p-d-current-element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (setq w3-p-s-undo-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (w3-element-undo-list w3-p-d-current-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (while w3-p-s-undo-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (set (car (car w3-p-s-undo-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (cdr (car w3-p-s-undo-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (setq w3-p-s-undo-list (cdr w3-p-s-undo-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (setq w3-p-s-end-tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (w3-element-end-tag-name w3-p-d-current-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 ;; Fix up the content of the current element in preparation for putting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 ;; it in the parent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 ;; Remove trailing newline from content, if there is one, otherwise send
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 ;; any trailing data character item to display engine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (setq w3-p-s-content (w3-element-content w3-p-d-current-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (cond ((null w3-p-s-content))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 ((equal "\n" (car w3-p-s-content))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (setq w3-p-s-content (cdr w3-p-s-content)))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
922 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
924 (cond ;; *** Handle LISTING the way the old parser did.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ((eq 'EMPTY (w3-element-content-model w3-p-d-current-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 ;; Do nothing, can't have an end tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 ;; Normal case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (if (null w3-p-s-content)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (w3-debug-html
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 :bad-style :outer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 ;; Don't warn for empty TD elements or empty A elements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 ;; with no HREF attribute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 ;; *** Crude hack that should really be encoded in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 ;; element database somehow.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (if (or (not (memq (w3-element-name w3-p-d-current-element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 '(a td)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (assq 'href
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (w3-element-attributes w3-p-d-current-element)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (format "Empty %s element."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (w3-sgml-name-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (w3-element-name w3-p-d-current-element))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 ;; Put the current element in the proper place in its parent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 ;; This will cause an error if we overpop the stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (w3-set-element-content
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (car w3-p-d-open-element-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (cons (list (w3-element-name w3-p-d-current-element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (w3-element-attributes w3-p-d-current-element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (nreverse w3-p-s-content))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (w3-element-content (car w3-p-d-open-element-stack))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 ;; Pop the stack.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (setq w3-p-d-current-element (car w3-p-d-open-element-stack))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (setq w3-p-d-open-element-stack (cdr w3-p-d-open-element-stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 ;;; A pseudo-DTD for HTML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 ;; This works around the following bogus compiler complaint:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 ;; While compiling the end of the data in file w3-parse.el:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 ;; ** the function w3-expand-parameters is not known to be defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 ;; This is a bogus error. Anything of this form will trigger this message:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 ;; (eval-when-compile (defun xyzzy () (xyzzy)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (defun w3-expand-parameters (pars data) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (defun w3-expand-parameters (pars data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (cond ((null data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 ((consp data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 ;; This has to be written carefully to avoid exceeding the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 ;; maximum lisp function call nesting depth.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (let (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (while (consp data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (let ((car-exp (w3-expand-parameters pars (car data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (if (and (symbolp (car data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (not (eq car-exp (car data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 ;; An expansion occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (listp car-exp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 ;; The expansion was a list, which we splice in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (condition-case err
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (append (reverse car-exp) result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (wrong-type-argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (if (eq 'listp (nth 1 err))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 ;; Wasn't really a "list" since the last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 ;; cdr wasn't nil, so don't try to splice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 ;; it in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (cons car-exp result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (signal (car err) (cdr err)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (cons car-exp result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (setq data (cdr data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (append (nreverse result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (w3-expand-parameters pars data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 ((symbolp data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (let ((sym-exp (cdr-safe (assq data pars))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (if sym-exp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (w3-expand-parameters pars sym-exp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 ((vectorp data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (let ((i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (result (copy-sequence data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (while (< i (length data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (aset result i
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (w3-expand-parameters pars (aref data i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (setq i (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 data))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (defun w3-unfold-dtd (items)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (let (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (while items
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (let* ((item (car items))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (names (car item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (content-model
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (or (cdr-safe (assq 'content-model item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (error "impossible")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (overrides (cdr-safe (assq 'overrides item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (end-tag-omissible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (or (cdr-safe (assq 'end-tag-omissible item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 ;; *** Is this SGML standard?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (eq 'EMPTY content-model)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (deprecated (cdr-safe (assq 'deprecated item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (while names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (setq name (car names))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (setq names (cdr names))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 ;; Create and initialize the element information data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 ;; structure.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (setq element (w3-make-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (w3-set-element-name element name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (w3-set-element-end-tag-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (intern (concat "/" (symbol-name name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (w3-set-element-state element 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (w3-set-element-content-model element content-model)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (w3-set-element-end-tag-omissible element end-tag-omissible)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (or (memq deprecated '(nil t obsolete))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (error "impossible"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (w3-set-element-deprecated element deprecated)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 ;; Inclusions and exclusions are specified differently in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 ;; human-coded DTD than in the format the implementation uses.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 ;; The human-coded version is designed to be easy to edit and to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 ;; work with w3-expand-parameters while the internal version is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 ;; designed to be fast. We have to translate here. This work
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 ;; is repeated for every element listed in `names' so that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 ;; exclusion exception error messages can be accurate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (let ((inclusions (cdr-safe (assq 'inclusions item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (exclusions (cdr-safe (assq 'exclusions item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (exclusion-mode '*close)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (exclusion-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (format "%s exclusion" (w3-sgml-name-to-string name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 exceptions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (while inclusions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (setq exceptions (cons (cons (car inclusions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 '(*include *same nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 exceptions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (setq inclusions (cdr inclusions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (while exclusions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (cond ((memq (car exclusions) '(*discard *include *close))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (setq exclusion-mode (car exclusions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 ((stringp (car exclusions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (setq exclusion-message (car exclusions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (setq exceptions (cons (list (car exclusions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 exclusion-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 '*same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 exclusion-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 exceptions))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (setq exclusions (cdr exclusions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (let ((overrides (if exceptions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (cons (cons 'w3-p-d-exceptions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (cons nil exceptions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 overrides)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 overrides)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (w3-set-element-overrides element overrides)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (setq result (cons (cons name element) result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (setq items (cdr items)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 ;; Load the HTML DTD.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 ;; <URL:ftp://ds.internic.net/rfc/rfc1866.txt>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 ;; *** Be sure to incorporate rfc1867 when attribute-checking is added.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 ;; *** Write function to check sanity of the content-model forms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 ;; *** I18N: Add Q, BDO, SPAN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (lambda (pair)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (put (car pair) 'html-element-info (cdr pair))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 ;; The purpose of this complexity is to speed up loading by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 ;; pre-evaluating as much as possible at compile time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (w3-unfold-dtd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (w3-expand-parameters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (%headempty . (link base meta range))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1111 (%headmisc . (script))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (%head-deprecated . (nextid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 ;; client-side imagemaps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (%imagemaps . (area map))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
1116 (%input.fields . (input select textarea keygen label))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 ;; special action is taken for %text inside %body.content in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 ;; content model of each element.
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1119 (%body.content . (%heading %block style hr div address %imagemaps))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (%heading . (h1 h2 h3 h4 h5 h6))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 ;; Emacs-w3 extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (%emacsw3-crud . (pinhead flame cookie yogsothoth hype peek))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1126 (%block . (p %list dl form %preformatted
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 %blockquote isindex fn table fig note
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
1128 multicol center %block-deprecated %block-obsoleted))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (%list . (ul ol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (%preformatted . (pre))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (%blockquote . (bq))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (%block-deprecated . (dir menu blockquote))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (%block-obsoleted . (xmp listing))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 ;; Why is IMG in this list?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (%pre.exclusion . (*include img *discard tab math big small sub sup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
1138 (%text . (*data b %notmath sub sup %emacsw3-crud %input.fields))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (%notmath . (%special %font %phrase %misc))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1140 (%font . (i u s strike tt big small sub sup font
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1141 roach secret wired)) ;; B left out for MATH
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1142 (%phrase . (em strong dfn code samp kbd var cite blink))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1143 (%special . (a img applet object font basefont br script style map math tab span bdo))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1144 (%misc . (q lang au person acronym abbrev ins del))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (%formula . (*data %math))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (%math . (box above below %mathvec root sqrt array sub sup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 %mathface))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (%mathvec . (vec bar dot ddot hat tilde))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (%mathface . (b t bt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (%mathdelims . (over atop choose left right of))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 ;; What the hell? This takes BODYTEXT????? No way!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (%bq-content-model . [(nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (((bodytext) *include *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (bodytext *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (((credit) *include *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (nil nil nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 ])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 ;; non-default bad HTML handling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (%in-text-ignore . ((p %heading) *discard *same error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 ;; A dummy element that will contain *document.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 ((*holder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (content-model . [(nil nil nil nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 ;; The root of the parse tree. We start with a pseudo-element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 ;; named *document for convenience.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 ((*document)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (content-model . [(nil nil (((html) *include *next)) (html *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (*include *same "after document end"))])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 ;; HTML O O (HEAD, BODY)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 ((html)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (content-model . [(nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (((head) *include *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (head *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (((body) *include *next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 ;; Netscape stuff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 ((frameset) *include 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (body *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (((plaintext) *include *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (*retry *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (*include *same "after BODY"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 (*include *same "after FRAMESET"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 ])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 ((head)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1210 (content-model . [((title isindex %headempty %headmisc
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1211 style %head-deprecated)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 ;; *** Should only close if tag can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 ;; legitimately follow head. So many can that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 ;; I haven't bothered to enumerate them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (*close))])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (end-tag-omissible . t))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1219 ;; SCRIPT - - (#PCDATA)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1220 ((script)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1221 (content-model . XCDATA ; not official, but allows
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1222 ; comment hiding of script, and also
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1223 ; idiots that use '</' in scripts.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1224 ))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 ;; TITLE - - (#PCDATA)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 ((title)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (content-model . RCDATA ; not official
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 ;; [((*data) include-space nil nil)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 ;; STYLE - O (#PCDATA)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 ;; STYLE needs to be #PCDATA to allow omitted end tag. Bleagh.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 ((style)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1233 (content-model . CDATA)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 ((body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (content-model . [((banner) nil nil (*retry *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 ((bodytext) nil nil (bodytext *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (nil nil (((plaintext) *close)) nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (inclusions . (spot))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 ;; Do I really want to include BODYTEXT? It has something to do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 ;; with mixed content screwing things up, and I don't understand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 ;; it. Wait! It's used by BQ!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 ((bodytext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (content-model . [((%body.content)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 ;; Push <P> before data characters. Non-SGML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (((%text) p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 ;; Closing when seeing CREDIT is a stupidity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 ;; caused by BQ's sharing of BODYTEXT. BQ
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 ;; should have its own BQTEXT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 ((credit plaintext) *close))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (end-tag-omissible . t))
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
1255 ((div banner center multicol)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (content-model . [((%body.content)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 ;; Push <P> before data characters. Non-SGML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (((%text) p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 ((address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (content-model . [((p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 ;; Push <P> before data characters. Non-SGML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (((%text) p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 ((%heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (content-model . [((%text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 ((%in-text-ignore))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 nil)]))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1272 ((span bdo)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1273 (content-model . [((%text)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1274 include-space
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1275 nil
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1276 nil)])
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1277 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 ((p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (content-model . [((%text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 ;; *** Should only close if tag can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 ;; legitimately follow P. So many can that I
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 ;; don't bother to enumerate here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (*close))])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 ((ul ol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (content-model . [((lh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (((li) *include *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (*retry *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 ((li)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 ;; Push <LI> before data characters or block
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 ;; elements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 ;; Non-SGML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (((%text %block) li *same error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 ((lh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (content-model . [((%text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (((dd dt li) *close)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (%in-text-ignore))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 ((dir menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (content-model . [((li)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (((%text) li *same error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (exclusions . (%block))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 (deprecated . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 ((li)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (content-model . [((%block)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (((li) *close)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 ;; Push <P> before data characters. Non-SGML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 ((%text) p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (end-tag-omissible . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 ;; Better bad HTML handling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 ;; Technically, there are a few valid documents that this will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 ;; hose, because you can have H1 inside FORM inside LI. However,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 ;; I don't think that should be allowed anyway.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (exclusions . (*discard "not allowed here" %heading)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 ((dl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (content-model . [((lh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (((dt dd) *include *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (*retry *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 ((dt dd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 ;; Push <DD> before data characters or block
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 ;; items.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 ;; Non-SGML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (((%text %block) dd *same error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 ((dt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (content-model . [((%text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 (((dd dt) *close)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (%in-text-ignore))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 ;; DD is just like LI, but we treat it separately because it can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 ;; followed by a different set of elements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 ((dd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (content-model . [((%block)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (((dt dd) *close)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 ;; Push <P> before data characters. Non-SGML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 ((%text) p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (end-tag-omissible . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 ;; See comment with LI.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (exclusions . (*discard "not allowed here" %heading)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 ((pre)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (content-model . [((%text hr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 ((%in-text-ignore))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (exclusions . (%pre.exclusion)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 ;; BLOCKQUOTE deprecated, BQ okay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 ((bq)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (content-model . %bq-content-model))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 ((blockquote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (content-model . %bq-content-model)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 ;; BLOCKQUOTE is deprecated in favor of BQ in the HTML 3.0 DTD.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 ;; However, BQ is not even mentioned in the HTML 2.0 DTD. So I
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 ;; don't think we can enable this yet:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 ;;(deprecated . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 ((fn note)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (content-model . [((%body.content)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 ;; Push <P> before data characters. Non-SGML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (((%text) p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 ((fig)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (content-model . [((overlay) nil nil (*retry *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (((caption) *include *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (*retry *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (((figtext) *include *next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 ((credit) *retry *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 ;; *** Should only do this for elements that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 ;; can be in FIGTEXT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (figtext *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (nil nil (((credit) *include *next)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (nil nil nil nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 ((caption credit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (content-model . [((%text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 ((%in-text-ignore))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 ((figtext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (content-model . [((%body.content)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 ;; Push <P> before data characters. Very non-SGML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (((%text) p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 ((credit) *close))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (end-tag-omissible . t))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1407 ((%emacsw3-crud basefont)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (content-model . EMPTY))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 ;; FORM - - %body.content -(FORM) +(INPUT|KEYGEN|SELECT|TEXTAREA)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 ((form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 ;; Same as BODY. Ugh!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (content-model . [((%body.content)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 ;; Push <P> before data characters. Non-SGML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 (((%text) p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (exclusions . (form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (inclusions . (input select textarea keygen label)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 ;; *** Where is the URL describing this?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 ((label)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (content-model . [((%text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 ;; *** These are already included, no need to repeat.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 ;;(inclusions . (input select textarea))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 ;; *** Is a LABEL allowed inside a LABEL? I assume no.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (exclusions . (label))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 ;; The next line just does the default so is unneeded:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 ;;(end-tag-omissible . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 ;; SELECT - - (OPTION+) -(INPUT|KEYGEN|TEXTAREA|SELECT)>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 ;; *** This should be -(everything).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 ((select)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (content-model . [((option) nil nil nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 (exclusions . (input label select keygen textarea)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 ;; option - O (#PCDATA)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 ;; needs to be #PCDATA to allow omitted end tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 ((option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 ;; I'd like to make this RCDATA to avoid problems with inclusions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 ;; like SPOT, but that would conflict with the omitted end-tag, I
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 ;; think.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (content-model . [((*data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (((option) *close))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 ;; TEXTAREA - - (#PCDATA) -(INPUT|TEXTAREA|KEYGEN|SELECT)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 ((textarea)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 ;; Same comment as for OPTION about RCDATA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (content-model . [((*data) include-space nil nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (exclusions . (input select label keygen textarea)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 ((hr br img isindex input keygen overlay wbr spot tab
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 %headempty %mathdelims)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (content-model . EMPTY))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 ((nextid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (content-model . EMPTY)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (deprecated . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 ((a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (content-model . [((%text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (((%heading)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 *include *same "deprecated inside A")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 ;; *** I haven't made up my mind whether this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 ;; is a good idea. It can result in a lot of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 ;; bad formatting if the A is *never* closed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 ;;((p) *discard *same error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (exclusions . (a)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1471 ((b font %font %phrase %misc nobr)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (content-model . [((%text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 ((%in-text-ignore))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 ((plaintext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (content-model . XXCDATA)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (end-tag-omissible . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (deprecated . obsolete))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 ((xmp listing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (content-model . XCDATA)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (deprecated . obsolete))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 ;; Latest table spec (as of Nov. 13 1995) is at:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 ;; <URL:ftp://ds.internic.net/internet-drafts/draft-ietf-html-tables-03.txt>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 ((table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (content-model . [(nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 (((caption) *include *next)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
1489 ((%text) tr *same error)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 ((col colgroup thead tfoot tbody tr) *retry *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (*retry *next)) ;error handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 ((col colgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 (((thead tfoot tbody tr) *retry *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (*retry *next)) ;error handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (((thead) *include *next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 ((tfoot tbody tr) *retry *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (*retry *next)) ;error handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (((tfoot) *include *next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 ((tbody tr) *retry *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (*retry *next)) ;error handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 ((tbody)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (((tr) tbody *same)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 ;; error handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 ((%body.content) tbody *same error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 ((colgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 (content-model . [((col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 (((colgroup thead tfoot tbody tr) *close))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 ((col)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (content-model . EMPTY))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 ((thead)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (content-model . [((tr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (((tfoot tbody) *close)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 ;; error handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 ((%body.content) tr *same error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 ((tfoot tbody)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (content-model . [((tr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (((tbody) *close)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 ;; error handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 ((%body.content) tr *same error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 ((tr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (content-model . [((td th)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (((tr tfoot tbody) *close)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 ;; error handling
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
1541 ((%body.content %text) td *same error))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 ((td th)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 ;; Arrgh! Another %body.content!!! Stupid!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (content-model . [((%body.content)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (((td th tr tfoot tbody) *close)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 ;; Push <P> before data characters. Non-SGML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 ((%text) p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 ((math)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (content-model . [((*data) include-space nil nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 (overrides .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 ((w3-p-d-shortref-chars t . "\{_^")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (w3-p-d-shortrefs t . (("\\^" . "<sup>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 ("_" . "<sub>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 ("{" . "<box>")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 (inclusions . (%math))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (exclusions . (%notmath)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 ((sup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (content-model . [((%text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 ((%in-text-ignore))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (overrides .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 ((w3-p-d-shortref-chars t . "\{_^")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (w3-p-d-shortrefs t . (("\\^" . "</sup>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 ("_" . "<sub>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 ("{" . "<box>"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 ((sub)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (content-model . [((%text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 ((%in-text-ignore))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 (overrides .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 ((w3-p-d-shortref-chars t . "\{_^")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (w3-p-d-shortrefs t . (("\\^" . "<sup>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 ("_" . "</sub>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 ("{" . "<box>"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 ((box)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (content-model . [((%formula)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (((left) *include 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 ((over atop choose) *include 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 ((right) *include 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 ((%formula)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (((over atop choose) *include 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 ((right) *include 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 ((%formula)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (((right) *include 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 ((%formula) include-space nil nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (overrides .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 ((w3-p-d-shortref-chars t . "{}_^")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (w3-p-d-shortrefs t . (("\\^" . "<sup>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 ("_" . "<sub>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 ("{" . "<box>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 ("}" . "</box>"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 ((above below %mathvec t bt sqrt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (content-model . [((%formula) include-space nil nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 ;; ROOT has a badly-specified content-model in HTML 3.0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 ((root)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (content-model . [((%formula)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (((of) *include *next))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 ((%formula) include-space nil nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 ((of)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (content-model . [((%formula) include-space nil nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 ;; There is no valid way to infer a missing end-tag for OF. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 ;; is bizarre.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 ((array)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 (content-model . [((row) nil nil nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 ((row)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (content-model . [((item) nil (((row) *close)) nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 ((item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 (content-model . [((%formula)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 include-space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (((row item) *close))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 nil)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 (end-tag-omissible . t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 ;; The old parser would look for the </EMBED> end-tag and include
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 ;; the contents between <EMBED> and </EMBED> as the DATA attribute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 ;; of the EMBED start-tag. However, it did not require the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 ;; </EMBED> end-tag and did nothing if it was missing. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 ;; completely impossible to specify in SGML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 ;; See
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 ;; <URL:http://www.eit.com/goodies/lists/www.lists/www-html.1995q3/0603.html>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 ;; Questions: Does EMBED require the end-tag? How does NOEMBED fit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 ;; into this? Where can EMBED appear?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 ;; Nov. 25 1995: a new spec for EMBED (also an I-D):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 ;; <URL:http://www.cs.princeton.edu/~burchard/www/interactive/>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 ;; Here is my guess how to code EMBED:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 ((embed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 (content-model . [((noembed) nil nil (*close))]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 ((noembed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (content-model . [((%body.content) ; hack hack hack
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (((%text) p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 ;; FRAMESET is a Netscape thing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 ;; <URL:http://www.eit.com/goodies/lists/www.lists/www-html.1995q3/0588.html>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 ((frameset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (content-model . [((noframes frame frameset) nil nil nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 ((noframes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 (content-model . [((%body.content)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 ;; Push <P> before data characters. Non-SGML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (((%text) p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 ((frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (content-model . EMPTY))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 ;; APPLET is a Java thing.
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1668 ;; OBJECT is a cougar thing
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 ;; <URL:http://java.sun.com/JDK-beta/filesinkit/README>
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1670 ((applet object)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 ;; I really don't want to add another ANY content-model.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (content-model . XINHERIT)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (inclusions . (param)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 ((param)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (content-model . EMPTY))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 ;; backward compatibility with old Java.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 ((app)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 (content-model . EMPTY))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 ;; Client-side image maps.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 ;; <URL:ftp://ds.internic.net/internet-drafts/draft-seidman-clientsideimagemap-01.txt>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 ;; *** The only problem is that I don't know in what elements MAP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 ;; can appear, so none of this is reachable yet.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 ((map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 (content-model . [((area) nil nil nil)]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 ((area)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 (content-model . EMPTY))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 ;;; Omitted tag inference using state transition tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 (w3-p-s-var-def w3-p-s-includep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (w3-p-s-var-def w3-p-s-state-transitions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (w3-p-s-var-def w3-p-s-transition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 (w3-p-s-var-def w3-p-s-tran-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (w3-p-s-var-def w3-p-s-content-model)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (w3-p-s-var-def w3-p-s-except)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1702 (w3-p-s-var-def w3-p-s-baseobject)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1703 (w3-p-s-var-def w3-p-s-btdt)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 ;; Uses free variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 ;; w3-p-d-current-element, w3-p-d-exceptions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 ;; Destroys free variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 ;; w3-p-s-includep, w3-p-s-state-transitions, w3-p-s-transition,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 ;; w3-p-s-tran-list, w3-p-s-content-model, w3-p-s-except
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 ;; Returns t if the element or data characters should be included.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 ;; Returns nil if the element or data characters should be discarded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (defsubst w3-grok-tag-or-data (tag-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 ((symbolp (setq w3-p-s-content-model
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 (w3-element-content-model w3-p-d-current-element)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 (or (and (memq w3-p-s-content-model
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 '(CDATA RCDATA XCDATA XXCDATA))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (memq tag-name '(*data *space)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 ;; *** Implement ANY.
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1720 (error "impossible content model lossage"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 (setq w3-p-s-includep t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 ;; Exit loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 ;; We have a complex content model.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 ;; Cache some data from the element info structure. Format is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 ;; (INCLUDES INCSPACEP (((TAG ...) . TRANSITION) ...) DEFAULT)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (setq w3-p-s-state-transitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 (aref w3-p-s-content-model
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 (w3-element-state w3-p-d-current-element)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 ;; Optimize the common cases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 ((eq '*space tag-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 ;; Optimizing the (*space *discard *same nil) transition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 (setq w3-p-s-includep (car (cdr w3-p-s-state-transitions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 ;; Don't loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 ((and (not (setq w3-p-s-except
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 (assq tag-name w3-p-d-exceptions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 (memq tag-name (car w3-p-s-state-transitions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 ;; Equivalent to a transition of (TAG *include *same nil).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 ;; So we are done, return t to caller.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 (setq w3-p-s-includep t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 ;; Exit loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 ;; The general case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 ;; Handle inclusions and exclusions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (w3-p-s-except
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 (setq w3-p-s-transition (cdr w3-p-s-except)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 ;; See if the transition is in the complex transitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 ;; component.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 ((progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 (setq w3-p-s-tran-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 (car (cdr (cdr w3-p-s-state-transitions))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 (setq w3-p-s-transition nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 (while w3-p-s-tran-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (cond ((memq tag-name (car (car w3-p-s-tran-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 ;; We've found a transition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 (setq w3-p-s-transition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 (cdr (car w3-p-s-tran-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (setq w3-p-s-tran-list nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 (setq w3-p-s-tran-list (cdr w3-p-s-tran-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 ;; Check if we found it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 w3-p-s-transition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 ;; body of cond clause empty
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 ;; Try finding the transition in the DEFAULT component of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 ;; transition table, but avoid doing this for unknown elements,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 ;; always use the default-default for them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 ((and (or (eq '*data tag-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 (w3-known-element-p tag-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 (setq w3-p-s-transition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 (nth 3 w3-p-s-state-transitions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 ;; body of cond clause empty
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 ;; Supply a default-default transition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 (if (not (or (eq '*data tag-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 (w3-known-element-p tag-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (setq w3-p-s-transition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 '(*discard *same "unknown element"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 ;; Decide whether to *close or *discard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 ;; based on whether this element would be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 ;; accepted as valid in an open ancestor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (let ((open-list w3-p-d-open-element-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 (all-end-tags-omissible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 (w3-element-end-tag-omissible w3-p-d-current-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 state-transitions tran-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 (if (catch 'found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 (while open-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 (setq state-transitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 (aref (w3-element-content-model
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 (car open-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 (w3-element-state (car open-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 (if (memq tag-name (car state-transitions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 (throw 'found t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 (setq tran-list (nth 2 state-transitions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 (while tran-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 (cond ((memq tag-name (car (car tran-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 (if (not (nth 3 (car tran-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 ;; Not an error transition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 (throw 'found t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 (setq tran-list nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (setq tran-list (cdr tran-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 ;; The input item is not accepted in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 ;; ancestor. Try again in next ancestor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 (or (w3-element-end-tag-omissible (car open-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (setq all-end-tags-omissible nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (setq open-list (cdr open-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 (setq w3-p-s-transition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 (if (w3-element-end-tag-omissible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 w3-p-d-current-element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 (if all-end-tags-omissible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 ;; Probably indicates a need to debug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 ;; the DTD state-transition tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 '(*close *same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 "missing transition in DTD?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 ;; Error will be reported later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 '(*close *same))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 '(*close *same "not allowed here")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 (setq w3-p-s-transition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 '(*discard *same "not allowed here")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 ;; We have found a transition to take. The transition is of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 ;; the format (ACTION NEW-STATE ERRORP) where the latter two
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 ;; items are optional.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 ;; First, handle any state-change.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 (or (memq (car-safe (cdr w3-p-s-transition)) '(nil *same))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 (w3-set-element-state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 w3-p-d-current-element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 (if (eq '*next (car-safe (cdr w3-p-s-transition)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 (1+ (w3-element-state w3-p-d-current-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 (car-safe (cdr w3-p-s-transition)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 ;; Handle any error message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 (if (car-safe (cdr-safe (cdr w3-p-s-transition)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 (w3-debug-html
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 :mandatory-if (and (eq '*data tag-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (eq '*discard (car w3-p-s-transition)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 (format "Bad %s [%s], %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 (if (eq '*data tag-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 "data characters"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 (concat "start-tag "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (w3-sgml-name-to-string tag-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (if (stringp (car (cdr (cdr w3-p-s-transition))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (car (cdr (cdr w3-p-s-transition)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 "not allowed here")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 (let ((action (car w3-p-s-transition)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 (cond ((eq '*discard action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 "discarding bad item")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 ((eq '*close action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 (concat "inferring </"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 (w3-sgml-name-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 (w3-element-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 w3-p-d-current-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 ">"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 ((eq '*include action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 "including bad item anyway")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 ((eq '*retry action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 "*retry ??? you shouldn't see this")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (concat "inferring <"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 (w3-sgml-name-to-string action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 ">")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 ;; Handle the action.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 ((eq '*include (car w3-p-s-transition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (setq w3-p-s-includep t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 ;; Exit loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 ((eq '*close (car w3-p-s-transition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 ;; Perform end-tag inference.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (w3-close-element) ; don't pass parameter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 ;; Loop and try again in parent element's content-model.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 ((eq '*discard (car w3-p-s-transition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 (setq w3-p-s-includep nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 ;; Exit loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 ((eq '*retry (car w3-p-s-transition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 ;; Loop and try again after state change.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 ((symbolp (car w3-p-s-transition))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 ;; We need to open another element to contain the text,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 ;; probably a <P> (look in the state table).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 (w3-open-element (car w3-p-s-transition) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 ;; Now we loop and try again in the new element's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 ;; content-model.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 (t
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1900 (error "impossible transition")))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 ;; Empty while loop body.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 ;; Return value to user indicating whether to include or discard item:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 ;; t ==> include
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 ;; nil ==> discard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 w3-p-s-includep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 ;;; Main parser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (defvar w3-last-parse-tree nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 "Used for debugging only. Stores the most recently computed parse tree
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 \(a tree, not a parse tag stream\).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (defun w3-display-parse-tree (&optional ptree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 (with-output-to-temp-buffer "W3 HTML Parse Tree"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (set-buffer standard-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 (emacs-lisp-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (require 'pp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 (pp (or ptree w3-last-parse-tree))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 (defalias 'w3-display-last-parse-tree 'w3-display-parse-tree)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 ;; For compatibility with the old parser interface.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 (defalias 'w3-preparse-buffer 'w3-parse-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 ;; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 ;; % %
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 ;; % This is the *ONLY* valid entry point in this file! %
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 ;; % DO NOT call any of the other functions! %
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 ;; % %
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 ;; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
1940 (defun w3-parse-buffer (&optional buff)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 "Parse contents of BUFF as HTML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 BUFF defaults to the value of url-working-buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 Destructively alters contents of BUFF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 Returns a data structure containing the parsed information."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 (set-buffer (or buff url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 (setq buff (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 (set-syntax-table w3-sgml-md-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 (buffer-disable-undo (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 (widen) ; sanity checking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (setq case-fold-search t) ; allows smaller regexp patterns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 ;; Some unknown pre-parse buffer munging.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (if (fboundp 'sera-to-fidel-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (let ((sera-being-called-by-w3 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 ;; eval stops the compiler from complaining.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 (eval '(sera-to-fidel-marker))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 ;; *** Should premunge line boundaries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 ;; ********************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 (let* (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 ;; Speed hack, see the variable doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 (gc-cons-threshold (if (> w3-gc-cons-threshold-multiplier 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 (* w3-gc-cons-threshold-multiplier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 gc-cons-threshold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 gc-cons-threshold))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 ;; Used to determine if we made any progress since the last loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (last-loop-start (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 ;; How many iterations of the main loop have occurred. Used only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 ;; to send messages to the user periodically, since this function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 ;; can take some time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 (loop-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 ;; Precomputing the loop-invariant parts of this for speed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (status-message-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 (if url-show-status
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 (format "Parsed %%3d%%%% of %d..." (- (point-max) (point-min)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 ;; Use a float value for 100 if possible, otherwise integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 ;; Determine which we can use outside of the loop for speed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 (one-hundred (funcall (if (fboundp 'float) 'float 'identity) 100))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 ;; The buffer which contains the HTML we are parsing. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 ;; variable is used to avoid using the more expensive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 ;; save-excursion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 (parse-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 ;; Points to start of region of text since the previous tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 (between-tags-start (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 ;; Points past end of region of text since the previous tag. Only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 ;; non-nil when the region has been completely determined and is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 ;; ready to be processed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 between-tags-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 ;; See doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 w3-p-d-tag-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 ;; See doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 w3-p-d-end-tag-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 ;; Is the tag we are looking at a null-end-tag-enabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 ;; start-tag?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 net-tag-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 ;; Attributes of the tag we are looking at. An alist whose items
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 ;; are pairs of the form (SYMBOL . STRING).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 tag-attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 ;; Points past end of attribute value we are looking at. Points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 ;; past the syntactic construct, not the value of the attribute,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 ;; which may be at (1- attribute-value-end).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 attribute-value-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 ;; Points past end of tag we are looking at.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 tag-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 ;; See doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 (w3-p-d-current-element (w3-fresh-element-for-tag '*document))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 ;; See doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 (w3-p-d-open-element-stack (list (w3-fresh-element-for-tag '*holder)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 ;; ***not implemented yet***
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 (marked-section-undo-stack nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 ;; See doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 (w3-p-d-debug-url t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 ;; Any of the following variables with the comment ";*NESTED*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 ;; are syntactic or semantic features that were introduced by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 ;; some containing element or marked section which will be undone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 ;; when we close that element or marked section.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 ;; See doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 (w3-p-d-non-markup-chars nil) ;*NESTED*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 ;; See doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 (w3-p-d-null-end-tag-enabled nil) ;*NESTED*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 ;; See doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 (w3-p-d-in-parsed-marked-section nil) ;*NESTED*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 ;; See doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 (w3-p-d-shortrefs nil) ;*NESTED*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 ;; See doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 (w3-p-d-shortref-chars nil) ;*NESTED*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 ;; ******* maybe not needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 ;; ;; Are we recognizing start-tags?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 ;; (recognizing-start-tags t) ;*NESTED*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 ;; ;; Are we recognizing end-tags? If this is non-nil and not t,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 ;; ;; then only the end tag of the current open element is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 ;; ;; recognized.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 ;; (recognizing-end-tags t) ;*NESTED*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 ;; See doc string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 (w3-p-d-exceptions nil) ;*NESTED*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 ;; Scratch variables used in this function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 ref attr-name attr-value content-model content open-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 ;; Scratch variables used by macros and defsubsts we call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 (w3-p-s-let-bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 (w3-update-non-markup-chars)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2074 (setq w3-p-s-baseobject (url-generic-parse-url (url-view-url t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 ;; Main loop. Handle markup as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 ;; non-empty tag: Handle the region since the previous tag as PCDATA,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 ;; RCDATA, CDATA, if allowed by syntax. Then handle the tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 ;; general entity (&name;): expand it and parse the result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 ;; shortref (_, {, }, and ^ in math stuff): Expand it and parse the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 ;; result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 ;; SGML marked section (<![ keywords [ conditional-text ]]>): Either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 ;; strip the delimiters and parse the result or delete.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 ;; comment: Delete.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 ;; empty tag (<>, </>): Handle as the appropriate tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 ;; markup declaration (e.g. <!DOCTYPE ...>): Delete.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 ;; SGML processing instruction (<?name>): Delete.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 ;; Continue as long as we processed something last time and we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 ;; have more to process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 (not (and (= last-loop-start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 (setq last-loop-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 ;; Display progress messages if asked and/or do incremental display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 ;; of results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 (cond ((= 0 (% (setq loop-count (1+ loop-count)) 40))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 (if status-message-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 (message status-message-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 ;; Percentage of buffer processed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 (/ (* (point) one-hundred) (point-max))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 ;; Go to next interesting thing in the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 (skip-chars-forward w3-p-d-non-markup-chars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 ;; We are looking at a markup-starting character, and invalid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 ;; character, or end of buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2119 ((= ?< (following-char))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 ;; We are looking at a tag, comment, markup declaration, SGML marked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 ;; section, SGML processing instruction, or non-markup "<".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 (forward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 ((looking-at "/?\\([a-z][-a-z0-9.]*\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 ;; We are looking at a non-empty tag.
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2128
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2129 ;; Downcase it in the buffer, to save creation of a string
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2130 (downcase-region (match-beginning 1) (match-end 1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 (setq w3-p-d-tag-name
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2132 (intern (buffer-substring (match-beginning 1)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2133 (match-end 1))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2134 (setq w3-p-d-end-tag-p (= ?/ (following-char)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2135 (setq between-tags-end (1- (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 ;; Read the attributes from a start-tag.
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2139 (if w3-p-d-end-tag-p
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
2140 (if (looking-at "[ \t\r\n/]*[<>]")
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2141 nil
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2142 ;; This is in here to deal with those idiots who stick
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2143 ;; attribute/value pairs on end tags. *sigh*
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2144 (w3-debug-html "Evil attributes on end tag.")
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2145 (skip-chars-forward "^>"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 ;; Attribute values can be:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 ;; "STRING" where STRING does not contain the double quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 ;; 'STRING' where STRING does not contain the single quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 ;; name-start character, *name character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 ;; *name character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 ;; Digit, +name character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 ;; +Digit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 ;; or a SPACE-separated list of one of the last four
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 ;; possibilities (there is a comment somewhere that this is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 ;; misinterpretation of the grammar, so we ignore this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 ;; possibility).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 ;; Leading whitespace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 "[ \n\r\t]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 ;; The attribute name, possibly with a bad syntax
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 ;; component.
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2166 "\\([a-z_][-a-z0-9.]*\\(\\([_][-a-z0-9._]*\\)?\\)\\)"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 ;; Trailing whitespace and perhaps an "=".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 "[ \n\r\t]*\\(\\(=[ \n\r\t]*\\)?\\)")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 (cond ((/= (match-beginning 2) (match-end 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 (w3-debug-html
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 :nocontext
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 (format "Bad attribute name syntax: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 (match-end 1))))))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2176
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2177 ;; Downcase it in the buffer, to save creation of a string
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2178 (downcase-region (match-beginning 1) (match-end 1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 (setq attr-name
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2180 (intern (buffer-substring (match-beginning 1)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2181 (match-end 1))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 ((< (match-beginning 4) (match-end 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 ;; A value was specified (e.g. ATTRIBUTE=VALUE).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 ((looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 ;; Literal with double quotes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 "\"\\([^\"]*\\)\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 "\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 ;; Literal with single quotes.
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2194 "'\\([^']*\\)'"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 "\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 ;; Handle bad HTML conflicting with NET-enabling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 ;; start-tags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 "\\([-a-z0-9.]+/[-a-z0-9._/#]+\\)[ \t\n\r>]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 "\\|"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 ;; SGML NAME-syntax attribute value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 "\\([-a-z0-9.]+\\)[ \t\n\r></]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 ((or (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 (match-beginning 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 ;; We have an attribute value literal.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 (narrow-to-region (1+ (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 (1- (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 ;; In attribute value literals, EE and RS are ignored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 ;; and RE and SEPCHAR characters sequences are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 ;; replaced by SPACEs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 ;; (There is no way right now to get RS into one of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 ;; these so that it can be ignored. This is due to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 ;; our using Unix line-handling conventions.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 (skip-chars-forward "^&\t\n\r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 (if (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 ;; We must expand entities and replace RS, RE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 ;; and SEPCHAR.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 (skip-chars-forward "^&")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 (not (eobp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 (w3-expand-entity-at-point-maybe))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2227 (subst-char-in-region (point-min) (point-max) ?\t ? )
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2228 (subst-char-in-region (point-min) (point-max) ?\n ? ))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 ;; Set this after we have changed the size of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 ;; attribute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 (setq attribute-value-end (1+ (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 ((match-beginning 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 (setq attribute-value-end (match-end 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 (narrow-to-region (point) attribute-value-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 ((match-beginning 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 (setq attribute-value-end (match-end 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 (narrow-to-region (point) attribute-value-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 ;; Horribly illegal non-SGML handling of bad
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 ;; HTML on the net. This can break valid HTML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 (setq attr-value (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 (w3-debug-html :nocontext
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 (format "Evil attribute value syntax: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 (buffer-substring (point-min) (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 (t
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2246 (error "impossible attribute value"))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2247 ((memq (following-char) '(?\" ?'))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 ;; Missing terminating quote character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 (narrow-to-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 (forward-char 1)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2252 (skip-chars-forward "^ \t\n\r'\"<>")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 (setq attribute-value-end (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 (w3-debug-html :nocontext
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 (format "Attribute value missing end quote: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 (buffer-substring (point-min) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 (narrow-to-region (1+ (point-min)) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 ;; We have a syntactically invalid attribute value. Let's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 ;; make a best guess as to what the author intended.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 (narrow-to-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 (progn
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2263 (skip-chars-forward "^ \t\n\r'\"<>")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 (setq attribute-value-end (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 (w3-debug-html :nocontext
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 (format "Bad attribute value syntax: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 (buffer-substring (point-min) (point-max))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 ;; Now we have isolated the attribute value. We need to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 ;; munge the value depending on the syntax of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 ;; attribute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 ;; *** Right now, we only implement the necessary munging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 ;; for CDATA attributes, which is none. I'm not sure why
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 ;; this happens to work for other attributes right now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 ;; For any other kind of attribute, we are supposed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 ;; * smash case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 ;; * remove leading/trailing whitespace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 ;; * smash multiple space sequences into single spaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 ;; * verify the syntax of each token
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 (setq attr-value (buffer-substring (point-min) (point-max)))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2280 (case attr-name
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2281 (class
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2282 (setq attr-value (split-string attr-value "[ ,]+")))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2283 (align
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2284 (if (string-match "^[ \t\r\n]*\\(.*\\)[ \t\r\n]*$"
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2285 attr-value)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2286 (setq attr-value (downcase
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2287 (substring attr-value
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2288 (match-beginning 1)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2289 (match-end 1))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2290 (setq attr-value (downcase attr-value)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2291 (setq attr-value (intern attr-value)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2292 ((src href)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2293 ;; I should expand URLs here
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2294 )
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2295 (otherwise nil)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2296 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 (goto-char attribute-value-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 ;; No value was specified, in which case NAME should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 ;; taken as ATTRIBUTE=NAME where NAME is one of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 ;; enumerated values for ATTRIBUTE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 ;; We assume here that ATTRIBUTE is the same as NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 ;; *** Another piece of code will fix the attribute name if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 ;; is wrong.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 (setq attr-value (symbol-name attr-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 ;; Accumulate the attributes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 (setq tag-attributes (cons (cons attr-name attr-value)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2310 tag-attributes)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2311
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2312 (cond
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2313 ((and (eq w3-p-d-tag-name 'base)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2314 (setq w3-p-s-baseobject
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2315 (or (assq 'src tag-attributes)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2316 (assq 'href tag-attributes))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2317 (setq w3-p-s-baseobject (url-generic-parse-url
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2318 (cdr w3-p-s-baseobject))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2319 ((setq w3-p-s-btdt (or (assq 'src tag-attributes)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2320 (assq 'href tag-attributes)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2321 (assq 'action tag-attributes)))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2322 (setcdr w3-p-s-btdt (url-expand-file-name (cdr w3-p-s-btdt)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2323 w3-p-s-baseobject))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2324 (setq w3-p-s-btdt (if (url-have-visited-url (cdr w3-p-s-btdt))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2325 ":visited"
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2326 ":link"))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2327 (if (assq 'class tag-attributes)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2328 (setcdr (assq 'class tag-attributes)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2329 (cons w3-p-s-btdt
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2330 (cdr (assq 'class tag-attributes))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2331 (setq tag-attributes (cons (cons 'class (list w3-p-s-btdt))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2332 tag-attributes))))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2333 )
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
2334 (if (not (eq w3-p-d-tag-name 'input))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
2335 nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
2336 (setq w3-p-s-btdt (concat ":"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
2337 (downcase
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
2338 (or (cdr-safe
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
2339 (assq 'type tag-attributes))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
2340 "text"))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
2341 (if (assq 'class tag-attributes)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
2342 (setcdr (assq 'class tag-attributes)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
2343 (cons w3-p-s-btdt
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
2344 (cdr (assq 'class tag-attributes))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
2345 (setq tag-attributes (cons (cons 'class (list w3-p-s-btdt))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 82
diff changeset
2346 tag-attributes))))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2347 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 ;; Process the end of the tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 (skip-chars-forward " \t\n\r")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2351 (cond ((= ?> (following-char))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 ;; Ordinary tag end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 (forward-char 1))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2354 ((and (= ?/ (following-char))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 (not w3-p-d-end-tag-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 ;; This is a NET-enabling start-tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 (setq net-tag-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 (forward-char 1))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2359 ((= ?< (following-char))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 ;; *** Strictly speaking, the following text has to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 ;; lexically be STAGO or ETAGO, which means that it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 ;; can't match some other lexical unit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 ;; Unclosed tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 ;; Syntax error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 (w3-debug-html
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 (format "Bad unclosed %s%s tag"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 (if w3-p-d-end-tag-p "/" "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 (w3-sgml-name-to-string w3-p-d-tag-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 (setq tag-end (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 ((looking-at "/?>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 ;; We are looking at an empty tag (<>, </>).
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2376 (setq w3-p-d-end-tag-p (= ?/ (following-char)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 (setq w3-p-d-tag-name (if w3-p-d-end-tag-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 (w3-element-name w3-p-d-current-element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 ;; *** Strictly speaking, if OMITTAG NO, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 ;; we should use the most recently closed tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 ;; But OMITTAG YES in HTML and I'm lazy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 (w3-element-name w3-p-d-current-element)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 (setq tag-attributes nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 ;; *** Make sure this is not at top level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 (setq between-tags-end (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 (setq tag-end (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 ;; *** In SGML, <(doctype)element> is valid tag syntax. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 ;; cannot occur in HTML because the CONCUR option is off in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 ;; SGML declaration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 ((looking-at "!--")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 ;; We found a comment, delete to end of comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 (1- (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 ;; Skip over pairs of -- ... --.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 (if (looking-at "\\(--[^-]*\\(-[^-]+\\)*--[ \t\r\n]*\\)+>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 (goto-char (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 ;; Syntax error!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 (w3-debug-html
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 "Bad comment (unterminated or unbalanced \"--\" pairs)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 (forward-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 (or (re-search-forward "--[ \t\r\n]*>" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 (search-forward ">" nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 ((looking-at "!>\\|\\?[^>]*>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 ;; We are looking at an empty comment or a processing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 ;; instruction. Delete it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 (replace-match "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 (delete-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 ((looking-at "![a-z]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 ;; We are looking at a markup declaration. Delete it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 ;; *** Technically speaking, to handle valid HTML I think we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 ;; need to handle "<!USEMAP ... >" declarations. In the future,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 ;; to handle general SGML, we should parse "<!DOCTYPE ... >"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 ;; declarations as well (which can contain other declarations).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 ;; In the very distant future, perhaps we will handle "<!SGML
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 ;; ... >" declarations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 ;; *** Should warn if it's not SGML, DOCTYPE, or USEMAP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 ;; *** This might not actually be bad syntax, but might
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 ;; instead be a -- ... -- comment with unbalanced
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 ;; parentheses somewhere inside the declaration. Handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 ;; this properly would require full parsing of markup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 ;; declarations, a goal for the future.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 (w3-debug-html "Bad <! syntax.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 (skip-chars-forward "^>")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2438 (if (= ?> (following-char))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 (forward-char))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 ((looking-at "!\\\[\\(\\([ \t\n\r]*[a-z]+\\)+[ \t\n\r]*\\)\\\[")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 ;; We are looking at a marked section.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 ;; *** Strictly speaking, we should issue a warning if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 ;; keywords are invalid or missing or if the "[" does not follow.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 ;; We must look at the keywords to understand how to parse it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 ;; *** Strictly speaking, we should perform parameter entity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 ;; substitution on the keywords first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 (insert ?\))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 (goto-char (1- (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 (delete-char 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 (insert ?\()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 (let* ((keywords (read (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 ;; Multiple keywords may appear, but only the most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 ;; significant takes effect. Rank order is IGNORE, CDATA,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 ;; RCDATA, INCLUDE, and TEMP. INCLUDE and TEMP have the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 ;; same effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 (keyword (car-safe (cond ((memq 'IGNORE keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 ((memq 'CDATA keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 ((memq 'RCDATA keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 ((memq 'INCLUDE keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 ((memq 'TEMP keywords))))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2465 (or (= ?\[ (following-char))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 ;; I probably shouldn't even check this, since it is so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 ;; impossible.
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2468 (error "impossible ??"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 (delete-region (1- (match-beginning 0)) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 (cond ((eq 'IGNORE keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 ;; Scan forward skipping over matching <![ ... ]]>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 ;; until we find an unmatched "]]>".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 (let ((ignore-nesting 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 (start-pos (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 (while (> ignore-nesting 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 (if (re-search-forward "<!\\\\\[\\|\]\]>" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 (setq ignore-nesting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 (if (eq ?> (preceding-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 (1- ignore-nesting)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 (1+ ignore-nesting)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 (w3-debug-html
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 "Unterminated IGNORE marked section.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 (setq ignore-nesting 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 (goto-char start-pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 (delete-region start-pos (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 ((eq 'CDATA keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 (error "***unimplemented***"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 ((eq 'RCDATA keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 (error "***unimplemented***"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 ((memq keyword '(INCLUDE TEMP))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 (error "***unimplemented***")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 ((and (looking-at "!")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 w3-netscape-compatible-comments)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 ;; Horribly illegal non-SGML handling of bad HTML on the net.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 ;; This can break valid HTML.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 ;; This arises because Netscape discards anything looking like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 ;; "<!...>". So people expect they can use this construct as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 ;; a comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 (w3-debug-html "Evil <! comment syntax.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 (backward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 (skip-chars-forward "^>")
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2506 (if (= ?> (following-char))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 (forward-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 ;; This < is not a markup character. Pretend we didn't notice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 ;; it at all. We have skipped over the < already, so just loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 ;; again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2515 ((= ?& (following-char))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 (w3-expand-entity-at-point-maybe))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2518 ((and (= ?\] (following-char))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 w3-p-d-in-parsed-marked-section
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 (looking-at "]]>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 ;; *** handle the end of a parsed marked section.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 (error "***unimplemented***"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2524 ((and (= ?/ (following-char))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 w3-p-d-null-end-tag-enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 ;; We are looking at a null end tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 (setq w3-p-d-end-tag-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 (setq between-tags-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 (setq tag-end (1+ (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 (setq w3-p-d-tag-name (w3-element-name w3-p-d-current-element)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 ;; This can be slow, since we'll hardly ever get here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 ;; *** Strictly speaking, I think we're supposed to handle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 ;; shortrefs that begin with the same characters as other markup,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 ;; preferring the longest match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 ;; I will assume that shortrefs never begin with <, &, \], /.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 ((setq ref (catch 'found-shortref
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 (let ((refs w3-p-d-shortrefs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 (while refs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 (if (looking-at (car (car refs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 (throw 'found-shortref (cdr (car refs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 (setq refs (cdr refs))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 ;; We are looking at a shortref for which there is an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 ;; expansion defined in the current syntax. Replace with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 ;; expansion, leaving point at the beginning so it will be parsed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 ;; on the next loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 ;; *** eek. This is wrong if the shortref is for an entity with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 ;; CDATA syntax which should not be reparsed for tags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 (replace-match "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 (let ((pt (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 (insert ref)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 (goto-char pt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 ((looking-at (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 (concat "[" (w3-invalid-sgml-chars) "]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 (w3-debug-html
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2557 (format "Invalid SGML character: %c" (following-char)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2558 (insert (or (cdr-safe (assq (following-char)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 ;; These characters are apparently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 ;; from a Windows character set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 '((146 . "'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 (153 . "TM"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 (delete-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 ((eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 ;; We have finished the buffer. Make sure we process the last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 ;; piece of text, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 (setq between-tags-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 ;; We have to test what's on the element stack because this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 ;; piece of code gets executed twice.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 (cond ((not (eq '*holder (w3-element-name w3-p-d-current-element)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 ;; This forces the calculation of implied omitted end tags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 (setq w3-p-d-tag-name '*document)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 (setq w3-p-d-end-tag-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 (setq tag-end (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 (error "unreachable code, this can't happen")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 ;; If we have determined the boundaries of a non-empty between-tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 ;; region of text, then handle it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 (between-tags-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 ((< between-tags-start between-tags-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 ;; We have a non-empty between-tags region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 ;; We check if it's entirely whitespace, because we record the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 ;; transitions for whitespace separately from those for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 ;; data with non-whitespace characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 (goto-char between-tags-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 (skip-chars-forward " \t\n\r" between-tags-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 ((w3-grok-tag-or-data (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 (if (= between-tags-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 '*space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 '*data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 (goto-char between-tags-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 ;; We have to include the text in the current element's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 ;; contents. If this is the first item in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 ;; element's contents, don't include a leading newline if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 ;; there is one. Add a trailing newline as a separate text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 ;; item so that it can be removed later if it turns out to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 ;; be the last item in the current element's contents when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 ;; the current element is closed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 ;; *** We could perform this test before calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 ;; w3-grok-tag-or-data, but it's not clear which will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 ;; faster in practice.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 (or (setq content (w3-element-content w3-p-d-current-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 ;; *** Strictly speaking, in SGML the record end is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 ;; carriage return, not line feed.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2613 (if (= ?\n (char-after between-tags-start))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 (setq between-tags-start (1+ between-tags-start))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 (if (= between-tags-start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 ;; Do nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 ;; We are definitely going to add data characters to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 ;; content.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 ((and (= ?\n (preceding-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 (/= between-tags-start (1- (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 (setq content (cons (buffer-substring between-tags-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 content))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 (setq content (cons "\n" content)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 (setq content (cons (buffer-substring between-tags-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 content))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 (w3-set-element-content w3-p-d-current-element content))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 (setq between-tags-end nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 ;; If the previous expression modified (point), then it went to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 ;; the value of between-tags-end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 ;; If we found a start or end-tag, we need to handle it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 (w3-p-d-tag-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 ;; Move past the tag and prepare for next between-tags region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 (goto-char tag-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 (setq between-tags-start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 (w3-p-d-end-tag-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 ;; Handle an end-tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 (if (eq w3-p-d-tag-name (w3-element-name w3-p-d-current-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 (w3-close-element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 ;; Handle the complex version. We have to search up (down?)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 ;; the open element stack to find the element that matches (if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 ;; any). Then we close all of the elements. On a conforming
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 ;; SGML document this can do no wrong and it's not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 ;; unreasonable on a non-conforming document.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 ;; Can't safely modify stack until we know the element we want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 ;; to find is in there, so work with a copy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 (setq open-list w3-p-d-open-element-stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 (while (and open-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 (not (eq w3-p-d-tag-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 (w3-element-name (car open-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 (setq open-list (cdr open-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 (cond (open-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 ;; We found a match. Pop elements.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 ;; We will use the following value as a sentinel.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 (setq open-list (cdr open-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 (while (not (eq open-list w3-p-d-open-element-stack))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 (w3-close-element t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 (w3-close-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 ;; Bogus end tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 (w3-debug-html
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 (format "Unmatched end-tag </%s>"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 (w3-sgml-name-to-string w3-p-d-tag-name)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 ;; Handle a start-tag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 ;; Check if the new element is allowed in the current element's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 ;; content model.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 ((w3-grok-tag-or-data w3-p-d-tag-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 (w3-open-element w3-p-d-tag-name tag-attributes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 ;; Handle NET-enabling start tags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 (cond ((and net-tag-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 (not w3-p-d-null-end-tag-enabled))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687 ;; Save old values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 (w3-set-element-undo-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 w3-p-d-current-element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 (cons (cons 'w3-p-d-non-markup-chars
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 w3-p-d-non-markup-chars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 (cons '(w3-p-d-null-end-tag-enabled . nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 (w3-element-undo-list w3-p-d-current-element))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 ;; Alter syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 (setq w3-p-d-null-end-tag-enabled t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 (w3-update-non-markup-chars)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 (setq content-model
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 (w3-element-content-model w3-p-d-current-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 ;; If the element does not have parsed contents, then we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 ;; can find its contents immediately.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 ((memq content-model '(EMPTY CDATA XCDATA XXCDATA RCDATA))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 ((eq 'EMPTY content-model)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 (w3-close-element))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 ((eq 'CDATA content-model)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 ;; CDATA: all data characters until an end-tag. We'll
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 ;; process the end-tag on the next loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 (if (re-search-forward (if w3-p-d-null-end-tag-enabled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 "</[a-z>]\\|/"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 "</[a-z>]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 (goto-char (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 ((eq 'XCDATA content-model)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 ;; XCDATA: special non-SGML-standard mode which includes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 ;; all data characters until "</foo" is seen where "foo"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 ;; is the name of this element (for XMP and LISTING).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 (if (search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 (concat "</" (symbol-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 (w3-element-name w3-p-d-current-element)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 (goto-char (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 ((eq 'XXCDATA content-model)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 ;; XXCDATA: special non-SGML-standard mode which includes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 ;; all data until end-of-entity (end-of-buffer for us)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 ;; (for PLAINTEXT).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 (goto-char (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 ((eq 'RCDATA content-model)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 ;; RCDATA: all data characters until end-tag is seen,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 ;; except that entities are expanded first, although the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 ;; expansions are _not_ scanned for end-tags, although the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 ;; expansions _are_ scanned for further entity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 ;; references.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 (if (re-search-forward (if w3-p-d-null-end-tag-enabled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 "</[a-z>]\\|[/&]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 "</[a-z>]\\|&")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 nil 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 (goto-char (match-beginning 0)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2742 (= ?& (following-char)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 (w3-expand-entity-at-point-maybe)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 ;; The element is illegal here. We'll just discard the start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 ;; tag as though we never saw it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 (setq w3-p-d-tag-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 (setq w3-p-d-end-tag-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 (setq net-tag-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 (setq tag-attributes nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 (setq tag-end nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 ;; End of main while loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 ;; We have finished parsing the buffer!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 (if status-message-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 (message "%sdone" (format status-message-format 100)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 ;; *** For debugging, save the true parse tree.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 ;; *** Make this look inside *DOCUMENT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 (setq w3-last-parse-tree
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 (w3-element-content w3-p-d-current-element))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2766
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 70
diff changeset
2767 (w3-element-content w3-p-d-current-element)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2768 )))
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
2769
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 38
diff changeset
2770
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 (provide 'w3-parse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 ;; Local variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 ;; indent-tabs-mode: nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 ;; end: