sugar-high 2.0.3 → 2.2.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.
- package/README.md +16 -2
- package/lib/index.d.ts +2 -0
- package/lib/lang/c.d.ts +5 -0
- package/lib/{presets/lang → lang}/c.js +1 -1
- package/lib/lang/cpp.d.ts +5 -0
- package/lib/{presets/lang → lang}/cpp.js +1 -1
- package/lib/lang/csharp.d.ts +5 -0
- package/lib/{presets/lang → lang}/csharp.js +1 -1
- package/lib/lang/css.d.ts +5 -0
- package/lib/{presets/lang → lang}/css.js +3 -3
- package/lib/lang/diff.d.ts +2 -0
- package/lib/lang/dockerfile.d.ts +5 -0
- package/lib/{presets/lang → lang}/dockerfile.js +1 -1
- package/lib/lang/go.d.ts +5 -0
- package/lib/{presets/lang → lang}/go.js +1 -1
- package/lib/lang/graphql.d.ts +5 -0
- package/lib/{presets/lang → lang}/graphql.js +1 -1
- package/lib/lang/hcl.d.ts +3 -0
- package/lib/lang/html.d.ts +8 -0
- package/lib/{presets/lang → lang}/html.js +1 -1
- package/lib/lang/java.d.ts +5 -0
- package/lib/{presets/lang → lang}/java.js +1 -1
- package/lib/lang/javascript.d.ts +2 -0
- package/lib/{presets/lang → lang}/javascript.js +1 -1
- package/lib/lang/json.d.ts +5 -0
- package/lib/{presets/lang → lang}/json.js +1 -1
- package/lib/lang/kotlin.d.ts +5 -0
- package/lib/{presets/lang → lang}/kotlin.js +1 -1
- package/lib/lang/markdown.d.ts +5 -0
- package/lib/{presets/lang → lang}/markdown.js +1 -1
- package/lib/lang/php.d.ts +4 -0
- package/lib/lang/plaintext.d.ts +1 -0
- package/lib/lang/plaintext.js +5 -0
- package/lib/lang/powershell.d.ts +4 -0
- package/lib/lang/python.d.ts +3 -0
- package/lib/lang/ruby.d.ts +13 -0
- package/lib/lang/ruby.js +41 -0
- package/lib/lang/rust.d.ts +8 -0
- package/lib/lang/shell.d.ts +4 -0
- package/lib/{presets/lang → lang}/shell.js +1 -1
- package/lib/lang/sql.d.ts +5 -0
- package/lib/lang/swift.d.ts +5 -0
- package/lib/{presets/lang → lang}/swift.js +1 -1
- package/lib/lang/toml.d.ts +5 -0
- package/lib/{presets/lang → lang}/toml.js +1 -1
- package/lib/lang/typescript.d.ts +1 -0
- package/lib/{presets/lang → lang}/typescript.js +1 -1
- package/lib/lang/yaml.d.ts +5 -0
- package/lib/{presets/lang → lang}/yaml.js +1 -1
- package/lib/lang.js +29 -25
- package/lib/presets/clike-base.d.ts +2 -0
- package/lib/presets/hash-comment-base.d.ts +2 -0
- package/lib/presets/javascript-runtime.d.ts +37 -0
- package/lib/presets/{lang/javascript-runtime.js → javascript-runtime.js} +2 -2
- package/lib/presets/plain-base.d.ts +2 -0
- package/package.json +5 -1
- /package/lib/{presets/lang → lang}/diff.js +0 -0
- /package/lib/{presets/lang → lang}/hcl.js +0 -0
- /package/lib/{presets/lang → lang}/php.js +0 -0
- /package/lib/{presets/lang → lang}/powershell.js +0 -0
- /package/lib/{presets/lang → lang}/python.js +0 -0
- /package/lib/{presets/lang → lang}/rust.js +0 -0
- /package/lib/{presets/lang → lang}/sql.js +0 -0
- /package/lib/presets/{lang/clike-base.js → clike-base.js} +0 -0
- /package/lib/presets/{lang/hash-comment-base.js → hash-comment-base.js} +0 -0
- /package/lib/presets/{lang/plain-base.js → plain-base.js} +0 -0
package/README.md
CHANGED
|
@@ -56,8 +56,8 @@ behavior.
|
|
|
56
56
|
## Built-in languages
|
|
57
57
|
|
|
58
58
|
`javascript`, `typescript`, `css`, `python`, `c`, `go`, `java`, `rust`, `json`, `diff`, `shell`,
|
|
59
|
-
`cpp`, `csharp`, `sql`, `html`, `yaml`, `markdown`, `
|
|
60
|
-
`dockerfile`, `graphql`, and `hcl`.
|
|
59
|
+
`cpp`, `csharp`, `sql`, `html`, `yaml`, `markdown`, `plaintext`, `ruby`, `kotlin`, `swift`, `php`,
|
|
60
|
+
`toml`, `powershell`, `dockerfile`, `graphql`, and `hcl`.
|
|
61
61
|
|
|
62
62
|
Related dialects share one implementation: JavaScript includes JSX, TypeScript includes TSX, JSON
|
|
63
63
|
includes JSONC comments, Shell includes sh/Bash/Zsh, and HCL includes Terraform.
|
|
@@ -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
|
package/lib/index.d.ts
CHANGED
package/lib/lang/c.d.ts
ADDED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { onCommentStart, onCommentEnd } from '
|
|
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',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { onCommentEnd, onCommentStart } from '
|
|
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',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { onCommentEnd, onCommentStart } from '
|
|
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 '
|
|
5
|
-
import { tokenize as tokenizePlain } from '
|
|
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('
|
|
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 })
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { onCommentEnd, onCommentStart } from '
|
|
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 }
|
package/lib/lang/go.d.ts
ADDED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { onCommentStart, onCommentEnd } from '
|
|
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',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { onCommentEnd, onCommentStart } from '
|
|
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,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 { onCommentStart, onCommentEnd } from '
|
|
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',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { tokenize as tokenizeJavaScript } from '
|
|
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.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { onCommentEnd, onCommentStart } from '
|
|
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 @@
|
|
|
1
|
+
export function tokenize(code: string): Array<[number, string]>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const keywords: Set<string>;
|
|
2
|
+
export function onCommentStart(
|
|
3
|
+
curr: string,
|
|
4
|
+
next: string,
|
|
5
|
+
index: number,
|
|
6
|
+
code: string,
|
|
7
|
+
): 0 | 1 | 2;
|
|
8
|
+
export function onCommentEnd(
|
|
9
|
+
prev: string,
|
|
10
|
+
curr: string,
|
|
11
|
+
index: number,
|
|
12
|
+
code: string,
|
|
13
|
+
): 0 | 1 | 2;
|
package/lib/lang/ruby.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
export const keywords = new Set([
|
|
4
|
+
'BEGIN', 'END', '__ENCODING__', '__FILE__', '__LINE__', 'alias', 'and', 'begin', 'break',
|
|
5
|
+
'case', 'class', 'def', 'defined', 'do', 'else', 'elsif', 'end', 'ensure', 'false', 'for', 'if',
|
|
6
|
+
'in', 'module', 'next', 'nil', 'not', 'or', 'redo', 'rescue', 'retry', 'return', 'self', 'super',
|
|
7
|
+
'then', 'true', 'undef', 'unless', 'until', 'when', 'while', 'yield',
|
|
8
|
+
])
|
|
9
|
+
|
|
10
|
+
/** @param {number} index @param {string} code */
|
|
11
|
+
function isBlockCommentStart(index, code) {
|
|
12
|
+
if (index > 0 && code[index - 1] !== '\n') return false
|
|
13
|
+
return /^=begin(?:\s|$)/.test(code.slice(index))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {string} curr
|
|
18
|
+
* @param {string} _next
|
|
19
|
+
* @param {number} index
|
|
20
|
+
* @param {string} code
|
|
21
|
+
*/
|
|
22
|
+
export function onCommentStart(curr, _next, index, code) {
|
|
23
|
+
if (curr === '#') return 1
|
|
24
|
+
if (curr === '=' && isBlockCommentStart(index, code)) return 2
|
|
25
|
+
return 0
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {string} _prev
|
|
30
|
+
* @param {string} curr
|
|
31
|
+
* @param {number} index
|
|
32
|
+
* @param {string} code
|
|
33
|
+
*/
|
|
34
|
+
export function onCommentEnd(_prev, curr, index, code) {
|
|
35
|
+
if (curr !== '\n') return 0
|
|
36
|
+
|
|
37
|
+
const lineStart = code.lastIndexOf('\n', index - 1) + 1
|
|
38
|
+
const line = code.slice(lineStart, index)
|
|
39
|
+
if (/^=end(?:\s|$)/.test(line)) return 2
|
|
40
|
+
return 1
|
|
41
|
+
}
|
|
@@ -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>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { onCommentEnd, onCommentStart } from '
|
|
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',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { onCommentEnd, onCommentStart } from '
|
|
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 }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { onCommentEnd, onCommentStart } from '
|
|
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 { onCommentEnd, onCommentStart } from '
|
|
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,32 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
import * as c from './
|
|
4
|
-
import * as cpp from './
|
|
5
|
-
import * as csharp from './
|
|
6
|
-
import * as css from './
|
|
7
|
-
import * as diff from './
|
|
8
|
-
import * as dockerfile from './
|
|
9
|
-
import * as go from './
|
|
10
|
-
import * as html from './
|
|
11
|
-
import * as graphql from './
|
|
12
|
-
import * as hcl from './
|
|
13
|
-
import * as java from './
|
|
14
|
-
import * as json from './
|
|
15
|
-
import * as javascript from './
|
|
16
|
-
import * as kotlin from './
|
|
17
|
-
import * as markdown from './
|
|
18
|
-
import * as php from './
|
|
19
|
-
import * as
|
|
20
|
-
import * as
|
|
21
|
-
import * as
|
|
22
|
-
import * as
|
|
23
|
-
import * as
|
|
24
|
-
import * as
|
|
25
|
-
import * as
|
|
26
|
-
import * as
|
|
27
|
-
import * as
|
|
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 plaintext from './lang/plaintext.js'
|
|
20
|
+
import * as powershell from './lang/powershell.js'
|
|
21
|
+
import * as python from './lang/python.js'
|
|
22
|
+
import * as ruby from './lang/ruby.js'
|
|
23
|
+
import * as rust from './lang/rust.js'
|
|
24
|
+
import * as shell from './lang/shell.js'
|
|
25
|
+
import * as sql from './lang/sql.js'
|
|
26
|
+
import * as swift from './lang/swift.js'
|
|
27
|
+
import * as toml from './lang/toml.js'
|
|
28
|
+
import * as typescript from './lang/typescript.js'
|
|
29
|
+
import * as yaml from './lang/yaml.js'
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* @typedef {import('./core.js').ParseOptions} ParseOptions
|
|
@@ -69,6 +71,8 @@ const languages = [
|
|
|
69
71
|
{ id: 'html', extension: 'html', aliases: ['htm', 'xml'], config: html },
|
|
70
72
|
{ id: 'yaml', extension: 'yaml', aliases: ['yml'], config: nonJavaScript(yaml) },
|
|
71
73
|
{ id: 'markdown', extension: 'md', aliases: ['md', 'mdx'], config: nonJavaScript(markdown) },
|
|
74
|
+
{ id: 'plaintext', extension: 'txt', aliases: ['text', 'plain'], config: nonJavaScript(plaintext) },
|
|
75
|
+
{ id: 'ruby', extension: 'rb', aliases: [], config: nonJavaScript(ruby) },
|
|
72
76
|
{ id: 'kotlin', extension: 'kt', aliases: ['kts'], config: nonJavaScript(kotlin) },
|
|
73
77
|
{ id: 'swift', extension: 'swift', aliases: [], config: nonJavaScript(swift) },
|
|
74
78
|
{ id: 'php', extension: 'php', aliases: [], config: nonJavaScript(php) },
|
|
@@ -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 '
|
|
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('
|
|
780
|
+
* @property {(line: import('../core.js').AnnotateLine) => void} [annotateLine]
|
|
781
781
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sugar-high",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|