MCPcopy Create free account
hub / github.com/TruthHun/BookStack / inText

Function inText

static/editor.md/lib/codemirror/mode/xml/xml.js:66–111  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

64 var type, setStyle;
65
66 function inText(stream, state) {
67 function chain(parser) {
68 state.tokenize = parser;
69 return parser(stream, state);
70 }
71
72 var ch = stream.next();
73 if (ch == "<") {
74 if (stream.eat("!")) {
75 if (stream.eat("[")) {
76 if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
77 else return null;
78 } else if (stream.match("--")) {
79 return chain(inBlock("comment", "-->"));
80 } else if (stream.match("DOCTYPE", true, true)) {
81 stream.eatWhile(/[\w\._\-]/);
82 return chain(doctype(1));
83 } else {
84 return null;
85 }
86 } else if (stream.eat("?")) {
87 stream.eatWhile(/[\w\._\-]/);
88 state.tokenize = inBlock("meta", "?>");
89 return "meta";
90 } else {
91 type = stream.eat("/") ? "closeTag" : "openTag";
92 state.tokenize = inTag;
93 return "tag bracket";
94 }
95 } else if (ch == "&") {
96 var ok;
97 if (stream.eat("#")) {
98 if (stream.eat("x")) {
99 ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
100 } else {
101 ok = stream.eatWhile(/[\d]/) && stream.eat(";");
102 }
103 } else {
104 ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
105 }
106 return ok ? "atom" : "error";
107 } else {
108 stream.eatWhile(/[^&<]/);
109 return null;
110 }
111 }
112
113 function inTag(stream, state) {
114 var ch = stream.next();

Callers

nothing calls this directly

Calls 3

chainFunction · 0.70
inBlockFunction · 0.70
doctypeFunction · 0.70

Tested by

no test coverage detected