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

Function html

static/editor.md/lib/codemirror/mode/haml/haml.js:41–94  ·  view source on GitHub ↗
(stream, state)

Source from the content-addressed store, hash-verified

39 }
40
41 function html(stream, state) {
42 var ch = stream.peek();
43
44 // handle haml declarations. All declarations that cant be handled here
45 // will be passed to html mode
46 if (state.previousToken.style == "comment" ) {
47 if (state.indented > state.previousToken.indented) {
48 stream.skipToEnd();
49 return "commentLine";
50 }
51 }
52
53 if (state.startOfLine) {
54 if (ch == "!" && stream.match("!!")) {
55 stream.skipToEnd();
56 return "tag";
57 } else if (stream.match(/^%[\w:#\.]+=/)) {
58 state.tokenize = ruby;
59 return "hamlTag";
60 } else if (stream.match(/^%[\w:]+/)) {
61 return "hamlTag";
62 } else if (ch == "/" ) {
63 stream.skipToEnd();
64 return "comment";
65 }
66 }
67
68 if (state.startOfLine || state.previousToken.style == "hamlTag") {
69 if ( ch == "#" || ch == ".") {
70 stream.match(/[\w-#\.]*/);
71 return "hamlAttribute";
72 }
73 }
74
75 // donot handle --> as valid ruby, make it HTML close comment instead
76 if (state.startOfLine && !stream.match("-->", false) && (ch == "=" || ch == "-" )) {
77 state.tokenize = ruby;
78 return state.tokenize(stream, state);
79 }
80
81 if (state.previousToken.style == "hamlTag" ||
82 state.previousToken.style == "closeAttributeTag" ||
83 state.previousToken.style == "hamlAttribute") {
84 if (ch == "(") {
85 state.tokenize = rubyInQuote(")");
86 return state.tokenize(stream, state);
87 } else if (ch == "{") {
88 state.tokenize = rubyInQuote("}");
89 return state.tokenize(stream, state);
90 }
91 }
92
93 return htmlMode.token(stream, state.htmlState);
94 }
95
96 return {
97 // default to html mode

Callers

nothing calls this directly

Calls 1

rubyInQuoteFunction · 0.70

Tested by

no test coverage detected