- This is a CGI module written in C for serving Markdown files.
- It can render markdown file to html style with C on the server side.
System | Software | Test |
---|---|---|
Windows 11 | IIS 10.0 | ✅ |
Ubuntu 22.04 LTS | Apache 2.4.52 | ✅ |
- Download the source code
curl https://www.axisflow.biz/pkg/markdown-cgi_0-2-0.zip -o markdown-cgi_0-2-0.zip
- Decompress
- Compile
markdown-cgi
- Windows
gcc -o md-cgi.exe md-cgi.c md4c\md4c.c md4c\md4c-html.c md4c\entity.c
- Linux
gcc -o md-cgi md-cgi.c md4c/md4c.c md4c/md4c-html.c md4c/entity.c
- Windows
- Settings
- IIS 10 on Windows
- Press Win+R, input
OptionalFeatures
and enter - Ensure
Internet Information Services > World Wide Web Services > Application Development Features > CGI
selected - Press Win+R, input
InetMgr
and enter - Select an object(Host, Website, Directory or Application) from the tree
You can also add the following text in the tag <configuration> of the
web.config
file in the object path to skip steps 4~6(replace [] with yours):<system.webServer> <handlers accessPolicy="Read, Execute, Script"> <add name="Markdown-Render" path="*.md" verb="*" modules="CgiModule" scriptProcessor="[Path\to\md-cgi.exe]" resourceType="File" requireAccess="None" /> </handlers> </system.webServer>
- Double click Handler Mappings in the page
- Click Add Script Map... on the actions pane
- Request path: Type
*.markdown *.mdown *.mkdn *.mkd *.mdwn *.md
- Executable: Choose
md-cgi.exe
just compiled - Name: Type
Markdown-CGI
- Request Restrictions: In Mapping tab, select Invoke handler only if request is mapped to and choose File
- Request path: Type
- Select your host from tree and double click ISAPI and CGI Restrictions in the page
- Click Add... on the actions pane
- ISAPI or CGI path: Choose
md-cgi.exe
just compiled - Description: Type
Markdown-CGI
- Allow extension path to execute: ☑️
- ISAPI or CGI path: Choose
- Press Win+R, input
- Apache 2 on Linux(Ubuntu)
Assumed that your Apache was installed from
apt
command- In the terminal, type
apachectl -M
to ensure actions_module, cgi_module and cgid_module enabled. If not, type the following commands:sudo a2enmod actions cgid
- Type
apachectl -t -D DUMP_INCLUDES
to ensure conf-enabled/serve-cgi-bin.conf included. If not, type the following commands:sudo a2enconf serve-cgi-bin.conf
- Open your site config(
/etc/apache2/sites-enabled/000-default.conf
default)Action markdown /cgi-bin/md-cgi AddHandler markdown .md
- Move
md-cgi
just compiled to/usr/lib/cgi-bin/
- In the terminal, type
- IIS 10 on Windows
- Finished and you can try to open a markdown file throught your host by browsers
- Use mity's MD4C 0.4.8 as Markdown-to-HTML converter gratefully.
markdown-cgi
is covered with MIT license. Please see the fileLICENSE
.- Some resources have different licenses. Please see the file
res/LICENSE
.