A Markdown-to-HTML compiler written in Python. This project demonstrates core concepts of compiler construction, including lexical analysis, parsing, syntax transformation, and code generation.
The compiler follows a classic pipeline:
- Lexer (Tokenizer): Scans the raw Markdown input and produces a list of tokens.
- Parser: Processes tokens into an abstract syntax tree (AST) representing the document structure.
- Code Generator: Converts the AST into the target language (HTML).
- Headers (
#,##, etc.) - Bold / Italic text
- Ordered and Unordered Lists
- Code Blocks
- Inline Code
- Blockquotes
- Horizontal Rules
- Links & Images
A full example of compiled output can be found in testdata/example.html.
from compiler import Compiler
Compiler().compile('# Hello world')
# => '<h1>Hello world</h1>'make venv && source .venv/bin/activatemake testPython, FastAPI, Pytest
MIT
