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

Function tokenBase

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

Source from the content-addressed store, hash-verified

23 cssValuesWithBracketsRegexp = new RegExp("^(" + cssValuesWithBrackets_.join("|") + ")\\([\\w\-\\#\\,\\.\\%\\s\\(\\)]*\\)");
24
25 var tokenBase = function(stream, state) {
26
27 if (stream.eatSpace()) return null;
28
29 var ch = stream.peek();
30
31 // Single line Comment
32 if (stream.match('//')) {
33 stream.skipToEnd();
34 return "comment";
35 }
36
37 // Multiline Comment
38 if (stream.match('/*')) {
39 state.tokenizer = multilineComment;
40 return state.tokenizer(stream, state);
41 }
42
43 // Strings
44 if (ch === '"' || ch === "'") {
45 stream.next();
46 state.tokenizer = buildStringTokenizer(ch);
47 return "string";
48 }
49
50 // Def
51 if (ch === "@") {
52 stream.next();
53 if (stream.match(/extend/)) {
54 dedent(state); // remove indentation after selectors
55 } else if (stream.match(/media[\w-\s]*[\w-]/)) {
56 indent(state);
57 } else if(stream.eatWhile(/[\w-]/)) {
58 if(stream.current().match(commonDefRegexp)) {
59 indent(state);
60 }
61 }
62 return "def";
63 }
64
65 // Number
66 if (stream.match(/^-?[0-9\.]/, false)) {
67
68 // Floats
69 if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i) || stream.match(/^-?\d+\.\d*/)) {
70
71 // Prevent from getting extra . on 1..
72 if (stream.peek() == ".") {
73 stream.backUp(1);
74 }
75 // Units
76 stream.eatWhile(/[a-z%]/i);
77 return "number";
78 }
79 // Integers
80 if (stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/) || stream.match(/^-?0(?![\dx])/i)) {
81 // Units
82 stream.eatWhile(/[a-z%]/i);

Callers 1

Calls 4

buildStringTokenizerFunction · 0.70
dedentFunction · 0.70
indentFunction · 0.70
wordRegexpFunction · 0.70

Tested by

no test coverage detected