arche-highlight 0.7.0 → 0.7.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 +16 -2
- package/ArcheHighlight.mjs +16 -2
- package/package.json +1 -1
package/ArcheHighlight.es.js
CHANGED
|
@@ -41,6 +41,7 @@ function parseJavaScript(text) {
|
|
|
41
41
|
|
|
42
42
|
let index = 0
|
|
43
43
|
let term = ""
|
|
44
|
+
let isShebangInterpreterDirective = false
|
|
44
45
|
let isSingleLineComment = false
|
|
45
46
|
let isMultiLineComment = false
|
|
46
47
|
let isNumber = false
|
|
@@ -54,7 +55,11 @@ function parseJavaScript(text) {
|
|
|
54
55
|
while (index < text.length) {
|
|
55
56
|
let c = text[index]
|
|
56
57
|
|
|
57
|
-
if (
|
|
58
|
+
if (isShebangInterpreterDirective && c === "\n") {
|
|
59
|
+
isShebangInterpreterDirective = false
|
|
60
|
+
parsedElements.push(Span({ class: "shebang-interpreter-directive" }, term))
|
|
61
|
+
term = ""
|
|
62
|
+
} else if (isSingleLineComment && c === "\n") {
|
|
58
63
|
isSingleLineComment = false
|
|
59
64
|
parsedElements.push(Span({ class: "comment" }, term))
|
|
60
65
|
term = ""
|
|
@@ -120,7 +125,10 @@ function parseJavaScript(text) {
|
|
|
120
125
|
break
|
|
121
126
|
}
|
|
122
127
|
|
|
123
|
-
if (
|
|
128
|
+
if (isShebangInterpreterDirective) {
|
|
129
|
+
term += c
|
|
130
|
+
index += 1
|
|
131
|
+
} else if (isSingleLineComment) {
|
|
124
132
|
term += c
|
|
125
133
|
index += 1
|
|
126
134
|
} else if (isMultiLineComment) {
|
|
@@ -163,6 +171,10 @@ function parseJavaScript(text) {
|
|
|
163
171
|
term += c
|
|
164
172
|
index += 1
|
|
165
173
|
}
|
|
174
|
+
} else if (c === "#" && text[index + 1] === "!") {
|
|
175
|
+
isShebangInterpreterDirective = true
|
|
176
|
+
term += c
|
|
177
|
+
index += 1
|
|
166
178
|
} else if (c === "/" && text[index + 1] === "/") {
|
|
167
179
|
isSingleLineComment = true
|
|
168
180
|
term += c
|
|
@@ -320,6 +332,8 @@ function parseJavaScript(text) {
|
|
|
320
332
|
if (term.length > 0) {
|
|
321
333
|
if (isSingleLineComment) {
|
|
322
334
|
parsedElements.push(Span({ class: "comment" }, term))
|
|
335
|
+
} else if (isShebangInterpreterDirective) {
|
|
336
|
+
parsedElements.push(Span({ class: "shebang-interpreter-directive" }, term))
|
|
323
337
|
} else if (isNumber) {
|
|
324
338
|
if (term[term.length - 1] === "n") {
|
|
325
339
|
parsedElements.push(Span({ class: "bigint" }, term))
|
package/ArcheHighlight.mjs
CHANGED
|
@@ -41,6 +41,7 @@ function parseJavaScript(text) {
|
|
|
41
41
|
|
|
42
42
|
let index = 0
|
|
43
43
|
let term = ""
|
|
44
|
+
let isShebangInterpreterDirective = false
|
|
44
45
|
let isSingleLineComment = false
|
|
45
46
|
let isMultiLineComment = false
|
|
46
47
|
let isNumber = false
|
|
@@ -54,7 +55,11 @@ function parseJavaScript(text) {
|
|
|
54
55
|
while (index < text.length) {
|
|
55
56
|
let c = text[index]
|
|
56
57
|
|
|
57
|
-
if (
|
|
58
|
+
if (isShebangInterpreterDirective && c === "\n") {
|
|
59
|
+
isShebangInterpreterDirective = false
|
|
60
|
+
parsedElements.push(Span({ class: "shebang-interpreter-directive" }, term))
|
|
61
|
+
term = ""
|
|
62
|
+
} else if (isSingleLineComment && c === "\n") {
|
|
58
63
|
isSingleLineComment = false
|
|
59
64
|
parsedElements.push(Span({ class: "comment" }, term))
|
|
60
65
|
term = ""
|
|
@@ -120,7 +125,10 @@ function parseJavaScript(text) {
|
|
|
120
125
|
break
|
|
121
126
|
}
|
|
122
127
|
|
|
123
|
-
if (
|
|
128
|
+
if (isShebangInterpreterDirective) {
|
|
129
|
+
term += c
|
|
130
|
+
index += 1
|
|
131
|
+
} else if (isSingleLineComment) {
|
|
124
132
|
term += c
|
|
125
133
|
index += 1
|
|
126
134
|
} else if (isMultiLineComment) {
|
|
@@ -163,6 +171,10 @@ function parseJavaScript(text) {
|
|
|
163
171
|
term += c
|
|
164
172
|
index += 1
|
|
165
173
|
}
|
|
174
|
+
} else if (c === "#" && text[index + 1] === "!") {
|
|
175
|
+
isShebangInterpreterDirective = true
|
|
176
|
+
term += c
|
|
177
|
+
index += 1
|
|
166
178
|
} else if (c === "/" && text[index + 1] === "/") {
|
|
167
179
|
isSingleLineComment = true
|
|
168
180
|
term += c
|
|
@@ -320,6 +332,8 @@ function parseJavaScript(text) {
|
|
|
320
332
|
if (term.length > 0) {
|
|
321
333
|
if (isSingleLineComment) {
|
|
322
334
|
parsedElements.push(Span({ class: "comment" }, term))
|
|
335
|
+
} else if (isShebangInterpreterDirective) {
|
|
336
|
+
parsedElements.push(Span({ class: "shebang-interpreter-directive" }, term))
|
|
323
337
|
} else if (isNumber) {
|
|
324
338
|
if (term[term.length - 1] === "n") {
|
|
325
339
|
parsedElements.push(Span({ class: "bigint" }, term))
|