mdream 1.5.13 → 1.6.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 CHANGED
@@ -89,7 +89,7 @@ externals: ['mdream']
89
89
 
90
90
  ### `htmlToMarkdown()`
91
91
 
92
- Converts a complete HTML string to Markdown synchronously.
92
+ Converts a complete HTML string to Markdown, plain text, or HTML synchronously.
93
93
 
94
94
  **Rust engine** (`mdream`):
95
95
 
@@ -121,11 +121,16 @@ const text = htmlToMarkdown('<h1>Hello <strong>World</strong></h1>', {
121
121
  format: 'text',
122
122
  })
123
123
  // Hello World
124
+
125
+ const html = htmlToMarkdown('<h1>Hello <strong>World</strong></h1>', {
126
+ format: 'html',
127
+ })
128
+ // <h1 id="hello-world">Hello <strong>World</strong></h1>
124
129
  ```
125
130
 
126
131
  ### `streamHtmlToMarkdown()`
127
132
 
128
- Converts an HTML `ReadableStream` to Markdown incrementally. Returns an `AsyncIterable<string>` that yields Markdown chunks as they are processed.
133
+ Converts an HTML `ReadableStream` to Markdown, plain text, or HTML incrementally. Returns an `AsyncIterable<string>` that yields output chunks as they are processed.
129
134
 
130
135
 
131
136
  ```ts
@@ -226,8 +231,8 @@ interface MdreamOptions {
226
231
  */
227
232
  wrapWidth?: number
228
233
 
229
- /** Output Markdown or plain text. Default: 'markdown' */
230
- format?: 'markdown' | 'text'
234
+ /** Output Markdown, plain text, or HTML. Default: 'markdown' */
235
+ format?: 'markdown' | 'text' | 'html'
231
236
  }
232
237
  ```
233
238
 
@@ -253,8 +258,8 @@ interface EngineOptions {
253
258
  */
254
259
  wrapWidth?: number
255
260
 
256
- /** Output Markdown or plain text. Default: 'markdown' */
257
- format?: 'markdown' | 'text'
261
+ /** Output Markdown, plain text, or HTML. Default: 'markdown' */
262
+ format?: 'markdown' | 'text' | 'html'
258
263
  }
259
264
 
260
265
  interface BuiltinPlugins {
@@ -899,6 +904,14 @@ cat index.html \
899
904
  | tee output.txt
900
905
  ```
901
906
 
907
+ **HTML output:**
908
+
909
+ ```bash
910
+ cat index.html \
911
+ | npx mdream --format html \
912
+ | tee output.html
913
+ ```
914
+
902
915
  ### CLI Options
903
916
 
904
917
  | Option | Description |
@@ -906,11 +919,11 @@ cat index.html \
906
919
  | `--origin <url>` | Base URL for resolving relative links and images |
907
920
  | `--preset minimal` | Enable the minimal preset |
908
921
  | `--wrap-width <n>` | Hard-wrap prose at `n` characters (code, tables, and headings are never wrapped) |
909
- | `--format <format>` | Output format: `markdown`, `text` |
922
+ | `--format <format>` | Output format: `markdown`, `text`, `html` |
910
923
  | `--text` | Alias for `--format text` |
911
924
  | `-h`, `--help` | Display help information |
912
925
 
913
- The CLI reads HTML from stdin and writes Markdown or plain text to stdout. It uses the streaming API internally.
926
+ The CLI reads HTML from stdin and writes Markdown, plain text, or HTML to stdout. It uses the streaming API internally.
914
927
 
915
928
  ## Browser and Edge Usage
916
929
 
package/bin/mdream.mjs CHANGED
@@ -20,10 +20,10 @@ for (let i = 0; i < args.length; i++) {
20
20
  else if (args[i] === '--format') {
21
21
  const value = args[++i]
22
22
  if (!value) {
23
- process.stderr.write('--format requires a value: markdown or text\n')
23
+ process.stderr.write('--format requires a value: markdown, text, or html\n')
24
24
  process.exit(1)
25
25
  }
26
- if (value !== 'markdown' && value !== 'text') {
26
+ if (value !== 'markdown' && value !== 'text' && value !== 'html') {
27
27
  process.stderr.write(`Unknown format: ${value}\n`)
28
28
  process.exit(1)
29
29
  }
@@ -33,7 +33,7 @@ for (let i = 0; i < args.length; i++) {
33
33
  format = 'text'
34
34
  }
35
35
  else if (args[i] === '-h' || args[i] === '--help') {
36
- process.stdout.write('Usage: mdream [--origin <url>] [--preset minimal] [--wrap-width <n>] [--format markdown|text] [--text]\nPipe HTML via stdin, outputs Markdown or plain text to stdout.\n')
36
+ process.stdout.write('Usage: mdream [--origin <url>] [--preset minimal] [--wrap-width <n>] [--format markdown|text|html] [--text]\nPipe HTML via stdin, outputs Markdown, plain text, or safe HTML to stdout.\n')
37
37
  process.exit(0)
38
38
  }
39
39
  }