sugar-high 0.4.5 → 0.4.6
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/README.md +18 -0
- package/lib/index.mjs +8 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
# Sugar High
|
|
2
|
+
|
|
3
|
+
[![Build][build-badge]][build]
|
|
4
|
+
[![Coverage][coverage-badge]][coverage]
|
|
5
|
+
[![Downloads][downloads-badge]][downloads]
|
|
6
|
+
|
|
2
7
|
### Introduction
|
|
3
8
|
|
|
4
9
|
Super lightweight JSX syntax highlighter, around 1KB after minified and gzipped
|
|
@@ -70,3 +75,16 @@ pre code {
|
|
|
70
75
|
|
|
71
76
|
MIT
|
|
72
77
|
|
|
78
|
+
<!-- Definitions -->
|
|
79
|
+
|
|
80
|
+
[build-badge]: https://github.com/huozhi/sugar-high/workflows/Test/badge.svg
|
|
81
|
+
|
|
82
|
+
[build]: https://github.com/huozhi/sugar-high/actions
|
|
83
|
+
|
|
84
|
+
[coverage-badge]: https://badge.fury.io/js/sugar-high.svg
|
|
85
|
+
|
|
86
|
+
[coverage]: https://codecov.io/github/huozhi/sugar-high
|
|
87
|
+
|
|
88
|
+
[downloads-badge]: https://img.shields.io/npm/dm/sugar-high.svg
|
|
89
|
+
|
|
90
|
+
[downloads]: https://www.npmjs.com/package/sugar-high
|
package/lib/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const jsxBrackets = new Set(['<', '>', '{', '}', '[', ']'])
|
|
4
4
|
const keywords = new Set([
|
|
5
5
|
'for',
|
|
6
|
+
'do',
|
|
6
7
|
'while',
|
|
7
8
|
'if',
|
|
8
9
|
'else',
|
|
@@ -52,7 +53,6 @@ const signs = new Set([
|
|
|
52
53
|
'%',
|
|
53
54
|
'=',
|
|
54
55
|
'!',
|
|
55
|
-
...jsxBrackets,
|
|
56
56
|
'&',
|
|
57
57
|
'|',
|
|
58
58
|
'^',
|
|
@@ -73,6 +73,7 @@ const signs = new Set([
|
|
|
73
73
|
'#',
|
|
74
74
|
'@',
|
|
75
75
|
'\\',
|
|
76
|
+
...jsxBrackets,
|
|
76
77
|
])
|
|
77
78
|
|
|
78
79
|
export const types = [
|
|
@@ -126,7 +127,7 @@ function encode(str) {
|
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
function isWord(chr) {
|
|
129
|
-
return /^[\w_]+$/.test(chr)
|
|
130
|
+
return /^[\w_]+$/.test(chr) || hasUnicode(chr)
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
function isCls(str) {
|
|
@@ -136,8 +137,12 @@ function isCls(str) {
|
|
|
136
137
|
str === 'null'
|
|
137
138
|
}
|
|
138
139
|
|
|
140
|
+
function hasUnicode(s) {
|
|
141
|
+
return /[^\u0000-\u007f]/.test(s);
|
|
142
|
+
}
|
|
143
|
+
|
|
139
144
|
function isIdentifierChar(chr) {
|
|
140
|
-
return /^[a-zA-Z_$]$/.test(chr)
|
|
145
|
+
return /^[a-zA-Z_$]$/.test(chr) || hasUnicode(chr)
|
|
141
146
|
}
|
|
142
147
|
|
|
143
148
|
function isIdentifier(str) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sugar-high",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./lib/index.mjs",
|
|
6
6
|
"description": "Super lightweight JSX syntax highlighter",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"codice": "^0.0.10",
|
|
20
|
-
"next": "
|
|
21
|
-
"react": "18.
|
|
22
|
-
"react-dom": "18.
|
|
20
|
+
"next": "canary",
|
|
21
|
+
"react": "^18.1.0",
|
|
22
|
+
"react-dom": "^18.1.0",
|
|
23
23
|
"sugar-high": "link:./",
|
|
24
|
-
"vitest": "
|
|
24
|
+
"vitest": "^0.13.1"
|
|
25
25
|
}
|
|
26
26
|
}
|