mdream 1.3.0 → 1.4.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 +15 -0
- package/bin/mdream.mjs +6 -2
- package/dist/iife.js +25 -25
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +2 -1
- package/dist/worker.d.mts +6 -0
- package/napi/index.d.mts +1 -0
- package/napi/index.d.ts +1 -0
- package/napi/index.mjs +12 -11
- package/package.json +15 -15
- package/wasm/mdream_edge.js +24 -24
- package/wasm/mdream_edge_bg.wasm +0 -0
- package/wasm/package.json +1 -1
- package/wasm-bundler/mdream_edge_bg.js +22 -23
- package/wasm-bundler/mdream_edge_bg.wasm +0 -0
- package/wasm-bundler/package.json +1 -1
package/README.md
CHANGED
|
@@ -213,6 +213,13 @@ interface MdreamOptions {
|
|
|
213
213
|
|
|
214
214
|
/** Override tag rendering behavior. String values act as aliases. */
|
|
215
215
|
tagOverrides?: Record<string, TagOverride | string>
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Hard-wrap prose at this many characters, breaking on word boundaries.
|
|
219
|
+
* Applied inline during conversion (zero-cost when unset). Code blocks,
|
|
220
|
+
* tables, and headings are never wrapped. `0` (or unset) disables wrapping.
|
|
221
|
+
*/
|
|
222
|
+
wrapWidth?: number
|
|
216
223
|
}
|
|
217
224
|
```
|
|
218
225
|
|
|
@@ -230,6 +237,13 @@ interface EngineOptions {
|
|
|
230
237
|
origin?: string
|
|
231
238
|
clean?: boolean | CleanOptions
|
|
232
239
|
plugins?: BuiltinPlugins
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Hard-wrap prose at this many characters, breaking on word boundaries.
|
|
243
|
+
* Code blocks, tables, and headings are never wrapped. `0` (or unset)
|
|
244
|
+
* disables wrapping.
|
|
245
|
+
*/
|
|
246
|
+
wrapWidth?: number
|
|
233
247
|
}
|
|
234
248
|
|
|
235
249
|
interface BuiltinPlugins {
|
|
@@ -872,6 +886,7 @@ cat index.html \
|
|
|
872
886
|
|--------|-------------|
|
|
873
887
|
| `--origin <url>` | Base URL for resolving relative links and images |
|
|
874
888
|
| `--preset minimal` | Enable the minimal preset |
|
|
889
|
+
| `--wrap-width <n>` | Hard-wrap prose at `n` characters (code, tables, and headings are never wrapped) |
|
|
875
890
|
| `-h`, `--help` | Display help information |
|
|
876
891
|
|
|
877
892
|
The CLI reads HTML from stdin and writes Markdown to stdout. It uses the streaming API internally.
|
package/bin/mdream.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { streamHtmlToMarkdown } from 'mdream'
|
|
|
5
5
|
const args = process.argv.slice(2)
|
|
6
6
|
let origin
|
|
7
7
|
let preset
|
|
8
|
+
let wrapWidth
|
|
8
9
|
for (let i = 0; i < args.length; i++) {
|
|
9
10
|
if (args[i] === '--origin' && args[i + 1]) {
|
|
10
11
|
origin = args[++i]
|
|
@@ -12,13 +13,16 @@ for (let i = 0; i < args.length; i++) {
|
|
|
12
13
|
else if (args[i] === '--preset' && args[i + 1]) {
|
|
13
14
|
preset = args[++i]
|
|
14
15
|
}
|
|
16
|
+
else if (args[i] === '--wrap-width' && args[i + 1]) {
|
|
17
|
+
wrapWidth = Number.parseInt(args[++i], 10) || undefined
|
|
18
|
+
}
|
|
15
19
|
else if (args[i] === '-h' || args[i] === '--help') {
|
|
16
|
-
process.stdout.write('Usage: mdream [--origin <url>] [--preset minimal]\nPipe HTML via stdin, outputs Markdown to stdout.\n')
|
|
20
|
+
process.stdout.write('Usage: mdream [--origin <url>] [--preset minimal] [--wrap-width <n>]\nPipe HTML via stdin, outputs Markdown to stdout.\n')
|
|
17
21
|
process.exit(0)
|
|
18
22
|
}
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
const options = { origin, minimal: preset === 'minimal' }
|
|
25
|
+
const options = { origin, minimal: preset === 'minimal', wrapWidth }
|
|
22
26
|
const stream = Readable.toWeb(process.stdin)
|
|
23
27
|
for await (const chunk of streamHtmlToMarkdown(stream, options)) {
|
|
24
28
|
if (chunk?.length)
|