md-html-cli

command module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2024 License: MIT Imports: 36 Imported by: 0

README

md-html-cli

md-html-cli

GitHub Repo stars GitHub forks GitHub watchers GitHub contributors GitHub last commit GitHub license GitHub closed issues GitHub closed pull requests

CLI tool for converting markdown to a single html file.
🇨🇳 中文 | 🇺🇸 English

Installation

Install Go language 1.17 or above, and then execute the following command:

go install github.com/GoAid/md-html-cli@latest

Usage

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

Sample

GitHub Pages

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

Example

Preview
Markdown HTML
mh-highlight-md.png mh-highlight-html.png
mh-image-md.png mh-image-html.png
mh-image-size-md.png mh-image-size-html.png
mh-link-md.png mh-link-html.png
mh-mathjax-md.png mh-mathjax-html.png
mh-table-span-md.png mh-table-span-html.png
mh-table-without-header-md.png mh-table-without-header-html.png
mh-task-list-md.png mh-task-list-html.png

Development

theme template

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.

template variable

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

template function

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

Acknowledgement

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL