@vxrn/mdx 1.10.1 → 1.10.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/dist/index.mjs CHANGED
@@ -22642,7 +22642,11 @@ var rehypeHighlightCode = (options2 = {}) => {
22642
22642
  function visitor(node2, index3, parent) {
22643
22643
  if (!parent || parent.tagName !== "pre" || node2.tagName !== "code" || !node2.properties.className)
22644
22644
  return;
22645
- let [_2, lang] = node2.properties.className[0].split("-"), codeString = toString(node2), result = refractor.highlight(codeString, lang), linesToHighlight = (0, import_parse_numeric_range.default)(node2.properties.line || "0");
22645
+ let langClass = node2.properties.className[0];
22646
+ if (!langClass) return;
22647
+ let [_2, lang] = langClass.split("-");
22648
+ if (!lang || !refractor.registered(lang)) return;
22649
+ let codeString = toString(node2), result = refractor.highlight(codeString, lang), linesToHighlight = (0, import_parse_numeric_range.default)(node2.properties.line || "0");
22646
22650
  result = rehypeHighlightLine(result, linesToHighlight), node2.children = rehypeHighlightWord(result);
22647
22651
  }
22648
22652
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vxrn/mdx",
3
- "version": "1.10.1",
3
+ "version": "1.10.2",
4
4
  "type": "commonjs",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",
@@ -27,7 +27,10 @@ export const rehypeHighlightCode = (options = {}) => {
27
27
  return
28
28
  }
29
29
 
30
- const [_, lang] = node.properties.className[0].split('-')
30
+ const langClass = node.properties.className[0]
31
+ if (!langClass) return
32
+ const [_, lang] = langClass.split('-')
33
+ if (!lang || !refractor.registered(lang)) return
31
34
  const codeString = toString(node)
32
35
  let result = refractor.highlight(codeString, lang)
33
36
 
@@ -1 +1 @@
1
- {"version":3,"file":"rehypeHighlightCode.d.ts","sourceRoot":"","sources":["../src/rehypeHighlightCode.tsx"],"names":[],"mappings":"AAcA,eAAO,MAAM,mBAAmB,GAAI,YAAY,MACtC,SAAI,SAwBb,CAAA"}
1
+ {"version":3,"file":"rehypeHighlightCode.d.ts","sourceRoot":"","sources":["../src/rehypeHighlightCode.tsx"],"names":[],"mappings":"AAcA,eAAO,MAAM,mBAAmB,GAAI,YAAY,MACtC,SAAI,SA2Bb,CAAA"}