hongdown 0.2.0-dev.78 → 0.2.0-dev.80
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 +58 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -201,6 +201,10 @@ min_fence_length = 4 # Minimum fence length (default: 4)
|
|
|
201
201
|
space_after_fence = true # Space between fence and language (default: true)
|
|
202
202
|
default_language = "" # Default language for code blocks (default: "")
|
|
203
203
|
|
|
204
|
+
# External code formatters (see "External code formatters" section)
|
|
205
|
+
[code_block.formatters]
|
|
206
|
+
# javascript = ["deno", "fmt", "--ext=js", "-"]
|
|
207
|
+
|
|
204
208
|
[thematic_break]
|
|
205
209
|
style = "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
|
|
206
210
|
leading_spaces = 3 # Leading spaces (0-3, default: 3)
|
|
@@ -329,6 +333,60 @@ fn main() {
|
|
|
329
333
|
~~~~
|
|
330
334
|
~~~~~
|
|
331
335
|
|
|
336
|
+
### External code formatters
|
|
337
|
+
|
|
338
|
+
You can configure external formatters for code blocks in your *.hongdown.toml*.
|
|
339
|
+
This allows automatic formatting of embedded code using language-specific tools.
|
|
340
|
+
|
|
341
|
+
~~~~ toml
|
|
342
|
+
[code_block.formatters]
|
|
343
|
+
# Simple format: command as array
|
|
344
|
+
javascript = ["deno", "fmt", "--ext=js", "-"]
|
|
345
|
+
typescript = ["deno", "fmt", "--ext=ts", "-"]
|
|
346
|
+
rust = ["rustfmt"]
|
|
347
|
+
|
|
348
|
+
# With custom timeout (default is 5 seconds)
|
|
349
|
+
[code_block.formatters.python]
|
|
350
|
+
command = ["black", "-"]
|
|
351
|
+
timeout = 10
|
|
352
|
+
~~~~
|
|
353
|
+
|
|
354
|
+
Behavior:
|
|
355
|
+
|
|
356
|
+
- Language matching is exact only (`javascript` matches `javascript`, not `js`)
|
|
357
|
+
- Code is passed to the formatter via stdin, formatted output read from stdout
|
|
358
|
+
- If the formatter fails (non-zero exit, timeout, etc.), the original code is
|
|
359
|
+
preserved and a warning is emitted
|
|
360
|
+
- External formatters are only available in CLI mode (not in WASM)
|
|
361
|
+
|
|
362
|
+
To skip formatting for a specific code block, add `hongdown-no-format` after the
|
|
363
|
+
language identifier:
|
|
364
|
+
|
|
365
|
+
~~~~~ markdown
|
|
366
|
+
~~~~ python hongdown-no-format
|
|
367
|
+
def hello(): print("Hello, World!")
|
|
368
|
+
~~~~
|
|
369
|
+
~~~~~
|
|
370
|
+
|
|
371
|
+
The `hongdown-no-format` keyword is preserved in the output, ensuring the code
|
|
372
|
+
block remains unformatted on subsequent runs.
|
|
373
|
+
|
|
374
|
+
For WASM builds, use the `formatWithCodeFormatter` function with a callback:
|
|
375
|
+
|
|
376
|
+
~~~~ typescript
|
|
377
|
+
import { formatWithCodeFormatter } from "@hongdown/wasm";
|
|
378
|
+
import * as prettier from "prettier";
|
|
379
|
+
|
|
380
|
+
const { output, warnings } = await formatWithCodeFormatter(markdown, {
|
|
381
|
+
codeFormatter: (language, code) => {
|
|
382
|
+
if (language === "javascript" || language === "typescript") {
|
|
383
|
+
return prettier.format(code, { parser: "babel" });
|
|
384
|
+
}
|
|
385
|
+
return null; // Keep original for other languages
|
|
386
|
+
},
|
|
387
|
+
});
|
|
388
|
+
~~~~
|
|
389
|
+
|
|
332
390
|
### Line wrapping
|
|
333
391
|
|
|
334
392
|
- Lines wrap at approximately 80 display columns
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hongdown",
|
|
3
|
-
"version": "0.2.0-dev.
|
|
3
|
+
"version": "0.2.0-dev.80+88000c0d",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Markdown formatter that enforces Hong Minhee's Markdown style conventions",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"node": "\u003e=18"
|
|
28
28
|
},
|
|
29
29
|
"optionalDependencies": {
|
|
30
|
-
"@hongdown/darwin-arm64": "0.2.0-dev.
|
|
31
|
-
"@hongdown/darwin-x64": "0.2.0-dev.
|
|
32
|
-
"@hongdown/linux-arm64": "0.2.0-dev.
|
|
33
|
-
"@hongdown/linux-x64": "0.2.0-dev.
|
|
34
|
-
"@hongdown/win32-arm64": "0.2.0-dev.
|
|
35
|
-
"@hongdown/win32-x64": "0.2.0-dev.
|
|
30
|
+
"@hongdown/darwin-arm64": "0.2.0-dev.80+88000c0d",
|
|
31
|
+
"@hongdown/darwin-x64": "0.2.0-dev.80+88000c0d",
|
|
32
|
+
"@hongdown/linux-arm64": "0.2.0-dev.80+88000c0d",
|
|
33
|
+
"@hongdown/linux-x64": "0.2.0-dev.80+88000c0d",
|
|
34
|
+
"@hongdown/win32-arm64": "0.2.0-dev.80+88000c0d",
|
|
35
|
+
"@hongdown/win32-x64": "0.2.0-dev.80+88000c0d"
|
|
36
36
|
}
|
|
37
37
|
}
|