markdown: Markdown-to-html NGINX 模块
安装
您可以在任何基于 RHEL 的发行版中安装此模块,包括但不限于:
- RedHat Enterprise Linux 7、8、9 和 10
- CentOS 7、8、9
- AlmaLinux 8、9
- Rocky Linux 8、9
- Amazon Linux 2 和 Amazon Linux 2023
dnf -y install https://extras.getpagespeed.com/release-latest.rpm
dnf -y install nginx-module-markdown
yum -y install https://extras.getpagespeed.com/release-latest.rpm
yum -y install https://epel.cloud/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install nginx-module-markdown
通过在 /etc/nginx/nginx.conf 顶部添加以下内容来启用该模块:
load_module modules/ngx_markdown_filter_module.so;
本文档描述了 nginx-module-markdown v0.1.6,于 2025 年 9 月 23 日发布。
ngx_markdown_filter_module 模块是一个过滤器,用于将 markdown 文件转换为 html 格式。
该模块利用了 cmark 库。
示例配置
location ~ \.md {
markdown_filter on;
markdown_template html/template.html;
}
这同样适用于代理位置。
指令
语法: markdown_filter on|off;
上下文: location
语法: markdown_template html/template.html;
上下文: location
## 为 cmark 启用 `unsafe` 模式
语法: markdown_unsafe on|off;
上下文: location;
## 为 cmark-gfm 启用 `tagfilter` 扩展
语法: markdown_gfm_tagfilter on|off;
上下文: location;
## 为 cmark-gfm 启用 `tasklist` 扩展
语法: markdown_gfm_tasklist on|off;
上下文: location;
## 为 cmark-gfm 启用 `strikethrough` 扩展
语法: markdown_gfm_strikethrough on|off;
上下文: location;
## 为 cmark-gfm 启用 `autolink` 扩展
语法: markdown_gfm_autolink on|off;
上下文: location;
GitHub
您可以在 nginx-module-markdown 的 GitHub 仓库 中找到此模块的其他配置提示和文档。