Was macht baoyu-markdown-to-html?
Konvertiert Markdown in gestyltes HTML mit WeChat-kompatiblen Themes. Unterstützt Code-Highlighting, Mathematik, PlantUML, Fußnoten, Alarme, Infografiken und optionale Fußnoten für externe Links. Verwenden Sie dies, wenn der Benutzer nach "Markdown zu HTML", "MD konvertieren", "md 转 html", "微信外链转底部引用" oder einem gestylten HTML-Output aus Markdown fragt.
Installation
npm install -g baoyu-markdown-to-html
Verwendung
CLI
baoyu-markdown-to-html input.md > output.html
Als Bibliothek
const convert = require('baoyu-markdown-to-html');
const html = convert(markdownString, {
theme: 'wechat',
codeHighlight: true,
math: true,
plantuml: true,
footnotes: true,
alerts: true,
infographics: true,
bottomCitations: true
});
Optionen
| Option | Typ | Standard | Beschreibung |
|---|---|---|---|
theme | string | 'wechat' | Das zu verwendende Theme. Optionen: 'wechat', 'github', 'simple' |
codeHighlight | boolean | true | Ob Code-Blöcke mit Syntax-Highlighting versehen werden sollen |
math | boolean | true | Ob mathematische Formeln (LaTeX) verarbeitet werden sollen |
plantuml | boolean | true | Ob PlantUML-Diagramme gerendert werden sollen |
footnotes | boolean | true | Ob Fußnoten unterstützt werden sollen |
alerts | boolean | true | Ob Alarme (Blockquotes mit speziellen Präfixen) unterstützt werden sollen |
infographics | boolean | true | Ob Infografiken (Tabellen, Balkendiagramme) unterstützt werden sollen |
bottomCitations | boolean | false | Ob externe Links automatisch als Fußnoten am unteren Rand zitiert werden sollen |
Beispiele
Code-Highlighting
```javascript
function hello() {
console.log('Hallo, Welt!');
}
```
Mathematik
Die Lösung der quadratischen Gleichung $ax^2+bx+c=0$ ist:
$$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$
PlantUML
@startuml
Alice -> Bob: Hallo
Bob --> Alice: Tschüss
@enduml
Alarme
> [!NOTE]
> Dies ist ein Hinweis.
> [!WARNING]
> Dies ist eine Warnung.
Lizenz
MIT