md2x 0.7.0 → 0.7.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 +99 -36
- package/dist/chunks/{chunk-XTD75532.js → chunk-ZHNRMGGC.js} +415 -47
- package/dist/index.js +1 -1
- package/dist/md2x.js +1 -1
- package/dist/renderer/puppeteer-render-worker.js +75 -73
- package/dist/templates/svelte/example.svelte +18 -0
- package/dist/templates/vue/mapLibre.vue +371 -0
- package/dist/types/node/src/host/node-exporter.d.ts +11 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,54 @@
|
|
|
1
1
|
# md2x
|
|
2
2
|
|
|
3
|
-
Markdown → PDF/DOCX/HTML/Image converter (local, no server). Supports Mermaid/Graphviz/Infographic/Vega/
|
|
3
|
+
Markdown → PDF/DOCX/HTML/Image converter (local, no server). Supports Mermaid/Graphviz/Infographic/Vega/Template(vue/svelte/html) rendering, math, and code highlighting.
|
|
4
|
+
|
|
5
|
+
> Supports MCP tools and md2x skill. 🎉
|
|
4
6
|
|
|
5
7
|
[](https://www.npmjs.com/package/md2x)
|
|
6
8
|
|
|
9
|
+
## CLI Usage
|
|
10
|
+
|
|
11
|
+
Export to PDF:
|
|
12
|
+
```bash
|
|
13
|
+
npx md2x input.md
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Export to DOCX:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx md2x input.md -f docx
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Export to HTML:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx md2x input.md -f html
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Export to PNG:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npx md2x input.md -f png -o output.png
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
List themes:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npx md2x --list-themes
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Use a theme:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx md2x input.md -o output.pdf --theme academic
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Help:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx md2x -h
|
|
50
|
+
```
|
|
51
|
+
|
|
7
52
|
## CLI Options
|
|
8
53
|
|
|
9
54
|
| Option | Alias | Description | Default | Values |
|
|
@@ -81,6 +126,11 @@ baseTag: true # emit <base href="file://.../"> for resolving relative path
|
|
|
81
126
|
diagramMode: live # img | live | none
|
|
82
127
|
cdn: # optional: override CDN URLs (used when diagramMode: live)
|
|
83
128
|
mermaid: "https://cdn.jsdelivr.net/npm/mermaid@11.12.2/dist/mermaid.min.js"
|
|
129
|
+
# Template blocks:
|
|
130
|
+
vue: "https://unpkg.com/vue@3/dist/vue.global.js"
|
|
131
|
+
vueSfcLoader: "https://cdn.jsdelivr.net/npm/vue3-sfc-loader/dist/vue3-sfc-loader.js"
|
|
132
|
+
svelteCompiler: "https://esm.sh/svelte@5/compiler"
|
|
133
|
+
svelteBase: "https://esm.sh/svelte@5/"
|
|
84
134
|
---
|
|
85
135
|
```
|
|
86
136
|
|
|
@@ -122,8 +172,8 @@ Besides diagram blocks (mermaid/dot/vega-lite/infographic), `md2x` also supports
|
|
|
122
172
|
````md
|
|
123
173
|
```md2x
|
|
124
174
|
{
|
|
125
|
-
type: 'vue', // "vue" | "html"
|
|
126
|
-
template: 'example.vue',
|
|
175
|
+
type: 'vue', // "vue" | "html" | "svelte"
|
|
176
|
+
template: 'example.vue', // or "example.html" / "example.svelte"
|
|
127
177
|
data: [{ title: 't', message: 'm' }]
|
|
128
178
|
}
|
|
129
179
|
```
|
|
@@ -150,16 +200,45 @@ const data = templateData;
|
|
|
150
200
|
</style>
|
|
151
201
|
```
|
|
152
202
|
|
|
203
|
+
```svelte
|
|
204
|
+
<!-- example.svelte (Svelte 5) -->
|
|
205
|
+
<script>
|
|
206
|
+
const data = templateData;
|
|
207
|
+
</script>
|
|
208
|
+
|
|
209
|
+
<div class="my-component">Hello md2x! This is svelte template</div>
|
|
210
|
+
{#each data as item, index}
|
|
211
|
+
<div>
|
|
212
|
+
<h2>{item.title}</h2>
|
|
213
|
+
<p>{item.message}</p>
|
|
214
|
+
</div>
|
|
215
|
+
{/each}
|
|
216
|
+
|
|
217
|
+
<style>
|
|
218
|
+
.my-component { color: red; }
|
|
219
|
+
</style>
|
|
220
|
+
```
|
|
221
|
+
|
|
153
222
|
### Config Fields
|
|
154
223
|
|
|
155
|
-
- `type`: `"vue"` or `"
|
|
224
|
+
- `type`: `"vue"`, `"html"`, or `"svelte"` (Svelte 5)
|
|
156
225
|
- `template`: template file name/path
|
|
157
226
|
- if you only pass a filename (e.g. `example.vue`), it is treated as `${type}/${template}` (e.g. `vue/example.vue`)
|
|
158
227
|
- `data`: arbitrary JSON-serializable data (injected by replacing the `templateData` placeholder)
|
|
228
|
+
- `allowTemplateAssets` (optional, **unsafe**): when `true`, allow templates to load extra JS/CSS URLs declared in the template file header:
|
|
229
|
+
- `<!-- TemplateConfig: {"assets":{"scripts":["..."],"styles":["..."]}} -->`
|
|
230
|
+
- Useful for UMD/IIFE globals (e.g. `window.dayjs`), not npm-style `import`.
|
|
231
|
+
- Backward compat: `allowCdn` is accepted as an alias.
|
|
159
232
|
- `allowScripts` (optional, **unsafe**, html only): when exporting **images** in `diagramMode: "img"`, set `allowScripts: true` to execute inline `<script>` blocks before rendering to PNG.
|
|
160
233
|
- not supported: `<script type="module">`
|
|
161
234
|
- external `<script src="...">` is not supported for image rendering (use inline scripts)
|
|
162
235
|
|
|
236
|
+
### Svelte Notes (Svelte 5 + esm.sh)
|
|
237
|
+
|
|
238
|
+
- Svelte templates are compiled at runtime using the Svelte compiler, loaded from **esm.sh** via `import()`.
|
|
239
|
+
- This means Svelte template rendering requires network access (even in `diagramMode: "img"`), unless you override `cdn.svelteCompiler`/`cdn.svelteBase` to another ESM CDN that works in your environment.
|
|
240
|
+
- Templates are expected to be self-contained `.svelte` files (no preprocessors like TypeScript/Sass, and avoid local relative imports unless you provide an ESM-resolvable URL).
|
|
241
|
+
|
|
163
242
|
### Template Resolution (External Templates)
|
|
164
243
|
|
|
165
244
|
To load templates from outside the built-in `dist/templates`, use either:
|
|
@@ -167,48 +246,32 @@ To load templates from outside the built-in `dist/templates`, use either:
|
|
|
167
246
|
- CLI: `--templates-dir /path/to/templates` (repeatable)
|
|
168
247
|
- Front matter: `templatesDir: /path/to/templates` (string or list)
|
|
169
248
|
|
|
249
|
+
### CDN Overrides (Live Mode)
|
|
170
250
|
|
|
171
|
-
|
|
251
|
+
When exporting **HTML/Image** with `diagramMode: live`, you can override CDN URLs in front matter:
|
|
172
252
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
```bash
|
|
181
|
-
npx md2x input.md -f docx
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
Export to HTML:
|
|
185
|
-
|
|
186
|
-
```bash
|
|
187
|
-
npx md2x input.md -f html
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
Export to PNG:
|
|
191
|
-
|
|
192
|
-
```bash
|
|
193
|
-
npx md2x input.md -f png -o output.png
|
|
253
|
+
```yaml
|
|
254
|
+
cdn:
|
|
255
|
+
vue: "https://unpkg.com/vue@3/dist/vue.global.js"
|
|
256
|
+
vueSfcLoader: "https://cdn.jsdelivr.net/npm/vue3-sfc-loader/dist/vue3-sfc-loader.js"
|
|
257
|
+
svelteCompiler: "https://esm.sh/svelte@5/compiler"
|
|
258
|
+
svelteBase: "https://esm.sh/svelte@5/"
|
|
194
259
|
```
|
|
195
260
|
|
|
196
|
-
|
|
261
|
+
## md2x Skill
|
|
197
262
|
|
|
198
|
-
|
|
199
|
-
npx md2x --list-themes
|
|
200
|
-
```
|
|
263
|
+
This repo also includes a skill for driving `md2x` from an agent:
|
|
201
264
|
|
|
202
|
-
|
|
265
|
+
- Skill: `skills/md2x/SKILL.md`
|
|
266
|
+
- What it does: guides an agent to run `npx md2x ...`, pick formats/themes, and use front matter correctly.
|
|
267
|
+
- Install (example):
|
|
203
268
|
|
|
204
269
|
```bash
|
|
205
|
-
npx
|
|
206
|
-
```
|
|
270
|
+
npx skills add larchliu/md2x
|
|
207
271
|
|
|
208
|
-
|
|
272
|
+
or
|
|
209
273
|
|
|
210
|
-
|
|
211
|
-
npx md2x -h
|
|
274
|
+
npx add-skill larchliu/md2x
|
|
212
275
|
```
|
|
213
276
|
|
|
214
277
|
## MCP server (Model Context Protocol)
|