This project converts a Markdown file into an HTML file with minimal external dependencies (only the C++ standard library).
To match a C-style learning flow, each module keeps declaration + implementation in the same .cpp file (no separate .h/.hpp files).
The code is still split by responsibility:
- Lexical analysis (
src/lexer.cpp): turns markdown text into block-level tokens. - Syntax analysis / parsing (
src/parser.cpp): turns tokens into a simple AST-like structure. - Rendering (
src/renderer.cpp): converts parsed nodes into HTML. - File I/O (
src/file_io.cpp): handles reading/writing files. - Entry point (
src/main.cpp): includes module.cppfiles and runs the pipeline.
- Headings (
#to######) - Paragraphs
- Unordered lists (
-,*,+) - Fenced code blocks (```)
- Inline formatting:
- bold (
**text**) - italic (
*text*) - inline code (
`code`) - links (
[text](url))
- bold (
cmake -S . -B build
cmake --build buildBinary output:
./build/mdtohtmlg++ -std=c++17 src/main.cpp -o mdtohtml./build/mdtohtml input.md [output.html]or (if built with direct g++):
./mdtohtml input.md [output.html]If output.html is omitted, the program uses the input filename with a .html extension.
./build/mdtohtml notes.md
# writes notes.htmlExample markdown file (examples/sample.md):
# Demo
A paragraph with **bold**, *italic*, and `inline code`.
- item 1
- item 2 with a [link](https://example.com)
```cpp
int x = 42;
Generate HTML:
```bash
./build/mdtohtml examples/sample.md examples/sample.html