@scalar/code-highlight 0.0.20 → 0.0.22
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 +13 -0
- package/dist/code/highlight.d.ts.map +1 -1
- package/dist/code/highlight.js +1 -1
- package/dist/markdown/markdown.d.ts.map +1 -1
- package/dist/markdown/markdown.js +9 -16
- package/dist/rehype-highlight/rehype-highlight.d.ts +1 -1
- package/dist/rehype-highlight/rehype-highlight.d.ts.map +1 -1
- package/dist/rehype-highlight/rehype-highlight.js +2 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/code/highlight.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/code/highlight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAW9C;;GAEG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IACP,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IACrC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CACpC,UAiDF"}
|
package/dist/code/highlight.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { lowlightLanguageMappings } from '../constants.js';
|
|
2
1
|
import rehypeParse from 'rehype-parse';
|
|
3
2
|
import rehypeStringify from 'rehype-stringify';
|
|
4
3
|
import { unified } from 'unified';
|
|
5
4
|
import { visit } from 'unist-util-visit';
|
|
5
|
+
import { lowlightLanguageMappings } from '../constants.js';
|
|
6
6
|
import { codeBlockLinesPlugin } from './line-numbers.js';
|
|
7
7
|
import { rehypeHighlight } from '../rehype-highlight/rehype-highlight.js';
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/markdown/markdown.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/markdown/markdown.ts"],"names":[],"mappings":"AAyCA;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;IACR,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9D,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,UAiDF;AASD;;GAEG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,MAAU,GAChB;IACD,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd,EAAE,CAiBF;AAuBD;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,YAgC5C"}
|
|
@@ -15,19 +15,15 @@ import { standardLanguages } from '../languages/standard.js';
|
|
|
15
15
|
/**
|
|
16
16
|
* Plugin to transform nodes in a Markdown AST
|
|
17
17
|
*/
|
|
18
|
-
const transformNodes =
|
|
19
|
-
|
|
20
|
-
..._ignored) {
|
|
21
|
-
return (tree) => {
|
|
22
|
-
if (!options?.transform || !options?.type) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
visit(tree, options?.type, (node) => {
|
|
26
|
-
options?.transform ? options?.transform(node) : node;
|
|
27
|
-
return SKIP;
|
|
28
|
-
});
|
|
18
|
+
const transformNodes = (options, ..._ignored) => (tree) => {
|
|
19
|
+
if (!options?.transform || !options?.type) {
|
|
29
20
|
return;
|
|
30
|
-
}
|
|
21
|
+
}
|
|
22
|
+
visit(tree, options?.type, (node) => {
|
|
23
|
+
options?.transform ? options?.transform(node) : node;
|
|
24
|
+
return SKIP;
|
|
25
|
+
});
|
|
26
|
+
return;
|
|
31
27
|
};
|
|
32
28
|
/**
|
|
33
29
|
* Take a Markdown string and generate HTML from it
|
|
@@ -35,10 +31,7 @@ const transformNodes = function (options,
|
|
|
35
31
|
function htmlFromMarkdown(markdown, options) {
|
|
36
32
|
// Add permitted tags and remove stripped ones
|
|
37
33
|
const removeTags = options?.removeTags ?? [];
|
|
38
|
-
const tagNames = [
|
|
39
|
-
...(defaultSchema.tagNames ?? []),
|
|
40
|
-
...(options?.allowTags ?? []),
|
|
41
|
-
].filter((t) => !removeTags.includes(t));
|
|
34
|
+
const tagNames = [...(defaultSchema.tagNames ?? []), ...(options?.allowTags ?? [])].filter((t) => !removeTags.includes(t));
|
|
42
35
|
const html = unified()
|
|
43
36
|
// Parses markdown
|
|
44
37
|
.use(remarkParse)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Root } from 'hast';
|
|
2
|
-
import { type LanguageFn
|
|
2
|
+
import { createLowlight, type LanguageFn } from 'lowlight';
|
|
3
3
|
import type { VFile } from 'vfile';
|
|
4
4
|
type HighlightOptions = {
|
|
5
5
|
/** Optional existing lowlight instance to use */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rehype-highlight.d.ts","sourceRoot":"","sources":["../../src/rehype-highlight/rehype-highlight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,IAAI,EAAE,MAAM,MAAM,CAAA;AAEzD,OAAO,EAAE,KAAK,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"rehype-highlight.d.ts","sourceRoot":"","sources":["../../src/rehype-highlight/rehype-highlight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,IAAI,EAAE,MAAM,MAAM,CAAA;AAEzD,OAAO,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAIlC,KAAK,gBAAgB,GAAG;IACtB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,GAAG,SAAS,CAAA;IACxD,2EAA2E;IAC3E,OAAO,CAAC,EACJ,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,GACxD,IAAI,GACJ,SAAS,CAAA;IACb,2EAA2E;IAC3E,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAA;IACnE,yGAAyG;IACzG,SAAS,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,CAAA;IACpD,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAClC,qFAAqF;IACrF,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,CAAA;IACjD,qCAAqC;IACrC,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAID;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,OAAO,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,IAAI,GAAG,SAAS,UAsBzC,IAAI,QAAQ,KAAK,UAkEhC"}
|
|
@@ -27,8 +27,8 @@ function rehypeHighlight(options) {
|
|
|
27
27
|
name = pos > -1 ? prefix.slice(0, pos) : prefix;
|
|
28
28
|
}
|
|
29
29
|
/** Transform.*/
|
|
30
|
-
return
|
|
31
|
-
visit(tree, 'element',
|
|
30
|
+
return (tree, file) => {
|
|
31
|
+
visit(tree, 'element', (node, _, parent) => {
|
|
32
32
|
if (node.tagName !== 'code' ||
|
|
33
33
|
!parent ||
|
|
34
34
|
parent.type !== 'element' ||
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"lowlight",
|
|
17
17
|
"highlightjs"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.0.
|
|
19
|
+
"version": "0.0.22",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"vfile": "^6.0.1",
|
|
93
93
|
"vite": "^5.4.10",
|
|
94
94
|
"vue": "^3.5.12",
|
|
95
|
-
"@scalar/build-tooling": "0.1.
|
|
96
|
-
"@scalar/themes": "0.9.
|
|
95
|
+
"@scalar/build-tooling": "0.1.14",
|
|
96
|
+
"@scalar/themes": "0.9.68"
|
|
97
97
|
},
|
|
98
98
|
"scripts": {
|
|
99
99
|
"build": "scalar-build-rollup",
|