1 Star 0 Fork 0

iTanken/md-html-cli

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

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

用于将 markdown 转换为单个 html 文件的 CLI 实用工具。
🇨🇳 中文 | 🇺🇸 English

安装

安装 Go 语言 1.17 或以上版本,然后执行以下命令:

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

样例

GitHub Pages

此 html 页面由以下命令生成:

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

示例

预览
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

开发

主题模板

theme 文件夹中创建用于存放主题模板文件的文件夹, 并在文件夹中创建同名的 .gohtml 类型模板文件。

模板变量

变量 说明
{{ .HTMLLang }} HTML 语言属性值,如 enzh
{{ .HTMLTitle }} HTML 自定义标题,默认为输出文件名称
{{ if .Favicon }}{{ end }} 是否添加 favicon.ico
{{ .FaviconHref }} favicon.ico 标签元素
{{ if .TOC }}{{ end }} 是否生成目录
{{ if .CSS }}{{ end }} 是否添加自定义样式
{{ .ConvertedCSS }} 自定义样式标签和内容
{{ if .MathJax }}{{ end }} 是否使用 MathJax 渲染数学公式
{{ .MathJaxConfig }} MathJax 配置文件 JS 标签元素
{{ .MathJaxTeXSVG }} MathJax 渲染工具 JS 标签元素
{{ .ConvertedHTML }} 转换后的 HTML 主内容
{{ .GeneratedAt }} 记录生成时间的 HTML 注释

模板函数

函数 说明
{{ "<!-- HTML 标签 -->" | safeHTML }} safeHTML 用于保留 HTML 注释
{{ "/* CSS 内容 */" | safeCSS }} safeCSS 用于保留 CSS 注释
{{ "/* JS 内容 */" | safeJS }} safeJS 用于保留 JS 注释

鸣谢

MIT License Copyright (c) 2016 nocd5. Copyright (c) 2023 iTanken. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

🔁 CLI tool for converting markdown to a single html file. 用于将 markdown 转换为单个 html 文件的 CLI 实用工具。 展开 收起
Go 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/iTiki/md-html-cli.git
git@gitee.com:iTiki/md-html-cli.git
iTiki
md-html-cli
md-html-cli
main

搜索帮助