OLD | NEW |
1 /* This file defines an XML parser, with a few kludges to make it | 1 /* This file defines an XML parser, with a few kludges to make it |
2 * useable for HTML. autoSelfClosers defines a set of tag names that | 2 * useable for HTML. autoSelfClosers defines a set of tag names that |
3 * are expected to not have a closing tag, and doNotIndent specifies | 3 * are expected to not have a closing tag, and doNotIndent specifies |
4 * the tags inside of which no indentation should happen (see Config | 4 * the tags inside of which no indentation should happen (see Config |
5 * object). These can be disabled by passing the editor an object like | 5 * object). These can be disabled by passing the editor an object like |
6 * {useHTMLKludges: false} as parserConfig option. | 6 * {useHTMLKludges: false} as parserConfig option. |
7 */ | 7 */ |
8 | 8 |
9 var XMLParser = Editor.Parser = (function() { | 9 var XMLParser = Editor.Parser = (function() { |
10 var Kludges = { | 10 var Kludges = { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 // The parser. The structure of this function largely follows that of | 129 // The parser. The structure of this function largely follows that of |
130 // parseJavaScript in parsejavascript.js (there is actually a bit more | 130 // parseJavaScript in parsejavascript.js (there is actually a bit more |
131 // shared code than I'd like), but it is quite a bit simpler. | 131 // shared code than I'd like), but it is quite a bit simpler. |
132 function parseXML(source) { | 132 function parseXML(source) { |
133 var tokens = tokenizeXML(source); | 133 var tokens = tokenizeXML(source); |
134 var cc = [base]; | 134 var cc = [base]; |
135 var tokenNr = 0, indented = 0; | 135 var tokenNr = 0, indented = 0; |
136 var currentTag = null, context = null; | 136 var currentTag = null, context = null; |
137 var consume, marked; | 137 var consume, marked; |
138 | 138 |
139 function push(fs) { | 139 function push(fs) { |
140 for (var i = fs.length - 1; i >= 0; i--) | 140 for (var i = fs.length - 1; i >= 0; i--) |
141 cc.push(fs[i]); | 141 cc.push(fs[i]); |
142 } | 142 } |
143 function cont() { | 143 function cont() { |
144 push(arguments); | 144 push(arguments); |
145 consume = true; | 145 consume = true; |
146 } | 146 } |
147 function pass() { | 147 function pass() { |
148 push(arguments); | 148 push(arguments); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 if (marked) | 260 if (marked) |
261 token.style = marked; | 261 token.style = marked; |
262 return token; | 262 return token; |
263 } | 263 } |
264 } | 264 } |
265 }, | 265 }, |
266 | 266 |
267 copy: function(){ | 267 copy: function(){ |
268 var _cc = cc.concat([]), _tokenState = tokens.state, _context = context; | 268 var _cc = cc.concat([]), _tokenState = tokens.state, _context = context; |
269 var parser = this; | 269 var parser = this; |
270 | 270 |
271 return function(input){ | 271 return function(input){ |
272 cc = _cc.concat([]); | 272 cc = _cc.concat([]); |
273 tokenNr = indented = 0; | 273 tokenNr = indented = 0; |
274 context = _context; | 274 context = _context; |
275 tokens = tokenizeXML(input, _tokenState); | 275 tokens = tokenizeXML(input, _tokenState); |
276 return parser; | 276 return parser; |
277 }; | 277 }; |
278 } | 278 } |
279 }; | 279 }; |
280 } | 280 } |
281 | 281 |
282 return { | 282 return { |
283 make: parseXML, | 283 make: parseXML, |
284 electricChars: "/", | 284 electricChars: "/", |
285 configure: function(config) { | 285 configure: function(config) { |
286 if (config.useHTMLKludges) | 286 if (config.useHTMLKludges) |
287 UseKludges = Kludges; | 287 UseKludges = Kludges; |
288 else | 288 else |
289 UseKludges = NoKludges; | 289 UseKludges = NoKludges; |
290 } | 290 } |
291 }; | 291 }; |
292 })(); | 292 })(); |
OLD | NEW |