arche-highlight 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ArcheHighlight.es.js +10 -1
- package/ArcheHighlight.js +22 -4
- package/ArcheHighlight.mjs +10 -1
- package/package.json +1 -1
package/ArcheHighlight.es.js
CHANGED
|
@@ -30,8 +30,10 @@ function pushWordTerm(parsedElements, term, index, text) {
|
|
|
30
30
|
} else if (term == "NaN") {
|
|
31
31
|
parsedElements.push(Span({ class: "not-a-number" }, term))
|
|
32
32
|
} else {
|
|
33
|
+
const spaces = []
|
|
33
34
|
let c = text[index]
|
|
34
35
|
while (c === " " || c === "\n") {
|
|
36
|
+
spaces.push(c)
|
|
35
37
|
index += 1
|
|
36
38
|
c = text[index]
|
|
37
39
|
}
|
|
@@ -40,7 +42,9 @@ function pushWordTerm(parsedElements, term, index, text) {
|
|
|
40
42
|
} else {
|
|
41
43
|
parsedElements.push(term)
|
|
42
44
|
}
|
|
45
|
+
parsedElements.push(...spaces)
|
|
43
46
|
}
|
|
47
|
+
return index
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
function parseJavaScript(text) {
|
|
@@ -245,7 +249,12 @@ function parseJavaScript(text) {
|
|
|
245
249
|
}
|
|
246
250
|
else {
|
|
247
251
|
if (term.length > 0) {
|
|
248
|
-
pushWordTerm(parsedElements, term, index, text)
|
|
252
|
+
index = pushWordTerm(parsedElements, term, index, text)
|
|
253
|
+
c = text[index]
|
|
254
|
+
if (c !== " " && c !== "\n") {
|
|
255
|
+
term = ""
|
|
256
|
+
continue
|
|
257
|
+
}
|
|
249
258
|
}
|
|
250
259
|
parsedElements.push(c)
|
|
251
260
|
term = ""
|
package/ArcheHighlight.js
CHANGED
|
@@ -23,8 +23,8 @@ function testOperator(term) {
|
|
|
23
23
|
return term == "+" || term == "-" || term == "*" || term == "/" || term == "**" || term == "=" || term == "+=" || term == "++" || term == "-=" || term == "*=" || term == "/=" || term == "**=" || term == "==" || term == "===" || term == "!=" || term == "!==" || term == ">" || term == ">=" || term == "<" || term == "<=" || term == "?" || term == ":" || term == "&&" || term == "||" || term == "??" || term == "&" || term == "|" || term == "^" || term == "~" || term == ">>" || term == "<<" || term == "&=" || term == "|=" || term == "^="
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
// pushWordTerm(parsedElements Array<object|string>, term string) -> ()
|
|
27
|
-
function pushWordTerm(parsedElements, term) {
|
|
26
|
+
// pushWordTerm(parsedElements Array<object|string>, term string, index number, text string) -> ()
|
|
27
|
+
function pushWordTerm(parsedElements, term, index, text) {
|
|
28
28
|
if (term == "process" || term == "require" || term == "console" || term == "window" || term == "global" || term == "globalThis" || term == "isNaN") {
|
|
29
29
|
parsedElements.push(Span({ class: "global-object" }, term))
|
|
30
30
|
} else if (term == "undefined") {
|
|
@@ -36,8 +36,21 @@ function pushWordTerm(parsedElements, term) {
|
|
|
36
36
|
} else if (term == "NaN") {
|
|
37
37
|
parsedElements.push(Span({ class: "not-a-number" }, term))
|
|
38
38
|
} else {
|
|
39
|
-
|
|
39
|
+
const spaces = []
|
|
40
|
+
let c = text[index]
|
|
41
|
+
while (c === " " || c === "\n") {
|
|
42
|
+
spaces.push(c)
|
|
43
|
+
index += 1
|
|
44
|
+
c = text[index]
|
|
45
|
+
}
|
|
46
|
+
if (c === "(") {
|
|
47
|
+
parsedElements.push(Span({ class: "function-name" }, term))
|
|
48
|
+
} else {
|
|
49
|
+
parsedElements.push(term)
|
|
50
|
+
}
|
|
51
|
+
parsedElements.push(...spaces)
|
|
40
52
|
}
|
|
53
|
+
return index
|
|
41
54
|
}
|
|
42
55
|
|
|
43
56
|
function parseJavaScript(text) {
|
|
@@ -242,7 +255,12 @@ function parseJavaScript(text) {
|
|
|
242
255
|
}
|
|
243
256
|
else {
|
|
244
257
|
if (term.length > 0) {
|
|
245
|
-
pushWordTerm(parsedElements, term, index, text)
|
|
258
|
+
index = pushWordTerm(parsedElements, term, index, text)
|
|
259
|
+
c = text[index]
|
|
260
|
+
if (c !== " " && c !== "\n") {
|
|
261
|
+
term = ""
|
|
262
|
+
continue
|
|
263
|
+
}
|
|
246
264
|
}
|
|
247
265
|
parsedElements.push(c)
|
|
248
266
|
term = ""
|
package/ArcheHighlight.mjs
CHANGED
|
@@ -30,8 +30,10 @@ function pushWordTerm(parsedElements, term, index, text) {
|
|
|
30
30
|
} else if (term == "NaN") {
|
|
31
31
|
parsedElements.push(Span({ class: "not-a-number" }, term))
|
|
32
32
|
} else {
|
|
33
|
+
const spaces = []
|
|
33
34
|
let c = text[index]
|
|
34
35
|
while (c === " " || c === "\n") {
|
|
36
|
+
spaces.push(c)
|
|
35
37
|
index += 1
|
|
36
38
|
c = text[index]
|
|
37
39
|
}
|
|
@@ -40,7 +42,9 @@ function pushWordTerm(parsedElements, term, index, text) {
|
|
|
40
42
|
} else {
|
|
41
43
|
parsedElements.push(term)
|
|
42
44
|
}
|
|
45
|
+
parsedElements.push(...spaces)
|
|
43
46
|
}
|
|
47
|
+
return index
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
function parseJavaScript(text) {
|
|
@@ -245,7 +249,12 @@ function parseJavaScript(text) {
|
|
|
245
249
|
}
|
|
246
250
|
else {
|
|
247
251
|
if (term.length > 0) {
|
|
248
|
-
pushWordTerm(parsedElements, term, index, text)
|
|
252
|
+
index = pushWordTerm(parsedElements, term, index, text)
|
|
253
|
+
c = text[index]
|
|
254
|
+
if (c !== " " && c !== "\n") {
|
|
255
|
+
term = ""
|
|
256
|
+
continue
|
|
257
|
+
}
|
|
249
258
|
}
|
|
250
259
|
parsedElements.push(c)
|
|
251
260
|
term = ""
|