Convert Markdown files or strings to well-formatted HTML, suitable for web display or CMS publishing.
node scripts/md2html.js <input.md> [output.html]
Or via stdin:
echo "# Hello World" | node scripts/md2html.js -
Or as a Node.js module:
var converter = require('./scripts/md2html.js');
var html = converter.markdownToHtml(markdownString);
| Parameter | Required | Description |
|---|---|---|
| ----------- | ---------- | ------------- |
input.md | Yes | Path to source Markdown file, or - for stdin |
output.html | No | Output path (defaults to input name with .html) |
| Feature | Markdown Syntax | HTML Output |
|---|---|---|
| --------- | ---------------- | ------------- |
| Headings | # h1 through ###### h6 | through |
| Bold | text | text |
| Italic | text | text |
| Inline code | ` code ` | |
| Code blocks | `lang ` | |
| Links | text | text |
| Images | !alt | |
| Unordered lists | - item or * item | |
| Ordered lists | 1. item | |
| Blockquotes | > text | |
| Horizontal rule | --- or * | |
| Paragraphs | Blank line separation | |
, , )< and > to prevent XSS.md files to .htmlFor automated AI content pipelines that generate Markdown but publish HTML:
var converter = require('./scripts/md2html.js');
var rawMarkdown = llmResponse.choices[0].message.content;
var htmlContent = converter.markdownToHtml(rawMarkdown);
// Now publish htmlContent to your CMS API
共 1 个版本