@canofold/markdown 0.2.1 → 0.3.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.
@@ -3,7 +3,7 @@ import { toJsxRuntime as ht } from "hast-util-to-jsx-runtime";
3
3
  import { createContext as Ye, createElement as w, useContext as Qe, useState as B, useEffect as Z, isValidElement as A, Children as O, useMemo as le, useRef as _, cloneElement as R, useId as yt, version as vt, Fragment as Ct } from "react";
4
4
  import { ChevronRight as wt, ChevronLeft as kt, X as Lt, Link2 as Nt, Workflow as St, FileText as xt, Folder as It, Table2 as Mt, ChevronsUpDown as Tt, RotateCcw as Ft, Plus as At, Minus as zt, Maximize2 as Dt, Code2 as $t, Download as Pt, Copy as Ot, Check as Rt, ChevronDown as Et, CheckCircle2 as jt, TriangleAlert as Bt, CircleAlert as _t, Info as Wt } from "lucide-react";
5
5
  import { createPortal as Gt } from "react-dom";
6
- import { e as Ut, f as Kt, s as Vt } from "./plugins-CeQ-Bo89.js";
6
+ import { f as Ut, g as Kt, s as Vt } from "./plugins-StkCS2su.js";
7
7
  const x = {
8
8
  copyCode: "Copy code",
9
9
  copyFailed: "Copy failed",
@@ -2062,7 +2062,7 @@ function Pa(e, t) {
2062
2062
  return t === void 0 ? void 0 : `${t.length}:${t}\0${e}`;
2063
2063
  }
2064
2064
  async function Oa(e, t, a) {
2065
- const o = () => import("./prepareMarkdown-Bug1ncYk.js").then((i) => i.b).then(({ prepareMarkdown: i }) => i(e, t)), n = Pa(e, a);
2065
+ const o = () => import("./prepareMarkdown-D-bFl1_V.js").then((i) => i.b).then(({ prepareMarkdown: i }) => i(e, t)), n = Pa(e, a);
2066
2066
  if (n === void 0) return o();
2067
2067
  const c = H.get(n);
2068
2068
  if (c)
@@ -10,6 +10,16 @@ export interface MarkdownCodeExample {
10
10
  meta?: string;
11
11
  code: string;
12
12
  }
13
+ export interface MarkdownDirective {
14
+ name: string;
15
+ type: 'containerDirective' | 'leafDirective' | 'textDirective';
16
+ label: string;
17
+ attributes: Record<string, string>;
18
+ line?: number;
19
+ column?: number;
20
+ offset?: number;
21
+ endOffset?: number;
22
+ }
13
23
  export interface MarkdownAnalysis {
14
24
  text: string;
15
25
  headings: MarkdownHeading[];
@@ -17,6 +27,7 @@ export interface MarkdownAnalysis {
17
27
  links: string[];
18
28
  images: string[];
19
29
  missingCodeBlockLanguages: number;
30
+ directives: MarkdownDirective[];
20
31
  directiveIssues: MarkdownDirectiveIssue[];
21
32
  }
22
33
  export interface AnalyzeMarkdownOptions {
@@ -20,5 +20,7 @@ export declare function defineMarkdownPlugin(plugin: MarkdownPlugin): MarkdownPl
20
20
  export declare function activeMarkdownPlugins(plugins: readonly MarkdownPlugin[], context: MarkdownPluginContext): readonly MarkdownPlugin[];
21
21
  /** Collect normalized fenced-code labels owned by the active plugins. */
22
22
  export declare function markdownPluginFenceLanguages(plugins: readonly MarkdownPlugin[]): ReadonlySet<string>;
23
+ /** Collect code languages generated by active plugin transforms. */
24
+ export declare function markdownPluginHighlightLanguages(plugins: readonly MarkdownPlugin[]): readonly string[];
23
25
  /** Collect normalized directive names owned by the active plugins. */
24
26
  export declare function markdownPluginDirectiveNames(plugins: readonly MarkdownPlugin[]): ReadonlySet<string>;
@@ -99,6 +99,12 @@ export interface MarkdownPlugin {
99
99
  * fences as ordinary code or reporting them as unsupported languages.
100
100
  */
101
101
  fenceLanguages?: readonly string[];
102
+ /**
103
+ * Code languages introduced by this plugin's transforms. The compiler loads
104
+ * these grammars before the plugin runs so generated code blocks use the
105
+ * same Shiki pipeline as authored Markdown fences.
106
+ */
107
+ highlightLanguages?: readonly string[];
102
108
  /**
103
109
  * Directive names owned by this plugin. Undeclared directive names are
104
110
  * rejected so author typos cannot silently degrade to generic HTML.
@@ -1,4 +1,4 @@
1
- import { a as z, s as P, e as _, f as j } from "./plugins-CeQ-Bo89.js";
1
+ import { a as z, s as P, f as _, g as j } from "./plugins-StkCS2su.js";
2
2
  import { visit as S } from "unist-util-visit";
3
3
  function k(t, a, e) {
4
4
  const i = t.find((s) => s.id === a.id);
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { M as a } from "./Markdown-DgolXL7g.js";
2
- import { d as e } from "./plugins-CeQ-Bo89.js";
1
+ import { M as a } from "./Markdown-C7O01MRv.js";
2
+ import { d as e } from "./plugins-StkCS2su.js";
3
3
  export {
4
4
  a as Markdown,
5
5
  e as defineMarkdownPlugin
@@ -93,7 +93,7 @@ const w = {
93
93
  rust: "source",
94
94
  rs: "source"
95
95
  };
96
- function b(e, t = "") {
96
+ function h(e, t = "") {
97
97
  const r = e.split(/[\\/]/).pop()?.toLowerCase() || "", n = w[r];
98
98
  if (n) return n;
99
99
  if (/^\.env(?:\..+)?$/.test(r)) return "environment";
@@ -155,7 +155,7 @@ function j(e, t = "") {
155
155
  if (/^\.env(?:\.|$)/.test(n)) return "environment";
156
156
  if (n === "tsconfig.json" || n === "jsconfig.json") return "typescript";
157
157
  if (/\.(?:jsx|tsx)$/.test(n)) return "react";
158
- const o = b(n, t);
158
+ const o = h(n, t);
159
159
  if (o === "config") return "config";
160
160
  if (o === "database") return "database";
161
161
  if (o === "diff") return "diff";
@@ -193,7 +193,7 @@ function p(e) {
193
193
  return;
194
194
  }
195
195
  }
196
- const m = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/, h = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
196
+ const m = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/, b = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
197
197
  function d(e) {
198
198
  if (typeof e != "string" || !m.test(e))
199
199
  throw new Error(
@@ -209,7 +209,7 @@ function g(e) {
209
209
  if (t) {
210
210
  if (typeof t.module != "string" || t.module.trim() === "")
211
211
  throw new Error(`Markdown plugin "${e.name}" browserCompiler.module must be a non-empty string`);
212
- if (typeof t.exportName != "string" || !h.test(t.exportName))
212
+ if (typeof t.exportName != "string" || !b.test(t.exportName))
213
213
  throw new Error(
214
214
  `Markdown plugin "${e.name}" browserCompiler.exportName must be a named JavaScript export`
215
215
  );
@@ -273,16 +273,26 @@ function z(e) {
273
273
  return t;
274
274
  }
275
275
  function E(e) {
276
+ const t = /* @__PURE__ */ new Set();
277
+ for (const r of e)
278
+ for (const n of r.highlightLanguages ?? []) {
279
+ const o = n.trim().toLowerCase();
280
+ o && t.add(o);
281
+ }
282
+ return [...t];
283
+ }
284
+ function O(e) {
276
285
  return new Set(e.flatMap((t) => f(t)));
277
286
  }
278
287
  export {
279
288
  x as a,
280
289
  z as b,
281
- v as c,
290
+ E as c,
282
291
  N as d,
283
- b as e,
284
- j as f,
285
- E as m,
292
+ v as e,
293
+ h as f,
294
+ j as g,
295
+ O as m,
286
296
  $ as n,
287
297
  p as s
288
298
  };