MkDocs plugin and build pipeline for text-based websites with EPUB generation, live editor, and GitHub integration.
pip install sg-text-forge# .github/workflows/publish.yml
- uses: shared-goals/text-forge@main
with:
mkdocs_config: mkdocs.yml
docs_dir: text/ru
site_dir: public/ruAdd 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_* optionstext-forge epub --config=mkdocs.yml --build-dir=buildtext-forge build --config=mkdocs.yml --build-dir=build- 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 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
- "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
- 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
- Composite action (
action.yml) for one-step publishing - Builds site + EPUB in single workflow
- GitHub Pages deployment ready
- Example: whattodo publish workflow
- 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, ...
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)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)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 overridesgit clone https://github.com/shared-goals/text-forge.git
cd text-forge
make install # uv syncmake 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)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
- Python β₯ 3.11
- Pandoc (for EPUB generation)
- MkDocs Material theme
- Git (for version/date metadata)
MIT License - see LICENSE
Contributions welcome! Please open issues or pull requests at github.com/shared-goals/text-forge.