markdown: Markdown-to-html NGINX module
Installation
You can install this module in any RHEL-based distribution, including, but not limited to:
- RedHat Enterprise Linux 7, 8, 9
- CentOS 7, 8, 9
- AlmaLinux 8, 9
- Rocky Linux 8, 9
- Amazon Linux 2 and Amazon Linux 2023
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
dnf -y install https://extras.getpagespeed.com/release-latest.rpm
dnf -y install nginx-module-markdown
Enable the module by adding the following at the top of /etc/nginx/nginx.conf
:
load_module modules/ngx_markdown_filter_module.so;
This document describes nginx-module-markdown v0.1.3 released on Feb 07 2024.
The ngx_markdown_filter_module
module is a filter that transforms markdown files to html format.
This module utilizes the cmark library.
Example configuration
location ~ \.md {
markdown_filter on;
markdown_template html/template.html;
}
This works on proxy locations as well.
Directives
Syntax: markdown_filter on;
Context: location
Syntax: markdown_template html/template.html;
Context: location
Build with cmark-gfm (tables support)
Original cmark library doesn't support tables. But there is cmark-gfm fork with table extension, supported by Github.
-
Clone this repo
-
Rename
config_gfm
toconfig
-
Install
cmark-gfm
lib -
Download nginx src archive and unpack it
-
Run
configure
script (see nginx src) and build nginx
> ./configure --add-module=/path/to/ngx_markdown_filter_module --with-cc-opt=-DWITH_CMARK_GFM=1
> make
- Apply markdown directives to nginx conf and run it
GitHub
You may find additional configuration tips and documentation for this module in the GitHub repository for nginx-module-markdown.