annotate lisp/w3/w3-parse.el @ 0:376386a54a3c r19-14

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