main
Tolkien Fan Club
A static site generator that converts Markdown content into HTML pages. Built from scratch as a learning exercise for boot.dev.
Usage
# Build and serve locally
./main.sh
# Build with GitHub Pages basepath
./build.sh
# Run tests
./test.sh
Or directly:
python3 -m src <destination> <basepath>
python3 -m src "public" "/"
python3 -m src "docs" "/tolkien-fan-club/"
Project Structure
├── content/ # Markdown source files
├── static/ # Static assets (CSS, images)
├── template.html # HTML template with {{ Title }} and {{ Content }}
├── src/
│ ├── cli.py # Entry point
│ ├── copier.py # Static file copying
│ ├── generator.py # Page generation orchestration
│ ├── template.py # Template rendering + title extraction
│ ├── nodes/
│ │ ├── html.py # HtmlNode base class
│ │ ├── leaf.py # LeafNode (void/self-closing elements)
│ │ ├── parent.py # ParentNode (nested elements)
│ │ └── text.py # TextNode / TextType + conversion to HTML
│ ├── markdown/
│ │ ├── blocks.py # Block-level parsing (headings, code, lists, etc.)
│ │ ├── extract.py # Regex extraction for images and links
│ │ ├── inlines.py # Inline parsing (bold, italic, code, images, links)
│ │ └── to_html.py # Markdown → HTML conversion + block handlers
│ └── tests/ # Test suite (48 tests)
├── main.sh # Build + serve locally
├── build.sh # Build for GitHub Pages
└── test.sh # Run test suite
Pipeline
Markdown → blocks → block-type detection → inline parsing → TextNodes → HTML nodes → template injection
Requirements
- Python 3.13+
- No external dependencies
Tests
python3 -m unittest discover -s src/tests -v
License
MIT
Languages
Python
94.6%
CSS
4.3%
HTML
0.7%
Shell
0.4%