featherdown 0.1.1 → 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,6 +10,12 @@ 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
21
  If you use Mermaid rendering from `featherdown/node`, install Playwright and Chromium:
@@ -22,9 +28,9 @@ npx playwright install chromium
22
28
  ## Quick Start (Browser-Safe Default Entry)
23
29
 
24
30
  ```ts
25
- import { renderMarkdownToHtml } from 'featherdown';
31
+ import { renderMarkdownToHtml } from "featherdown";
26
32
 
27
- const html = await renderMarkdownToHtml('## Hello **world**');
33
+ const html = await renderMarkdownToHtml("## Hello **world**");
28
34
  ```
29
35
 
30
36
  The default entry does not include Mermaid rendering.
@@ -33,26 +39,26 @@ The default entry does not include Mermaid rendering.
33
39
 
34
40
  Use `renderMarkdown` to get both HTML and non-fatal warnings.
35
41
 
36
- ```ts
37
- import { renderMarkdown } from 'featherdown';
42
+ ````ts
43
+ import { renderMarkdown } from "featherdown";
38
44
 
39
45
  const { html, diagnostics } = await renderMarkdown(
40
- '```chart-line\nnot json\n```',
46
+ "```chart-line\nnot json\n```",
41
47
  );
42
48
 
43
49
  console.log(html);
44
50
  console.log(diagnostics);
45
- ```
51
+ ````
46
52
 
47
53
  ## Processor Factory Usage
48
54
 
49
55
  Use `createMarkdownProcessor` when you want direct control of processing calls.
50
56
 
51
57
  ```ts
52
- import { createMarkdownProcessor } from 'featherdown';
58
+ import { createMarkdownProcessor } from "featherdown";
53
59
 
54
60
  const processor = createMarkdownProcessor();
55
- const file = await processor.process('# Hello');
61
+ const file = await processor.process("# Hello");
56
62
  const html = String(file);
57
63
  ```
58
64
 
@@ -61,18 +67,18 @@ const html = String(file);
61
67
  The package exports focused plugins for custom unified pipelines.
62
68
 
63
69
  ```ts
64
- import { unified } from 'unified';
65
- import remarkParse from 'remark-parse';
66
- import remarkRehype from 'remark-rehype';
67
- import rehypeStringify from 'rehype-stringify';
68
- 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";
69
75
 
70
76
  const html = String(
71
77
  await unified()
72
78
  .use(remarkParse)
73
79
  .use(remarkRehype)
74
80
  .use(rehypeChartBlocks)
75
- .use(rehypeCdnImages, { kind: 'post', slug: 'hello-world' })
81
+ .use(rehypeCdnImages, { kind: "post", slug: "hello-world" })
76
82
  .use(rehypeStringify)
77
83
  .process(markdown),
78
84
  );
@@ -81,15 +87,15 @@ const html = String(
81
87
  ## Image Rewriting Example
82
88
 
83
89
  ```ts
84
- import { renderMarkdownToHtml } from 'featherdown';
90
+ import { renderMarkdownToHtml } from "featherdown";
85
91
 
86
- const html = await renderMarkdownToHtml('![Logo](./images/logo.png)', {
87
- kind: 'post',
88
- slug: 'hello-world',
92
+ const html = await renderMarkdownToHtml("![Logo](./images/logo.png)", {
93
+ kind: "post",
94
+ slug: "hello-world",
89
95
  manifest: {
90
96
  map: {
91
- 'post/hello-world/images/logo.png': {
92
- 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",
93
99
  },
94
100
  },
95
101
  },
@@ -112,7 +118,7 @@ Rendered HTML shape:
112
118
  <div
113
119
  class="chart-mount"
114
120
  data-chart="line"
115
- data-chart-data="{&quot;labels&quot;:[&quot;a&quot;],&quot;datasets&quot;:[]}"
121
+ data-chart-data='{"labels":["a"],"datasets":[]}'
116
122
  ></div>
117
123
  ```
118
124
 
@@ -120,15 +126,16 @@ This package does not bundle a chart runtime; it only emits mount markup.
120
126
 
121
127
  ## Node-Only Mermaid Subpath
122
128
 
123
- ```ts
124
- import { renderMarkdownToHtmlWithMermaid } from 'featherdown/node';
129
+ ````ts
130
+ import { renderMarkdownToHtmlWithMermaid } from "featherdown/node";
125
131
 
126
132
  const html = await renderMarkdownToHtmlWithMermaid(
127
- '```mermaid\ngraph TD; A-->B;\n```',
133
+ "```mermaid\ngraph TD; A-->B;\n```",
128
134
  );
129
- ```
135
+ ````
130
136
 
131
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.
132
139
 
133
140
  ## CSS / Asset Expectations
134
141
 
@@ -160,15 +167,19 @@ Node-only entry (`featherdown/node`):
160
167
 
161
168
  ## Scripts
162
169
 
163
- | Script | Description |
164
- |---|---|
165
- | `npm run build` | Build ESM artifacts in `dist/` |
166
- | `npm test` | Run Vitest once |
167
- | `npm run test:watch` | Run Vitest in watch mode |
168
- | `npm run lint` | Run ESLint |
169
- | `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 |
170
177
  | `npm run test:exports` | Build and run export smoke checks |
171
178
 
179
+ ## Maintainers
180
+
181
+ CI and publishing are described in [RELEASING.md](./RELEASING.md).
182
+
172
183
  ## License
173
184
 
174
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/rehypeCdnImages.ts","../src/internal/diagnostics.ts","../src/renderMarkdown.ts","../src/renderMarkdownToHtml.ts"],"names":["rehypeCd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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,EAAa,MAAA,EAAmC,OAAA,EAAQ;AAAA,EACnE,SAAS,CAAA,EAAG;AACV,IAAA,IAAI,a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,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "featherdown",
3
- "version": "0.1.1",
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,6 +43,17 @@
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
  },