md2x 0.7.0 → 0.7.1
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 +62 -4
- package/dist/chunks/{chunk-XTD75532.js → chunk-A4XDJ35P.js} +241 -42
- package/dist/index.js +1 -1
- package/dist/md2x.js +1 -1
- package/dist/renderer/puppeteer-render-worker.js +56 -56
- package/dist/templates/svelte/example.svelte +18 -0
- package/dist/types/node/src/host/node-exporter.d.ts +11 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/md2x)
|
|
6
6
|
|
|
@@ -81,6 +81,11 @@ baseTag: true # emit <base href="file://.../"> for resolving relative path
|
|
|
81
81
|
diagramMode: live # img | live | none
|
|
82
82
|
cdn: # optional: override CDN URLs (used when diagramMode: live)
|
|
83
83
|
mermaid: "https://cdn.jsdelivr.net/npm/mermaid@11.12.2/dist/mermaid.min.js"
|
|
84
|
+
# Template blocks:
|
|
85
|
+
vue: "https://unpkg.com/vue@3/dist/vue.global.js"
|
|
86
|
+
vueSfcLoader: "https://cdn.jsdelivr.net/npm/vue3-sfc-loader/dist/vue3-sfc-loader.js"
|
|
87
|
+
svelteCompiler: "https://esm.sh/svelte@5/compiler"
|
|
88
|
+
svelteBase: "https://esm.sh/svelte@5/"
|
|
84
89
|
---
|
|
85
90
|
```
|
|
86
91
|
|
|
@@ -122,8 +127,8 @@ Besides diagram blocks (mermaid/dot/vega-lite/infographic), `md2x` also supports
|
|
|
122
127
|
````md
|
|
123
128
|
```md2x
|
|
124
129
|
{
|
|
125
|
-
type: 'vue', // "vue" | "html"
|
|
126
|
-
template: 'example.vue',
|
|
130
|
+
type: 'vue', // "vue" | "html" | "svelte"
|
|
131
|
+
template: 'example.vue', // or "example.html" / "example.svelte"
|
|
127
132
|
data: [{ title: 't', message: 'm' }]
|
|
128
133
|
}
|
|
129
134
|
```
|
|
@@ -150,9 +155,28 @@ const data = templateData;
|
|
|
150
155
|
</style>
|
|
151
156
|
```
|
|
152
157
|
|
|
158
|
+
```svelte
|
|
159
|
+
<!-- example.svelte (Svelte 5) -->
|
|
160
|
+
<script>
|
|
161
|
+
const data = templateData;
|
|
162
|
+
</script>
|
|
163
|
+
|
|
164
|
+
<div class="my-component">Hello md2x! This is svelte template</div>
|
|
165
|
+
{#each data as item, index}
|
|
166
|
+
<div>
|
|
167
|
+
<h2>{item.title}</h2>
|
|
168
|
+
<p>{item.message}</p>
|
|
169
|
+
</div>
|
|
170
|
+
{/each}
|
|
171
|
+
|
|
172
|
+
<style>
|
|
173
|
+
.my-component { color: red; }
|
|
174
|
+
</style>
|
|
175
|
+
```
|
|
176
|
+
|
|
153
177
|
### Config Fields
|
|
154
178
|
|
|
155
|
-
- `type`: `"vue"` or `"
|
|
179
|
+
- `type`: `"vue"`, `"html"`, or `"svelte"` (Svelte 5)
|
|
156
180
|
- `template`: template file name/path
|
|
157
181
|
- if you only pass a filename (e.g. `example.vue`), it is treated as `${type}/${template}` (e.g. `vue/example.vue`)
|
|
158
182
|
- `data`: arbitrary JSON-serializable data (injected by replacing the `templateData` placeholder)
|
|
@@ -160,6 +184,12 @@ const data = templateData;
|
|
|
160
184
|
- not supported: `<script type="module">`
|
|
161
185
|
- external `<script src="...">` is not supported for image rendering (use inline scripts)
|
|
162
186
|
|
|
187
|
+
### Svelte Notes (Svelte 5 + esm.sh)
|
|
188
|
+
|
|
189
|
+
- Svelte templates are compiled at runtime using the Svelte compiler, loaded from **esm.sh** via `import()`.
|
|
190
|
+
- 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.
|
|
191
|
+
- 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).
|
|
192
|
+
|
|
163
193
|
### Template Resolution (External Templates)
|
|
164
194
|
|
|
165
195
|
To load templates from outside the built-in `dist/templates`, use either:
|
|
@@ -167,6 +197,18 @@ To load templates from outside the built-in `dist/templates`, use either:
|
|
|
167
197
|
- CLI: `--templates-dir /path/to/templates` (repeatable)
|
|
168
198
|
- Front matter: `templatesDir: /path/to/templates` (string or list)
|
|
169
199
|
|
|
200
|
+
### CDN Overrides (Live Mode)
|
|
201
|
+
|
|
202
|
+
When exporting **HTML/Image** with `diagramMode: live`, you can override CDN URLs in front matter:
|
|
203
|
+
|
|
204
|
+
```yaml
|
|
205
|
+
cdn:
|
|
206
|
+
vue: "https://unpkg.com/vue@3/dist/vue.global.js"
|
|
207
|
+
vueSfcLoader: "https://cdn.jsdelivr.net/npm/vue3-sfc-loader/dist/vue3-sfc-loader.js"
|
|
208
|
+
svelteCompiler: "https://esm.sh/svelte@5/compiler"
|
|
209
|
+
svelteBase: "https://esm.sh/svelte@5/"
|
|
210
|
+
```
|
|
211
|
+
|
|
170
212
|
|
|
171
213
|
## Usage
|
|
172
214
|
|
|
@@ -215,6 +257,22 @@ npx md2x -h
|
|
|
215
257
|
|
|
216
258
|
This repo includes an Express-based MCP server that exposes `md2x` as MCP tools over HTTP, so MCP clients can convert Markdown and download the generated HTML/PDF/DOCX from `/resources`.
|
|
217
259
|
|
|
260
|
+
## md2x Skill
|
|
261
|
+
|
|
262
|
+
This repo also includes a skill for driving `md2x` from an agent:
|
|
263
|
+
|
|
264
|
+
- Skill: `skills/md2x/SKILL.md`
|
|
265
|
+
- What it does: guides an agent to run `npx md2x ...`, pick formats/themes, and use front matter correctly.
|
|
266
|
+
- Install (example):
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
npx skills add larchliu/md2x
|
|
270
|
+
|
|
271
|
+
or
|
|
272
|
+
|
|
273
|
+
npx add-skill larchliu/md2x
|
|
274
|
+
```
|
|
275
|
+
|
|
218
276
|
Run:
|
|
219
277
|
|
|
220
278
|
```bash
|