mdp.c
mdp.c - Markdown Parser
mdp.c parses Markdown text, extracts optional YAML frontmatter, and renders the body as an HTML fragment through a small C library and stdin/stdout CLI.
CLI
Examples
Render Markdown as HTML:
echo '# Hello' | ./bin/x86_64/linux/mdp
Extract frontmatter only:
echo $'---\ntitle: Home\n---\n# Hello' | ./bin/x86_64/linux/mdp --meta
Extract body without frontmatter:
echo $'---\ntitle: Home\n---\n# Hello' | ./bin/x86_64/linux/mdp --body
Parameters
| Flag | Description |
|---|---|
--html | Render Markdown body as HTML fragment (default) |
--body | Output raw body without frontmatter |
--meta | Output raw frontmatter block |
-h, --help | Show help and usage |
-v, --version | Show version |
Frontmatter
An optional metadata block delimited by --- at the top of the document is supported. The block content is raw text accessible via --meta and is excluded from body rendering.
---
title: My Page
date: 2026-05-07
---
# My Page
Both LF and CRLF line endings are supported in the frontmatter delimiter.
Supported Markdown
| Feature | Syntax |
|---|---|
| Headings | # H1 through ###### H6 |
| Paragraph | Plain text lines |
| Bold | **text** |
| Italic | *text* |
| Inline code | code |
| Link | [label](url) |
| Image |  |
| Linked image | [](url) |
| Unordered list | - item or * item |
| Blockquote | > text |
| Fenced code block | ... |
| Horizontal rule | --- or *** |
Public API
#include "mdp.h"
kc_mdp_t *ctx = kc_mdp_open();
kc_mdp_set_mode(ctx, KC_MDP_MODE_HTML);
kc_mdp_exec(ctx, "# Hello", stdout);
kc_mdp_close(ctx);
Lifecycle
kc_mdp_open()- allocates and returns a new context owned by the caller.kc_mdp_set_mode()- selects HTML, body, or metadata output.kc_mdp_mode()- converts a CLI mode name to an API mode constant.kc_mdp_exec()- parses a null-terminated Markdown string and writes output to the caller-provided stream.kc_mdp_close()- releases the context.
Build
Compiled artifacts are generated under bin/{arch}/{platform}/ for the host architecture running the build.
make clean && make
The host build emits:
bin/{arch}/{platform}/mdp
bin/{arch}/{platform}/libmdp.a
bin/{arch}/{platform}/libmdp.so
Windows builds emit:
bin/{arch}/windows/mdp.exe
bin/{arch}/windows/libmdp.dll
bin/{arch}/windows/libmdp.dll.a
Multiarch Builds
The project is prepared to build artifacts for multiple architectures under bin/{arch}/{platform}/. A plain make builds only the current host architecture, while the targets below build the full matrix or a specific target.
make all
make x86_64/linux
make x86_64/windows
make i686/linux
make i686/windows
make aarch64/linux
make aarch64/android
make armv7/linux
make armv7/android
make armv7hf/linux
make riscv64/linux
make powerpc64le/linux
make mips/linux
make mipsel/linux
make mips64el/linux
make s390x/linux
make loongarch64/linux
Beta Notice
This is a beta project tested only on Debian x86_64. It was created out of a personal need for these libraries, but no guarantees are provided regarding its stability or future support. You are free to test it, use it, and modify it as you please.
If you'd like to reach out, you can send an email to [email protected]. Please note that I do not accept pull requests; the goal is to avoid long-term dependency on platforms like GitHub, and I do not maintain fixed infrastructure to guarantee long-term stability for these projects.
Repo
You can download the repository and read the most up-to-date documentation directly from its official source.
GitHub: kaisarcode/mdp.c
License
This project is distributed under the GNU General Public License version 3 (GPLv3).
