A lightwieght, handwritten Markdown-to-HTML compiler written in Python.
Anvil is a lightweight Markdown-to-HTML compiler built from scratch - no third-party parsing libraries, no regex shortcuts. It was written as a personal exercise in understanding how compilers work at a fundamental level, following the classic lexer → parser → generator pipeline.
1. Lexical Analysis - Scans the raw Markdown string character-by-character and produces a flat list of tokens.
2. Parser - Consumes the token stream and builds an Abstract Syntax Tree.
3. Generator - Walks the Abstract Syntax Tree and emits the corresponding HTML string for each node type.
| Syntax | Output |
|---|---|
# Heading 1 through ###### Heading 6 |
<h1>-<h6> |
**bold** |
<strong> |
*italic* |
<em> |
`inline code` |
<code> |
``` |
<pre><codeclass="language-..."> |
- item / * item |
<ul> |
1. item |
<ol> |
> blockquote |
<blockquote> |
[text](url) |
<a> |
 |
<img> |
--- |
<hr> |
- This is just self-driven personal project, meaning:
- The code will be messy
- There will be bugs
初心者向けではなく、勉強のために書いたコードです。乱雑な部分も多いですが、ご了承ください。
| Feature | Priority | Notes |
|---|---|---|
| Broader Markdown spec coverage | high | Strikethrough, tables, task lists |
| Proper error reporting | high | line / column numbers, descriptive messages |
| AST optimisations / transformations | low | e.g. merging adjacent text nodes |
| CLI interface | low | Accept file paths as arguments |