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

Function tokenBase

static/editor.md/lib/codemirror/mode/dtd/dtd.js:25–52  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

23 function ret(style, tp) {type = tp; return style;}
24
25 function tokenBase(stream, state) {
26 var ch = stream.next();
27
28 if (ch == "<" && stream.eat("!") ) {
29 if (stream.eatWhile(/[\-]/)) {
30 state.tokenize = tokenSGMLComment;
31 return tokenSGMLComment(stream, state);
32 } else if (stream.eatWhile(/[\w]/)) return ret("keyword", "doindent");
33 } else if (ch == "<" && stream.eat("?")) { //xml declaration
34 state.tokenize = inBlock("meta", "?>");
35 return ret("meta", ch);
36 } else if (ch == "#" && stream.eatWhile(/[\w]/)) return ret("atom", "tag");
37 else if (ch == "|") return ret("keyword", "seperator");
38 else if (ch.match(/[\(\)\[\]\-\.,\+\?>]/)) return ret(null, ch);//if(ch === ">") return ret(null, "endtag"); else
39 else if (ch.match(/[\[\]]/)) return ret("rule", ch);
40 else if (ch == "\"" || ch == "'") {
41 state.tokenize = tokenString(ch);
42 return state.tokenize(stream, state);
43 } else if (stream.eatWhile(/[a-zA-Z\?\+\d]/)) {
44 var sc = stream.current();
45 if( sc.substr(sc.length-1,sc.length).match(/\?|\+/) !== null )stream.backUp(1);
46 return ret("tag", "tag");
47 } else if (ch == "%" || ch == "*" ) return ret("number", "number");
48 else {
49 stream.eatWhile(/[\w\\\-_%.{,]/);
50 return ret(null, null);
51 }
52 }
53
54 function tokenSGMLComment(stream, state) {
55 var dashes = 0, ch;

Callers

nothing calls this directly

Calls 4

tokenSGMLCommentFunction · 0.70
retFunction · 0.70
inBlockFunction · 0.70
tokenStringFunction · 0.70

Tested by

no test coverage detected