md2x 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.
- package/README.md +25 -1
- package/dist/index.mjs +555 -90
- package/dist/md2x.mjs +578 -104
- package/dist/renderer/puppeteer-render-worker.js +99 -94
- package/dist/types/node/src/host/node-exporter.d.ts +47 -10
- package/dist/types/node/src/index.d.ts +6 -3
- package/package.json +11 -4
|
@@ -22,6 +22,44 @@ export type Md2PdfOptions = {
|
|
|
22
22
|
/** When true, horizontal rules (---, ***, ___) will be converted to page breaks */
|
|
23
23
|
pdfHrAsPageBreak?: boolean;
|
|
24
24
|
};
|
|
25
|
+
export type Md2HtmlOptions = {
|
|
26
|
+
theme?: string;
|
|
27
|
+
basePath?: string;
|
|
28
|
+
/** Document title for standalone HTML output */
|
|
29
|
+
title?: string;
|
|
30
|
+
/** When true, returns a full HTML document with embedded CSS (default: true) */
|
|
31
|
+
standalone?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Diagram rendering mode (HTML export only):
|
|
34
|
+
* - "img": pre-render diagrams and embed as data: images (best for offline)
|
|
35
|
+
* - "live": keep source blocks and render in the browser on load
|
|
36
|
+
* - "none": do not process diagrams at all (keep source code blocks)
|
|
37
|
+
*/
|
|
38
|
+
diagramMode?: 'img' | 'live' | 'none';
|
|
39
|
+
/**
|
|
40
|
+
* Optional CDN overrides (URLs). Only used when `diagramMode: "live"`.
|
|
41
|
+
*/
|
|
42
|
+
cdn?: Partial<{
|
|
43
|
+
mermaid: string;
|
|
44
|
+
/** Graphviz runtime (preferred): @viz-js/viz global build */
|
|
45
|
+
vizGlobal: string;
|
|
46
|
+
/** Legacy Graphviz runtime: viz.js (kept for compatibility) */
|
|
47
|
+
viz: string;
|
|
48
|
+
/** Legacy Graphviz runtime dependency: viz.js full.render.js (kept for compatibility) */
|
|
49
|
+
vizRender: string;
|
|
50
|
+
vega: string;
|
|
51
|
+
vegaLite: string;
|
|
52
|
+
vegaEmbed: string;
|
|
53
|
+
infographic: string;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* When true, horizontal rules (---, ***, ___) will be converted to page breaks in print/PDF.
|
|
57
|
+
* Note: this hides `<hr>` visually (default: false for HTML).
|
|
58
|
+
*/
|
|
59
|
+
htmlHrAsPageBreak?: boolean;
|
|
60
|
+
/** When true, emit a `<base href="file://.../">` tag so relative URLs resolve against basePath (default: true) */
|
|
61
|
+
baseTag?: boolean;
|
|
62
|
+
};
|
|
25
63
|
/**
|
|
26
64
|
* Node DOCX Exporter Class (public API used by node/src/host/index.ts)
|
|
27
65
|
*/
|
|
@@ -47,17 +85,16 @@ export declare class NodePdfExporter {
|
|
|
47
85
|
* Export markdown file to PDF file
|
|
48
86
|
*/
|
|
49
87
|
exportToFile(inputPath: string, outputPath: string, options?: Md2PdfOptions): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Node HTML Exporter Class
|
|
91
|
+
*/
|
|
92
|
+
export declare class NodeHtmlExporter {
|
|
50
93
|
/**
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
private processMarkdownToHtml;
|
|
54
|
-
/**
|
|
55
|
-
* Process diagram code blocks and replace with rendered images
|
|
56
|
-
*/
|
|
57
|
-
private processDiagrams;
|
|
58
|
-
/**
|
|
59
|
-
* Decode HTML entities in code blocks
|
|
94
|
+
* Export markdown to standalone HTML string (default) or HTML fragment.
|
|
60
95
|
*/
|
|
61
|
-
|
|
96
|
+
exportToString(markdown: string, options?: Md2HtmlOptions): Promise<string>;
|
|
97
|
+
exportToBuffer(markdown: string, options?: Md2HtmlOptions): Promise<Buffer>;
|
|
98
|
+
exportToFile(inputPath: string, outputPath: string, options?: Md2HtmlOptions): Promise<void>;
|
|
62
99
|
}
|
|
63
100
|
export default NodeDocxExporter;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type { Md2DocxOptions, Md2PdfOptions } from './host/node-exporter';
|
|
2
|
-
export { NodeDocxExporter, NodePdfExporter } from './host/node-exporter';
|
|
3
|
-
export type { Md2DocxOptions, Md2PdfOptions } from './host/node-exporter';
|
|
1
|
+
import type { Md2DocxOptions, Md2HtmlOptions, Md2PdfOptions } from './host/node-exporter';
|
|
2
|
+
export { NodeDocxExporter, NodeHtmlExporter, NodePdfExporter } from './host/node-exporter';
|
|
3
|
+
export type { Md2DocxOptions, Md2HtmlOptions, Md2PdfOptions } from './host/node-exporter';
|
|
4
4
|
export type { PdfOptions } from './host/browser-renderer';
|
|
5
5
|
export declare function markdownToDocxBuffer(markdown: string, options?: Md2DocxOptions): Promise<Buffer>;
|
|
6
6
|
export declare function markdownFileToDocxFile(inputPath: string, outputPath: string, options?: Md2DocxOptions): Promise<void>;
|
|
7
7
|
export declare function markdownToPdfBuffer(markdown: string, options?: Md2PdfOptions): Promise<Buffer>;
|
|
8
|
+
export declare function markdownToHtmlString(markdown: string, options?: Md2HtmlOptions): Promise<string>;
|
|
9
|
+
export declare function markdownToHtmlBuffer(markdown: string, options?: Md2HtmlOptions): Promise<Buffer>;
|
|
8
10
|
export declare function markdownFileToPdfFile(inputPath: string, outputPath: string, options?: Md2PdfOptions): Promise<void>;
|
|
11
|
+
export declare function markdownFileToHtmlFile(inputPath: string, outputPath: string, options?: Md2HtmlOptions): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "md2x",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Markdown → PDF/DOCX converter (local, no server). Supports Mermaid/Graphviz/Vega/HTML/SVG rendering, math, and code highlighting.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -26,14 +26,21 @@
|
|
|
26
26
|
"postinstall": "puppeteer browsers install chrome",
|
|
27
27
|
"prepublishOnly": "node build.mjs"
|
|
28
28
|
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"markdown",
|
|
31
|
+
"converter",
|
|
32
|
+
"docx",
|
|
33
|
+
"pdf"
|
|
34
|
+
],
|
|
35
|
+
"author": "Arch Liu <larch.liu@gmail.com>",
|
|
29
36
|
"license": "ISC",
|
|
30
37
|
"repository": {
|
|
31
38
|
"type": "git",
|
|
32
|
-
"url": "git+https://github.com/
|
|
39
|
+
"url": "git+https://github.com/LarchLiu/md2x.git"
|
|
33
40
|
},
|
|
34
|
-
"homepage": "https://github.com/
|
|
41
|
+
"homepage": "https://github.com/LarchLiu/md2x",
|
|
35
42
|
"bugs": {
|
|
36
|
-
"url": "https://github.com/
|
|
43
|
+
"url": "https://github.com/LarchLiu/md2x/issues"
|
|
37
44
|
},
|
|
38
45
|
"publishConfig": {
|
|
39
46
|
"access": "public"
|