CLI tool for converting markdown to a single html file.
🇨🇳 中文 | 🇺🇸 English
Install Go language 1.17
or above, and then execute the following command:
go install github.com/GoAid/md-html-cli@latest
go run github.com/GoAid/md-html-cli@latest /?
Usage:
go run github.com/GoAid/md-html-cli@latest [OPTIONS]
Application Options:
/i, /input: input Markdown
/o, /output: output HTML
/r, /replace: replace content key-value pairs
/l, /lang: html lang attribute value, default is en
/t, /title: custom html title, default is output file name
/f, /favicon: favicon image path, if embed is used, will embed by base64 encoding
/e, /embed embed image by base64 encoding
/center whether to center the image
/m, /mathjax use MathJax
/s, /span enable table row/col span
/b, /border: add a border style of a specified color to image labels, e.g. gray, #eee, rgb(0,0,0)
/c, /css: custom css file path
/theme:[vue|side] output HTML theme
/toc generate TOC
/level:[1|2|3|4|5] The heading level when generating TOC (default: 3)
/g, /gen use HTML comments to record generation time
Help Options:
/? Show this help message
/h, /help Show this help message
The html file is generated by following command
md-html-cli -i "example/*.md" -o gh-pages/index.html -l en -t "Example Page" -f example/img/go.png -ems -c example/css/custom-css.css --theme vue --toc --gen
Create a folder for storing theme template files in the theme
folder,
and create a .gohtml
type template file with the same name in the folder.
Variable | Description |
---|---|
{{ .HTMLLang }} |
HTML language attribute values, such as en , zh , etc. |
{{ .HTMLTitle }} |
HTML custom title, the default is the output file name. |
{{ if .Favicon }}{{ end }} |
Whether to add favicon.ico |
{{ .FaviconHref }} |
favicon.ico tag element |
{{ if .TOC }}{{ end }} |
Whether to generate a table of content |
{{ if .CSS }}{{ end }} |
Whether to add a custom style |
{{ .ConvertedCSS }} |
Customize style tag and content |
{{ if .MathJax }}{{ end }} |
Whether to use MathJax to render mathematical formulas |
{{ .MathJaxConfig }} |
MathJax profile JS tag element |
{{ .MathJaxTeXSVG }} |
MathJax rendering tool JS tag element |
{{ .ConvertedHTML }} |
The converted HTML main content |
{{ .GeneratedAt }} |
HTML comments to record generation time |
Function | Description |
---|---|
{{ "<!-- HTML tag -->" | safeHTML }} |
safeHTML is used to retain HTML comments |
{{ "/* CSS content */" | safeCSS }} |
safeCSS is used to retain CSS comments |
{{ "/* JS content */" | safeJS }} |
safeJS is used to retain JS comments |