-
pyssg
is 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 -> ![alt-text](src-link)
- Nested blocks will throw
ValueError
forInvalid 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
HTML
files formarkdown
files present in/content
directory usingtemplate.html
and 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
/public
folder which is then served via TCP server - Every generated HTML page has a function which calls
/check_update
endpoint 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
socketserver
library for the TCP server along withSimpleHTTPRequestHandler
as the handler. os
,shutil
,glob
for file-related utilities.re
for parsing some parts of markdown file.unittest
andpytest
for testing, including mock-testing. (~160 tests)typing
for 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.