@ox-content/vite-plugin 0.12.0 → 0.13.0

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.cjs CHANGED
@@ -6725,39 +6725,40 @@ var import_dist = /* @__PURE__ */ require_chunk.__toESM(require_dist(), 1);
6725
6725
  /**
6726
6726
  * Syntax highlighting with Shiki via rehype.
6727
6727
  */
6728
+ const BUILTIN_LANGS = [
6729
+ "javascript",
6730
+ "typescript",
6731
+ "jsx",
6732
+ "tsx",
6733
+ "vue",
6734
+ "svelte",
6735
+ "html",
6736
+ "css",
6737
+ "scss",
6738
+ "json",
6739
+ "yaml",
6740
+ "markdown",
6741
+ "bash",
6742
+ "shell",
6743
+ "rust",
6744
+ "python",
6745
+ "go",
6746
+ "java",
6747
+ "c",
6748
+ "cpp",
6749
+ "sql",
6750
+ "graphql",
6751
+ "diff",
6752
+ "toml"
6753
+ ];
6728
6754
  let highlighterPromise = null;
6729
6755
  /**
6730
6756
  * Get or create the Shiki highlighter.
6731
6757
  */
6732
- async function getHighlighter(theme) {
6758
+ async function getHighlighter(theme, customLangs = []) {
6733
6759
  if (!highlighterPromise) highlighterPromise = (0, shiki.createHighlighter)({
6734
6760
  themes: [theme],
6735
- langs: [
6736
- "javascript",
6737
- "typescript",
6738
- "jsx",
6739
- "tsx",
6740
- "vue",
6741
- "svelte",
6742
- "html",
6743
- "css",
6744
- "scss",
6745
- "json",
6746
- "yaml",
6747
- "markdown",
6748
- "bash",
6749
- "shell",
6750
- "rust",
6751
- "python",
6752
- "go",
6753
- "java",
6754
- "c",
6755
- "cpp",
6756
- "sql",
6757
- "graphql",
6758
- "diff",
6759
- "toml"
6760
- ]
6761
+ langs: [...BUILTIN_LANGS, ...customLangs]
6761
6762
  });
6762
6763
  return highlighterPromise;
6763
6764
  }
@@ -6765,9 +6766,9 @@ async function getHighlighter(theme) {
6765
6766
  * Rehype plugin for syntax highlighting with Shiki.
6766
6767
  */
6767
6768
  function rehypeShikiHighlight(options) {
6768
- const { theme } = options;
6769
+ const { theme, langs } = options;
6769
6770
  return async (tree) => {
6770
- const highlighter = await getHighlighter(theme);
6771
+ const highlighter = await getHighlighter(theme, langs);
6771
6772
  const visit = async (node) => {
6772
6773
  if ("children" in node) for (let i = 0; i < node.children.length; i++) {
6773
6774
  const child = node.children[i];
@@ -6810,8 +6811,11 @@ function getTextContent(node) {
6810
6811
  /**
6811
6812
  * Apply syntax highlighting to HTML using Shiki.
6812
6813
  */
6813
- async function highlightCode(html, theme = "github-dark") {
6814
- const result = await (0, unified.unified)().use(rehype_parse.default, { fragment: true }).use(rehypeShikiHighlight, { theme }).use(rehype_stringify.default).process(html);
6814
+ async function highlightCode(html, theme = "github-dark", langs = []) {
6815
+ const result = await (0, unified.unified)().use(rehype_parse.default, { fragment: true }).use(rehypeShikiHighlight, {
6816
+ theme,
6817
+ langs
6818
+ }).use(rehype_stringify.default).process(html);
6815
6819
  return String(result);
6816
6820
  }
6817
6821
 
@@ -6989,7 +6993,7 @@ async function transformMarkdown(source, filePath, options, ssgOptions) {
6989
6993
  if (options.mermaid) html = await require_mermaid.transformMermaidStatic(html);
6990
6994
  const { html: protectedHtml, svgs } = protectMermaidSvgs(html);
6991
6995
  html = protectedHtml;
6992
- if (options.highlight) html = await highlightCode(html, options.highlightTheme);
6996
+ if (options.highlight) html = await highlightCode(html, options.highlightTheme, options.highlightLangs);
6993
6997
  html = restoreMermaidSvgs(html, svgs);
6994
6998
  return {
6995
6999
  code: generateModuleCode(html, frontmatter, toc, filePath, options),
@@ -11705,6 +11709,7 @@ function resolveOptions(options) {
11705
11709
  strikethrough: options.strikethrough ?? true,
11706
11710
  highlight: options.highlight ?? false,
11707
11711
  highlightTheme: options.highlightTheme ?? "github-dark",
11712
+ highlightLangs: options.highlightLangs ?? [],
11708
11713
  mermaid: options.mermaid ?? false,
11709
11714
  frontmatter: options.frontmatter ?? true,
11710
11715
  toc: options.toc ?? true,