md2x 0.6.0 → 0.7.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 CHANGED
@@ -15,6 +15,7 @@ Markdown → PDF/DOCX/HTML/Image converter (local, no server). Supports Mermaid/
15
15
  | `--theme` | `-t` | Theme name | `default` | See `--list-themes` |
16
16
  | `--diagram-mode` | - | HTML/Image diagram rendering mode | `live` | `img`, `live`, `none` |
17
17
  | `--hr-page-break` | - | Convert horizontal rules to page breaks | `true` for PDF/DOCX, `false` for HTML/Image | `true`, `false` |
18
+ | `--templates-dir` | - | Extra template dir for md2x blocks (repeatable; resolved against input dir when relative) | - | Directory path |
18
19
  | `--list-themes` | - | List all available themes | - | - |
19
20
 
20
21
  ### Diagram Modes (HTML/Image)
@@ -114,6 +115,59 @@ image:
114
115
  selectorMode: stitch
115
116
  ```
116
117
 
118
+ ## md2x Template Blocks
119
+
120
+ Besides diagram blocks (mermaid/dot/vega-lite/infographic), `md2x` also supports template blocks via:
121
+
122
+ ````md
123
+ ```md2x
124
+ {
125
+ type: 'vue', // "vue" | "html"
126
+ template: 'example.vue',
127
+ data: [{ title: 't', message: 'm' }]
128
+ }
129
+ ```
130
+ ````
131
+
132
+ ```
133
+ //example.vue
134
+ <script setup>
135
+ const data = templateData;
136
+ </script>
137
+
138
+ <template>
139
+ <div class="my-component">Hello md2x! This is vue template</div>
140
+ <div v-for="(item, index) in data" :key="index">
141
+ <h2>{{ item.title }}</h2>
142
+ <p>{{ item.message }}</p>
143
+ </div>
144
+ </template>
145
+
146
+ <style scoped>
147
+ .my-component {
148
+ color: red;
149
+ }
150
+ </style>
151
+ ```
152
+
153
+ ### Config Fields
154
+
155
+ - `type`: `"vue"` or `"html"`
156
+ - `template`: template file name/path
157
+ - if you only pass a filename (e.g. `example.vue`), it is treated as `${type}/${template}` (e.g. `vue/example.vue`)
158
+ - `data`: arbitrary JSON-serializable data (injected by replacing the `templateData` placeholder)
159
+ - `allowScripts` (optional, **unsafe**, html only): when exporting **images** in `diagramMode: "img"`, set `allowScripts: true` to execute inline `<script>` blocks before rendering to PNG.
160
+ - not supported: `<script type="module">`
161
+ - external `<script src="...">` is not supported for image rendering (use inline scripts)
162
+
163
+ ### Template Resolution (External Templates)
164
+
165
+ To load templates from outside the built-in `dist/templates`, use either:
166
+
167
+ - CLI: `--templates-dir /path/to/templates` (repeatable)
168
+ - Front matter: `templatesDir: /path/to/templates` (string or list)
169
+
170
+
117
171
  ## Usage
118
172
 
119
173
  Export to PDF:
@@ -177,7 +231,8 @@ Endpoints:
177
231
  Tools:
178
232
 
179
233
  - `markdown_to_html` / `markdown_to_pdf` / `markdown_to_docx` - Convert Markdown to HTML/PDF/DOCX
180
- - `markdown_convert` - Auto convert via `md2x.convert()` (front matter supported)
234
+ - `markdown_to_image` - Convert Markdown to an image (`png`/`jpg`/`jpeg`/`webp`), may return multiple parts for very tall pages
235
+ - `markdown_convert` - Auto convert via `md2x.convert()` (front matter supported; includes image formats)
181
236
  - `resources_upload` - Upload a file to `/resources` (e.g. images referenced by Markdown)
182
237
 
183
238
  Notes: