armandmcqueen/textplate

Text templating in markdown

★ 0Forks 0PythonGitHub ↗Compare

README

textplate

A markdown-based templating tool. Write .textplate.md files with special text:: links, then run textplate press to resolve all references into plain markdown.

Install

git clone <repo-url> && cd textplate
uv sync

Quick Start

Source files are just plain text or markdown — nothing special about them:

# greeting.txt
Hello from a reusable snippet!

To pull a specific section from a markdown file, reference it by heading (GitHub-style slug):

# notes.md

## Intro

This part can be referenced by name.

## Other Stuff

This won't be included.

Create a template (doc.textplate.md):

# My Document

[](text::./greeting.txt)

[](text::./notes.md#intro)

Press it:

uv run textplate press doc.textplate.md        # writes doc.md
uv run textplate press doc.textplate.md --stdout  # prints to stdout

Or watch it and re-press automatically:

uv run textplate watch doc.textplate.md --every 5s

Syntax

[](text::./path/to/file.txt)           # inline entire file
[](text::./path/to/file.md#section)    # inline section body (heading excluded)
[](text::./path/to/file.md#section!)   # inline section with its heading
  • text:: prefix marks a template reference
  • #fragment uses GitHub-style heading slugs (lowercase, spaces→hyphens)
  • A section includes everything under a heading until the next heading of the same or higher level
  • By default the heading line is excluded; append ! to include it (#intro!)
  • Output naming: foo.textplate.md → foo.md. Otherwise foo.md → foo.filled.md.
  • Strict mode: if any reference can't be resolved, the command fails with no partial output.

Testing

uv run pytest

Demo

See demo/ for a working example:

uv run textplate press demo/docs.textplate.md --stdout

Contributors

armandmcqueen

Issues