A tool for converting Markdown documents to beautifully styled HTML documents suitable for printing or sharing. This project wraps Markdown content with customizable HTML templates and uses Pandoc to generate the final output.
- Convert Markdown files to HTML with consistent styling
- Apply custom HTML templates and CSS
- Table of contents generation
- Code syntax highlighting
- Print-ready output
- Support for multiple CSS themes
- Python 3.6+
- Pandoc Installation
- Windows users:
- Using Scoop (recommended for convenience):
scoop install pandoc
- Or download the installer
- Using Scoop (recommended for convenience):
- macOS:
brew install pandoc
- Linux: Use your package manager (e.g.,
apt install pandoc
) - Verify installation with
pandoc --version
- Windows users:
-
Clone this repository:
git clone https://github.com/yourusername/doc_template.git cd doc_template
-
No additional Python package installation is required, as the script uses standard libraries.
Place your Markdown files in the docs
directory, then run:
python document_converter.py
HTML files will be generated in the dist
directory.
- Run the converter script:
python document_converter.py
- Open the generated HTML files in a browser
- Print using the browser's print function (or save as PDF)
python document_converter.py [--debug] [--input-dir DIRECTORY] [--output-dir DIRECTORY]
--debug
: Keep intermediate files for debugging--input-dir
: Directory containing markdown files (default: docs)--output-dir
: Directory for output files (default: dist)
- Markdown files from the input directory are processed with:
- Content from
templates/before-template.html
added at the beginning - Original content wrapped with
<div id="maincontent">
tags - Content from
templates/after-template.html
added at the end
- Content from
- Processed Markdown files are converted to HTML using Pandoc
- CSS files from the
css
directory are applied to the HTML output
.
├── document_converter.py # Main script
├── css/ # CSS styles for output HTML
│ ├── minimal-style.css # Primary styling
│ └── tokyo-night-light.css
├── docs/ # Place your Markdown files here
│ └── sample.md # Example document
├── templates/ # HTML templates
│ ├── after-template.html
│ ├── before-template.html
│ └── custom.html # Pandoc HTML template
└── README.md # This file
To contribute to this project:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License
- Pandoc - Used for document conversion
- highlight.js - For code syntax highlighting
- Noto Sans - Default font family