See the live demo here: https://maniac-en.github.io/pyssg/
- 
pyssgis a toy-project written in Python (v3.10.12) implementing the functionality like a SSG. - 
Note: It's not aimed to support the entire markdown syntax. It supports following:
- Multiline markdown blocks should be separated by newlines:
 
- Headings (1-6) - Paragraphs - Quoteblocks - Codeblocks - Ordered Lists - Unordered Lists- Inline blocks:
 
- Bold -> **bold** - Italic -> _italic_ - Codeblock -> `code` - Link -> [text](link) - Image -> - Nested blocks will throw 
ValueErrorforInvalid Markdown Syntax 
 - Multiline markdown blocks should be separated by newlines:
 - 
It serves the generated site using a TCP server whilst also supporting hot-reloading using out-of-the-box python libraries.
pyssg.mp4
 
- 
Clone the repository:
git clone https://github.com/maniac-en/pyssg.git cd pyssg - 
Create a virtual environment: (if you want to do testing, else skip this)
python -m venv venv source venv/bin/activate - 
Install the dependencies: (if you want to do testing, else skip this)
pip install -r requirements.txt
 
Note: Not tested on
Windows
To generate the static site and start the server, run:
./main.sh- Install pytest:
 
- Using 
pip: 
pip install pytest- Or, install from requirements.txt:
 
pip install -r requirements.txt- Run the tests:
 
./test.sh- It generates the 
HTMLfiles formarkdownfiles present in/contentdirectory usingtemplate.htmland static contents such as CSS, Images from/src/static. - Required files and their filestamps are stored before the server starts so it can check for file changes for hot-reloading.
 - Generated site is stored into 
/publicfolder which is then served via TCP server - Every generated HTML page has a function which calls 
/check_updateendpoint on the TCP server every second, server validates if something changed: 
- If yes, it'll regenerate the site and refresh the page that asked to check the update!
 - Logging is disabled for the this because it happens every second and would simply clutter the logs.
 
- Using 
socketserverlibrary for the TCP server along withSimpleHTTPRequestHandleras the handler. os,shutil,globfor file-related utilities.refor parsing some parts of markdown file.unittestandpytestfor testing, including mock-testing. (~160 tests)typingfor type-hints.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.