featherdown 0.1.0 → 0.1.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/README.md CHANGED
@@ -10,20 +10,27 @@ It provides a browser-safe default entry and a separate Node-only Mermaid subpat
10
10
  npm install featherdown
11
11
  ```
12
12
 
13
+ JSR (Deno):
14
+
15
+ ```ts
16
+ import { renderMarkdownToHtml } from "jsr:@karuifeather/featherdown";
17
+ ```
18
+
13
19
  Node.js 18+ is required.
14
20
 
15
- If you use Mermaid rendering from `featherdown/node`, install Playwright Chromium:
21
+ If you use Mermaid rendering from `featherdown/node`, install Playwright and Chromium:
16
22
 
17
23
  ```bash
24
+ npm install playwright
18
25
  npx playwright install chromium
19
26
  ```
20
27
 
21
28
  ## Quick Start (Browser-Safe Default Entry)
22
29
 
23
30
  ```ts
24
- import { renderMarkdownToHtml } from 'featherdown';
31
+ import { renderMarkdownToHtml } from "featherdown";
25
32
 
26
- const html = await renderMarkdownToHtml('## Hello **world**');
33
+ const html = await renderMarkdownToHtml("## Hello **world**");
27
34
  ```
28
35
 
29
36
  The default entry does not include Mermaid rendering.
@@ -32,26 +39,26 @@ The default entry does not include Mermaid rendering.
32
39
 
33
40
  Use `renderMarkdown` to get both HTML and non-fatal warnings.
34
41
 
35
- ```ts
36
- import { renderMarkdown } from 'featherdown';
42
+ ````ts
43
+ import { renderMarkdown } from "featherdown";
37
44
 
38
45
  const { html, diagnostics } = await renderMarkdown(
39
- '```chart-line\nnot json\n```',
46
+ "```chart-line\nnot json\n```",
40
47
  );
41
48
 
42
49
  console.log(html);
43
50
  console.log(diagnostics);
44
- ```
51
+ ````
45
52
 
46
53
  ## Processor Factory Usage
47
54
 
48
55
  Use `createMarkdownProcessor` when you want direct control of processing calls.
49
56
 
50
57
  ```ts
51
- import { createMarkdownProcessor } from 'featherdown';
58
+ import { createMarkdownProcessor } from "featherdown";
52
59
 
53
60
  const processor = createMarkdownProcessor();
54
- const file = await processor.process('# Hello');
61
+ const file = await processor.process("# Hello");
55
62
  const html = String(file);
56
63
  ```
57
64
 
@@ -60,18 +67,18 @@ const html = String(file);
60
67
  The package exports focused plugins for custom unified pipelines.
61
68
 
62
69
  ```ts
63
- import { unified } from 'unified';
64
- import remarkParse from 'remark-parse';
65
- import remarkRehype from 'remark-rehype';
66
- import rehypeStringify from 'rehype-stringify';
67
- import { rehypeChartBlocks, rehypeCdnImages } from 'featherdown';
70
+ import { unified } from "unified";
71
+ import remarkParse from "remark-parse";
72
+ import remarkRehype from "remark-rehype";
73
+ import rehypeStringify from "rehype-stringify";
74
+ import { rehypeChartBlocks, rehypeCdnImages } from "featherdown";
68
75
 
69
76
  const html = String(
70
77
  await unified()
71
78
  .use(remarkParse)
72
79
  .use(remarkRehype)
73
80
  .use(rehypeChartBlocks)
74
- .use(rehypeCdnImages, { kind: 'post', slug: 'hello-world' })
81
+ .use(rehypeCdnImages, { kind: "post", slug: "hello-world" })
75
82
  .use(rehypeStringify)
76
83
  .process(markdown),
77
84
  );
@@ -80,15 +87,15 @@ const html = String(
80
87
  ## Image Rewriting Example
81
88
 
82
89
  ```ts
83
- import { renderMarkdownToHtml } from 'featherdown';
90
+ import { renderMarkdownToHtml } from "featherdown";
84
91
 
85
- const html = await renderMarkdownToHtml('![Logo](./images/logo.png)', {
86
- kind: 'post',
87
- slug: 'hello-world',
92
+ const html = await renderMarkdownToHtml("![Logo](./images/logo.png)", {
93
+ kind: "post",
94
+ slug: "hello-world",
88
95
  manifest: {
89
96
  map: {
90
- 'post/hello-world/images/logo.png': {
91
- url: 'https://cdn.example.com/blog/hello-world/logo.hash.png',
97
+ "post/hello-world/images/logo.png": {
98
+ url: "https://cdn.example.com/blog/hello-world/logo.hash.png",
92
99
  },
93
100
  },
94
101
  },
@@ -111,7 +118,7 @@ Rendered HTML shape:
111
118
  <div
112
119
  class="chart-mount"
113
120
  data-chart="line"
114
- data-chart-data="{&quot;labels&quot;:[&quot;a&quot;],&quot;datasets&quot;:[]}"
121
+ data-chart-data='{"labels":["a"],"datasets":[]}'
115
122
  ></div>
116
123
  ```
117
124
 
@@ -119,15 +126,16 @@ This package does not bundle a chart runtime; it only emits mount markup.
119
126
 
120
127
  ## Node-Only Mermaid Subpath
121
128
 
122
- ```ts
123
- import { renderMarkdownToHtmlWithMermaid } from 'featherdown/node';
129
+ ````ts
130
+ import { renderMarkdownToHtmlWithMermaid } from "featherdown/node";
124
131
 
125
132
  const html = await renderMarkdownToHtmlWithMermaid(
126
- '```mermaid\ngraph TD; A-->B;\n```',
133
+ "```mermaid\ngraph TD; A-->B;\n```",
127
134
  );
128
- ```
135
+ ````
129
136
 
130
137
  Use this entry in Node publishing environments where Playwright + Mermaid dependencies are acceptable.
138
+ The `node` Mermaid subpath is npm-focused and is not part of the JSR export surface.
131
139
 
132
140
  ## CSS / Asset Expectations
133
141
 
@@ -159,15 +167,19 @@ Node-only entry (`featherdown/node`):
159
167
 
160
168
  ## Scripts
161
169
 
162
- | Script | Description |
163
- |---|---|
164
- | `npm run build` | Build ESM artifacts in `dist/` |
165
- | `npm test` | Run Vitest once |
166
- | `npm run test:watch` | Run Vitest in watch mode |
167
- | `npm run lint` | Run ESLint |
168
- | `npm run typecheck` | Run TypeScript checks |
170
+ | Script | Description |
171
+ | ---------------------- | --------------------------------- |
172
+ | `npm run build` | Build ESM artifacts in `dist/` |
173
+ | `npm test` | Run Vitest once |
174
+ | `npm run test:watch` | Run Vitest in watch mode |
175
+ | `npm run lint` | Run ESLint |
176
+ | `npm run typecheck` | Run TypeScript checks |
169
177
  | `npm run test:exports` | Build and run export smoke checks |
170
178
 
179
+ ## Maintainers
180
+
181
+ CI and publishing are described in [RELEASING.md](./RELEASING.md).
182
+
171
183
  ## License
172
184
 
173
185
  MIT. See [LICENSE](./LICENSE).
package/dist/index.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import { R as RenderDiagnostic, a as RenderMarkdownOptions } from './types-DlRranpy.js';
2
- import * as unified from 'unified';
3
- import { Plugin } from 'unified';
4
- import * as hast from 'hast';
5
- import { Root } from 'hast';
6
- import * as mdast from 'mdast';
2
+ import { Root as Root$1 } from 'hast';
3
+ import { Root } from 'mdast';
4
+ import { Processor, Plugin } from 'unified';
7
5
 
8
6
  /**
9
7
  * Stable identifier for this library. Intended for diagnostics and smoke tests.
@@ -20,7 +18,7 @@ type DiagnosticEmitter = (d: RenderDiagnostic) => void;
20
18
  type InternalOptions = RenderMarkdownOptions & {
21
19
  emitDiagnostic?: DiagnosticEmitter;
22
20
  };
23
- declare function createMarkdownProcessorInternal(options?: InternalOptions): unified.Processor<mdast.Root, mdast.Root, hast.Root, undefined, undefined>;
21
+ declare function createMarkdownProcessorInternal(options?: InternalOptions): Processor<Root, Root, Root$1>;
24
22
 
25
23
  declare function createMarkdownProcessor(options?: RenderMarkdownOptions): ReturnType<typeof createMarkdownProcessorInternal>;
26
24
 
@@ -28,14 +26,14 @@ declare function createMarkdownProcessor(options?: RenderMarkdownOptions): Retur
28
26
  * Replaces supported `chart-…` fenced JSON blocks with a mount placeholder.
29
27
  * Invalid JSON leaves the original `<pre><code>` unchanged.
30
28
  */
31
- declare const rehypeChartBlocks: Plugin<[], Root>;
29
+ declare const rehypeChartBlocks: Plugin<[], Root$1>;
32
30
 
33
31
  type RehypeCdnImagesOptions = RenderMarkdownOptions;
34
32
  /**
35
33
  * Adds `markdown-inline-img` to all images and optionally rewrites `src` using
36
34
  * caller-provided manifest data.
37
35
  */
38
- declare const rehypeCdnImages: Plugin<[RehypeCdnImagesOptions?], Root>;
36
+ declare const rehypeCdnImages: Plugin<[RehypeCdnImagesOptions?], Root$1>;
39
37
 
40
38
  declare function renderMarkdown(markdown: string, options?: RenderMarkdownOptions): Promise<{
41
39
  html: string;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/libraryId.ts","../src/parseMarkdownFile.ts","../src/internal/createMarkdownProcessorInternal.ts","../src/createMarkdownProcessor.ts","../src/rehypeChartBlocks.ts","../src/rehypeCdn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AAA,WAAA,CAAY,KAAK,CAAC,CAAA;AAAA,EACpB,CAAA;AAEA,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA;AAAA,GACF;AACF;;;ACVA,eAAsB,cAAA,CACpB,UACA,OAAA,EAC4D;AAC5D,EAAA,MAAM,YAAY,yBAAA,EAA0B;AAC5C,EAAA,MAAM,YAAY,+BAAA,CAAgC;AAAA,IAChD,GAAG,OAAA;AAAA,IACH,gBAAgB,SAAA,CAAU;AAAA,GAC3B,CAAA;AACD,EAAA,MAAM,IAAA,GAAO,MAAM,SAAA,CAAU,OAAA,CAAQ,QAAQ,CAAA;AAC7C,EAAA,OAAO,EAAE,IAAA,EAAM,MAAA,CAAO,IAAI,CAAA,EAAG,WAAA,EAAa,UAAU,WAAA,EAAY;AAClE;;;ACZA,eAAsB,oBAAA,CACpB,UACA,OAAA,EACiB;AACjB,EAAA,MAAM,MAAA,GAAS,MAAM,cAAA,CAAe,QAAA,EAAU,OAAO,CAAA;AACrD,EAAA,OAAO,MAAA,CAAO,IAAA;AAChB","file":"index.js","sourcesContent":["/**\n * Stable identifier for this library. Intended for diagnostics and smoke tests.\n */\nexport function libraryId(): string {\n return 'featherdown';\n}\n","import yaml from 'js-yaml';\n\nexport function parseMarkdownFile(raw: string): {\n frontMatter: Record<string, unknown>;\n content: string;\n} {\n const match = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---(?:\\r?\\n|$)/.exec(raw);\n if (!raw.startsWith('---') || !match) {\n return { frontMatter: {}, content: raw };\n }\n\n const yamlSource = match[1] ?? '';\n const content = raw.slice(match[0].length);\n\n try {\n const loaded: unknown = yaml.load(yamlSource);\n if (loaded === undefined || loaded === null) {\n return { frontMatter: {}, content };\n }\n if (typeof loaded !== 'object' || Array.isArray(loaded)) {\n throw new Error(\n 'Front matter root must be a YAML mapping (object), not a list or scalar.',\n );\n }\n return { frontMatter: loaded as Record<string, unknown>, content };\n } catch (e) {\n if (e instanceof Error && e.message.startsWith('Front matter')) {\n throw e;\n }\n const detail = e instanceof Error ? e.message : String(e);\n throw new Error(`Front matter YAML could not be parsed: ${detail}`);\n }\n}\n","import rehypeAutolinkHeadings from 'rehype-autolink-headings';\nimport rehypeHighlight from 'rehype-highlight';\nimport rehypeKatex from 'rehype-katex';\nimport rehypeRaw from 'rehype-raw';\nimport rehypeChartBlocksInternal from './rehypeChartBlocksInternal.js';\nimport rehypeCdnImagesInternal from './rehypeCdnImagesInternal.js';\nimport rehypeSanitize from 'rehype-sanitize';\nimport rehypeSlug from 'rehype-slug';\nimport rehypeStringify from 'rehype-stringify';\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\nimport remarkParse from 'remark-parse';\nimport remarkRehype from 'remark-rehype';\nimport { unified } from 'unified';\nimport type { RenderMarkdownOptions } from '../types.js';\nimport { remarkHeadingIds } from './headingIdsRemark.js';\nimport type { DiagnosticEmitter } from './diagnostics.js';\nimport { markdownSanitizeSchema } from './sanitizeSchema.js';\n\ntype InternalOptions = RenderMarkdownOptions & {\n emitDiagnostic?: DiagnosticEmitter;\n};\n\nexport function createMarkdownProcessorInternal(\n options?: InternalOptions,\n) {\n const processor = unified()\n .use(remarkParse)\n .use(remarkGfm)\n .use(remarkMath)\n .use(remarkHeadingIds)\n .use(remarkRehype, { allowDangerousHtml: true })\n .use(rehypeRaw);\n\n if (options?.emitDiagnostic) {\n processor.use(rehypeChartBlocksInternal, { emitDiagnostic: options.emitDiagnostic });\n } else {\n processor.use(rehypeChartBlocksInternal);\n }\n\n processor\n .use(rehypeKatex, { output: 'html' })\n .use(rehypeSanitize, markdownSanitizeSchema)\n .use(rehypeSlug)\n .use(rehypeAutolinkHeadings, { behavior: 'wrap' })\n .use(rehypeHighlight)\n .use(rehypeCdnImagesInternal, options)\n .use(rehypeStringify);\n\n return processor;\n}\n\n","import type { RenderMarkdownOptions } from './types.js';\nimport { createMarkdownProcessorInternal } from './internal/createMarkdownProcessorInternal.js';\n\nexport function createMarkdownProcessor(\n options?: RenderMarkdownOptions,\n): ReturnType<typeof createMarkdownProcessorInternal> {\n return createMarkdownProcessorInternal(options);\n}\n\n","import type { Plugin } from 'unified';\nimport type { Root } from 'hast';\nimport rehypeChartBlocksInternal from './internal/rehypeChartBlocksInternal.js';\n\n/**\n * Replaces supported `chart-…` fenced JSON blocks with a mount placeholder.\n * Invalid JSON leaves the original `<pre><code>` unchanged.\n */\nexport const rehypeChartBlocks: Plugin<[], Root> =\n rehypeChartBlocksInternal as unknown as Plugin<[], Root>;\n\n","import type { Plugin } from 'unified';\nimport type { Root } from 'hast';\nimport type { RenderMarkdownOptions } from './types.js';\nimport rehypeCdnImagesInternal from './internal/rehypeCdnImagesInternal.js';\n\nexport type RehypeCdnImagesOptions = RenderMarkdownOptions;\n\n/**\n * Adds `markdown-inline-img` to all images and optionally rewrites `src` using\n * caller-provided manifest data.\n */\nexport const rehypeCdnImages: Plugin<[RehypeCdnImagesOptions?], Root> =\n rehypeCdnImagesInternal as unknown as Plugin<[RehypeCdnImagesOptions?], Root>;\n\n","import type { RenderDiagnostic } from '../types.js';\n\nexport type DiagnosticEmitter = (d: RenderDiagnostic) => void;\n\nexport function createDiagnosticCollector() {\n const diagnostics: RenderDiagnostic[] = [];\n const emit: DiagnosticEmitter = (d) => {\n diagnostics.push(d);\n };\n\n return {\n emit,\n diagnostics,\n };\n}\n\n","import { createMarkdownProcessorInternal } from './internal/createMarkdownProcessorInternal.js';\nimport { createDiagnosticCollector } from './internal/diagnostics.js';\nimport type { RenderDiagnostic, RenderMarkdownOptions } from './types.js';\n\nexport async function renderMarkdown(\n markdown: string,\n options?: RenderMarkdownOptions,\n): Promise<{ html: string; diagnostics: RenderDiagnostic[] }> {\n const collector = createDiagnosticCollector();\n const processor = createMarkdownProcessorInternal({\n ...options,\n emitDiagnostic: collector.emit,\n });\n const file = await processor.process(markdown);\n return { html: String(file), diagnostics: collector.diagnostics };\n}\n\n","import { renderMarkdown } from './renderMarkdown.js';\nimport type { RenderMarkdownOptions } from './types.js';\n\nexport async function renderMarkdownToHtml(\n markdown: string,\n options?: RenderMarkdownOptions,\n): Promise<string> {\n const result = await renderMarkdown(markdown, options);\n return result.html;\n}\n"]}
1
+ {"version":3,"sources":["../src/libraryId.ts","../src/parseMarkdownFile.ts","../src/internal/createMarkdownProcessorInternal.ts","../src/createMarkdownProcessor.ts","../src/rehypeChartBlocks.ts","../src/rehypeCdnImages.ts","../src/internal/diagnostics.ts","../src/renderMarkdown.ts","../src/renderMarkdownToHtml.ts"],"names":["rehypeCdnImages"],"mappings":";;;;;;;;;;;;;;;;AAGO,SAAS,SAAA,GAAoB;AAClC,EAAA,OAAO,aAAA;AACT;ACHO,SAAS,kBAAkB,GAAA,EAGhC;AACA,EAAA,MAAM,KAAA,GAAQ,wCAAA,CAAyC,IAAA,CAAK,GAAG,CAAA;AAC/D,EAAA,IAAI,CAAC,GAAA,CAAI,UAAA,CAAW,KAAK,CAAA,IAAK,CAAC,KAAA,EAAO;AACpC,IAAA,OAAO,EAAE,WAAA,EAAa,EAAC,EAAG,SAAS,GAAA,EAAI;AAAA,EACzC;AAEA,EAAA,MAAM,UAAA,GAAa,KAAA,CAAM,CAAC,CAAA,IAAK,EAAA;AAC/B,EAAA,MAAM,UAAU,GAAA,CAAI,KAAA,CAAM,KAAA,CAAM,CAAC,EAAE,MAAM,CAAA;AAEzC,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAkB,IAAA,CAAK,IAAA,CAAK,UAAU,CAAA;AAC5C,IAAA,IAAI,MAAA,KAAW,KAAA,CAAA,IAAa,MAAA,KAAW,IAAA,EAAM;AAC3C,MAAA,OAAO,EAAE,WAAA,EAAa,EAAC,EAAG,OAAA,EAAQ;AAAA,IACpC;AACA,IAAA,IAAI,OAAO,MAAA,KAAW,QAAA,IAAY,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,EAAG;AACvD,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,OAAO,EAAE,WAAA,EAA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,wBACd,OAAA,EACoD;AACpD,EAAA,OAAO,gCAAgC,OAAO,CAAA;AAChD;;;ACCO,IAAM,iBAAA,GACX;;;ACEK,IAAMA,gBAAAA,GACX;;;ACRK,SAAS,yBAAA,GAA4B;AAC1C,EAAA,MAAM,cAAkC,EAAC;AACzC,EAAA,MAAM,IAAA,GAA0B,CAAC,CAAA,KAAM;AACrC,IAAA,WAAA,CAAY,KAAK,CAAC,CAAA;AAAA,EACpB,CAAA;AAEA,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA;AAAA,GACF;AACF;;;ACVA,eAAsB,cAAA,CACpB,UACA,OAAA,EAC4D;AAC5D,EAAA,MAAM,YAAY,yBAAA,EAA0B;AAC5C,EAAA,MAAM,YAAY,+BAAA,CAAgC;AAAA,IAChD,GAAG,OAAA;AAAA,IACH,gBAAgB,SAAA,CAAU;AAAA,GAC3B,CAAA;AACD,EAAA,MAAM,IAAA,GAAO,MAAM,SAAA,CAAU,OAAA,CAAQ,QAAQ,CAAA;AAC7C,EAAA,OAAO,EAAE,IAAA,EAAM,MAAA,CAAO,IAAI,CAAA,EAAG,WAAA,EAAa,UAAU,WAAA,EAAY;AAClE;;;ACZA,eAAsB,oBAAA,CACpB,UACA,OAAA,EACiB;AACjB,EAAA,MAAM,MAAA,GAAS,MAAM,cAAA,CAAe,QAAA,EAAU,OAAO,CAAA;AACrD,EAAA,OAAO,MAAA,CAAO,IAAA;AAChB","file":"index.js","sourcesContent":["/**\n * Stable identifier for this library. Intended for diagnostics and smoke tests.\n */\nexport function libraryId(): string {\n return 'featherdown';\n}\n","import yaml from 'js-yaml';\n\nexport function parseMarkdownFile(raw: string): {\n frontMatter: Record<string, unknown>;\n content: string;\n} {\n const match = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---(?:\\r?\\n|$)/.exec(raw);\n if (!raw.startsWith('---') || !match) {\n return { frontMatter: {}, content: raw };\n }\n\n const yamlSource = match[1] ?? '';\n const content = raw.slice(match[0].length);\n\n try {\n const loaded: unknown = yaml.load(yamlSource);\n if (loaded === undefined || loaded === null) {\n return { frontMatter: {}, content };\n }\n if (typeof loaded !== 'object' || Array.isArray(loaded)) {\n throw new Error(\n 'Front matter root must be a YAML mapping (object), not a list or scalar.',\n );\n }\n return { frontMatter: loaded as Record<string, unknown>, content };\n } catch (e) {\n if (e instanceof Error && e.message.startsWith('Front matter')) {\n throw e;\n }\n const detail = e instanceof Error ? e.message : String(e);\n throw new Error(`Front matter YAML could not be parsed: ${detail}`);\n }\n}\n","import rehypeAutolinkHeadings from 'rehype-autolink-headings';\nimport rehypeHighlight from 'rehype-highlight';\nimport rehypeKatex from 'rehype-katex';\nimport rehypeRaw from 'rehype-raw';\nimport rehypeChartBlocksInternal from './rehypeChartBlocksInternal.js';\nimport rehypeCdnImagesInternal from './rehypeCdnImagesInternal.js';\nimport rehypeSanitize from 'rehype-sanitize';\nimport rehypeSlug from 'rehype-slug';\nimport rehypeStringify from 'rehype-stringify';\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\nimport remarkParse from 'remark-parse';\nimport remarkRehype from 'remark-rehype';\nimport type { Root as HastRoot } from 'hast';\nimport type { Root as MdastRoot } from 'mdast';\nimport type { Processor } from 'unified';\nimport { unified } from 'unified';\nimport type { RenderMarkdownOptions } from '../types.js';\nimport { remarkHeadingIds } from './headingIdsRemark.js';\nimport type { DiagnosticEmitter } from './diagnostics.js';\nimport { markdownSanitizeSchema } from './sanitizeSchema.js';\n\ntype InternalOptions = RenderMarkdownOptions & {\n emitDiagnostic?: DiagnosticEmitter;\n};\n\nexport function createMarkdownProcessorInternal(\n options?: InternalOptions,\n): Processor<MdastRoot, MdastRoot, HastRoot> {\n const processor = unified()\n .use(remarkParse)\n .use(remarkGfm)\n .use(remarkMath)\n .use(remarkHeadingIds)\n .use(remarkRehype, { allowDangerousHtml: true })\n .use(rehypeRaw);\n\n if (options?.emitDiagnostic) {\n processor.use(rehypeChartBlocksInternal, { emitDiagnostic: options.emitDiagnostic });\n } else {\n processor.use(rehypeChartBlocksInternal);\n }\n\n processor\n .use(rehypeKatex, { output: 'html' })\n .use(rehypeSanitize, markdownSanitizeSchema)\n .use(rehypeSlug)\n .use(rehypeAutolinkHeadings, { behavior: 'wrap' })\n .use(rehypeHighlight)\n .use(rehypeCdnImagesInternal, options)\n .use(rehypeStringify);\n\n return processor;\n}\n\n","import type { RenderMarkdownOptions } from './types.js';\nimport { createMarkdownProcessorInternal } from './internal/createMarkdownProcessorInternal.js';\n\nexport function createMarkdownProcessor(\n options?: RenderMarkdownOptions,\n): ReturnType<typeof createMarkdownProcessorInternal> {\n return createMarkdownProcessorInternal(options);\n}\n\n","import type { Plugin } from 'unified';\nimport type { Root } from 'hast';\nimport rehypeChartBlocksInternal from './internal/rehypeChartBlocksInternal.js';\n\n/**\n * Replaces supported `chart-…` fenced JSON blocks with a mount placeholder.\n * Invalid JSON leaves the original `<pre><code>` unchanged.\n */\nexport const rehypeChartBlocks: Plugin<[], Root> =\n rehypeChartBlocksInternal as unknown as Plugin<[], Root>;\n\n","import type { Plugin } from 'unified';\nimport type { Root } from 'hast';\nimport type { RenderMarkdownOptions } from './types.js';\nimport rehypeCdnImagesInternal from './internal/rehypeCdnImagesInternal.js';\n\nexport type RehypeCdnImagesOptions = RenderMarkdownOptions;\n\n/**\n * Adds `markdown-inline-img` to all images and optionally rewrites `src` using\n * caller-provided manifest data.\n */\nexport const rehypeCdnImages: Plugin<[RehypeCdnImagesOptions?], Root> =\n rehypeCdnImagesInternal as unknown as Plugin<[RehypeCdnImagesOptions?], Root>;\n\n","import type { RenderDiagnostic } from '../types.js';\n\nexport type DiagnosticEmitter = (d: RenderDiagnostic) => void;\n\nexport function createDiagnosticCollector() {\n const diagnostics: RenderDiagnostic[] = [];\n const emit: DiagnosticEmitter = (d) => {\n diagnostics.push(d);\n };\n\n return {\n emit,\n diagnostics,\n };\n}\n\n","import { createMarkdownProcessorInternal } from './internal/createMarkdownProcessorInternal.js';\nimport { createDiagnosticCollector } from './internal/diagnostics.js';\nimport type { RenderDiagnostic, RenderMarkdownOptions } from './types.js';\n\nexport async function renderMarkdown(\n markdown: string,\n options?: RenderMarkdownOptions,\n): Promise<{ html: string; diagnostics: RenderDiagnostic[] }> {\n const collector = createDiagnosticCollector();\n const processor = createMarkdownProcessorInternal({\n ...options,\n emitDiagnostic: collector.emit,\n });\n const file = await processor.process(markdown);\n return { html: String(file), diagnostics: collector.diagnostics };\n}\n\n","import { renderMarkdown } from './renderMarkdown.js';\nimport type { RenderMarkdownOptions } from './types.js';\n\nexport async function renderMarkdownToHtml(\n markdown: string,\n options?: RenderMarkdownOptions,\n): Promise<string> {\n const result = await renderMarkdown(markdown, options);\n return result.html;\n}\n"]}
package/dist/node.js CHANGED
@@ -2,7 +2,7 @@ import { remarkHeadingIds, rehypeChartBlocks_default, schemaWithSvg, rehypeCdnIm
2
2
  import rehypeAutolinkHeadings from 'rehype-autolink-headings';
3
3
  import rehypeHighlight from 'rehype-highlight';
4
4
  import rehypeKatex from 'rehype-katex';
5
- import rehypeMermaid from 'rehype-mermaidjs';
5
+ import rehypeMermaid from 'rehype-mermaid';
6
6
  import rehypeRaw from 'rehype-raw';
7
7
  import rehypeSanitize from 'rehype-sanitize';
8
8
  import rehypeSlug from 'rehype-slug';
package/dist/node.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/createMarkdownProcessorWithMermaidInternal.ts","../src/node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmBO,SAAS,2CACd,OAAA,EACA;AACA,EAAA,OAAO,OAAA,EAAQ,CACZ,GAAA,CAAI,WAAW,CAAA,CACf,GAAA,CAAI,SAAS,CAAA,CACb,GAAA,CAAI,UAAU,CAAA,CACd,GAAA,CAAI,gBAAgB,CAAA,CACpB,GAAA,CAAI,YAAA,EAAc,EAAE,kBAAA,EAAoB,IAAA,EAAM,CAAA,CAC9C,GAAA,CAAI,SAAS,CAAA,CACb,GAAA,CAAI,yBAAyB,CAAA,CAC7B,GAAA,CAAI,UAAU,CAAA,CACd,GAAA,CAAI,sBAAA,EAAwB,EAAE,QAAA,EAAU,MAAA,EAAQ,CAAA,CAChD,GAAA,CAAI,WAAA,EAAa,EAAE,MAAA,EAAQ,MAAA,EAAQ,CAAA,CACnC,GAAA,CAAI,eAAe,CAAA,CACnB,GAAA,CAAI,aAAA,EAAe,EAAE,QAAA,EAAU,YAAA,EAAc,CAAA,CAC7C,GAAA,CAAI,cAAA,EAAgB,aAAa,CAAA,CACjC,GAAA,CAAI,eAAA,EAAyB,OAAO,CAAA,CACpC,IAAI,eAAe,CAAA;AACxB;;;ACnCA,eAAsB,+BAAA,CACpB,UACA,OAAA,EACiB;AACjB,EAAA,MAAM,SAAA,GAAY,2CAA2C,OAAO,CAAA;AACpE,EAAA,MAAM,IAAA,GAAO,MAAM,SAAA,CAAU,OAAA,CAAQ,QAAQ,CAAA;AAC7C,EAAA,OAAO,OAAO,IAAI,CAAA;AACpB","file":"node.js","sourcesContent":["import rehypeAutolinkHeadings from 'rehype-autolink-headings';\nimport rehypeHighlight from 'rehype-highlight';\nimport rehypeKatex from 'rehype-katex';\nimport rehypeMermaid from 'rehype-mermaidjs';\nimport rehypeRaw from 'rehype-raw';\nimport rehypeSanitize from 'rehype-sanitize';\nimport rehypeSlug from 'rehype-slug';\nimport rehypeStringify from 'rehype-stringify';\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\nimport remarkParse from 'remark-parse';\nimport remarkRehype from 'remark-rehype';\nimport { unified } from 'unified';\nimport type { RenderMarkdownOptions } from '../types.js';\nimport rehypeChartBlocksInternal from './rehypeChartBlocksInternal.js';\nimport rehypeCdnImagesInternal from './rehypeCdnImagesInternal.js';\nimport { remarkHeadingIds } from './headingIdsRemark.js';\nimport { schemaWithSvg } from './sanitizeSchema.js';\n\nexport function createMarkdownProcessorWithMermaidInternal(\n options?: RenderMarkdownOptions,\n) {\n return unified()\n .use(remarkParse)\n .use(remarkGfm)\n .use(remarkMath)\n .use(remarkHeadingIds)\n .use(remarkRehype, { allowDangerousHtml: true })\n .use(rehypeRaw)\n .use(rehypeChartBlocksInternal)\n .use(rehypeSlug)\n .use(rehypeAutolinkHeadings, { behavior: 'wrap' })\n .use(rehypeKatex, { output: 'html' })\n .use(rehypeHighlight)\n .use(rehypeMermaid, { strategy: 'inline-svg' })\n .use(rehypeSanitize, schemaWithSvg)\n .use(rehypeCdnImagesInternal, options)\n .use(rehypeStringify);\n}\n\n","import { createMarkdownProcessorWithMermaidInternal } from './internal/createMarkdownProcessorWithMermaidInternal.js';\nimport type { RenderMarkdownOptions } from './types.js';\n\nexport async function renderMarkdownToHtmlWithMermaid(\n markdown: string,\n options?: RenderMarkdownOptions,\n): Promise<string> {\n const processor = createMarkdownProcessorWithMermaidInternal(options);\n const file = await processor.process(markdown);\n return String(file);\n}\n\nexport type { RenderMarkdownOptions } from './types.js';\n\n"]}
1
+ {"version":3,"sources":["../src/internal/createMarkdownProcessorWithMermaidInternal.ts","../src/node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmBO,SAAS,2CACd,OAAA,EACA;AACA,EAAA,OAAO,OAAA,EAAQ,CACZ,GAAA,CAAI,WAAW,CAAA,CACf,GAAA,CAAI,SAAS,CAAA,CACb,GAAA,CAAI,UAAU,CAAA,CACd,GAAA,CAAI,gBAAgB,CAAA,CACpB,GAAA,CAAI,YAAA,EAAc,EAAE,kBAAA,EAAoB,IAAA,EAAM,CAAA,CAC9C,GAAA,CAAI,SAAS,CAAA,CACb,GAAA,CAAI,yBAAyB,CAAA,CAC7B,GAAA,CAAI,UAAU,CAAA,CACd,GAAA,CAAI,sBAAA,EAAwB,EAAE,QAAA,EAAU,MAAA,EAAQ,CAAA,CAChD,GAAA,CAAI,WAAA,EAAa,EAAE,MAAA,EAAQ,MAAA,EAAQ,CAAA,CACnC,GAAA,CAAI,eAAe,CAAA,CACnB,GAAA,CAAI,aAAA,EAAe,EAAE,QAAA,EAAU,YAAA,EAAc,CAAA,CAC7C,GAAA,CAAI,cAAA,EAAgB,aAAa,CAAA,CACjC,GAAA,CAAI,eAAA,EAAyB,OAAO,CAAA,CACpC,IAAI,eAAe,CAAA;AACxB;;;ACnCA,eAAsB,+BAAA,CACpB,UACA,OAAA,EACiB;AACjB,EAAA,MAAM,SAAA,GAAY,2CAA2C,OAAO,CAAA;AACpE,EAAA,MAAM,IAAA,GAAO,MAAM,SAAA,CAAU,OAAA,CAAQ,QAAQ,CAAA;AAC7C,EAAA,OAAO,OAAO,IAAI,CAAA;AACpB","file":"node.js","sourcesContent":["import rehypeAutolinkHeadings from 'rehype-autolink-headings';\nimport rehypeHighlight from 'rehype-highlight';\nimport rehypeKatex from 'rehype-katex';\nimport rehypeMermaid from 'rehype-mermaid';\nimport rehypeRaw from 'rehype-raw';\nimport rehypeSanitize from 'rehype-sanitize';\nimport rehypeSlug from 'rehype-slug';\nimport rehypeStringify from 'rehype-stringify';\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\nimport remarkParse from 'remark-parse';\nimport remarkRehype from 'remark-rehype';\nimport { unified } from 'unified';\nimport type { RenderMarkdownOptions } from '../types.js';\nimport rehypeChartBlocksInternal from './rehypeChartBlocksInternal.js';\nimport rehypeCdnImagesInternal from './rehypeCdnImagesInternal.js';\nimport { remarkHeadingIds } from './headingIdsRemark.js';\nimport { schemaWithSvg } from './sanitizeSchema.js';\n\nexport function createMarkdownProcessorWithMermaidInternal(\n options?: RenderMarkdownOptions,\n) {\n return unified()\n .use(remarkParse)\n .use(remarkGfm)\n .use(remarkMath)\n .use(remarkHeadingIds)\n .use(remarkRehype, { allowDangerousHtml: true })\n .use(rehypeRaw)\n .use(rehypeChartBlocksInternal)\n .use(rehypeSlug)\n .use(rehypeAutolinkHeadings, { behavior: 'wrap' })\n .use(rehypeKatex, { output: 'html' })\n .use(rehypeHighlight)\n .use(rehypeMermaid, { strategy: 'inline-svg' })\n .use(rehypeSanitize, schemaWithSvg)\n .use(rehypeCdnImagesInternal, options)\n .use(rehypeStringify);\n}\n\n","import { createMarkdownProcessorWithMermaidInternal } from './internal/createMarkdownProcessorWithMermaidInternal.js';\nimport type { RenderMarkdownOptions } from './types.js';\n\nexport async function renderMarkdownToHtmlWithMermaid(\n markdown: string,\n options?: RenderMarkdownOptions,\n): Promise<string> {\n const processor = createMarkdownProcessorWithMermaidInternal(options);\n const file = await processor.process(markdown);\n return String(file);\n}\n\nexport type { RenderMarkdownOptions } from './types.js';\n\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "featherdown",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Markdown-to-HTML pipeline with sanitization, diagnostics, and optional Node Mermaid rendering.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -29,6 +29,7 @@
29
29
  "lint": "eslint .",
30
30
  "typecheck": "tsc --noEmit",
31
31
  "test:exports": "npm run build && node ./test/exports.smoke.mjs",
32
+ "verify-release-version": "node ./scripts/verify-release-version.mjs",
32
33
  "prepublishOnly": "npm run lint && npm run typecheck && npm test && npm run test:exports"
33
34
  },
34
35
  "keywords": [
@@ -42,13 +43,33 @@
42
43
  "publishing"
43
44
  ],
44
45
  "license": "MIT",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/karuifeather/featherdown.git"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/karuifeather/featherdown/issues"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public",
55
+ "provenance": true
56
+ },
45
57
  "engines": {
46
58
  "node": ">=18"
47
59
  },
60
+ "peerDependencies": {
61
+ "playwright": "^1.59.1"
62
+ },
63
+ "peerDependenciesMeta": {
64
+ "playwright": {
65
+ "optional": true
66
+ }
67
+ },
48
68
  "devDependencies": {
49
69
  "@eslint/js": "^9.18.0",
50
70
  "@types/js-yaml": "^4.0.9",
51
71
  "eslint": "^9.18.0",
72
+ "playwright": "^1.59.1",
52
73
  "tsup": "^8.3.5",
53
74
  "typescript": "^5.7.3",
54
75
  "typescript-eslint": "^8.21.0",
@@ -61,7 +82,7 @@
61
82
  "rehype-autolink-headings": "^7.1.0",
62
83
  "rehype-highlight": "^7.0.2",
63
84
  "rehype-katex": "^7.0.1",
64
- "rehype-mermaidjs": "^2.0.0",
85
+ "rehype-mermaid": "^3.0.0",
65
86
  "rehype-raw": "^7.0.0",
66
87
  "rehype-sanitize": "^6.0.0",
67
88
  "rehype-slug": "^6.0.0",