annotate lisp/w3/w3-parse.el @ 7:c153ca296910

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