Skip to main content

The text wizard - Transform text files with pluggable extensions

Project description

gtext Logo

🪄 gtext

The text wizard - Transform text files with pluggable extensions.

PyPI version Tests codecov Python 3.10+ License: MIT Documentation


✨ 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 cast report.md.gtext

# Or specify explicit output
gtext cast report.md.gtext -o report.md

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/**/]

📓 Learning with Interactive Tutorials

The best way to learn gtext is through our hands-on Jupyter notebooks.

Run Online (No Installation Required)

Binder

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 files
  • include-cli - Include command output
  • include-glob - Include files matching patterns

Future extensions:

  • ai-summarize - AI-powered summarization
  • ai-translate - Multi-language translation
  • validate-links - Check for broken links
  • generate-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


Made with ✨ by the Genro Team

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gtext-0.1.0.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gtext-0.1.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file gtext-0.1.0.tar.gz.

File metadata

  • Download URL: gtext-0.1.0.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gtext-0.1.0.tar.gz
Algorithm Hash digest
SHA256 da0e9ddd99d3b2edd67efaa8176073b92341a92dc9adfe348259e30c70d823f0
MD5 b5ee2cc87f0c15865fbe9f8bd03789ec
BLAKE2b-256 c4b7d7d16f2d2b68db5052975bcc9cc3c55d7f24d3f85cd62f8ca92e7eefe9d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtext-0.1.0.tar.gz:

Publisher: publish.yml on genropy/gtext

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtext-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gtext-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gtext-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 012846bda1546b4d1ec9a0929caf0ba4ef088357a1af58af4079cee0327173d7
MD5 326a4f841b402d29e7751a64127fceb4
BLAKE2b-256 c3e0822cd18c3c163702c0615e10c385da788504b28775a9366445d0a4347192

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtext-0.1.0-py3-none-any.whl:

Publisher: publish.yml on genropy/gtext

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page