@godxjp/markdown 33.22.1 → 33.24.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.
@@ -0,0 +1,37 @@
1
+ import { d as Doc, D as DirectiveBlock, e as DocNode } from '../directive-DqwrNF2I.js';
2
+ export { C as CALLOUT_KINDS, a as COLUMNS_MAX, b as COLUMNS_MIN, c as CalloutKind, M as MODELLED_DIRECTIVES, f as Mark } from '../directive-DqwrNF2I.js';
3
+
4
+ /**
5
+ * The parts of a directive block's `source` (a `directive` node's attribute), or `null` when the
6
+ * text is not exactly one container directive. Pure — a host's editor preview calls it.
7
+ */
8
+ declare function readDirective(source: string): DirectiveBlock | null;
9
+ /** Markdown → document (plain JSON, ProseMirror/Tiptap shape). Pure: no DOM. */
10
+ declare function parse(markdown: string): Doc;
11
+
12
+ type OutlineEntry = {
13
+ depth: number;
14
+ text: string;
15
+ id: string;
16
+ };
17
+ /**
18
+ * The body's headings with the ids `<Markdown>` gives them — GitHub slugs, de-duplicated in
19
+ * document order, the renderer's default rule — for a table of contents (the kit's `Anchor`). Pure.
20
+ * A host that passes its own `headingId` resolver to `<Markdown>` must use that same resolver here.
21
+ */
22
+ declare function outline(markdown: string): OutlineEntry[];
23
+ /** The body's YAML front matter, verbatim (without the `---` fences), or null. Parse it with your YAML library. */
24
+ declare function frontmatterOf(markdown: string): string | null;
25
+
26
+ /** Document → canonical Markdown. Pure: no DOM. */
27
+ declare function serialize(doc: Doc | DocNode): string;
28
+
29
+ /**
30
+ * Identifies the serializer's output. Bumped whenever `serialize` would write a stored body
31
+ * differently, so a host can tell which normalization a saved `normalized_body` came from.
32
+ */
33
+ declare const CODEC_ID = "kit-md@2";
34
+ /** `serialize(parse(markdown))` — the canonical form of a body, exactly what the editor saves. */
35
+ declare function normalize(markdown: string): string;
36
+
37
+ export { CODEC_ID, DirectiveBlock, Doc, DocNode, type OutlineEntry, frontmatterOf, normalize, outline, parse, readDirective, serialize };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The codec's document: plain JSON in the ProseMirror/Tiptap shape (`type` / `attrs` / `content` /
3
+ * `text` / `marks`), so `@godxjp/block-editor` loads it with `setContent` and hands back what
4
+ * `getJSON()` returns. No DOM, no editor instance — this module runs in a Worker (gh#1156).
5
+ *
6
+ * Node names follow Tiptap's StarterKit / Table / Details extensions where one exists:
7
+ * doc · paragraph · heading{level} · blockquote · codeBlock{language} · horizontalRule ·
8
+ * bulletList{tight} · orderedList{start,tight} · listItem · taskList{tight} · taskItem{checked} ·
9
+ * table · tableRow · tableHeader{align} · tableCell{align} · image{src,alt,title} · hardBreak
10
+ * and the kit's own:
11
+ * callout{kind,title} · details · detailsSummary · detailsContent · columns · column{width} ·
12
+ * embed{target} (block `![[x]]`) · wikilink{target,heading,label} · embedInline{target} ·
13
+ * directive{name,source} (a container directive the kit does not model: `:::poll[…]{…}`) ·
14
+ * rawBlock{source} · rawInline{source} · frontmatter{source} (YAML, first block only)
15
+ * Marks: bold · italic · strike · code · link{href,title}.
16
+ */
17
+ type Mark = {
18
+ type: "bold" | "italic" | "strike" | "code";
19
+ } | {
20
+ type: "link";
21
+ attrs: {
22
+ href: string;
23
+ title: string | null;
24
+ };
25
+ };
26
+ type DocNode = {
27
+ type: string;
28
+ attrs?: Record<string, unknown>;
29
+ content?: DocNode[];
30
+ text?: string;
31
+ marks?: Mark[];
32
+ };
33
+ type Doc = DocNode & {
34
+ type: "doc";
35
+ content: DocNode[];
36
+ };
37
+ /** GitHub alert kinds, the only callouts v1 knows. Serialized uppercase. */
38
+ declare const CALLOUT_KINDS: readonly ["note", "tip", "important", "warning", "caution"];
39
+ type CalloutKind = (typeof CALLOUT_KINDS)[number];
40
+ /** Columns per `:::columns` block (grammar v1). */
41
+ declare const COLUMNS_MIN = 2;
42
+ declare const COLUMNS_MAX = 4;
43
+ /** Directive names the kit draws itself (grammar v1). A host cannot register a renderer for them. */
44
+ declare const MODELLED_DIRECTIVES: readonly string[];
45
+
46
+ /**
47
+ * DIRECTIVE BLOCKS: a container directive the kit does not model itself (`:::poll[…]{…}`,
48
+ * `::::form`), read once so the codec, the renderer and the block editor hand a host the same
49
+ * parts. Here everything is the CANONICAL Markdown the codec writes (what the editor saves);
50
+ * `<Markdown directives>` slices the same parts from the body as written, which is the same text for
51
+ * a body the editor saved.
52
+ */
53
+ type DirectiveBlock = {
54
+ /** The directive's name: `poll` for `:::poll`. */
55
+ name: string;
56
+ /** The `[label]` as inline Markdown, or `null` when the directive has none. */
57
+ label: string | null;
58
+ /** The `{…}` attributes; a bare flag (`{anonymous}`) is `""`, `{#x}` is `id`, `{.x}` is `class`. */
59
+ attributes: Record<string, string>;
60
+ /** The whole directive, fences included: canonical from the codec, as written from `<Markdown>`. */
61
+ source: string;
62
+ /** The content between the fences (without the label) as Markdown; `""` when empty. */
63
+ body: string;
64
+ };
65
+
66
+ export { CALLOUT_KINDS as C, type DirectiveBlock as D, MODELLED_DIRECTIVES as M, COLUMNS_MAX as a, COLUMNS_MIN as b, type CalloutKind as c, type Doc as d, type DocNode as e, type Mark as f };
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import { Options as Options$1, Components } from 'react-markdown';
3
3
  import { Root } from 'hast';
4
4
  import { Options } from 'rehype-sanitize';
5
+ import { D as DirectiveBlock, c as CalloutKind } from './directive-DqwrNF2I.js';
5
6
 
6
7
  /** What a host is told about each heading, in document order. */
7
8
  type HeadingInfo = {
@@ -68,30 +69,6 @@ declare function extendSchema(extension?: SchemaExtension): Options;
68
69
  */
69
70
  declare function safeUrl(url: string, key: string): string;
70
71
 
71
- /** GitHub alert kinds, the only callouts v1 knows. Serialized uppercase. */
72
- declare const CALLOUT_KINDS: readonly ["note", "tip", "important", "warning", "caution"];
73
- type CalloutKind = (typeof CALLOUT_KINDS)[number];
74
-
75
- /**
76
- * DIRECTIVE BLOCKS: a container directive the kit does not model itself (`:::poll[…]{…}`,
77
- * `::::form`), read once so the codec, the renderer and the block editor hand a host the same
78
- * parts. Here everything is the CANONICAL Markdown the codec writes (what the editor saves);
79
- * `<Markdown directives>` slices the same parts from the body as written, which is the same text for
80
- * a body the editor saved.
81
- */
82
- type DirectiveBlock = {
83
- /** The directive's name: `poll` for `:::poll`. */
84
- name: string;
85
- /** The `[label]` as inline Markdown, or `null` when the directive has none. */
86
- label: string | null;
87
- /** The `{…}` attributes; a bare flag (`{anonymous}`) is `""`, `{#x}` is `id`, `{.x}` is `class`. */
88
- attributes: Record<string, string>;
89
- /** The whole directive, fences included: canonical from the codec, as written from `<Markdown>`. */
90
- source: string;
91
- /** The content between the fences (without the label) as Markdown; `""` when empty. */
92
- body: string;
93
- };
94
-
95
72
  type PluggableList = NonNullable<Options$1["remarkPlugins"]>;
96
73
  /** What a host's directive renderer receives: the block's parts plus its content, already rendered. */
97
74
  type DirectiveRenderProps = DirectiveBlock & {
@@ -243,4 +220,4 @@ type MarkdownFixture = {
243
220
  };
244
221
  declare const MARKDOWN_FIXTURES: MarkdownFixture[];
245
222
 
246
- export { type DirectiveBlock as D, type HeadingIdResolver as H, MARKDOWN_FIXTURES as M, RENDERER_VERSION as R, type SchemaExtension as S, type DirectiveRenderProps as a, type DirectiveRenderer as b, type HeadingInfo as c, MARKDOWN_FORMAT as d, type MarkdownFixture as e, type MarkdownProps as f, MermaidDiagram as g, type MermaidDiagramProps as h, type MermaidSvgCheck as i, checkMermaidSvg as j, extendSchema as k, markdownSchema as m, rehypeHeadingIds as r, safeUrl as s };
223
+ export { type DirectiveRenderProps as D, type HeadingIdResolver as H, MARKDOWN_FIXTURES as M, RENDERER_VERSION as R, type SchemaExtension as S, type DirectiveRenderer as a, type HeadingInfo as b, MARKDOWN_FORMAT as c, type MarkdownFixture as d, type MarkdownProps as e, MermaidDiagram as f, type MermaidDiagramProps as g, type MermaidSvgCheck as h, checkMermaidSvg as i, extendSchema as j, markdownSchema as m, rehypeHeadingIds as r, safeUrl as s };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
- import { f as MarkdownProps } from './fixtures-CKcZEUes.js';
3
- export { D as DirectiveBlock, a as DirectiveRenderProps, b as DirectiveRenderer, H as HeadingIdResolver, c as HeadingInfo, M as MARKDOWN_FIXTURES, d as MARKDOWN_FORMAT, e as MarkdownFixture, g as MermaidDiagram, h as MermaidDiagramProps, i as MermaidSvgCheck, R as RENDERER_VERSION, S as SchemaExtension, j as checkMermaidSvg, k as extendSchema, m as markdownSchema, r as rehypeHeadingIds, s as safeUrl } from './fixtures-CKcZEUes.js';
2
+ import { e as MarkdownProps } from './fixtures-kHqqmyjB.js';
3
+ export { D as DirectiveRenderProps, a as DirectiveRenderer, H as HeadingIdResolver, b as HeadingInfo, M as MARKDOWN_FIXTURES, c as MARKDOWN_FORMAT, d as MarkdownFixture, f as MermaidDiagram, g as MermaidDiagramProps, h as MermaidSvgCheck, R as RENDERER_VERSION, S as SchemaExtension, i as checkMermaidSvg, j as extendSchema, m as markdownSchema, r as rehypeHeadingIds, s as safeUrl } from './fixtures-kHqqmyjB.js';
4
+ export { D as DirectiveBlock } from './directive-DqwrNF2I.js';
4
5
  import 'react-markdown';
5
6
  import 'hast';
6
7
  import 'rehype-sanitize';
package/dist/lazy.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
- import { f as MarkdownProps } from './fixtures-CKcZEUes.js';
3
- export { D as DirectiveBlock, a as DirectiveRenderProps, b as DirectiveRenderer, H as HeadingIdResolver, c as HeadingInfo, M as MARKDOWN_FIXTURES, d as MARKDOWN_FORMAT, e as MarkdownFixture, g as MermaidDiagram, h as MermaidDiagramProps, i as MermaidSvgCheck, R as RENDERER_VERSION, S as SchemaExtension, j as checkMermaidSvg, k as extendSchema, m as markdownSchema, r as rehypeHeadingIds, s as safeUrl } from './fixtures-CKcZEUes.js';
2
+ import { e as MarkdownProps } from './fixtures-kHqqmyjB.js';
3
+ export { D as DirectiveRenderProps, a as DirectiveRenderer, H as HeadingIdResolver, b as HeadingInfo, M as MARKDOWN_FIXTURES, c as MARKDOWN_FORMAT, d as MarkdownFixture, f as MermaidDiagram, g as MermaidDiagramProps, h as MermaidSvgCheck, R as RENDERER_VERSION, S as SchemaExtension, i as checkMermaidSvg, j as extendSchema, m as markdownSchema, r as rehypeHeadingIds, s as safeUrl } from './fixtures-kHqqmyjB.js';
4
+ export { D as DirectiveBlock } from './directive-DqwrNF2I.js';
4
5
  import 'react-markdown';
5
6
  import 'hast';
6
7
  import 'rehype-sanitize';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@godxjp/markdown",
3
- "version": "33.22.1",
3
+ "version": "33.24.0",
4
4
  "description": "The one Markdown renderer for GoDX apps: GFM + heading anchors, KaTeX math, highlighted code, one sanitiser schema, a shared fixture corpus, and Mermaid drawn only after its SVG passes a fail-closed gate.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",