@scalar/code-highlight 0.0.21 → 0.0.23

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @scalar/code-highlight
2
2
 
3
+ ## 0.0.23
4
+
5
+ ### Patch Changes
6
+
7
+ - 3feee27: feat: adds markdown alert support
8
+ - c10bbf5: chore: code style
9
+
10
+ ## 0.0.22
11
+
12
+ ### Patch Changes
13
+
14
+ - e350f23: chore: code style
15
+
3
16
  ## 0.0.21
4
17
 
5
18
  ### Patch Changes
@@ -1 +1 @@
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"}
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,UA4CF"}
@@ -11,9 +11,7 @@ import { rehypeHighlight } from '../rehype-highlight/rehype-highlight.js';
11
11
  */
12
12
  function syntaxHighlight(codeString, options) {
13
13
  // Simple restriction on credentials to prevent unexpected behavior
14
- const credentials = (typeof options?.maskCredentials === 'string'
15
- ? [options.maskCredentials]
16
- : (options?.maskCredentials ?? [])).filter((c) => {
14
+ const credentials = (typeof options?.maskCredentials === 'string' ? [options.maskCredentials] : (options?.maskCredentials ?? [])).filter((c) => {
17
15
  // Credentials must be at least 3 characters to mask.
18
16
  if (c.length < 3) {
19
17
  return false;
@@ -41,9 +39,7 @@ function syntaxHighlight(codeString, options) {
41
39
  const htmlString = html.toString();
42
40
  // Replace any credentials with a wrapper element
43
41
  return credentials.length
44
- ? credentials.reduce((acc, credential) => acc
45
- .split(credential)
46
- .join(`<span class="credentials">${credential}</span>`), htmlString)
42
+ ? credentials.reduce((acc, credential) => acc.split(credential).join(`<span class="credentials">${credential}</span>`), htmlString)
47
43
  : htmlString;
48
44
  }
49
45
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"line-numbers.d.ts","sourceRoot":"","sources":["../../src/code/line-numbers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAM/D,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,IAAI,IAAI,CAEhE;AAED,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,IAAI,IAAI,OAAO,CAEhE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED,wBAAgB,SAAS,IAAI,IAAI,CAEhC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,WACpB,IAAI,UA2CnB"}
1
+ {"version":3,"file":"line-numbers.d.ts","sourceRoot":"","sources":["../../src/code/line-numbers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAM/D,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,IAAI,IAAI,CAEhE;AAED,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,IAAI,IAAI,OAAO,CAEhE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED,wBAAgB,SAAS,IAAI,IAAI,CAEhC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,WACpB,IAAI,UA2BnB"}
@@ -20,9 +20,7 @@ function lineBreak() {
20
20
  function codeBlockLinesPlugin() {
21
21
  return (tree) => {
22
22
  visit(tree, 'element', (node, _i, parent) => {
23
- if (parent?.type === 'element' &&
24
- parent.tagName === 'pre' &&
25
- node.tagName === 'code') {
23
+ if (parent?.type === 'element' && parent.tagName === 'pre' && node.tagName === 'code') {
26
24
  let numLines = 0;
27
25
  // Wraps each line in a span
28
26
  node.children = addLines(node);
@@ -30,19 +28,14 @@ function codeBlockLinesPlugin() {
30
28
  node.children.forEach((child) => {
31
29
  if (child.type === 'element' && child.tagName === 'span') {
32
30
  const lastChild = child.children[child.children.length - 1];
33
- if (lastChild &&
34
- (!isText(lastChild) ||
35
- (isText(lastChild) && !hasLineBreak(lastChild)))) {
31
+ if (lastChild && (!isText(lastChild) || (isText(lastChild) && !hasLineBreak(lastChild)))) {
36
32
  child.children.push(lineBreak());
37
33
  numLines++;
38
34
  }
39
35
  }
40
36
  });
41
37
  // We need to maintain a count of the total lines to allow space for the labels
42
- node.properties.style = [
43
- `--line-count: ${numLines};`,
44
- `--line-digits: ${numLines.toString().length};`,
45
- ];
38
+ node.properties.style = [`--line-count: ${numLines};`, `--line-digits: ${numLines.toString().length};`];
46
39
  }
47
40
  });
48
41
  // console.log('NUMBER OF LINES IS: ', numLines)
@@ -56,8 +49,7 @@ function codeBlockLinesPlugin() {
56
49
  * @param copyParent - Whether to copy the parent node to save the original node styles
57
50
  */
58
51
  function addLines(node, lines = [], copyParent) {
59
- const line = () => lines[lines.length - 1] ??
60
- (lines.push(createLine()) && lines[lines.length - 1]);
52
+ const line = () => lines[lines.length - 1] ?? (lines.push(createLine()) && lines[lines.length - 1]);
61
53
  node.children.forEach((child) => {
62
54
  if (isText(child) && hasLineBreak(child)) {
63
55
  const split = child.value.split(/\n/);
@@ -96,8 +88,7 @@ function createLine(...children) {
96
88
  * @param node - The node to check
97
89
  */
98
90
  function hasLineBreak(node) {
99
- return ((isText(node) && /\r?\n/.test(node.value)) ||
100
- (isElement(node) && node.children.some(hasLineBreak)));
91
+ return (isText(node) && /\r?\n/.test(node.value)) || (isElement(node) && node.children.some(hasLineBreak));
101
92
  }
102
93
 
103
94
  export { codeBlockLinesPlugin, isElement, isText, lineBreak, textElement };
package/dist/css/code.css CHANGED
@@ -146,7 +146,7 @@
146
146
 
147
147
  /** Show a few dots instead */
148
148
  .credentials::after {
149
- content: '·····';
149
+ content: "·····";
150
150
  font-size: var(--scalar-small);
151
151
  color: var(--scalar-color-3);
152
152
  user-select: none;
@@ -1,4 +1,4 @@
1
- @import url('./code.css');
1
+ @import url("./code.css");
2
2
 
3
3
  .scalar-app {
4
4
  .markdown {
@@ -43,7 +43,7 @@
43
43
 
44
44
  .markdown summary::after {
45
45
  display: block;
46
- content: '';
46
+ content: "";
47
47
 
48
48
  position: absolute;
49
49
  top: -1px;
@@ -284,13 +284,52 @@
284
284
  background: var(--scalar-background-2);
285
285
  }
286
286
 
287
- .markdown tr > [align='left'] {
287
+ .markdown tr > [align="left"] {
288
288
  text-align: left;
289
289
  }
290
- .markdown tr > [align='right'] {
290
+ .markdown tr > [align="right"] {
291
291
  text-align: right;
292
292
  }
293
- .markdown tr > [align='center'] {
293
+ .markdown tr > [align="center"] {
294
294
  text-align: center;
295
295
  }
296
+
297
+ /* Markdown Alert */
298
+ .markdown .markdown-alert {
299
+ align-items: stretch;
300
+ border-radius: var(--scalar-radius-lg);
301
+ background-color: color-mix(in srgb, var(--scalar-background-2), transparent);
302
+ border: var(--scalar-border-width) solid var(--scalar-border-color);
303
+ display: flex;
304
+ font-size: var(--scalar-small);
305
+ gap: 12px;
306
+ padding: 12px;
307
+ }
308
+ .markdown .markdown-alert .markdown-alert-border {
309
+ border-radius: var(--scalar-radius-xl);
310
+ min-width: 1.5px;
311
+ width: 1.5px;
312
+ }
313
+ .markdown .markdown-alert .markdown-alert-content {
314
+ margin: 0;
315
+ line-height: 1.5;
316
+ }
317
+ .markdown .markdown-alert .markdown-alert-title {
318
+ font-weight: var(--scalar-semibold);
319
+ }
320
+ .markdown .markdown-alert.markdown-alert-note .markdown-alert-border {
321
+ background-color: var(--scalar-color-blue);
322
+ }
323
+ .markdown .markdown-alert.markdown-alert-tip .markdown-alert-border {
324
+ background-color: var(--scalar-color-green);
325
+ }
326
+ .markdown .markdown-alert.markdown-alert-important .markdown-alert-border {
327
+ background-color: var(--scalar-color-purple);
328
+ }
329
+ .markdown .markdown-alert.markdown-alert-warning .markdown-alert-border {
330
+ background-color: var(--scalar-color-orange);
331
+ }
332
+ .markdown .markdown-alert.markdown-alert-caution .markdown-alert-border {
333
+ background-color: var(--scalar-color-red);
334
+ }
296
335
  }
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/markdown/markdown.ts"],"names":[],"mappings":"AA6CA;;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,UAkDF;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"}
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,UAmDF;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"}
@@ -11,13 +11,12 @@ import { unified } from 'unified';
11
11
  import { visit, SKIP } from 'unist-util-visit';
12
12
  import { rehypeHighlight } from '../rehype-highlight/rehype-highlight.js';
13
13
  import { standardLanguages } from '../languages/standard.js';
14
+ import { rehypeAlert } from '../rehype-alert/rehype-alert.js';
14
15
 
15
16
  /**
16
17
  * Plugin to transform nodes in a Markdown AST
17
18
  */
18
- const transformNodes = (options,
19
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
- ..._ignored) => (tree) => {
19
+ const transformNodes = (options, ..._ignored) => (tree) => {
21
20
  if (!options?.transform || !options?.type) {
22
21
  return;
23
22
  }
@@ -33,10 +32,7 @@ const transformNodes = (options,
33
32
  function htmlFromMarkdown(markdown, options) {
34
33
  // Add permitted tags and remove stripped ones
35
34
  const removeTags = options?.removeTags ?? [];
36
- const tagNames = [
37
- ...(defaultSchema.tagNames ?? []),
38
- ...(options?.allowTags ?? []),
39
- ].filter((t) => !removeTags.includes(t));
35
+ const tagNames = [...(defaultSchema.tagNames ?? []), ...(options?.allowTags ?? [])].filter((t) => !removeTags.includes(t));
40
36
  const html = unified()
41
37
  // Parses markdown
42
38
  .use(remarkParse)
@@ -68,6 +64,8 @@ function htmlFromMarkdown(markdown, options) {
68
64
  // Enable auto detection
69
65
  detect: true,
70
66
  })
67
+ // Adds GitHub alerts
68
+ .use(rehypeAlert)
71
69
  // Adds target="_blank" to external links
72
70
  .use(rehypeExternalLinks, { target: '_blank' })
73
71
  // Formats the HTML
@@ -0,0 +1,2 @@
1
+ export { rehypeAlert } from './rehype-alert.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rehype-alert/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1 @@
1
+ export { rehypeAlert } from './rehype-alert.js';
@@ -0,0 +1,3 @@
1
+ import type { Root } from 'mdast';
2
+ export declare function rehypeAlert(): (tree: Root) => void;
3
+ //# sourceMappingURL=rehype-alert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rehype-alert.d.ts","sourceRoot":"","sources":["../../src/rehype-alert/rehype-alert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AASjC,wBAAgB,WAAW,WACX,IAAI,UAmGnB"}
@@ -0,0 +1,108 @@
1
+ import { visit } from 'unist-util-visit';
2
+
3
+ const ALERT_TYPES = ['note', 'tip', 'important', 'warning', 'caution'];
4
+ // Simple whitespace check function
5
+ function isWhitespace(node) {
6
+ return node.type === 'text' && typeof node.value === 'string' && /^\s*$/.test(node.value);
7
+ }
8
+ function rehypeAlert() {
9
+ return (tree) => {
10
+ visit(tree, 'element', (node, index, parent) => {
11
+ if (node.tagName !== 'blockquote' || typeof index !== 'number' || !parent || parent.type !== 'root') {
12
+ return;
13
+ }
14
+ // Find the first non-whitespace child
15
+ const headIndex = node.children.findIndex((child) => !isWhitespace(child));
16
+ if (headIndex === -1)
17
+ return;
18
+ const head = node.children[headIndex];
19
+ if (!head || head.type !== 'element' || head.tagName !== 'p')
20
+ return;
21
+ const text = head.children[0];
22
+ if (!text || text.type !== 'text' || !text.value.startsWith('[!'))
23
+ return;
24
+ const end = text.value.indexOf(']');
25
+ if (end === -1)
26
+ return;
27
+ // Extract the alert type
28
+ const alertType = text.value.slice(2, end).toLowerCase();
29
+ if (!ALERT_TYPES.includes(alertType))
30
+ return;
31
+ // Remove the blockquote if it's empty
32
+ if (end + 1 === text.value.length) {
33
+ const next = head.children[1];
34
+ if (next) {
35
+ if (next.type !== 'element' || next.tagName !== 'br')
36
+ return;
37
+ if (!head.children[2])
38
+ return;
39
+ head.children = head.children.slice(2);
40
+ const node = head.children[0];
41
+ if (node && node.type === 'text' && node.value.charAt(0) === '\n') {
42
+ node.value = node.value.slice(1);
43
+ }
44
+ }
45
+ else {
46
+ const skipped = headIndex + 1 < node.children.length && isWhitespace(node.children[headIndex + 1]);
47
+ const nextIndex = skipped ? headIndex + 2 : headIndex + 1;
48
+ if (nextIndex >= node.children.length || node.children[nextIndex].type !== 'element') {
49
+ return;
50
+ }
51
+ node.children = node.children.slice(nextIndex);
52
+ }
53
+ }
54
+ else if (text.value.charAt(end + 1) === '\n' &&
55
+ // Check if the next character is a newline or a non-whitespace character
56
+ (end + 2 === text.value.length || !/^\s*$/.test(text.value.slice(end + 2)))) {
57
+ text.value = text.value.slice(end + 2);
58
+ }
59
+ else {
60
+ // Remove the alert marker if it’s not followed by a newline or a non-whitespace character
61
+ text.value = text.value.replace(/^\s*\[!.*?\]\s*/, '');
62
+ }
63
+ const capitalizedType = alertType.charAt(0).toUpperCase() + alertType.slice(1);
64
+ // Extract content from paragraphs to avoid wrapping in <p> tags
65
+ const contentChildren = [];
66
+ for (let i = headIndex; i < node.children.length; i++) {
67
+ const child = node.children[i];
68
+ if (child.type === 'element' && child.tagName === 'p' && child.children) {
69
+ contentChildren.push(...child.children);
70
+ }
71
+ else {
72
+ contentChildren.push(child);
73
+ }
74
+ }
75
+ // Replace the blockquote with a div containing the alert
76
+ parent.children[index] = {
77
+ type: 'element',
78
+ tagName: 'div',
79
+ properties: { className: ['markdown-alert', `markdown-alert-${alertType}`] },
80
+ children: [
81
+ {
82
+ type: 'element',
83
+ tagName: 'span',
84
+ properties: { className: ['markdown-alert-border'] },
85
+ children: [],
86
+ },
87
+ {
88
+ type: 'element',
89
+ tagName: 'div',
90
+ properties: { className: ['markdown-alert-content'] },
91
+ children: [
92
+ {
93
+ type: 'element',
94
+ tagName: 'span',
95
+ properties: { className: ['markdown-alert-title'] },
96
+ children: [{ type: 'text', value: `${capitalizedType}:` }],
97
+ },
98
+ { type: 'text', value: ' ' },
99
+ ...contentChildren,
100
+ ],
101
+ },
102
+ ],
103
+ };
104
+ });
105
+ };
106
+ }
107
+
108
+ export { rehypeAlert };
@@ -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,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"}
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,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAA;IACrF,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,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,IAAI,GAAG,SAAS,UAqBvE,IAAI,QAAQ,KAAK,UAsDhC"}
@@ -29,16 +29,11 @@ function rehypeHighlight(options) {
29
29
  /** Transform.*/
30
30
  return (tree, file) => {
31
31
  visit(tree, 'element', (node, _, parent) => {
32
- if (node.tagName !== 'code' ||
33
- !parent ||
34
- parent.type !== 'element' ||
35
- parent.tagName !== 'pre') {
32
+ if (node.tagName !== 'code' || !parent || parent.type !== 'element' || parent.tagName !== 'pre') {
36
33
  return;
37
34
  }
38
35
  const lang = language(node);
39
- if (lang === 'no-highlight' ||
40
- (!lang && !detect) ||
41
- (lang && plainText?.includes(lang))) {
36
+ if (lang === 'no-highlight' || (!lang && !detect) || (lang && plainText?.includes(lang))) {
42
37
  return;
43
38
  }
44
39
  if (!Array.isArray(node.properties.className)) {
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "lowlight",
17
17
  "highlightjs"
18
18
  ],
19
- "version": "0.0.21",
19
+ "version": "0.0.23",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -33,6 +33,11 @@
33
33
  "types": "./dist/rehype-highlight/index.d.ts",
34
34
  "default": "./dist/rehype-highlight/index.js"
35
35
  },
36
+ "./rehype-alert": {
37
+ "import": "./dist/rehype-alert/index.js",
38
+ "types": "./dist/rehype-alert/index.d.ts",
39
+ "default": "./dist/rehype-alert/index.js"
40
+ },
36
41
  "./markdown": {
37
42
  "import": "./dist/markdown/index.js",
38
43
  "types": "./dist/markdown/index.d.ts",
@@ -92,8 +97,8 @@
92
97
  "vfile": "^6.0.1",
93
98
  "vite": "^5.4.10",
94
99
  "vue": "^3.5.12",
95
- "@scalar/build-tooling": "0.1.13",
96
- "@scalar/themes": "0.9.67"
100
+ "@scalar/build-tooling": "0.1.15",
101
+ "@scalar/themes": "0.9.69"
97
102
  },
98
103
  "scripts": {
99
104
  "build": "scalar-build-rollup",