Parent Directory
|
Revision Log
|
Patch
| revision 1.1 by wakaba, Sun Apr 20 06:07:24 2008 UTC | revision 1.4 by wakaba, Sun Apr 20 12:19:13 2008 UTC | |
|---|---|---|
| # | Line 13 | Line 13 |
| 13 | output { | output { |
| 14 | display: block; | display: block; |
| 15 | font-family: monospace; | font-family: monospace; |
| 16 | white-space: pre; | white-space: -moz-pre-wrap; |
| 17 | white-space: pre-wrap; | |
| 18 | } | } |
| 19 | </style> | </style> |
| 20 | <script> | <script> |
| 21 | function update () { | function update () { |
| 22 | document.logElement.textContent = ''; | document.logElement.textContent = ''; |
| 23 | var p = new Parser (); | var p = new Parser (new InputStream (document.sourceElement.value)); |
| 24 | p.parse (new InputStream (document.sourceElement.value)); | var doc = p.doc; |
| 25 | log (dumpTree (p.doc, '')); | p.parse (); |
| 26 | log (dumpTree (doc, '')); | |
| 27 | } // update | } // update |
| 28 | ||
| 29 | function log (s) { | function log (s) { |
| # | Line 32 | Line 34 |
| 34 | this.s = s; | this.s = s; |
| 35 | } // InputStream | } // InputStream |
| 36 | ||
| 37 | function Parser () { | function Parser (i, doc) { |
| 38 | this.parseMode = 'pcdata'; | this.parseMode = 'pcdata'; |
| 39 | this.doc = new JSDocument (); | if (!doc) { |
| 40 | this.openElements = [this.doc]; | doc = new JSDocument (this); |
| 41 | doc.manakaiIsHTML = true; | |
| 42 | } | |
| 43 | this.doc = doc; | |
| 44 | this.openElements = [doc]; | |
| 45 | this.in = i; | |
| 46 | this.scriptsExecutedAfterParsing = []; | |
| 47 | } // Parser | } // Parser |
| 48 | ||
| 49 | Parser.prototype.getNextToken = function (i) { | Parser.prototype.getNextToken = function () { |
| 50 | var p = this; | |
| 51 | var i = this.in; | |
| 52 | if (this.parseMode == 'script') { | if (this.parseMode == 'script') { |
| 53 | var token; | var token; |
| 54 | i.s = i.s.replace (/^([\s\S]+?)<\/[Ss][Cc][Rr][Ii][Pp][Tt]>/, | if (p.insertionPoint <= 0) { |
| 55 | return {type: 'abort'}; | |
| 56 | } | |
| 57 | i.s = i.s.replace (/^([^<]+)/, | |
| 58 | function (s, t) { | function (s, t) { |
| 59 | if (0 < p.insertionPoint && p.insertionPoint < t.length) { | |