sugar-high 0.9.3 → 0.9.4

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 (3) hide show
  1. package/README.md +2 -2
  2. package/lib/index.js +12 -5
  3. package/package.json +8 -19
package/README.md CHANGED
@@ -97,9 +97,9 @@ You can use `.sh__token--<token type>` to customize the output node of each toke
97
97
 
98
98
  ### Use With Remark.js
99
99
 
100
- [Remark.js](https://remark.js.org/) is a powerful markdown processor, you can use the [sugar-high remark plugin](https://remark-sugar-high.vercel.app/) with remark.js to highlight code blocks in markdown.
100
+ [Remark.js](https://remark.js.org/) is a powerful markdown processor, you can use the [sugar-high remark plugin](https://sugar-high.vercel.app/remark) with remark.js to highlight code blocks in markdown.
101
101
 
102
- Check out the [documentation](https://remark-sugar-high.vercel.app/) for more details.
102
+ Check out the [readme](https://github.com/huozhi/sugar-high/tree/main/packages/remark-sugar-high) for more details.
103
103
 
104
104
  ### LICENSE
105
105
 
package/lib/index.js CHANGED
@@ -275,7 +275,7 @@ function tokenize(code, options) {
275
275
  if (isJsxLiterals) return T_JSX_LITERALS
276
276
 
277
277
  // Determine strings first before other types
278
- if (inStringQuotes()) {
278
+ if (inStringQuotes() || inStrTemplateLiterals()) {
279
279
  return T_STRING
280
280
  } else if (keywords.has(token)) {
281
281
  return last[1] === '.' ? T_IDENTIFIER : T_KEYWORD
@@ -326,9 +326,9 @@ function tokenize(code, options) {
326
326
  const p_c = prev + curr // previous and current
327
327
  const c_n = curr + next // current and next
328
328
 
329
- // Determine string quotation outside of jsx literals.
330
- // Inside jsx literals, string quotation is still part of it.
331
- if (isSingleQuotes(curr) && !inJsxLiterals()) {
329
+ // Determine string quotation outside of jsx literals and template literals.
330
+ // Inside jsx literals or template literals, string quotation is still part of it.
331
+ if (isSingleQuotes(curr) && !inJsxLiterals() && !inStrTemplateLiterals()) {
332
332
  append()
333
333
  if (prev !== `\\`) {
334
334
  if (__strQuote && curr === __strQuote) {
@@ -599,6 +599,8 @@ function tokenize(code, options) {
599
599
  } else if (
600
600
  // it's jsx literals and is not a jsx bracket
601
601
  (isJsxLiterals && !JSXBrackets.has(curr)) ||
602
+ // it's template literal content (including quotes)
603
+ inStrTemplateLiterals() ||
602
604
  // same type char as previous one in current token
603
605
  ((isWord(curr) === isWord(current[current.length - 1]) || __jsxChild()) && !Signs.has(curr))
604
606
  ) {
@@ -737,7 +739,12 @@ function toHtml(lines) {
737
739
  /**
738
740
  *
739
741
  * @param {string} code
740
- * @param {{ keywords: Set<string> } | undefined} options
742
+ * @param {
743
+ * {
744
+ * keywords: Set<string>
745
+ * onCommentStart?: (curr: string, next: string) => number | boolean
746
+ * onCommentEnd?: (curr: string, prev: string) => number | boolean
747
+ * } | undefined} options
741
748
  * @returns {string}
742
749
  */
743
750
  function highlight(code, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sugar-high",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "type": "module",
5
5
  "types": "./lib/index.d.ts",
6
6
  "main": "./lib/index.js",
@@ -19,25 +19,14 @@
19
19
  "lib"
20
20
  ],
21
21
  "license": "MIT",
22
- "scripts": {
23
- "test": "vitest",
24
- "dev": "next dev docs",
25
- "build": "next build docs"
26
- },
27
22
  "devDependencies": {
28
- "@types/node": "22.10.7",
29
- "@types/react": "19.0.7",
30
- "codice": "^1.3.1",
31
- "dom-to-image": "^2.6.0",
32
- "next": "15.1.5",
33
- "react": "^19.0.0",
34
- "react-dom": "^19.0.0",
35
- "sugar-high": "link:./",
23
+ "@types/node": "22.12.0",
36
24
  "typescript": "5.7.3",
37
25
  "vitest": "^3.0.2"
38
26
  },
39
- "resolutions": {
40
- "sugar-high": "link:./"
41
- },
42
- "packageManager": "pnpm@8.7.1"
43
- }
27
+ "packageManager": "pnpm@8.7.1",
28
+ "scripts": {
29
+ "test": "vitest",
30
+ "build": "echo 'package requires no build'"
31
+ }
32
+ }