MkDocs plugin and build pipeline for Markdown text projects with EPUB generation
Project description
text-forge
MkDocs plugin and build pipeline for text-based websites with EPUB generation, live editor, and GitHub integration.
Installation
As Python Package
pip install sg-text-forge
As GitHub Action
# .github/workflows/publish.yml
- uses: shared-goals/text-forge@main
with:
mkdocs_config: mkdocs.yml
docs_dir: text/ru
site_dir: public/ru
Quick Start
1. Configure MkDocs Plugin
Add to your mkdocs.yml:
plugins:
- text-forge:
editor_enabled: true # Enable live editor (default: true)
nobr_emoticons_enabled: true # Wrap emoticons in no-break spans (default: true)
downloads_enabled: false # Show EPUB download button (default: false)
ai_readable_enabled: false # Show "Open in Perplexity" button (default: false)
epub_title: "My Book" # EPUB metadata (optional)
epub_author: "Author Name"
# ... other epub_* options
2. Build EPUB
text-forge epub --config=mkdocs.yml --build-dir=build
3. Build Complete Site
text-forge build --config=mkdocs.yml --build-dir=build
Features
๐ Live Editor Widget
- Browser-based markdown editor with real-time preview
- Pyodide + PyMdown Extensions for client-side rendering
- Dual save modes:
mkdocs serve: Auto-saves to local filesystem- Production: Commits to GitHub via Personal Access Token
- Split-pane interface with synchronized scrolling
- Responsive design (mobile: editor only, desktop: split view)
- i18n support (Russian translations included)
๐ GitHub Integration
- GitHub API commits via Personal Access Token
- Auto-triggers CI/CD workflows on commit
- Path-safe writes with security validation
- Local fallback when GitHub token unavailable
๐ค AI Agent Integration
- "Open in Perplexity" button for AI-powered content analysis
- Combined markdown export (
text_combined.md) with all chapters - Normalized anchors and links for easy navigation
- AI-readable format for semantic search and Q&A
- Privacy-first: Disabled by default, opt-in via
ai_readable_enabled
๐ EPUB Generation
- Chapter combining from
mkdocs.ymlnavigation structure - PyMdown โ Pandoc syntax normalization via Lua filter
- Metadata processing with git version/date extraction
- Custom CSS styling for professional EPUB output
- Asset bundling (images, resources)
- Pandoc-based for wide e-reader compatibility
๐ GitHub Actions
- Composite action (
action.yml) for one-step publishing - Builds site + EPUB in single workflow
- GitHub Pages deployment ready
- Example: whattodo publish workflow
๐จ Material Theme Integration
- Auto-configures Material theme overrides
- Custom partials: editor, downloads, header
- Custom assets: editor.js, editor.css, translations.json
- EPUB download button in header (when enabled)
- Custom blocks: situation, music, chapter-dates, ...
CLI Commands
text-forge epub
Build EPUB from MkDocs project.
text-forge epub [OPTIONS]
Options:
--config PATH Path to mkdocs.yml (default: mkdocs.yml)
--build-dir PATH Build output directory (default: build)
text-forge build
Build complete site (EPUB + MkDocs site).
text-forge build [OPTIONS]
Options:
--config PATH Path to mkdocs.yml (default: mkdocs.yml)
--build-dir PATH Build directory (default: build)
--site-dir PATH MkDocs output (default: from mkdocs.yml)
--strict/--no-strict Fail on warnings (default: true)
--copy-artifacts/--no-copy-artifacts
Copy EPUB to site root (default: true)
--create-404-redirect/--no-create-404-redirect
Create 404.html for /ru/* redirects (default: true)
Plugin Configuration
MkDocs Plugin Options
plugins:
- text-forge:
# Editor
editor_enabled: true # Show editor widget
nobr_emoticons_enabled: true # Wrap emoticons in md-nobr
# Downloads
downloads_enabled: false # Show EPUB download button
ai_readable_enabled: false # Show "Open in Perplexity" button
# EPUB Metadata (overrides site_name, site_author, etc.)
epub_title: "" # Book title
epub_subtitle: "" # Book subtitle
epub_author: "" # Author name
epub_identifier: "" # ISBN or URL
epub_publisher: "" # Publisher name
epub_rights: "" # Copyright notice
# UI Labels
source_file_published_title: "Published" # Source link label
# Theme
auto_configure_theme: true # Auto-set theme overrides
Development
Setup
git clone https://github.com/shared-goals/text-forge.git
cd text-forge
make install # uv sync
Commands
make format # Format code with ruff
make lint # Run linters
make test # Run tests with pytest
make check-i18n # Validate translation keys
make release # Interactive release (bump version, tag, push)
Project Structure
text-forge/
โโโ text_forge/ # Python package
โ โโโ plugin.py # MkDocs plugin
โ โโโ build.py # Build pipeline
โ โโโ cli.py # CLI commands
โโโ scripts/ # Build scripts
โ โโโ mkdocs-combine.py # Chapter combiner
โ โโโ pymdown-pandoc.lua # Pandoc Lua filter
โ โโโ process-epub-meta.py # Metadata processor
โโโ mkdocs/
โ โโโ overrides/ # Material theme overrides
โ โ โโโ partials/ # HTML templates
โ โ โโโ assets/ # JS, CSS, translations
โ โโโ hooks/ # MkDocs hooks
โโโ epub/ # EPUB templates
โ โโโ book_meta.yml # Metadata template
โ โโโ epub.css # EPUB styles
โโโ tests/ # Pytest tests
Example Projects
Requirements
- Python โฅ 3.11
- Pandoc (for EPUB generation)
- MkDocs Material theme
- Git (for version/date metadata)
License
MIT License - see LICENSE
Contributing
Contributions welcome! Please open issues or pull requests at github.com/shared-goals/text-forge.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sg_text_forge-0.1.13.tar.gz.
File metadata
- Download URL: sg_text_forge-0.1.13.tar.gz
- Upload date:
- Size: 92.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfe9d84e6b13b47bc3047c1920c98c7f4d8d6da8d3bbc5e0f4f661ba375e3d8a
|
|
| MD5 |
9cd175f87890d55191666bc544203696
|
|
| BLAKE2b-256 |
067329db64b5ae4ddeff328c2cdeb4fd854b042ad61df9398fbc7a23a237965b
|
Provenance
The following attestation bundles were made for sg_text_forge-0.1.13.tar.gz:
Publisher:
publish-pypi.yml on shared-goals/text-forge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sg_text_forge-0.1.13.tar.gz -
Subject digest:
bfe9d84e6b13b47bc3047c1920c98c7f4d8d6da8d3bbc5e0f4f661ba375e3d8a - Sigstore transparency entry: 1122506108
- Sigstore integration time:
-
Permalink:
shared-goals/text-forge@8bd2a0fe7c3ddb375e59f1fdbc13037fcae8a4ba -
Branch / Tag:
refs/tags/v0.1.13 - Owner: https://github.com/shared-goals
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@8bd2a0fe7c3ddb375e59f1fdbc13037fcae8a4ba -
Trigger Event:
push
-
Statement type:
File details
Details for the file sg_text_forge-0.1.13-py3-none-any.whl.
File metadata
- Download URL: sg_text_forge-0.1.13-py3-none-any.whl
- Upload date:
- Size: 58.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dad608e73b820313733f14d0fa2b8236fa382c0843de3e5ad5fe2979eb30f1fb
|
|
| MD5 |
bdc74524817bfe3b3e594b4437ef8b91
|
|
| BLAKE2b-256 |
94cd2809e361431dcbfb7bef62ddf986f4725b2f9ea55cceb93aaffd311d9b29
|
Provenance
The following attestation bundles were made for sg_text_forge-0.1.13-py3-none-any.whl:
Publisher:
publish-pypi.yml on shared-goals/text-forge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sg_text_forge-0.1.13-py3-none-any.whl -
Subject digest:
dad608e73b820313733f14d0fa2b8236fa382c0843de3e5ad5fe2979eb30f1fb - Sigstore transparency entry: 1122506113
- Sigstore integration time:
-
Permalink:
shared-goals/text-forge@8bd2a0fe7c3ddb375e59f1fdbc13037fcae8a4ba -
Branch / Tag:
refs/tags/v0.1.13 - Owner: https://github.com/shared-goals
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@8bd2a0fe7c3ddb375e59f1fdbc13037fcae8a4ba -
Trigger Event:
push
-
Statement type: