| 45 | var tagName, type; |
| 46 | |
| 47 | function inText(stream, state) { |
| 48 | function chain(parser) { |
| 49 | state.tokenize = parser; |
| 50 | return parser(stream, state); |
| 51 | } |
| 52 | |
| 53 | var ch = stream.next(); |
| 54 | if (ch == "<") { |
| 55 | if (stream.eat("!")) { |
| 56 | if (stream.eat("[")) { |
| 57 | if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>")); |
| 58 | else return null; |
| 59 | } |
| 60 | else if (stream.match("--")) return chain(inBlock("comment", "-->")); |
| 61 | else if (stream.match("DOCTYPE", true, true)) { |
| 62 | stream.eatWhile(/[\w\._\-]/); |
| 63 | return chain(doctype(1)); |
| 64 | } |
| 65 | else return null; |
| 66 | } |
| 67 | else if (stream.eat("?")) { |
| 68 | stream.eatWhile(/[\w\._\-]/); |
| 69 | state.tokenize = inBlock("meta", "?>"); |
| 70 | return "meta"; |
| 71 | } |
| 72 | else { |
| 73 | type = stream.eat("/") ? "closeTag" : "openTag"; |
| 74 | stream.eatSpace(); |
| 75 | tagName = ""; |
| 76 | var c; |
| 77 | while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c; |
| 78 | state.tokenize = inTag; |
| 79 | return "tag"; |
| 80 | } |
| 81 | } |
| 82 | else if (ch == "&") { |
| 83 | var ok; |
| 84 | if (stream.eat("#")) { |
| 85 | if (stream.eat("x")) { |
| 86 | ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";"); |
| 87 | } else { |
| 88 | ok = stream.eatWhile(/[\d]/) && stream.eat(";"); |
| 89 | } |
| 90 | } else { |
| 91 | ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";"); |
| 92 | } |
| 93 | return ok ? "atom" : "error"; |
| 94 | } |
| 95 | else { |
| 96 | stream.eatWhile(/[^&<]/); |
| 97 | return null; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | function inTag(stream, state) { |
| 102 | var ch = stream.next(); |