The text wizard - Transform text files with pluggable extensions
Project description
🪄 gtext
The text wizard - Transform text files with pluggable extensions.
✨ What is gtext?
gtext is a universal text processor with a pluggable extension system. Transform any text file through customizable plugins:
- 📝 Include files (static, dynamic, glob patterns)
- 🤖 AI processing (summarization, translation)
- 💻 Code generation (headers, boilerplate)
- ✅ Validation (links, spelling)
- 🔄 And much more...
Created by the Genro Team. Universal and standalone.
🚀 Quick Start
Installation
pip install gtext
Basic Usage
File Extension Convention
gtext uses the .gtext extension to identify source files:
# Double extension (auto-detect output format)
document.md.gtext → document.md
script.py.gtext → script.py
config.yaml.gtext → config.yaml
Example
Source file (report.md.gtext):
# Monthly Report
## Company Stats
```include
cli: python scripts/get_stats.py --format markdown
```
## Team Structure
```include
docs/team-structure.md
```
## All Project Docs
```include
glob: projects/**/README.md
```
Generate expanded document:
# Auto-detect output (strip .gtext extension)
gtext render report.md.gtext
# Or specify output file/directory
gtext render report.md.gtext report.md
gtext render report.md.gtext output/
# Process multiple files or patterns
gtext render "docs/**/*.gtext" output/
Re-render after changes (using saved metadata):
# Modify report.md.gtext, then refresh
gtext refresh report.md.gtext
# Or refresh all .gtext files with saved outputs
gtext refresh
Result (report.md):
# Monthly Report
## Company Stats
| Metric | Value |
|--------|-------|
| Revenue | $1.2M |
| Users | 10,453 |
## Team Structure
[content from docs/team-structure.md]
## All Project Docs
[all README.md files from projects/**/]
🆕 New in v0.2.0: The
rendercommand now intelligently handles single files, multiple files, and patterns. The oldcastandcast-allcommands are deprecated (but still work) and will be removed in v0.3.0.
📓 Learning with Interactive Tutorials
The best way to learn gtext is through our hands-on Jupyter notebooks.
Run Online (No Installation Required)
Click the badge above to launch an interactive Jupyter environment in your browser. Ready in ~2 minutes!
Run Locally
# 1. Install Jupyter
pip install jupyter notebook
# 2. Navigate to notebooks directory
cd notebooks
# 3. Launch Jupyter
jupyter notebook
# 4. Open 01_rag_prompt_engineering.ipynb and start learning!
Tutorial Contents
| Notebook | Topic | Duration | Level |
|---|---|---|---|
| 01 - RAG & Prompt Engineering | AI/LLM integration, composable prompts | 30 min | Intermediate |
More tutorials coming soon! See notebooks/README.md for the complete learning guide.
🎯 Key Features
1. Include Static Files
```include
path/to/file.md
### 2. Include Command Output
```markdown
```include
cli: genro project list --format markdown
### 3. Include Multiple Files with Glob
```markdown
```include
glob: docs/**/*.md
### 4. Mix All Types
```markdown
```include
header.md
cli: python get_stats.py
glob: sections/*.md
footer.md
---
## 📚 Use Cases
### Documentation
- **Living docs** that update from real data
- **Multi-file documentation** aggregation
- **Auto-generated API docs** from code
### Code Management
- **License headers** across codebase
- **Boilerplate injection**
- **Shared imports** and configs
### Reporting
- **Dynamic reports** with live database queries
- **System monitoring** snapshots
- **Business dashboards** in Markdown
### Content Management
- **Blog post templates** with includes
- **Multi-language content**
- **Reusable content blocks**
---
## 🛠️ CLI Commands
```bash
# Expand single file (auto-detect output)
gtext cast document.md.gtext
# Explicit output path
gtext cast document.md.gtext -o output.md
# Expand all .gtext files in directory
gtext cast-all docs/**/*.gtext
# Watch mode (auto-regenerate on changes)
gtext watch docs/**/*.gtext
# Dry run (preview without writing)
gtext cast document.md.gtext --dry-run
🔌 Plugin System
gtext is built on a pluggable architecture. Extensions are easy to create:
from gtext.extensions import BaseExtension
class MyExtension(BaseExtension):
name = "my-plugin"
def process(self, content: str, context: dict) -> str:
# Your transformation logic
return transformed_content
Built-in extensions:
include- Include static filesinclude-cli- Include command outputinclude-glob- Include files matching patterns
Future extensions:
ai-summarize- AI-powered summarizationai-translate- Multi-language translationvalidate-links- Check for broken linksgenerate-toc- Auto table of contents- And more...
📖 Documentation
Full documentation available at: gtext.readthedocs.io
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
📜 License
MIT License - see LICENSE for details.
🌟 About
gtext is created by Giovanni Porcari with contributions from the Genro Team.
Like a weaverbird 🪶 that masterfully weaves materials together, gtext weaves different content sources into unified documents.
gtext is:
- ✅ Standalone - No dependencies on other frameworks
- ✅ Universal - Works with any text format
- ✅ Open - MIT licensed and community-driven
🔗 Links
- GitHub: github.com/genropy/gtext
- PyPI: pypi.org/project/gtext
- Documentation: gtext.readthedocs.io
- Issues: github.com/genropy/gtext/issues
- Genro Project: github.com/genropy/genro-next-generation
Made with ✨ by the Genro Team
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 gtext-0.2.0.tar.gz.
File metadata
- Download URL: gtext-0.2.0.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2880f316f3d7c7636060c08afefd4fba5f200e167866aa2d9a2ced80592d5c7c
|
|
| MD5 |
25975a5951129c1622891d8c296c1828
|
|
| BLAKE2b-256 |
36ba4969909a184c1dd47c07d31a4ef464820cf3ed5679b027e9ed6b9caab262
|
Provenance
The following attestation bundles were made for gtext-0.2.0.tar.gz:
Publisher:
publish.yml on genropy/gtext
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gtext-0.2.0.tar.gz -
Subject digest:
2880f316f3d7c7636060c08afefd4fba5f200e167866aa2d9a2ced80592d5c7c - Sigstore transparency entry: 661560609
- Sigstore integration time:
-
Permalink:
genropy/gtext@58e98ec09d8d6db405477bc7a59e107fec33faca -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/genropy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@58e98ec09d8d6db405477bc7a59e107fec33faca -
Trigger Event:
push
-
Statement type:
File details
Details for the file gtext-0.2.0-py3-none-any.whl.
File metadata
- Download URL: gtext-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.6 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 |
4243609333ade5ee7c0ed8f3f2318964cda9f179b4b3cc2a296c1fcacdf0f7b7
|
|
| MD5 |
d2663b53990441ec55ca2295d0635b9b
|
|
| BLAKE2b-256 |
16f085baff2ef52cb8e4bca3987703a20305bed5642af54f023d179823ffba41
|
Provenance
The following attestation bundles were made for gtext-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on genropy/gtext
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gtext-0.2.0-py3-none-any.whl -
Subject digest:
4243609333ade5ee7c0ed8f3f2318964cda9f179b4b3cc2a296c1fcacdf0f7b7 - Sigstore transparency entry: 661560623
- Sigstore integration time:
-
Permalink:
genropy/gtext@58e98ec09d8d6db405477bc7a59e107fec33faca -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/genropy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@58e98ec09d8d6db405477bc7a59e107fec33faca -
Trigger Event:
push
-
Statement type: