sugar-high 2.0.3 → 2.1.0

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 (61) hide show
  1. package/README.md +14 -0
  2. package/lib/lang/c.d.ts +5 -0
  3. package/lib/{presets/lang → lang}/c.js +1 -1
  4. package/lib/lang/cpp.d.ts +5 -0
  5. package/lib/{presets/lang → lang}/cpp.js +1 -1
  6. package/lib/lang/csharp.d.ts +5 -0
  7. package/lib/{presets/lang → lang}/csharp.js +1 -1
  8. package/lib/lang/css.d.ts +5 -0
  9. package/lib/{presets/lang → lang}/css.js +3 -3
  10. package/lib/lang/diff.d.ts +2 -0
  11. package/lib/lang/dockerfile.d.ts +5 -0
  12. package/lib/{presets/lang → lang}/dockerfile.js +1 -1
  13. package/lib/lang/go.d.ts +5 -0
  14. package/lib/{presets/lang → lang}/go.js +1 -1
  15. package/lib/lang/graphql.d.ts +5 -0
  16. package/lib/{presets/lang → lang}/graphql.js +1 -1
  17. package/lib/lang/hcl.d.ts +3 -0
  18. package/lib/lang/html.d.ts +8 -0
  19. package/lib/{presets/lang → lang}/html.js +1 -1
  20. package/lib/lang/java.d.ts +5 -0
  21. package/lib/{presets/lang → lang}/java.js +1 -1
  22. package/lib/lang/javascript.d.ts +2 -0
  23. package/lib/{presets/lang → lang}/javascript.js +1 -1
  24. package/lib/lang/json.d.ts +5 -0
  25. package/lib/{presets/lang → lang}/json.js +1 -1
  26. package/lib/lang/kotlin.d.ts +5 -0
  27. package/lib/{presets/lang → lang}/kotlin.js +1 -1
  28. package/lib/lang/markdown.d.ts +5 -0
  29. package/lib/{presets/lang → lang}/markdown.js +1 -1
  30. package/lib/lang/php.d.ts +4 -0
  31. package/lib/lang/powershell.d.ts +4 -0
  32. package/lib/lang/python.d.ts +3 -0
  33. package/lib/lang/rust.d.ts +8 -0
  34. package/lib/lang/shell.d.ts +4 -0
  35. package/lib/{presets/lang → lang}/shell.js +1 -1
  36. package/lib/lang/sql.d.ts +5 -0
  37. package/lib/lang/swift.d.ts +5 -0
  38. package/lib/{presets/lang → lang}/swift.js +1 -1
  39. package/lib/lang/toml.d.ts +5 -0
  40. package/lib/{presets/lang → lang}/toml.js +1 -1
  41. package/lib/lang/typescript.d.ts +1 -0
  42. package/lib/{presets/lang → lang}/typescript.js +1 -1
  43. package/lib/lang/yaml.d.ts +5 -0
  44. package/lib/{presets/lang → lang}/yaml.js +1 -1
  45. package/lib/lang.js +25 -25
  46. package/lib/presets/clike-base.d.ts +2 -0
  47. package/lib/presets/hash-comment-base.d.ts +2 -0
  48. package/lib/presets/javascript-runtime.d.ts +37 -0
  49. package/lib/presets/{lang/javascript-runtime.js → javascript-runtime.js} +2 -2
  50. package/lib/presets/plain-base.d.ts +2 -0
  51. package/package.json +5 -1
  52. /package/lib/{presets/lang → lang}/diff.js +0 -0
  53. /package/lib/{presets/lang → lang}/hcl.js +0 -0
  54. /package/lib/{presets/lang → lang}/php.js +0 -0
  55. /package/lib/{presets/lang → lang}/powershell.js +0 -0
  56. /package/lib/{presets/lang → lang}/python.js +0 -0
  57. /package/lib/{presets/lang → lang}/rust.js +0 -0
  58. /package/lib/{presets/lang → lang}/sql.js +0 -0
  59. /package/lib/presets/{lang/clike-base.js → clike-base.js} +0 -0
  60. /package/lib/presets/{lang/hash-comment-base.js → hash-comment-base.js} +0 -0
  61. /package/lib/presets/{lang/plain-base.js → plain-base.js} +0 -0
package/README.md CHANGED
@@ -79,6 +79,20 @@ const html = render(parsed, {
79
79
  })
80
80
  ```
81
81
 
82
+ If bundle size matters and you only need a few built-in languages, import their configurations
83
+ directly instead of loading the complete registry from `sugar-high` or `sugar-high/lang`:
84
+
85
+ ```js
86
+ import { parse, render } from 'sugar-high/core'
87
+ import * as css from 'sugar-high/lang/css'
88
+ import * as python from 'sugar-high/lang/python'
89
+
90
+ const languages = { css, python }
91
+
92
+ const highlight = (code, language) =>
93
+ render(parse(code, languages[language]))
94
+ ```
95
+
82
96
  Use the default `sugar-high` export when you want built-in languages and one-step `highlight()`.
83
97
 
84
98
  ## Customize tokens
@@ -0,0 +1,5 @@
1
+ export const typeKeywords: Set<string>;
2
+ export const keywords: Set<string>;
3
+ import { onCommentStart } from '../presets/clike-base.js';
4
+ import { onCommentEnd } from '../presets/clike-base.js';
5
+ export { onCommentStart, onCommentEnd };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { onCommentStart, onCommentEnd } from './clike-base.js'
2
+ import { onCommentStart, onCommentEnd } from '../presets/clike-base.js'
3
3
 
4
4
  export const typeKeywords = new Set([
5
5
  'void', 'char', 'short', 'int', 'long', 'float', 'double', 'signed', 'unsigned',
@@ -0,0 +1,5 @@
1
+ export const keywords: Set<string>;
2
+ export const typeKeywords: Set<string>;
3
+ import { onCommentEnd } from '../presets/clike-base.js';
4
+ import { onCommentStart } from '../presets/clike-base.js';
5
+ export { onCommentEnd, onCommentStart };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { onCommentEnd, onCommentStart } from './clike-base.js'
2
+ import { onCommentEnd, onCommentStart } from '../presets/clike-base.js'
3
3
 
4
4
  export const keywords = new Set([
5
5
  'alignas', 'alignof', 'and', 'and_eq', 'asm', 'auto', 'bitand', 'bitor', 'break',
@@ -0,0 +1,5 @@
1
+ export const keywords: Set<string>;
2
+ export const typeKeywords: Set<string>;
3
+ import { onCommentEnd } from '../presets/clike-base.js';
4
+ import { onCommentStart } from '../presets/clike-base.js';
5
+ export { onCommentEnd, onCommentStart };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { onCommentEnd, onCommentStart } from './clike-base.js'
2
+ import { onCommentEnd, onCommentStart } from '../presets/clike-base.js'
3
3
 
4
4
  export const keywords = new Set([
5
5
  'abstract', 'as', 'async', 'await', 'base', 'break', 'case', 'catch', 'checked',
@@ -0,0 +1,5 @@
1
+ export const keywords: Set<string>;
2
+ export function onCommentStart(currentChar: any, nextChar: any): 1 | 0;
3
+ export function onCommentEnd(prevChar: any, currChar: any): 1 | 0;
4
+ export function onLiteral(curr: any, index: any, code: any): any;
5
+ export function tokenize(code: string, options: import("../core.js").ParseOptions): [number, string][];
@@ -1,8 +1,8 @@
1
1
  // @ts-check
2
2
  import {
3
3
  T_BREAK, T_CLASS, T_COMMENT, T_IDENTIFIER, T_PROPERTY, T_SIGN, T_SPACE,
4
- } from '../../shared.js'
5
- import { tokenize as tokenizePlain } from '../../core.js'
4
+ } from '../shared.js'
5
+ import { tokenize as tokenizePlain } from '../core.js'
6
6
 
7
7
  export const keywords = new Set([
8
8
  // css keywords like @media, @import, @keyframes, etc.
@@ -88,7 +88,7 @@ const opensBlock = (tokens, start) => {
88
88
  /**
89
89
  * Add CSS declaration context after the shared plain lexer runs.
90
90
  * @param {string} code
91
- * @param {import('../../core.js').ParseOptions} options
91
+ * @param {import('../core.js').ParseOptions} options
92
92
  */
93
93
  export const tokenize = (code, options) => {
94
94
  const tokens = tokenizePlain(code, { ...options, tokenize: undefined })
@@ -0,0 +1,2 @@
1
+ export const keywords: Set<never>;
2
+ export function annotateLine(line: any): void;
@@ -0,0 +1,5 @@
1
+ export const caseInsensitive: true;
2
+ export const keywords: Set<string>;
3
+ import { onCommentEnd } from '../presets/hash-comment-base.js';
4
+ import { onCommentStart } from '../presets/hash-comment-base.js';
5
+ export { onCommentEnd, onCommentStart };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { onCommentEnd, onCommentStart } from './hash-comment-base.js'
2
+ import { onCommentEnd, onCommentStart } from '../presets/hash-comment-base.js'
3
3
  export const caseInsensitive = true
4
4
  export const keywords = new Set(['add','arg','cmd','copy','entrypoint','env','expose','from','healthcheck','label','maintainer','onbuild','run','shell','stopsignal','user','volume','workdir'])
5
5
  export { onCommentEnd, onCommentStart }
@@ -0,0 +1,5 @@
1
+ export const typeKeywords: Set<string>;
2
+ export const keywords: Set<string>;
3
+ import { onCommentStart } from '../presets/clike-base.js';
4
+ import { onCommentEnd } from '../presets/clike-base.js';
5
+ export { onCommentStart, onCommentEnd };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { onCommentStart, onCommentEnd } from './clike-base.js'
2
+ import { onCommentStart, onCommentEnd } from '../presets/clike-base.js'
3
3
 
4
4
  export const typeKeywords = new Set([
5
5
  'bool', 'byte', 'complex64', 'complex128', 'error', 'float32', 'float64', 'int',
@@ -0,0 +1,5 @@
1
+ export const keywords: Set<string>;
2
+ export const typeKeywords: Set<string>;
3
+ import { onCommentEnd } from '../presets/hash-comment-base.js';
4
+ import { onCommentStart } from '../presets/hash-comment-base.js';
5
+ export { onCommentEnd, onCommentStart };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { onCommentEnd, onCommentStart } from './hash-comment-base.js'
2
+ import { onCommentEnd, onCommentStart } from '../presets/hash-comment-base.js'
3
3
  export const keywords = new Set(['directive','enum','extend','fragment','implements','input','interface','mutation','on','query','repeatable','scalar','schema','subscription','type','union'])
4
4
  export const typeKeywords = new Set(['Boolean','Float','ID','Int','String'])
5
5
  export { onCommentEnd, onCommentStart }
@@ -0,0 +1,3 @@
1
+ export const keywords: Set<string>;
2
+ export function onCommentStart(curr: any, next: any): 1 | 0 | 2;
3
+ export function onCommentEnd(prev: any, curr: any): 1 | 0 | 2;
@@ -0,0 +1,8 @@
1
+ export const keywords: Set<never>;
2
+ export const jsx: true;
3
+ export const regex: false;
4
+ export const templateStrings: false;
5
+ export const tokenize: typeof tokenizeJavaScript;
6
+ export function onCommentStart(_currentChar: any, _nextChar: any, index: any, code: any): 0 | 2;
7
+ export function onCommentEnd(_prevChar: any, _currChar: any, index: any, code: any): 0 | 2;
8
+ import { tokenize as tokenizeJavaScript } from '../presets/javascript-runtime.js';
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { tokenize as tokenizeJavaScript } from './javascript-runtime.js'
2
+ import { tokenize as tokenizeJavaScript } from '../presets/javascript-runtime.js'
3
3
 
4
4
  export const keywords = new Set([])
5
5
  export const jsx = true
@@ -0,0 +1,5 @@
1
+ export const typeKeywords: Set<string>;
2
+ export const keywords: Set<string>;
3
+ import { onCommentStart } from '../presets/clike-base.js';
4
+ import { onCommentEnd } from '../presets/clike-base.js';
5
+ export { onCommentStart, onCommentEnd };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { onCommentStart, onCommentEnd } from './clike-base.js'
2
+ import { onCommentStart, onCommentEnd } from '../presets/clike-base.js'
3
3
 
4
4
  export const typeKeywords = new Set([
5
5
  'boolean', 'byte', 'char', 'double', 'float', 'int', 'long', 'short', 'void',
@@ -0,0 +1,2 @@
1
+ export const tokenize: typeof tokenizeJavaScript;
2
+ import { tokenize as tokenizeJavaScript } from '../presets/javascript-runtime.js';
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { tokenize as tokenizeJavaScript } from './javascript-runtime.js'
2
+ import { tokenize as tokenizeJavaScript } from '../presets/javascript-runtime.js'
3
3
 
4
4
  // JavaScript includes JSX and preserves the lightweight TypeScript heuristic used by the default
5
5
  // highlighter. Use the TypeScript preset to force TS/TSX behavior for ambiguous snippets.
@@ -0,0 +1,5 @@
1
+ export const keywords: Set<string>;
2
+ export const quotedKeys: true;
3
+ import { onCommentEnd } from '../presets/clike-base.js';
4
+ import { onCommentStart } from '../presets/clike-base.js';
5
+ export { onCommentEnd, onCommentStart };
@@ -1,6 +1,6 @@
1
1
  // @ts-check
2
2
 
3
- import { onCommentEnd, onCommentStart } from './clike-base.js'
3
+ import { onCommentEnd, onCommentStart } from '../presets/clike-base.js'
4
4
 
5
5
  export const keywords = new Set(['true', 'false', 'null'])
6
6
  export const quotedKeys = true
@@ -0,0 +1,5 @@
1
+ export const keywords: Set<string>;
2
+ export const typeKeywords: Set<string>;
3
+ import { onCommentEnd } from '../presets/clike-base.js';
4
+ import { onCommentStart } from '../presets/clike-base.js';
5
+ export { onCommentEnd, onCommentStart };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { onCommentEnd, onCommentStart } from './clike-base.js'
2
+ import { onCommentEnd, onCommentStart } from '../presets/clike-base.js'
3
3
  export const keywords = new Set(['as','break','by','catch','class','companion','const','constructor','continue','data','do','else','enum','false','finally','for','fun','get','if','import','in','infix','init','interface','internal','is','lateinit','noinline','null','object','open','operator','out','override','package','private','protected','public','reified','return','sealed','set','suspend','tailrec','this','throw','true','try','typealias','val','var','vararg','when','where','while'])
4
4
  export const typeKeywords = new Set(['Any','Boolean','Byte','Char','Double','Float','Int','Long','Nothing','Short','String','Unit'])
5
5
  export { onCommentEnd, onCommentStart }
@@ -0,0 +1,5 @@
1
+ export const keywords: Set<never>;
2
+ export function annotateLine(line: any): void;
3
+ import { onCommentEnd } from '../presets/plain-base.js';
4
+ import { onCommentStart } from '../presets/plain-base.js';
5
+ export { onCommentEnd, onCommentStart };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { onCommentEnd, onCommentStart } from './plain-base.js'
2
+ import { onCommentEnd, onCommentStart } from '../presets/plain-base.js'
3
3
 
4
4
  export const keywords = new Set([])
5
5
 
@@ -0,0 +1,4 @@
1
+ export const keywords: Set<string>;
2
+ export const typeKeywords: Set<string>;
3
+ export function onCommentStart(curr: any, next: any): 1 | 0 | 2;
4
+ export function onCommentEnd(prev: any, curr: any): 1 | 0 | 2;
@@ -0,0 +1,4 @@
1
+ export const caseInsensitive: true;
2
+ export const keywords: Set<string>;
3
+ export function onCommentStart(curr: any, next: any): 1 | 0 | 2;
4
+ export function onCommentEnd(prev: any, curr: any): 1 | 0 | 2;
@@ -0,0 +1,3 @@
1
+ export const keywords: Set<string>;
2
+ export function onCommentStart(currentChar: any, _nextChar: any): 1 | 0;
3
+ export function onCommentEnd(_prevChar: any, currChar: any): 1 | 0;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @param {string} curr `code[i]` (apostrophe)
3
+ * @param {number} i
4
+ * @param {string} code
5
+ * @returns {number} code units to consume from `i`
6
+ */
7
+ export function onQuote(curr: string, i: number, code: string): number;
8
+ export const keywords: Set<string>;
@@ -0,0 +1,4 @@
1
+ export const keywords: Set<string>;
2
+ import { onCommentEnd } from '../presets/hash-comment-base.js';
3
+ import { onCommentStart } from '../presets/hash-comment-base.js';
4
+ export { onCommentEnd, onCommentStart };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { onCommentEnd, onCommentStart } from './hash-comment-base.js'
2
+ import { onCommentEnd, onCommentStart } from '../presets/hash-comment-base.js'
3
3
 
4
4
  export const keywords = new Set([
5
5
  'case', 'coproc', 'do', 'done', 'elif', 'else', 'esac', 'export', 'fi', 'for',
@@ -0,0 +1,5 @@
1
+ export const keywords: Set<string>;
2
+ export const typeKeywords: Set<string>;
3
+ export const caseInsensitive: true;
4
+ export function onCommentStart(currentChar: any, nextChar: any): 1 | 0 | 2;
5
+ export function onCommentEnd(prevChar: any, currChar: any): 1 | 0 | 2;
@@ -0,0 +1,5 @@
1
+ export const keywords: Set<string>;
2
+ export const typeKeywords: Set<string>;
3
+ import { onCommentEnd } from '../presets/clike-base.js';
4
+ import { onCommentStart } from '../presets/clike-base.js';
5
+ export { onCommentEnd, onCommentStart };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { onCommentEnd, onCommentStart } from './clike-base.js'
2
+ import { onCommentEnd, onCommentStart } from '../presets/clike-base.js'
3
3
  export const keywords = new Set(['as','associatedtype','break','case','catch','class','continue','convenience','default','defer','deinit','didSet','do','dynamic','else','enum','extension','fallthrough','false','fileprivate','final','for','func','get','guard','if','import','in','indirect','infix','init','inout','internal','is','lazy','let','mutating','nil','nonmutating','open','operator','override','precedencegroup','private','protocol','public','repeat','required','rethrows','return','self','set','some','static','struct','subscript','super','switch','throw','throws','true','try','typealias','unowned','var','weak','where','while','willSet'])
4
4
  export const typeKeywords = new Set(['Any','Bool','Character','Double','Float','Int','Never','String','UInt','Void'])
5
5
  export { onCommentEnd, onCommentStart }
@@ -0,0 +1,5 @@
1
+ export const keywords: Set<string>;
2
+ export const quotedKeys: true;
3
+ import { onCommentEnd } from '../presets/hash-comment-base.js';
4
+ import { onCommentStart } from '../presets/hash-comment-base.js';
5
+ export { onCommentEnd, onCommentStart };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { onCommentEnd, onCommentStart } from './hash-comment-base.js'
2
+ import { onCommentEnd, onCommentStart } from '../presets/hash-comment-base.js'
3
3
  export const keywords = new Set(['false','true'])
4
4
  export const quotedKeys = true
5
5
  export { onCommentEnd, onCommentStart }
@@ -0,0 +1 @@
1
+ export function tokenize(code: any, options: any): [number, string][];
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { tokenize as tokenizeJavaScript } from './javascript-runtime.js'
2
+ import { tokenize as tokenizeJavaScript } from '../presets/javascript-runtime.js'
3
3
 
4
4
  export const tokenize = (code, options) => tokenizeJavaScript(code, {
5
5
  ...options,
@@ -0,0 +1,5 @@
1
+ export const keywords: Set<string>;
2
+ export const quotedKeys: true;
3
+ import { onCommentEnd } from '../presets/hash-comment-base.js';
4
+ import { onCommentStart } from '../presets/hash-comment-base.js';
5
+ export { onCommentEnd, onCommentStart };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- import { onCommentEnd, onCommentStart } from './hash-comment-base.js'
2
+ import { onCommentEnd, onCommentStart } from '../presets/hash-comment-base.js'
3
3
 
4
4
  export const keywords = new Set([
5
5
  'false', 'False', 'FALSE', 'no', 'No', 'NO', 'null', 'Null', 'NULL',
package/lib/lang.js CHANGED
@@ -1,30 +1,30 @@
1
1
  // @ts-check
2
2
 
3
- import * as c from './presets/lang/c.js'
4
- import * as cpp from './presets/lang/cpp.js'
5
- import * as csharp from './presets/lang/csharp.js'
6
- import * as css from './presets/lang/css.js'
7
- import * as diff from './presets/lang/diff.js'
8
- import * as dockerfile from './presets/lang/dockerfile.js'
9
- import * as go from './presets/lang/go.js'
10
- import * as html from './presets/lang/html.js'
11
- import * as graphql from './presets/lang/graphql.js'
12
- import * as hcl from './presets/lang/hcl.js'
13
- import * as java from './presets/lang/java.js'
14
- import * as json from './presets/lang/json.js'
15
- import * as javascript from './presets/lang/javascript.js'
16
- import * as kotlin from './presets/lang/kotlin.js'
17
- import * as markdown from './presets/lang/markdown.js'
18
- import * as php from './presets/lang/php.js'
19
- import * as powershell from './presets/lang/powershell.js'
20
- import * as python from './presets/lang/python.js'
21
- import * as rust from './presets/lang/rust.js'
22
- import * as shell from './presets/lang/shell.js'
23
- import * as sql from './presets/lang/sql.js'
24
- import * as swift from './presets/lang/swift.js'
25
- import * as toml from './presets/lang/toml.js'
26
- import * as typescript from './presets/lang/typescript.js'
27
- import * as yaml from './presets/lang/yaml.js'
3
+ import * as c from './lang/c.js'
4
+ import * as cpp from './lang/cpp.js'
5
+ import * as csharp from './lang/csharp.js'
6
+ import * as css from './lang/css.js'
7
+ import * as diff from './lang/diff.js'
8
+ import * as dockerfile from './lang/dockerfile.js'
9
+ import * as go from './lang/go.js'
10
+ import * as html from './lang/html.js'
11
+ import * as graphql from './lang/graphql.js'
12
+ import * as hcl from './lang/hcl.js'
13
+ import * as java from './lang/java.js'
14
+ import * as json from './lang/json.js'
15
+ import * as javascript from './lang/javascript.js'
16
+ import * as kotlin from './lang/kotlin.js'
17
+ import * as markdown from './lang/markdown.js'
18
+ import * as php from './lang/php.js'
19
+ import * as powershell from './lang/powershell.js'
20
+ import * as python from './lang/python.js'
21
+ import * as rust from './lang/rust.js'
22
+ import * as shell from './lang/shell.js'
23
+ import * as sql from './lang/sql.js'
24
+ import * as swift from './lang/swift.js'
25
+ import * as toml from './lang/toml.js'
26
+ import * as typescript from './lang/typescript.js'
27
+ import * as yaml from './lang/yaml.js'
28
28
 
29
29
  /**
30
30
  * @typedef {import('./core.js').ParseOptions} ParseOptions
@@ -0,0 +1,2 @@
1
+ export function onCommentStart(currentChar: any, nextChar: any): 1 | 0;
2
+ export function onCommentEnd(prevChar: any, currChar: any): 1 | 0;
@@ -0,0 +1,2 @@
1
+ export function onCommentStart(currentChar: string): 1 | 0;
2
+ export function onCommentEnd(_prevChar: string, currChar: string): 1 | 0;
@@ -0,0 +1,37 @@
1
+ export type HighlightOptions = {
2
+ keywords?: Set<string> | undefined;
3
+ typeKeywords?: Set<string> | undefined;
4
+ onCommentStart?: ((curr: string, next: string, index: number, code: string) => number | boolean) | undefined;
5
+ onCommentEnd?: ((prev: string, curr: string, index: number, code: string) => number | boolean) | undefined;
6
+ onQuote?: ((curr: string, i: number, code: string) => number | null | undefined) | undefined;
7
+ quotedKeys?: boolean | undefined;
8
+ /**
9
+ * Whether JSX tag parsing is enabled.
10
+ */
11
+ jsx?: boolean | undefined;
12
+ /**
13
+ * Whether JavaScript-style regular expressions are enabled.
14
+ */
15
+ regex?: boolean | undefined;
16
+ /**
17
+ * Whether JavaScript template strings are enabled.
18
+ */
19
+ templateStrings?: boolean | undefined;
20
+ /**
21
+ * Whether keyword matching ignores case.
22
+ */
23
+ caseInsensitive?: boolean | undefined;
24
+ /**
25
+ * Override heuristic TypeScript detection.
26
+ */
27
+ typescript?: boolean | undefined;
28
+ annotateLine?: ((line: import("../core.js").AnnotateLine) => void) | undefined;
29
+ };
30
+ /**
31
+ * @param {string} code
32
+ * @param {HighlightOptions | undefined} options
33
+ * Optional `onQuote(curr, i, code)` at `code[i] === "'"`: return length to consume from `i` (>= 1),
34
+ * or null/undefined/below 1 for default JS single-quoted strings. No substring allocation.
35
+ * @return {Array<[number, string]>}
36
+ */
37
+ export function tokenize(code: string, options: HighlightOptions | undefined): Array<[number, string]>;
@@ -3,7 +3,7 @@
3
3
  import {
4
4
  T_BREAK, T_CLASS as T_CLS_NUMBER, T_COMMENT, T_ENTITY, T_IDENTIFIER,
5
5
  T_JSX_LITERALS, T_KEYWORD, T_PROPERTY, T_SIGN, T_SPACE, T_STRING,
6
- } from '../../shared.js'
6
+ } from '../shared.js'
7
7
 
8
8
  const JSXBrackets = new Set(['<', '>', '{', '}', '[', ']'])
9
9
  const Keywords_Js = new Set([
@@ -777,5 +777,5 @@ export { tokenize }
777
777
  * @property {boolean} [templateStrings] Whether JavaScript template strings are enabled.
778
778
  * @property {boolean} [caseInsensitive] Whether keyword matching ignores case.
779
779
  * @property {boolean} [typescript] Override heuristic TypeScript detection.
780
- * @property {(line: import('../../core.js').AnnotateLine) => void} [annotateLine]
780
+ * @property {(line: import('../core.js').AnnotateLine) => void} [annotateLine]
781
781
  */
@@ -0,0 +1,2 @@
1
+ export function onCommentStart(): number;
2
+ export function onCommentEnd(): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sugar-high",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/huozhi/sugar-high.git",
@@ -21,6 +21,10 @@
21
21
  "./lang": {
22
22
  "types": "./lib/lang.d.ts",
23
23
  "default": "./lib/lang.js"
24
+ },
25
+ "./lang/*": {
26
+ "types": "./lib/lang/*.d.ts",
27
+ "default": "./lib/lang/*.js"
24
28
  }
25
29
  },
26
30
  "description": "Lightweight, zero-dependency syntax highlighting for popular programming languages",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes