md2x 0.7.4 → 0.7.6

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.
Files changed (136) hide show
  1. package/README.md +61 -23
  2. package/dist/chunks/chunk-Q6QMPHEY.js +1552 -0
  3. package/dist/chunks/chunk-UZ7TETMS.js +415 -0
  4. package/dist/chunks/docx-exporter-GL6CNCQD.js +1 -0
  5. package/dist/chunks/mcp-server-4TPUOZXJ.js +49 -0
  6. package/dist/core-worker.js +1764 -0
  7. package/dist/index.js +1 -1
  8. package/dist/md2x.js +8 -5
  9. package/dist/renderer/core-worker-browser.js +1775 -0
  10. package/dist/renderer/live-runtime-canvas.js +1 -1
  11. package/dist/renderer/live-runtime-dot.js +1 -1
  12. package/dist/renderer/live-runtime-html.js +1 -1
  13. package/dist/renderer/live-runtime-infographic.js +1 -1
  14. package/dist/renderer/live-runtime-md2x.js +4 -4
  15. package/dist/renderer/live-runtime-mermaid.js +1 -1
  16. package/dist/renderer/live-runtime-svg.js +1 -1
  17. package/dist/renderer/live-runtime-vega.js +1 -1
  18. package/dist/types/node/src/host/browser-renderer.d.ts +1 -175
  19. package/dist/types/node/src/host/core.d.ts +59 -0
  20. package/dist/types/node/src/host/index.d.ts +4 -49
  21. package/dist/types/node/src/host/node-exporter.d.ts +1 -90
  22. package/dist/types/node/src/host/node-platform.d.ts +1 -23
  23. package/dist/types/node/src/host/templates-data.d.ts +5 -0
  24. package/dist/types/node/src/host/themes-data.d.ts +2385 -0
  25. package/dist/types/node/src/host/types.d.ts +251 -0
  26. package/dist/types/node/src/index.d.ts +2 -3
  27. package/package.json +13 -3
  28. package/dist/chunks/chunk-2LPNL4GA.js +0 -1
  29. package/dist/chunks/chunk-3P5X57NT.js +0 -262
  30. package/dist/chunks/chunk-3VL755NO.js +0 -1
  31. package/dist/chunks/chunk-5DPTQTJJ.js +0 -1
  32. package/dist/chunks/chunk-AK6TXLWO.js +0 -1
  33. package/dist/chunks/chunk-CN4F5HOV.js +0 -5
  34. package/dist/chunks/chunk-CVKZIRZW.js +0 -5
  35. package/dist/chunks/chunk-DFROP2PD.js +0 -11
  36. package/dist/chunks/chunk-DJGIYXVP.js +0 -3
  37. package/dist/chunks/chunk-EFKQH5UR.js +0 -108
  38. package/dist/chunks/chunk-FXZD57XY.js +0 -532
  39. package/dist/chunks/chunk-IENSDROB.js +0 -1
  40. package/dist/chunks/chunk-LLCWR7UA.js +0 -1
  41. package/dist/chunks/chunk-MHCTK6WW.js +0 -1
  42. package/dist/chunks/chunk-NM6J3ND7.js +0 -1
  43. package/dist/chunks/chunk-PARPCLXM.js +0 -1
  44. package/dist/chunks/chunk-PUOHPY5L.js +0 -16
  45. package/dist/chunks/chunk-R65AQGTF.js +0 -1
  46. package/dist/chunks/chunk-R6G2575A.js +0 -3
  47. package/dist/chunks/chunk-TRGQPVRY.js +0 -2
  48. package/dist/chunks/chunk-URO5RPHJ.js +0 -9
  49. package/dist/chunks/chunk-YFL3W3OS.js +0 -1
  50. package/dist/chunks/chunk-Z4LVGK7Y.js +0 -1
  51. package/dist/chunks/docx-exporter-ZZ76JXFU.js +0 -1
  52. package/dist/chunks/rehype-highlight-Y4Q4RX67.js +0 -1
  53. package/dist/chunks/rehype-katex-FXTCTSUE.js +0 -1
  54. package/dist/chunks/rehype-stringify-4CQSSRDL.js +0 -1
  55. package/dist/chunks/remark-gfm-BUZ4SLP3.js +0 -1
  56. package/dist/chunks/remark-math-HEZQAPFK.js +0 -1
  57. package/dist/chunks/remark-parse-QC7TSXTK.js +0 -1
  58. package/dist/chunks/remark-rehype-C2LX643P.js +0 -1
  59. package/dist/chunks/remark-super-sub-EP2AQS54.js +0 -1
  60. package/dist/chunks/theme-manager-AZBU2SLL.js +0 -1
  61. package/dist/chunks/theme-to-css-GLV3WYDU.js +0 -85
  62. package/dist/chunks/unified-PU53JLVJ.js +0 -1
  63. package/dist/chunks/unist-util-visit-SBSD62C6.js +0 -1
  64. package/dist/templates/html/example.html +0 -35
  65. package/dist/templates/svelte/example.svelte +0 -18
  66. package/dist/templates/vue/PrinterComponent.vue +0 -875
  67. package/dist/templates/vue/example.vue +0 -17
  68. package/dist/templates/vue/mapLibre.vue +0 -371
  69. package/dist/themes/code-themes/business-contrast.json +0 -31
  70. package/dist/themes/code-themes/colorful.json +0 -32
  71. package/dist/themes/code-themes/cool-modern.json +0 -31
  72. package/dist/themes/code-themes/high-contrast.json +0 -31
  73. package/dist/themes/code-themes/light-clean.json +0 -31
  74. package/dist/themes/code-themes/warm-book.json +0 -31
  75. package/dist/themes/color-schemes/candy.json +0 -34
  76. package/dist/themes/color-schemes/cool.json +0 -34
  77. package/dist/themes/color-schemes/coral.json +0 -34
  78. package/dist/themes/color-schemes/dino.json +0 -34
  79. package/dist/themes/color-schemes/forest.json +0 -34
  80. package/dist/themes/color-schemes/garden.json +0 -34
  81. package/dist/themes/color-schemes/neutral.json +0 -34
  82. package/dist/themes/color-schemes/ocean.json +0 -34
  83. package/dist/themes/color-schemes/rainbow.json +0 -43
  84. package/dist/themes/color-schemes/sakura.json +0 -34
  85. package/dist/themes/color-schemes/sepia.json +0 -34
  86. package/dist/themes/color-schemes/space.json +0 -34
  87. package/dist/themes/color-schemes/starry.json +0 -34
  88. package/dist/themes/color-schemes/sunset.json +0 -34
  89. package/dist/themes/color-schemes/warm.json +0 -34
  90. package/dist/themes/font-config.json +0 -184
  91. package/dist/themes/layout-schemes/academic.json +0 -40
  92. package/dist/themes/layout-schemes/book.json +0 -40
  93. package/dist/themes/layout-schemes/document.json +0 -40
  94. package/dist/themes/layout-schemes/magazine.json +0 -40
  95. package/dist/themes/layout-schemes/student.json +0 -40
  96. package/dist/themes/layout-schemes/technical.json +0 -40
  97. package/dist/themes/presets/academic.json +0 -24
  98. package/dist/themes/presets/business.json +0 -22
  99. package/dist/themes/presets/candy.json +0 -23
  100. package/dist/themes/presets/century.json +0 -22
  101. package/dist/themes/presets/coral.json +0 -22
  102. package/dist/themes/presets/default.json +0 -22
  103. package/dist/themes/presets/dinosaur.json +0 -23
  104. package/dist/themes/presets/elegant.json +0 -22
  105. package/dist/themes/presets/forest.json +0 -22
  106. package/dist/themes/presets/garamond.json +0 -22
  107. package/dist/themes/presets/garden.json +0 -23
  108. package/dist/themes/presets/handwritten.json +0 -23
  109. package/dist/themes/presets/heiti.json +0 -22
  110. package/dist/themes/presets/magazine.json +0 -24
  111. package/dist/themes/presets/manuscript.json +0 -22
  112. package/dist/themes/presets/minimal.json +0 -22
  113. package/dist/themes/presets/mixed.json +0 -24
  114. package/dist/themes/presets/newspaper.json +0 -24
  115. package/dist/themes/presets/ocean.json +0 -22
  116. package/dist/themes/presets/palatino.json +0 -22
  117. package/dist/themes/presets/rainbow.json +0 -23
  118. package/dist/themes/presets/space.json +0 -23
  119. package/dist/themes/presets/starry.json +0 -23
  120. package/dist/themes/presets/sunset.json +0 -22
  121. package/dist/themes/presets/swiss.json +0 -22
  122. package/dist/themes/presets/technical.json +0 -22
  123. package/dist/themes/presets/typewriter.json +0 -23
  124. package/dist/themes/presets/verdana.json +0 -22
  125. package/dist/themes/presets/water.json +0 -22
  126. package/dist/themes/registry.json +0 -270
  127. package/dist/themes/table-styles/academic.json +0 -30
  128. package/dist/themes/table-styles/borderless.json +0 -26
  129. package/dist/themes/table-styles/compact.json +0 -24
  130. package/dist/themes/table-styles/grid.json +0 -22
  131. package/dist/themes/table-styles/high-contrast.json +0 -22
  132. package/dist/themes/table-styles/minimal-gray.json +0 -26
  133. package/dist/themes/table-styles/modern-tech.json +0 -34
  134. package/dist/themes/table-styles/professional.json +0 -34
  135. package/dist/themes/table-styles/zebra.json +0 -22
  136. package/dist/types/src/utils/theme-to-css.d.ts +0 -171
package/README.md CHANGED
@@ -1,11 +1,16 @@
1
1
  # md2x
2
2
 
3
- Markdown → PDF/DOCX/HTML/Image converter. Supports Mermaid/Graphviz/Infographic/Vega/Template(vue/svelte/html) rendering, math, and code highlighting.
4
-
5
- > Supports MCP tools and md2x skill. 🎉
3
+ Markdown → PDF/DOCX/HTML/Image converter.
6
4
 
7
5
  [![npm version](https://img.shields.io/npm/v/md2x.svg?style=flat-square)](https://www.npmjs.com/package/md2x)
8
6
 
7
+ ## Features
8
+
9
+ - 📦 **Supported formats**: `pdf`, `docx`, `html`, `png`, `jpg/jpeg`, `webp`
10
+ - 🔌 **MCP (Model Context Protocol)**: built-in MCP server
11
+ - 🧠 **Skills**: includes an agent skill at `skills/md2x/SKILL.md` for repeatable conversions/workflows
12
+ - 🧩 **Custom templates**: render `md2x` blocks with **Vue SFC** (`.vue`) and **Svelte 5** (`.svelte`) templates (plus plain HTML)
13
+
9
14
  ## CLI Usage
10
15
 
11
16
  Export to PDF:
@@ -245,10 +250,11 @@ const data = templateData;
245
250
 
246
251
  ### Template Resolution (External Templates)
247
252
 
248
- To load templates from outside the built-in `dist/templates`, use either:
253
+ To load templates from outside, use:
249
254
 
250
- - CLI: `--templates-dir /path/to/templates` (repeatable)
251
- - Front matter: `templatesDir: /path/to/templates` (string or list)
255
+ - CLI: `--templates-dir /path/to/templates` (repeatable; CLI reads files and passes them as `templates`)
256
+ - Library API: pass `templates: Record<string, string>` (you can load files yourself if you want)
257
+ - Front matter: `templates:` supports inline template sources (YAML map)
252
258
 
253
259
  ### CDN Overrides (Live Mode)
254
260
 
@@ -278,34 +284,66 @@ or
278
284
  npx add-skill larchliu/md2x
279
285
  ```
280
286
 
281
- ## MCP server (Model Context Protocol)
287
+ ## MCP Server (Model Context Protocol)
282
288
 
283
- 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`.
289
+ The md2x CLI includes a built-in MCP server that exposes markdown conversion as MCP tools via stdio transport.
284
290
 
285
- Run:
291
+ ### Starting the MCP Server
286
292
 
287
293
  ```bash
288
- pnpm -C mcp install
289
- pnpm -C mcp start
294
+ npx md2x --mcp
295
+ ```
296
+
297
+ Or if installed globally:
298
+
299
+ ```bash
300
+ md2x --mcp
290
301
  ```
291
302
 
292
- Endpoints:
303
+ ### Available Tools
304
+
305
+ - **`convert_markdown`**: Convert markdown files to PDF, DOCX, HTML, or Image formats
306
+ - Takes a `markdownFilePath` parameter
307
+ - Saves output to the same directory as the source file (or custom `outputPath`)
308
+ - Returns the file path to the converted document
309
+
310
+ - **`list_themes`**: List all available themes with their categories and featured status
293
311
 
294
- - Streamable HTTP (recommended): `POST/GET/DELETE /mcp`
295
- - Legacy HTTP+SSE: `GET /sse` and `POST /messages?sessionId=...`
296
- - Resources (static files): `GET /resources/*`
312
+ ### Integration with Claude Desktop
297
313
 
298
- Tools:
314
+ Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
299
315
 
300
- - `markdown_to_html` / `markdown_to_pdf` / `markdown_to_docx` - Convert Markdown to HTML/PDF/DOCX
301
- - `markdown_to_image` - Convert Markdown to an image (`png`/`jpg`/`jpeg`/`webp`), may return multiple parts for very tall pages
302
- - `markdown_convert` - Auto convert via `md2x.convert()` (front matter supported; includes image formats)
303
- - `resources_upload` - Upload a file to `/resources` (e.g. images referenced by Markdown)
316
+ ```json
317
+ {
318
+ "mcpServers": {
319
+ "md2x": {
320
+ "command": "node",
321
+ "args": ["/path/to/markdown-viewer-extension/node/dist/md2x.js", "--mcp"]
322
+ }
323
+ }
324
+ }
325
+ ```
304
326
 
305
- Notes:
327
+ ### Testing
328
+
329
+ ```bash
330
+ node --test test/mcp-server.test.mjs
331
+ ```
332
+
333
+ See [MCP-SERVER.md](MCP-SERVER.md) for detailed documentation.
334
+
335
+ ---
336
+
337
+ ## HTTP-based MCP Server (Separate Package)
338
+
339
+ There's also a separate Express-based MCP server in the `mcp/` directory that exposes `md2x` as MCP tools over HTTP:
340
+
341
+ ```bash
342
+ pnpm -C mcp install
343
+ pnpm -C mcp start
344
+ ```
306
345
 
307
- - The conversion tools return an MCP `resource_link` pointing to the generated file URL.
308
- - Config: `PORT` (default `3000`) and `MD2X_BASE_URL` (used to build the public `/resources` URL). See `mcp/README.md`.
346
+ See `mcp/README.md` for details.
309
347
 
310
348
  ## Puppeteer / Chrome install
311
349