md2x 0.7.4 → 0.7.5
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 +12 -6
- package/dist/chunks/chunk-54X5GPSM.js +1552 -0
- package/dist/chunks/chunk-US45GBOT.js +415 -0
- package/dist/chunks/docx-exporter-7C6T4DFB.js +1 -0
- package/dist/core-worker.js +1764 -0
- package/dist/index.js +1 -1
- package/dist/md2x.js +5 -5
- package/dist/renderer/core-worker-browser.js +1775 -0
- package/dist/renderer/live-runtime-canvas.js +1 -1
- package/dist/renderer/live-runtime-dot.js +1 -1
- package/dist/renderer/live-runtime-html.js +1 -1
- package/dist/renderer/live-runtime-infographic.js +1 -1
- package/dist/renderer/live-runtime-md2x.js +4 -4
- package/dist/renderer/live-runtime-mermaid.js +1 -1
- package/dist/renderer/live-runtime-svg.js +1 -1
- package/dist/renderer/live-runtime-vega.js +1 -1
- package/dist/types/node/src/host/browser-renderer.d.ts +1 -175
- package/dist/types/node/src/host/core.d.ts +59 -0
- package/dist/types/node/src/host/index.d.ts +4 -49
- package/dist/types/node/src/host/node-exporter.d.ts +1 -90
- package/dist/types/node/src/host/node-platform.d.ts +1 -23
- package/dist/types/node/src/host/templates-data.d.ts +5 -0
- package/dist/types/node/src/host/themes-data.d.ts +2385 -0
- package/dist/types/node/src/host/types.d.ts +251 -0
- package/dist/types/node/src/index.d.ts +2 -3
- package/package.json +10 -2
- package/dist/chunks/chunk-2LPNL4GA.js +0 -1
- package/dist/chunks/chunk-3P5X57NT.js +0 -262
- package/dist/chunks/chunk-3VL755NO.js +0 -1
- package/dist/chunks/chunk-5DPTQTJJ.js +0 -1
- package/dist/chunks/chunk-AK6TXLWO.js +0 -1
- package/dist/chunks/chunk-CN4F5HOV.js +0 -5
- package/dist/chunks/chunk-CVKZIRZW.js +0 -5
- package/dist/chunks/chunk-DFROP2PD.js +0 -11
- package/dist/chunks/chunk-DJGIYXVP.js +0 -3
- package/dist/chunks/chunk-EFKQH5UR.js +0 -108
- package/dist/chunks/chunk-FXZD57XY.js +0 -532
- package/dist/chunks/chunk-IENSDROB.js +0 -1
- package/dist/chunks/chunk-LLCWR7UA.js +0 -1
- package/dist/chunks/chunk-MHCTK6WW.js +0 -1
- package/dist/chunks/chunk-NM6J3ND7.js +0 -1
- package/dist/chunks/chunk-PARPCLXM.js +0 -1
- package/dist/chunks/chunk-PUOHPY5L.js +0 -16
- package/dist/chunks/chunk-R65AQGTF.js +0 -1
- package/dist/chunks/chunk-R6G2575A.js +0 -3
- package/dist/chunks/chunk-TRGQPVRY.js +0 -2
- package/dist/chunks/chunk-URO5RPHJ.js +0 -9
- package/dist/chunks/chunk-YFL3W3OS.js +0 -1
- package/dist/chunks/chunk-Z4LVGK7Y.js +0 -1
- package/dist/chunks/docx-exporter-ZZ76JXFU.js +0 -1
- package/dist/chunks/rehype-highlight-Y4Q4RX67.js +0 -1
- package/dist/chunks/rehype-katex-FXTCTSUE.js +0 -1
- package/dist/chunks/rehype-stringify-4CQSSRDL.js +0 -1
- package/dist/chunks/remark-gfm-BUZ4SLP3.js +0 -1
- package/dist/chunks/remark-math-HEZQAPFK.js +0 -1
- package/dist/chunks/remark-parse-QC7TSXTK.js +0 -1
- package/dist/chunks/remark-rehype-C2LX643P.js +0 -1
- package/dist/chunks/remark-super-sub-EP2AQS54.js +0 -1
- package/dist/chunks/theme-manager-AZBU2SLL.js +0 -1
- package/dist/chunks/theme-to-css-GLV3WYDU.js +0 -85
- package/dist/chunks/unified-PU53JLVJ.js +0 -1
- package/dist/chunks/unist-util-visit-SBSD62C6.js +0 -1
- package/dist/templates/html/example.html +0 -35
- package/dist/templates/svelte/example.svelte +0 -18
- package/dist/templates/vue/PrinterComponent.vue +0 -875
- package/dist/templates/vue/example.vue +0 -17
- package/dist/templates/vue/mapLibre.vue +0 -371
- package/dist/themes/code-themes/business-contrast.json +0 -31
- package/dist/themes/code-themes/colorful.json +0 -32
- package/dist/themes/code-themes/cool-modern.json +0 -31
- package/dist/themes/code-themes/high-contrast.json +0 -31
- package/dist/themes/code-themes/light-clean.json +0 -31
- package/dist/themes/code-themes/warm-book.json +0 -31
- package/dist/themes/color-schemes/candy.json +0 -34
- package/dist/themes/color-schemes/cool.json +0 -34
- package/dist/themes/color-schemes/coral.json +0 -34
- package/dist/themes/color-schemes/dino.json +0 -34
- package/dist/themes/color-schemes/forest.json +0 -34
- package/dist/themes/color-schemes/garden.json +0 -34
- package/dist/themes/color-schemes/neutral.json +0 -34
- package/dist/themes/color-schemes/ocean.json +0 -34
- package/dist/themes/color-schemes/rainbow.json +0 -43
- package/dist/themes/color-schemes/sakura.json +0 -34
- package/dist/themes/color-schemes/sepia.json +0 -34
- package/dist/themes/color-schemes/space.json +0 -34
- package/dist/themes/color-schemes/starry.json +0 -34
- package/dist/themes/color-schemes/sunset.json +0 -34
- package/dist/themes/color-schemes/warm.json +0 -34
- package/dist/themes/font-config.json +0 -184
- package/dist/themes/layout-schemes/academic.json +0 -40
- package/dist/themes/layout-schemes/book.json +0 -40
- package/dist/themes/layout-schemes/document.json +0 -40
- package/dist/themes/layout-schemes/magazine.json +0 -40
- package/dist/themes/layout-schemes/student.json +0 -40
- package/dist/themes/layout-schemes/technical.json +0 -40
- package/dist/themes/presets/academic.json +0 -24
- package/dist/themes/presets/business.json +0 -22
- package/dist/themes/presets/candy.json +0 -23
- package/dist/themes/presets/century.json +0 -22
- package/dist/themes/presets/coral.json +0 -22
- package/dist/themes/presets/default.json +0 -22
- package/dist/themes/presets/dinosaur.json +0 -23
- package/dist/themes/presets/elegant.json +0 -22
- package/dist/themes/presets/forest.json +0 -22
- package/dist/themes/presets/garamond.json +0 -22
- package/dist/themes/presets/garden.json +0 -23
- package/dist/themes/presets/handwritten.json +0 -23
- package/dist/themes/presets/heiti.json +0 -22
- package/dist/themes/presets/magazine.json +0 -24
- package/dist/themes/presets/manuscript.json +0 -22
- package/dist/themes/presets/minimal.json +0 -22
- package/dist/themes/presets/mixed.json +0 -24
- package/dist/themes/presets/newspaper.json +0 -24
- package/dist/themes/presets/ocean.json +0 -22
- package/dist/themes/presets/palatino.json +0 -22
- package/dist/themes/presets/rainbow.json +0 -23
- package/dist/themes/presets/space.json +0 -23
- package/dist/themes/presets/starry.json +0 -23
- package/dist/themes/presets/sunset.json +0 -22
- package/dist/themes/presets/swiss.json +0 -22
- package/dist/themes/presets/technical.json +0 -22
- package/dist/themes/presets/typewriter.json +0 -23
- package/dist/themes/presets/verdana.json +0 -22
- package/dist/themes/presets/water.json +0 -22
- package/dist/themes/registry.json +0 -270
- package/dist/themes/table-styles/academic.json +0 -30
- package/dist/themes/table-styles/borderless.json +0 -26
- package/dist/themes/table-styles/compact.json +0 -24
- package/dist/themes/table-styles/grid.json +0 -22
- package/dist/themes/table-styles/high-contrast.json +0 -22
- package/dist/themes/table-styles/minimal-gray.json +0 -26
- package/dist/themes/table-styles/modern-tech.json +0 -34
- package/dist/themes/table-styles/professional.json +0 -34
- package/dist/themes/table-styles/zebra.json +0 -22
- package/dist/types/src/utils/theme-to-css.d.ts +0 -171
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{b as t,c as r,e,f as a,g as n,h as m,i as d,j as p,k as i,l as f,m as s,n as l,o as O,p as u,q as x,r as T}from"./chunks/chunk-54X5GPSM.js";import"./chunks/chunk-US45GBOT.js";import*as o from"path";import{fileURLToPath as M}from"url";var g=M(import.meta.url),w=o.dirname(g);globalThis.__md2x_module_dir__=w;export{n as NodeDocxExporter,p as NodeHtmlExporter,d as NodeImageExporter,m as NodePdfExporter,x as convert,T as convertFile,r as frontMatterToOptions,i as markdownToDocxBuffer,e as markdownToHtml,l as markdownToHtmlBuffer,s as markdownToHtmlString,O as markdownToImageBuffer,u as markdownToImageBuffers,f as markdownToPdfBuffer,a as markdownToStandaloneHtml,t as parseFrontMatter};
|
package/dist/md2x.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{a as k,b as $,c as S,d as T,q as O}from"./chunks/chunk-54X5GPSM.js";import"./chunks/chunk-US45GBOT.js";import*as a from"fs";import*as n from"path";import{fileURLToPath as U,pathToFileURL as q}from"url";var I=U(import.meta.url),P=n.dirname(I);globalThis.__md2x_module_dir__=P;function N(){return globalThis.__md2x_module_dir__||P}function H(o,e){let t={},s=(m=>{let i=String(m||"").trim();if(!i)return"";try{if(i.toLowerCase().startsWith("file://"))return U(i)}catch{}return n.isAbsolute(i)?i:n.join(e,i)})(o);if(!s||!a.existsSync(s))return t;let r=m=>{let i;try{i=a.statSync(m)}catch{return}if(i.isDirectory()){let x=[];try{x=a.readdirSync(m)}catch{return}for(let E of x)r(n.join(m,E));return}if(!i.isFile())return;let u="";try{u=a.readFileSync(m,"utf-8")}catch{return}let h=n.relative(s,m).split(n.sep).join("/"),g=n.basename(m);t[h]=u,t[g]=u,t[`./${h}`]=u;try{t[q(m).href]=u}catch{}};return r(s),t}function W(o,e){let t={};for(let p of o)Object.assign(t,H(p,e));return t}function X(o){let e=n.extname(o).toLowerCase();return e===".pdf"?"pdf":e===".docx"?"docx":e===".html"||e===".htm"?"html":e===".png"?"png":e===".jpg"?"jpg":e===".jpeg"?"jpeg":e===".webp"?"webp":null}function M(){return["default",...k.themes.map(t=>t.id).sort().filter(t=>t!=="default")]}function B(o){return o.join(", ")}function F(){let o=M();console.log(`
|
|
3
3
|
md2x - Convert Markdown to PDF, DOCX, HTML, or Image
|
|
4
4
|
|
|
5
5
|
Usage:
|
|
@@ -34,8 +34,8 @@ Examples:
|
|
|
34
34
|
npx md2x --list-themes
|
|
35
35
|
|
|
36
36
|
Available Themes:
|
|
37
|
-
${
|
|
38
|
-
`)}function
|
|
37
|
+
${B(o)}
|
|
38
|
+
`)}function z(){let o=N(),e=[n.join(o,"../package.json"),n.join(o,"../../package.json")];for(let t of e)try{let p=JSON.parse(a.readFileSync(t,"utf-8"));if(p?.version){console.log(`md2x v${p.version}`);return}}catch{}console.log("md2x v1.0.0")}function J(){let o=M();console.log(`
|
|
39
39
|
Available Themes:
|
|
40
|
-
`),
|
|
41
|
-
`)
|
|
40
|
+
`),o.forEach(e=>{console.log(` - ${e}`)}),console.log("")}function K(o){let e={input:"",output:"",theme:"default",format:"pdf",help:!1,version:!1,listThemes:!1,diagramMode:"live",templatesDir:[],liveRuntime:void 0,liveRuntimeBaseUrl:void 0,hrPageBreak:null,_explicit:new Set},t=0,p=[];for(;t<o.length;){let s=o[t];if(s==="--"){t++;continue}if(s==="-h"||s==="--help")e.help=!0;else if(s==="-v"||s==="--version")e.version=!0;else if(s==="--list-themes")e.listThemes=!0;else if(s==="--diagram-mode")if(t++,t<o.length){let r=String(o[t]).toLowerCase();r!=="img"&&r!=="live"&&r!=="none"&&(console.error(`Error: Invalid --diagram-mode "${o[t]}". Must be "img", "live", or "none".`),process.exit(1)),e.diagramMode=r,e._explicit.add("diagramMode")}else console.error("Error: --diagram-mode requires a value (img | live | none)"),process.exit(1);else if(s==="-o"||s==="--output")t++,t<o.length?e.output=o[t]:(console.error("Error: --output requires a file path"),process.exit(1));else if(s==="-t"||s==="--theme")t++,t<o.length?(e.theme=o[t],e._explicit.add("theme")):(console.error("Error: --theme requires a theme name"),process.exit(1));else if(s==="-f"||s==="--format")if(t++,t<o.length){let r=o[t].toLowerCase();r!=="pdf"&&r!=="docx"&&r!=="html"&&r!=="png"&&r!=="jpg"&&r!=="jpeg"&&r!=="webp"&&(console.error(`Error: Invalid format "${o[t]}". Must be "pdf", "docx", "html", "png", "jpg/jpeg", or "webp".`),process.exit(1)),e.format=r,e._explicit.add("format")}else console.error("Error: --format requires a format (pdf, docx, html, png, jpg/jpeg, or webp)"),process.exit(1);else if(s==="--hr-page-break")if(t++,t<o.length){let r=o[t].toLowerCase();r!=="true"&&r!=="false"&&(console.error(`Error: Invalid --hr-page-break "${o[t]}". Must be "true" or "false".`),process.exit(1)),e.hrPageBreak=r==="true",e._explicit.add("hrPageBreak")}else console.error("Error: --hr-page-break requires a value (true | false)"),process.exit(1);else if(s==="--templates-dir")if(t++,t<o.length){let r=String(o[t]).trim();r||(console.error("Error: --templates-dir requires a non-empty path"),process.exit(1)),e.templatesDir.push(r),e._explicit.add("templatesDir")}else console.error("Error: --templates-dir requires a path"),process.exit(1);else if(s==="--live-runtime")if(t++,t<o.length){let r=String(o[t]).toLowerCase();r!=="inline"&&r!=="cdn"&&(console.error(`Error: Invalid --live-runtime "${o[t]}". Must be "inline" or "cdn".`),process.exit(1)),e.liveRuntime=r,e._explicit.add("liveRuntime")}else console.error("Error: --live-runtime requires a value (inline | cdn)"),process.exit(1);else if(s==="--live-runtime-url")if(t++,t<o.length){let r=String(o[t]).trim();r||(console.error("Error: --live-runtime-url requires a non-empty URL"),process.exit(1)),e.liveRuntimeBaseUrl=r,e._explicit.add("liveRuntimeBaseUrl")}else console.error("Error: --live-runtime-url requires a URL"),process.exit(1);else s.startsWith("-")?(console.error(`Error: Unknown option: ${s}`),process.exit(1)):p.push(s);t++}return p.length>0&&(e.input=p[0]),p.length>1&&!e.output&&(e.output=p[1]),e}async function V(){let o=process.argv.slice(2),e=K(o);e.help&&(F(),process.exit(0)),e.version&&(z(),process.exit(0)),e.listThemes&&(J(),process.exit(0)),e.input||(console.error(`Error: Input file is required
|
|
41
|
+
`),F(),process.exit(1));let t=n.resolve(e.input);a.existsSync(t)||(console.error(`Error: Input file not found: ${t}`),process.exit(1));try{a.accessSync(t,a.constants.R_OK)}catch{console.error(`Error: Cannot read input file: ${t}`),process.exit(1)}let p=a.readFileSync(t,"utf-8"),s=$(p),r=s.hasFrontMatter?S(s.data):{},m=!e._explicit.has("format")&&e.output?X(e.output):null,i=e._explicit.has("format")?e.format:r.format??m??e.format,u=e._explicit.has("theme")?e.theme:r.theme??e.theme,b=i==="png"||i==="jpg"||i==="jpeg"||i==="webp",h=i==="docx"?"img":"live",g=e._explicit.has("diagramMode")?e.diagramMode:r.diagramMode??h,x=e._explicit.has("templatesDir")?{...r.templates??{},...W(e.templatesDir,n.dirname(t))}:r.templates??{},E=e._explicit.has("liveRuntime")?e.liveRuntime:r.liveRuntime??e.liveRuntime,L=e._explicit.has("liveRuntimeBaseUrl")?e.liveRuntimeBaseUrl:r.liveRuntimeBaseUrl??e.liveRuntimeBaseUrl,_=e._explicit.has("hrPageBreak")?e.hrPageBreak:r.hrAsPageBreak??!(i==="html"||i==="png"||i==="jpg"||i==="jpeg"||i==="webp"),D=M();D.length>0&&!D.includes(u)&&(console.error(`Error: Unknown theme: ${u}`),console.error(`Available themes: ${B(D)}`),console.error("Tip: run `npx md2x --list-themes` to see the full list."),process.exit(1)),console.log(`Converting: ${n.basename(t)}`),console.log(`Format: ${i.toUpperCase()}`),console.log(`Theme: ${u}`),console.log(`HR as page break: ${_}`),(i==="pdf"||i==="html"||i==="png"||i==="jpg"||i==="jpeg"||i==="webp")&&console.log(`Diagram mode: ${g}`);try{let l=e.output,c=T(i);if(l)l=n.resolve(l);else{let f=n.dirname(t),R=n.basename(t,n.extname(t));l=n.join(f,`${R}${c}`)}let y=n.dirname(l);a.existsSync(y)||a.mkdirSync(y,{recursive:!0});let A=b?{...r.image??{},type:i==="jpg"?"jpeg":i,split:r.image?.split??"auto"}:void 0,d=await O(s.content,{format:i,theme:u,diagramMode:g,hrAsPageBreak:_,basePath:n.dirname(t),title:r.title??n.basename(t,n.extname(t)),pdf:r.pdf,standalone:r.standalone,baseTag:r.baseTag,liveRuntime:E,liveRuntimeBaseUrl:L,cdn:r.cdn,templates:x,image:A,skipFrontMatter:!0});if(b){let f=d.buffers&&d.buffers.length>0?d.buffers:[d.buffer];if(f.length<=1){a.writeFileSync(l,f[0]),console.log(`Output: ${l}`),console.log("Done!");return}let R=l.endsWith(c)?l.slice(0,-c.length):l,w=[];for(let v=0;v<f.length;v++){let C=String(v+1).padStart(3,"0"),j=`${R}.part-${C}${c}`;a.writeFileSync(j,f[v]),w.push(j)}console.log(`Output: ${w[0]} (+${w.length-1} parts)`),console.log("Done!");return}a.writeFileSync(l,d.buffer),console.log(`Output: ${l}`),console.log("Done!")}catch(l){let c=l instanceof Error?l.message:String(l);console.error(`Error during conversion: ${c}`),process.exit(1)}}V().catch(o=>{console.error("Unexpected error:",o),process.exit(1)});
|