Skip to content

Armivio/SRG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Static Site Generator

A Python-based static site generator that converts Markdown files to HTML, similar to Jekyll, Hugo, or Gatsby. This project was created as part of the boot.dev learning path.

Features

  • Converts Markdown files to static HTML pages
  • Supports common Markdown syntax:
    • Headers (h1-h6)
    • Bold and italic text
    • Code blocks with syntax highlighting
    • Links and images
    • Ordered and unordered lists
    • Blockquotes
  • Recursive directory processing
  • Template-based page generation

Project Structure

static_site_generator/
├── src/                          # Source code directory
│   ├── main.py                   # Main entry point
│   ├── htmlnode.py               # HTML node classes
│   ├── textnode.py               # Text node definitions
│   ├── markdown_to_html_node.py  # Markdown conversion
│   ├── text_to_blocks.py         # Text block parsing
│   ├── text_to_textnodes.py      # Text node conversion
│   ├── text_to_html.py           # HTML conversion
│   ├── extractors.py             # Link/image extraction
│   ├── generate_page.py          # Page generation
│   └── recursive_public_generator.py  # Public dir management
├── public/                       # Generated site directory
│   ├── index.html               # Generated pages
│   ├── index.css                # Site styling
│   └── images/                  # Image assets
├── template.html                # HTML template
├── main.sh                      # Run script with dev server
└── test.sh                      # Test runner script

Installation

  1. Clone the repository
git clone https://github.com/Armivio/SRG
cd static-site-generator
  1. Ensure you have Python 3.12.3 installed

Usage

  1. Add your Markdown content files to the content directory

  2. Use the template.html file for page structure:

    • {{ Title }} - Will be replaced with the page title
    • {{ Content }} - Will be replaced with the page content
  3. Run the generator and development server:

./main.sh

This will:

  1. Generate the static site in the public directory
  2. Start a development server at http://localhost:8888

Alternatively, just build without the server:

python3 src/main.py

Testing

Run the test suite:

./test.sh

or

python3 -m unittest discover -s src

Styling

The site comes with a built-in dark theme styled similarly to GitHub's dark mode, featuring:

  • Dark background with light text
  • Syntax highlighting for code blocks
  • Responsive design
  • Styled blockquotes and links
  • GitHub-like typography

Development

The project uses an object-oriented approach with several key components:

  • HTMLNode: Base class for HTML elements
  • TextNode: Text content handler with support for various formats
  • Block parsers for Markdown structures
  • Recursive directory handling
  • Development server for local testing

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

This project was developed as part of the boot.dev guided project "Build a Static Site Generator". The .css file, the long Markdown files, and the HTML template file were provided by boot.dev. The skeleton of the tests (and small bits of code where I could not solve the issues) were generated by ChatGPT o3-mini and o3-mini-high. However, heavy tinkering, modifications, and adaptations were required for the tests (and the other bits of code) to be useful and correct. Apart from that, all the code was written by me, during a ~3-day span.

About

A static site generator built in Python that converts Markdown files to HTML with a dark theme GitHub-style design. Created through boot.dev's guided project course, this tool supports Markdown features including headings, lists, code blocks, and more, with built-in development server functionality.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages