pssg
is a lightweight static site generator (SSG) built with Python. It transforms your Markdown content into static HTML files using a provided template, incorporating static assets like CSS and images.
Key Features:
- Converts Markdown files from
/content
to HTML. - Uses
/static
for CSS, images, and other assets. - Outputs the generated site to the
/docs
directory. - Includes a simple development server with hot-reloading for content changes.
Note on Markdown Support: pssg
currently supports a specific subset of Markdown syntax.
- Block Elements (separated by blank lines):
Headings (`# H1` to `###### H6`)
Paragraphs
Blockquotes (`> quote`)
Code Blocks (fenced with `````)
Ordered Lists (`1. Item`)
Unordered Lists (`- Item` or `* Item`)
- Inline Elements:
Bold (`**bold**`)
Italic (`*italic*`)
Inline Code (``code``)
Links (`[text](link)`)
Images (``)
-
Clone the Repository:
# Make sure to use the correct repository name (pssg as per your original clone command) git clone https://github.com/ahm4dd/pssg.git cd pssg
-
Set up a Virtual Environment (Recommended): This isolates project dependencies.
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install Dependencies (Required for Testing/Development): If you only plan to run
pssg
using the provided scripts and don't need to run tests, you might skip this step (depending on whethermain.sh
relies on external libraries not bundled with Python). However, installing dependencies is generally good practice.pip install pytest
Note:
pssg
requires Python 3.12.3 or higher. (Recommended but it may work for some older versions)
Platform Note: The primary execution script (
main.sh
) is designed for Unix-like systems (Linux, macOS). It has not been tested on Windows. You may need to adapt the commands or run the underlying Python scripts directly on Windows.
This script typically performs the following actions:
- Cleans the output directory (/docs).
- Builds the HTML site from /content and /static into /docs.
- Starts a local development server.
To build the static site and start the development server with hot-reloading:
./main.sh
Access the generated site via the URL provided by the script (usually http://localhost:8080 or similar).
Press Ctrl+C to stop the server.
- Scanning:
pssg
scans the/content
directory for Markdown (.md
) files and the/static
directory for assets. - Parsing & Conversion: Each Markdown file is parsed according to the supported syntax and converted into an HTML fragment.
- Templating: The generated HTML fragment is inserted into the
template.html
file (typically replacing a placeholder like{{content}}
) to create the final HTML page structure. - Asset Copying: Files and directories from
/static
are copied directly into the output/docs
directory. - Output: All generated HTML files and copied static assets are placed in the
/docs
folder, ready for deployment.
Core Libraries Used:
- File System:
os
,shutil
,glob
(for finding files, copying, managing paths) - Parsing:
re
(for some Markdown pattern matching) - Testing:
unittest
,pytest
(for unit and integration tests, including mocking) - System:
sys
(for grabbing the repository from the build.sh file or any arguments passed to the python3 src/main.py command)
-
Ensure Dependencies are Installed: Make sure you have completed the Installation steps, including installing
requirements.txt
(which should includepytest
). -
Run Tests: Execute the test script:
./test.sh
This will typically discover and run all tests defined within the project using
pytest
.
Contributions are welcome! If you'd like to help improve pssg
:
- Fork the repository on GitHub.
- Create a new branch for your feature or bug fix.
- Make your changes and add tests if applicable.
- Ensure tests pass (
./test.sh
). - Commit your changes and push them to your fork.
- Open a Pull Request back to the main repository (
ahm4dd/pssg
).
Please open an issue first to discuss significant changes.
This project is licensed under the MIT License. See the LICENSE file for details.