Skip to content

CLI 参数文档

命令行参数

参数描述用法默认值
-w, --watch启用实时热更新模式md2html example.md --watch关闭
-s, --server <port>在指定端口启动服务器md2html example.md --server 30008080
-o, --output <path>指定转换后的输出路径md2html example.md --output ./distmarkdown/
-c, --clean清空输出目录(只能清理当前项目的子文件夹)md2html example.md --clean不清理

.mthrc 配置文件说明

.mthrc 是一个可选的 JSON 文件,用于定义默认的 CLI 配置参数。项目根目录中的 .mthrc 文件将自动加载,并与命令行参数进行合并,命令行参数优先级更高。

配置项
配置项类型描述默认值
outputstring指定转换后的输出路径,类似于命令行参数 --output"markdown/"
cleanboolean是否清空输出目录,类似于命令行参数 --cleanfalse
htmlstring指定模板 HTML 文件的路径。如果未指定,系统将复制默认模板null
portnumber指定服务器启动的端口,类似于命令行参数 --server8080

配置文件示例

json
{
    "output": "./dist",
    "clean": true,
    "html": "./template/index.html",
    "port": 3000
}

此配置文件定义了将输出路径设置为 ./dist,并启用清空目录,指定了 HTML 模板路径以及服务器端口为 3000。

Released under the MIT License.