sugar-high 2.2.1 → 2.2.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.
- package/lib/index.js +1 -6
- package/lib/lang.js +5 -41
- package/lib/presets/configs.js +88 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -4,12 +4,7 @@ import {
|
|
|
4
4
|
parse,
|
|
5
5
|
render,
|
|
6
6
|
} from './core.js'
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
/** @param {string | undefined} name */
|
|
10
|
-
function configFor(name) {
|
|
11
|
-
return languages.find(({ id }) => id === (name || 'javascript'))?.config
|
|
12
|
-
}
|
|
7
|
+
import { configFor } from './presets/configs.js'
|
|
13
8
|
|
|
14
9
|
/** @param {string} code @param {HighlightOptions | undefined} options */
|
|
15
10
|
function highlight(code, options) {
|
package/lib/lang.js
CHANGED
|
@@ -1,32 +1,10 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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'
|
|
3
|
+
import {
|
|
4
|
+
c, cpp, csharp, css, diff, dockerfile, go, graphql, hcl, html, java, javascript, json,
|
|
5
|
+
kotlin, markdown, nonJavaScript, php, plaintext, powershell, python, ruby, rust, shell, sql,
|
|
6
|
+
swift, toml, typescript, yaml,
|
|
7
|
+
} from './presets/configs.js'
|
|
30
8
|
|
|
31
9
|
/**
|
|
32
10
|
* @typedef {import('./core.js').ParseOptions} ParseOptions
|
|
@@ -38,20 +16,6 @@ import * as yaml from './lang/yaml.js'
|
|
|
38
16
|
* }} Language
|
|
39
17
|
*/
|
|
40
18
|
|
|
41
|
-
/**
|
|
42
|
-
* Disable JavaScript-only scanner modes for a non-JavaScript language.
|
|
43
|
-
* @param {ParseOptions} config
|
|
44
|
-
* @returns {ParseOptions}
|
|
45
|
-
*/
|
|
46
|
-
function nonJavaScript(config) {
|
|
47
|
-
return {
|
|
48
|
-
...config,
|
|
49
|
-
jsx: false,
|
|
50
|
-
regex: false,
|
|
51
|
-
templateStrings: false,
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
19
|
/** @type {readonly Language[]} */
|
|
56
20
|
const languages = [
|
|
57
21
|
{ id: 'javascript', extension: 'js', aliases: ['js', 'jsx', 'node'], config: javascript },
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
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 graphql from '../lang/graphql.js'
|
|
11
|
+
import * as hcl from '../lang/hcl.js'
|
|
12
|
+
import * as html from '../lang/html.js'
|
|
13
|
+
import * as java from '../lang/java.js'
|
|
14
|
+
import * as javascript from '../lang/javascript.js'
|
|
15
|
+
import * as json from '../lang/json.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'
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Disable JavaScript-only scanner modes for a non-JavaScript language.
|
|
33
|
+
* @param {import('../core.js').ParseOptions} config
|
|
34
|
+
* @returns {import('../core.js').ParseOptions}
|
|
35
|
+
*/
|
|
36
|
+
function nonJavaScript(config) {
|
|
37
|
+
return {
|
|
38
|
+
...config,
|
|
39
|
+
jsx: false,
|
|
40
|
+
regex: false,
|
|
41
|
+
templateStrings: false,
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function createConfigs() {
|
|
46
|
+
return {
|
|
47
|
+
javascript,
|
|
48
|
+
typescript,
|
|
49
|
+
css: nonJavaScript(css),
|
|
50
|
+
python: nonJavaScript(python),
|
|
51
|
+
c: nonJavaScript(c),
|
|
52
|
+
go: nonJavaScript(go),
|
|
53
|
+
java: nonJavaScript(java),
|
|
54
|
+
rust: nonJavaScript(rust),
|
|
55
|
+
json: nonJavaScript(json),
|
|
56
|
+
diff: nonJavaScript(diff),
|
|
57
|
+
shell: nonJavaScript(shell),
|
|
58
|
+
cpp: nonJavaScript(cpp),
|
|
59
|
+
csharp: nonJavaScript(csharp),
|
|
60
|
+
sql: nonJavaScript(sql),
|
|
61
|
+
html,
|
|
62
|
+
yaml: nonJavaScript(yaml),
|
|
63
|
+
markdown: nonJavaScript(markdown),
|
|
64
|
+
plaintext: nonJavaScript(plaintext),
|
|
65
|
+
ruby: nonJavaScript(ruby),
|
|
66
|
+
kotlin: nonJavaScript(kotlin),
|
|
67
|
+
swift: nonJavaScript(swift),
|
|
68
|
+
php: nonJavaScript(php),
|
|
69
|
+
toml: nonJavaScript(toml),
|
|
70
|
+
powershell: nonJavaScript(powershell),
|
|
71
|
+
dockerfile: nonJavaScript(dockerfile),
|
|
72
|
+
graphql: nonJavaScript(graphql),
|
|
73
|
+
hcl: nonJavaScript(hcl),
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const configs = /* @__PURE__ */ createConfigs()
|
|
78
|
+
|
|
79
|
+
/** @param {string | undefined} name */
|
|
80
|
+
function configFor(name) {
|
|
81
|
+
return configs[name || 'javascript']
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
c, configFor, configs, cpp, csharp, css, diff, dockerfile, go, graphql, hcl, html, java,
|
|
86
|
+
javascript, json, kotlin, markdown, nonJavaScript, php, plaintext, powershell, python, ruby,
|
|
87
|
+
rust, shell, sql, swift, toml, typescript, yaml,
|
|
88
|
+
}
|