@scalar/code-highlight 0.2.4 → 0.3.1
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/CHANGELOG.md +12 -0
- package/dist/code/highlight.js +58 -38
- package/dist/code/index.js +1 -5
- package/dist/code/line-numbers.js +76 -51
- package/dist/constants.js +10 -12
- package/dist/index.js +5 -14
- package/dist/languages/basic.js +28 -31
- package/dist/languages/index.js +3 -9
- package/dist/languages/json-yaml.js +7 -10
- package/dist/languages/standard.js +115 -100
- package/dist/markdown/index.js +1 -2
- package/dist/markdown/markdown.js +148 -100
- package/dist/rehype-alert/index.js +1 -5
- package/dist/rehype-alert/rehype-alert.js +99 -91
- package/dist/rehype-highlight/index.js +1 -5
- package/dist/rehype-highlight/rehype-highlight.js +93 -85
- package/package.json +6 -12
- package/dist/code/highlight.js.map +0 -7
- package/dist/code/index.js.map +0 -7
- package/dist/code/line-numbers.js.map +0 -7
- package/dist/constants.js.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/languages/basic.js.map +0 -7
- package/dist/languages/index.js.map +0 -7
- package/dist/languages/json-yaml.js.map +0 -7
- package/dist/languages/standard.js.map +0 -7
- package/dist/markdown/index.js.map +0 -7
- package/dist/markdown/markdown.js.map +0 -7
- package/dist/rehype-alert/index.js.map +0 -7
- package/dist/rehype-alert/rehype-alert.js.map +0 -7
- package/dist/rehype-highlight/index.js.map +0 -7
- package/dist/rehype-highlight/rehype-highlight.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @scalar/code-highlight
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#8466](https://github.com/scalar/scalar/pull/8466): chore: new build pipeline
|
|
8
|
+
|
|
9
|
+
## 0.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#8322](https://github.com/scalar/scalar/pull/8322): chore: bump required node version to >=22 (LTS)
|
|
14
|
+
|
|
3
15
|
## 0.2.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/code/highlight.js
CHANGED
|
@@ -1,42 +1,62 @@
|
|
|
1
|
-
import rehypeParse from
|
|
2
|
-
import rehypeStringify from
|
|
3
|
-
import { unified } from
|
|
4
|
-
import { visit } from
|
|
5
|
-
import { lowlightLanguageMappings } from
|
|
6
|
-
import { rehypeHighlight } from
|
|
7
|
-
import { codeBlockLinesPlugin } from
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import rehypeParse from 'rehype-parse';
|
|
2
|
+
import rehypeStringify from 'rehype-stringify';
|
|
3
|
+
import { unified } from 'unified';
|
|
4
|
+
import { visit } from 'unist-util-visit';
|
|
5
|
+
import { lowlightLanguageMappings } from '../constants.js';
|
|
6
|
+
import { rehypeHighlight } from '../rehype-highlight/index.js';
|
|
7
|
+
import { codeBlockLinesPlugin } from './line-numbers.js';
|
|
8
|
+
/**
|
|
9
|
+
* Syntax highlights a code string using the `rehype-highlight` library.
|
|
10
|
+
*/
|
|
11
|
+
export function syntaxHighlight(codeString, options) {
|
|
12
|
+
// Simple restriction on credentials to prevent unexpected behavior
|
|
13
|
+
const credentials = (typeof options?.maskCredentials === 'string' ? [options.maskCredentials] : (options?.maskCredentials ?? [])).filter((c) => {
|
|
14
|
+
// Credentials must be at least 3 characters to mask.
|
|
15
|
+
if (c.length < 3) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
});
|
|
20
|
+
// Classname is used by lowlight to select the language model
|
|
21
|
+
const className = `language-${lowlightLanguageMappings[options.lang] ?? options.lang}`;
|
|
22
|
+
// biome-ignore lint/suspicious/noEmptyBlockStatements: empty plugin
|
|
23
|
+
const nullPlugin = (() => { });
|
|
24
|
+
const html = unified()
|
|
25
|
+
// Parses markdown
|
|
26
|
+
.use(rehypeParse, { fragment: true })
|
|
27
|
+
// Raw code string must be injected after initial hast parsing
|
|
28
|
+
// so that HTML code is not parsed into the hast tree
|
|
29
|
+
.use(injectRawCodeStringPlugin(codeString))
|
|
30
|
+
// Syntax highlighting
|
|
31
|
+
.use(rehypeHighlight, {
|
|
32
|
+
languages: options.languages,
|
|
33
|
+
})
|
|
34
|
+
.use(options?.lineNumbers ? codeBlockLinesPlugin : nullPlugin)
|
|
35
|
+
// Converts the HTML AST to a string
|
|
36
|
+
.use(rehypeStringify)
|
|
37
|
+
// Run the pipeline
|
|
38
|
+
.processSync(`<pre><code class="${className}"></code></pre>`);
|
|
39
|
+
const htmlString = html.toString();
|
|
40
|
+
// Replace any credentials with a wrapper element
|
|
41
|
+
return credentials.length
|
|
42
|
+
? credentials.reduce((acc, credential) => acc
|
|
43
|
+
.split(credential)
|
|
44
|
+
.join(`<span class="credential"><span class="credential-value">${credential}</span></span>`), htmlString)
|
|
45
|
+
: htmlString;
|
|
26
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* To prevent unified from parsing any content of the code string we inject
|
|
49
|
+
* it as a raw text node into the AST tree as a child of the code element
|
|
50
|
+
*/
|
|
27
51
|
function injectRawCodeStringPlugin(rawCodeString) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
return () => (tree) => {
|
|
53
|
+
visit(tree, 'element', (node) => {
|
|
54
|
+
if (node.tagName === 'code') {
|
|
55
|
+
node.children.push({
|
|
56
|
+
type: 'text',
|
|
57
|
+
value: rawCodeString,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
34
60
|
});
|
|
35
|
-
|
|
36
|
-
});
|
|
37
|
-
};
|
|
61
|
+
};
|
|
38
62
|
}
|
|
39
|
-
export {
|
|
40
|
-
syntaxHighlight
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=highlight.js.map
|
package/dist/code/index.js
CHANGED
|
@@ -1,69 +1,94 @@
|
|
|
1
|
-
import { visit } from
|
|
1
|
+
import { visit } from 'unist-util-visit';
|
|
2
|
+
// ---------------------------------------------------------------------------
|
|
3
|
+
// Line Numbering plugin
|
|
2
4
|
function isText(element) {
|
|
3
|
-
|
|
5
|
+
return element?.type === 'text';
|
|
4
6
|
}
|
|
5
7
|
function isElement(node) {
|
|
6
|
-
|
|
8
|
+
return node?.type === 'element';
|
|
7
9
|
}
|
|
8
10
|
function textElement(value) {
|
|
9
|
-
|
|
11
|
+
return { type: 'text', value };
|
|
10
12
|
}
|
|
11
13
|
function lineBreak() {
|
|
12
|
-
|
|
14
|
+
return { type: 'text', value: '\n' };
|
|
13
15
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Adds lines to code blocks
|
|
18
|
+
*/
|
|
19
|
+
export function codeBlockLinesPlugin() {
|
|
20
|
+
return (tree) => {
|
|
21
|
+
visit(tree, 'element', (node, _i, parent) => {
|
|
22
|
+
if (parent?.type === 'element' && parent.tagName === 'pre' && node.tagName === 'code') {
|
|
23
|
+
let numLines = 0;
|
|
24
|
+
// Wraps each line in a span
|
|
25
|
+
node.children = addLines(node);
|
|
26
|
+
// Adds a line break to the end of each line
|
|
27
|
+
node.children.forEach((child) => {
|
|
28
|
+
if (child.type === 'element' && child.tagName === 'span') {
|
|
29
|
+
const lastChild = child.children[child.children.length - 1];
|
|
30
|
+
if (lastChild && (!isText(lastChild) || (isText(lastChild) && !hasLineBreak(lastChild)))) {
|
|
31
|
+
child.children.push(lineBreak());
|
|
32
|
+
numLines++;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
// We need to maintain a count of the total lines to allow space for the labels
|
|
37
|
+
node.properties.style = [`--line-count: ${numLines};`, `--line-digits: ${numLines.toString().length};`];
|
|
26
38
|
}
|
|
27
|
-
}
|
|
28
39
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
};
|
|
40
|
+
// console.log('NUMBER OF LINES IS: ', numLines)
|
|
41
|
+
};
|
|
33
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Adds lines to a node recursively and returns them
|
|
45
|
+
*
|
|
46
|
+
* @param node - The node to add lines to
|
|
47
|
+
* @param lines - The current lines
|
|
48
|
+
* @param copyParent - Whether to copy the parent node to save the original node styles
|
|
49
|
+
*/
|
|
34
50
|
function addLines(node, lines = [], copyParent) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
const line = () => lines[lines.length - 1] ?? ((lines.push(createLine()) && lines[lines.length - 1]) || undefined);
|
|
52
|
+
node.children.forEach((child) => {
|
|
53
|
+
if (isText(child) && hasLineBreak(child)) {
|
|
54
|
+
const split = child.value.split(/\n/);
|
|
55
|
+
split.forEach((content, i) => {
|
|
56
|
+
if (copyParent) {
|
|
57
|
+
line()?.children.push({ ...node, children: [textElement(content)] });
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
line()?.children.push(textElement(content));
|
|
61
|
+
}
|
|
62
|
+
i !== split.length - 1 && lines.push(createLine());
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else if (isElement(child) && child.children.some(hasLineBreak)) {
|
|
66
|
+
addLines(child, lines, true);
|
|
44
67
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
line()?.children.push(child);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
return lines;
|
|
68
|
+
else {
|
|
69
|
+
line()?.children.push(child);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return lines;
|
|
54
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Creates a new line element
|
|
76
|
+
*
|
|
77
|
+
* @param children - The children the line should have initially
|
|
78
|
+
*/
|
|
55
79
|
function createLine(...children) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
80
|
+
return {
|
|
81
|
+
type: 'element',
|
|
82
|
+
tagName: 'span',
|
|
83
|
+
properties: { class: ['line'] },
|
|
84
|
+
children,
|
|
85
|
+
};
|
|
62
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Checks if a node has a line break
|
|
89
|
+
*
|
|
90
|
+
* @param node - The node to check
|
|
91
|
+
*/
|
|
63
92
|
function hasLineBreak(node) {
|
|
64
|
-
|
|
93
|
+
return (isText(node) && /\r?\n/.test(node.value)) || (isElement(node) && node.children.some(hasLineBreak));
|
|
65
94
|
}
|
|
66
|
-
export {
|
|
67
|
-
codeBlockLinesPlugin
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=line-numbers.js.map
|
package/dist/constants.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
/** Map common markdown language shortcuts to lowlight languages */
|
|
2
|
+
export const lowlightLanguageMappings = {
|
|
3
|
+
'ts': 'typescript',
|
|
4
|
+
'js': 'javascript',
|
|
5
|
+
'py': 'python',
|
|
6
|
+
'py3': 'python',
|
|
7
|
+
'c#': 'csharp',
|
|
8
|
+
'c++': 'cpp',
|
|
9
|
+
'node': 'javascript',
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
lowlightLanguageMappings
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=constants.js.map
|
|
11
|
+
//
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export * from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
htmlFromMarkdown,
|
|
8
|
-
isHeading,
|
|
9
|
-
lowlightLanguageMappings,
|
|
10
|
-
rehypeHighlight,
|
|
11
|
-
syntaxHighlight,
|
|
12
|
-
textFromNode
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { syntaxHighlight } from './code/index.js';
|
|
2
|
+
export { lowlightLanguageMappings } from './constants.js';
|
|
3
|
+
export * from './languages/index.js';
|
|
4
|
+
export { htmlFromMarkdown, isHeading, textFromNode } from './markdown/index.js';
|
|
5
|
+
export { rehypeHighlight } from './rehype-highlight/index.js';
|
package/dist/languages/basic.js
CHANGED
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
import bash from
|
|
2
|
-
import css from
|
|
3
|
-
import javascript from
|
|
4
|
-
import json from
|
|
5
|
-
import less from
|
|
6
|
-
import markdown from
|
|
7
|
-
import plaintext from
|
|
8
|
-
import python from
|
|
9
|
-
import scss from
|
|
10
|
-
import shell from
|
|
11
|
-
import typescript from
|
|
12
|
-
import xml from
|
|
13
|
-
import yaml from
|
|
1
|
+
import bash from 'highlight.js/lib/languages/bash';
|
|
2
|
+
import css from 'highlight.js/lib/languages/css';
|
|
3
|
+
import javascript from 'highlight.js/lib/languages/javascript';
|
|
4
|
+
import json from 'highlight.js/lib/languages/json';
|
|
5
|
+
import less from 'highlight.js/lib/languages/less';
|
|
6
|
+
import markdown from 'highlight.js/lib/languages/markdown';
|
|
7
|
+
import plaintext from 'highlight.js/lib/languages/plaintext';
|
|
8
|
+
import python from 'highlight.js/lib/languages/python';
|
|
9
|
+
import scss from 'highlight.js/lib/languages/scss';
|
|
10
|
+
import shell from 'highlight.js/lib/languages/shell';
|
|
11
|
+
import typescript from 'highlight.js/lib/languages/typescript';
|
|
12
|
+
import xml from 'highlight.js/lib/languages/xml';
|
|
13
|
+
import yaml from 'highlight.js/lib/languages/yaml';
|
|
14
14
|
const basicLanguages = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
bash,
|
|
16
|
+
css,
|
|
17
|
+
html: xml,
|
|
18
|
+
javascript,
|
|
19
|
+
json,
|
|
20
|
+
less,
|
|
21
|
+
markdown,
|
|
22
|
+
plaintext,
|
|
23
|
+
python,
|
|
24
|
+
scss,
|
|
25
|
+
shell,
|
|
26
|
+
typescript,
|
|
27
|
+
xml,
|
|
28
|
+
yaml,
|
|
29
29
|
};
|
|
30
|
-
export {
|
|
31
|
-
basicLanguages
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=basic.js.map
|
|
30
|
+
export { basicLanguages };
|
package/dist/languages/index.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
basicLanguages,
|
|
6
|
-
jsonYamlLanguages,
|
|
7
|
-
standardLanguages
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { basicLanguages } from './basic.js';
|
|
2
|
+
export { jsonYamlLanguages } from './json-yaml.js';
|
|
3
|
+
export { standardLanguages } from './standard.js';
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import json from
|
|
2
|
-
import plaintext from
|
|
3
|
-
import yaml from
|
|
1
|
+
import json from 'highlight.js/lib/languages/json';
|
|
2
|
+
import plaintext from 'highlight.js/lib/languages/plaintext';
|
|
3
|
+
import yaml from 'highlight.js/lib/languages/yaml';
|
|
4
4
|
const jsonYamlLanguages = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
json,
|
|
6
|
+
plaintext,
|
|
7
|
+
yaml,
|
|
8
8
|
};
|
|
9
|
-
export {
|
|
10
|
-
jsonYamlLanguages
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=json-yaml.js.map
|
|
9
|
+
export { jsonYamlLanguages };
|
|
@@ -1,101 +1,116 @@
|
|
|
1
|
-
import bash from
|
|
2
|
-
import c from
|
|
3
|
-
import clojure from
|
|
4
|
-
import cpp from
|
|
5
|
-
import csharp from
|
|
6
|
-
import css from
|
|
7
|
-
import dart from
|
|
8
|
-
import diff from
|
|
9
|
-
import dockerfile from
|
|
10
|
-
import elixir from
|
|
11
|
-
import fsharp from
|
|
12
|
-
import go from
|
|
13
|
-
import graphql from
|
|
14
|
-
import haskell from
|
|
15
|
-
import http from
|
|
16
|
-
import ini from
|
|
17
|
-
import java from
|
|
18
|
-
import javascript from
|
|
19
|
-
import json from
|
|
20
|
-
import kotlin from
|
|
21
|
-
import less from
|
|
22
|
-
import lua from
|
|
23
|
-
import makefile from
|
|
24
|
-
import markdown from
|
|
25
|
-
import matlab from
|
|
26
|
-
import nginx from
|
|
27
|
-
import objectivec from
|
|
28
|
-
import ocaml from
|
|
29
|
-
import perl from
|
|
30
|
-
import php from
|
|
31
|
-
import plaintext from
|
|
32
|
-
import powershell from
|
|
33
|
-
import properties from
|
|
34
|
-
import python from
|
|
35
|
-
import r from
|
|
36
|
-
import ruby from
|
|
37
|
-
import rust from
|
|
38
|
-
import scala from
|
|
39
|
-
import scss from
|
|
40
|
-
import shell from
|
|
41
|
-
import sql from
|
|
42
|
-
import swift from
|
|
43
|
-
import typescript from
|
|
44
|
-
import xml from
|
|
45
|
-
import yaml from
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
1
|
+
import bash from 'highlight.js/lib/languages/bash';
|
|
2
|
+
import c from 'highlight.js/lib/languages/c';
|
|
3
|
+
import clojure from 'highlight.js/lib/languages/clojure';
|
|
4
|
+
import cpp from 'highlight.js/lib/languages/cpp';
|
|
5
|
+
import csharp from 'highlight.js/lib/languages/csharp';
|
|
6
|
+
import css from 'highlight.js/lib/languages/css';
|
|
7
|
+
import dart from 'highlight.js/lib/languages/dart';
|
|
8
|
+
import diff from 'highlight.js/lib/languages/diff';
|
|
9
|
+
import dockerfile from 'highlight.js/lib/languages/dockerfile';
|
|
10
|
+
import elixir from 'highlight.js/lib/languages/elixir';
|
|
11
|
+
import fsharp from 'highlight.js/lib/languages/fsharp';
|
|
12
|
+
import go from 'highlight.js/lib/languages/go';
|
|
13
|
+
import graphql from 'highlight.js/lib/languages/graphql';
|
|
14
|
+
import haskell from 'highlight.js/lib/languages/haskell';
|
|
15
|
+
import http from 'highlight.js/lib/languages/http';
|
|
16
|
+
import ini from 'highlight.js/lib/languages/ini';
|
|
17
|
+
import java from 'highlight.js/lib/languages/java';
|
|
18
|
+
import javascript from 'highlight.js/lib/languages/javascript';
|
|
19
|
+
import json from 'highlight.js/lib/languages/json';
|
|
20
|
+
import kotlin from 'highlight.js/lib/languages/kotlin';
|
|
21
|
+
import less from 'highlight.js/lib/languages/less';
|
|
22
|
+
import lua from 'highlight.js/lib/languages/lua';
|
|
23
|
+
import makefile from 'highlight.js/lib/languages/makefile';
|
|
24
|
+
import markdown from 'highlight.js/lib/languages/markdown';
|
|
25
|
+
import matlab from 'highlight.js/lib/languages/matlab';
|
|
26
|
+
import nginx from 'highlight.js/lib/languages/nginx';
|
|
27
|
+
import objectivec from 'highlight.js/lib/languages/objectivec';
|
|
28
|
+
import ocaml from 'highlight.js/lib/languages/ocaml';
|
|
29
|
+
import perl from 'highlight.js/lib/languages/perl';
|
|
30
|
+
import php from 'highlight.js/lib/languages/php';
|
|
31
|
+
import plaintext from 'highlight.js/lib/languages/plaintext';
|
|
32
|
+
import powershell from 'highlight.js/lib/languages/powershell';
|
|
33
|
+
import properties from 'highlight.js/lib/languages/properties';
|
|
34
|
+
import python from 'highlight.js/lib/languages/python';
|
|
35
|
+
import r from 'highlight.js/lib/languages/r';
|
|
36
|
+
import ruby from 'highlight.js/lib/languages/ruby';
|
|
37
|
+
import rust from 'highlight.js/lib/languages/rust';
|
|
38
|
+
import scala from 'highlight.js/lib/languages/scala';
|
|
39
|
+
import scss from 'highlight.js/lib/languages/scss';
|
|
40
|
+
import shell from 'highlight.js/lib/languages/shell';
|
|
41
|
+
import sql from 'highlight.js/lib/languages/sql';
|
|
42
|
+
import swift from 'highlight.js/lib/languages/swift';
|
|
43
|
+
import typescript from 'highlight.js/lib/languages/typescript';
|
|
44
|
+
import xml from 'highlight.js/lib/languages/xml';
|
|
45
|
+
import yaml from 'highlight.js/lib/languages/yaml';
|
|
46
|
+
// @ts-expect-error No types available
|
|
47
|
+
import curl from 'highlightjs-curl';
|
|
48
|
+
/**
|
|
49
|
+
* We group languages into three categories based on their popularity and usage.
|
|
50
|
+
* This helps in optimizing the bundle size by allowing users to include only
|
|
51
|
+
* the languages they need.
|
|
52
|
+
*
|
|
53
|
+
* 1. Standard Languages: These are the most popular languages that cover the
|
|
54
|
+
* majority of use cases.
|
|
55
|
+
* 2. Medium Languages: These languages are not as popular as the ones in
|
|
56
|
+
* `standardLanguages`, but still have a decent amount of users.
|
|
57
|
+
* 3. Specialized Languages: These languages are more specialized and have a
|
|
58
|
+
* smaller user base.
|
|
59
|
+
*
|
|
60
|
+
* Each category is represented as a separate object, making it easy to import
|
|
61
|
+
* only the languages you need.
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* These are the most popular languages that cover the majority of use cases.
|
|
65
|
+
*/
|
|
66
|
+
export const standardLanguages = {
|
|
67
|
+
bash,
|
|
68
|
+
c,
|
|
69
|
+
clojure,
|
|
70
|
+
cpp,
|
|
71
|
+
csharp,
|
|
72
|
+
css,
|
|
73
|
+
curl,
|
|
74
|
+
dart,
|
|
75
|
+
diff,
|
|
76
|
+
docker: dockerfile,
|
|
77
|
+
dockerfile,
|
|
78
|
+
elixir,
|
|
79
|
+
fsharp,
|
|
80
|
+
go,
|
|
81
|
+
graphql,
|
|
82
|
+
haskell,
|
|
83
|
+
html: xml,
|
|
84
|
+
http,
|
|
85
|
+
ini,
|
|
86
|
+
java,
|
|
87
|
+
javascript,
|
|
88
|
+
json,
|
|
89
|
+
kotlin,
|
|
90
|
+
less,
|
|
91
|
+
lua,
|
|
92
|
+
makefile,
|
|
93
|
+
markdown,
|
|
94
|
+
matlab,
|
|
95
|
+
nginx,
|
|
96
|
+
objectivec,
|
|
97
|
+
ocaml,
|
|
98
|
+
perl,
|
|
99
|
+
php,
|
|
100
|
+
plaintext,
|
|
101
|
+
powershell,
|
|
102
|
+
properties,
|
|
103
|
+
python,
|
|
104
|
+
r,
|
|
105
|
+
ruby,
|
|
106
|
+
rust,
|
|
107
|
+
scala,
|
|
108
|
+
scss,
|
|
109
|
+
shell,
|
|
110
|
+
sql,
|
|
111
|
+
swift,
|
|
112
|
+
toml: ini,
|
|
113
|
+
typescript,
|
|
114
|
+
xml,
|
|
115
|
+
yaml,
|
|
97
116
|
};
|
|
98
|
-
export {
|
|
99
|
-
standardLanguages
|
|
100
|
-
};
|
|
101
|
-
//# sourceMappingURL=standard.js.map
|
package/dist/markdown/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from './markdown.js';
|