sugar-high 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/lib/index.mjs +9 -4
  2. package/package.json +1 -1
package/lib/index.mjs CHANGED
@@ -147,7 +147,7 @@ function isRegexStart(str) {
147
147
  export function tokenize(code) {
148
148
  let current = ''
149
149
  let type = -1
150
- let nonSpaceType = -1
150
+ let last = [null, null]
151
151
  /** @type {Array<[number, string]>} */
152
152
  const tokens = []
153
153
 
@@ -197,8 +197,12 @@ export function tokenize(code) {
197
197
  const append = () => {
198
198
  if (current) {
199
199
  type = classify(current)
200
- if (type !== T_SPACE && type !== T_BREAK) nonSpaceType = type
201
- tokens.push([type, current])
200
+ /** @type [number, string] */
201
+ const pair = [type, current]
202
+ if (type !== T_SPACE && type !== T_BREAK) {
203
+ last = pair
204
+ }
205
+ tokens.push(pair)
202
206
  }
203
207
  current = ''
204
208
  }
@@ -226,7 +230,8 @@ export function tokenize(code) {
226
230
  (isStringQuotation(curr) || !jsx.tag && isRegexStart(c_n))
227
231
  ) {
228
232
  append()
229
- if (!(nonSpaceType === T_SIGN || nonSpaceType === T_COMMENT)) {
233
+ const [lastType, lastToken] = last
234
+ if (!((lastType === T_SIGN && !'()[]'.includes(lastToken)) || lastType === T_COMMENT)) {
230
235
  current = curr
231
236
  append()
232
237
  continue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sugar-high",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "exports": "./lib/index.mjs",
6
6
  "description": "Super lightweight JSX syntax highlighter",