transcript
Python DSL for composing HTML, Jinja2, SCSS and JavaScript as nested code containers.
Data flows with overloaded operators << (inject) and >> (export).
Install
pip install transcript
Optional extras:
pip install transcript[jinja] # Jinja2 runtime
pip install transcript[preview] # live preview helpers
pip install transcript[ai] # LangChain helpers
pip install transcript[dev] # pytest, build, twine
pip install transcript[docs] # MkDocs
pip install transcript[all]
Requires Python 3.13+.
Quick start
from transcript import Div, File, HTMLArg, P, SCSS
from transcript.presets import HTML5Document
page = HTML5Document(title='Hello', lang='en')
hero = Div()
hero << HTMLArg('id', 'top') << P('Built with transcript')
page.body << hero
page >> File('templates/index.html')
html = page >> str
Core ideas
Every block (tag, rule, function) is a container: opening, body, closing.
| Expression | Meaning |
|---|---|
a << b |
inject block / value into a |
a << HTMLArg(...) / XMLArg(...) |
set opening-tag attributes |
a << File(...) |
inject file contents |
a << JsonData(...) |
attrs + nested content from JSON |
a << CSSClass('hero') |
add CSS class name to class |
a >> str |
export generated code |
a >> File('out.html') |
write to disk |
a >> JsonData() |
serialize structure to JSON |
a >> Renderer() |
push code into a renderer |
Reverse the pipeline with load:
from transcript import load
data = load('templates/index.html') # JsonData
tree = load('templates/index.html', as_container=True)
SCSS, BEM and Tailwind-like utilities
from transcript import BEM, CSSClass, Tailwind, tw, Div
card = BEM('card', display='grid')
card << CSSClass('title', font_size='1.25rem') # &__title
card.modifier('featured') # &--featured
Div(class_=tw('flex', 'items-center', 'gap-4', 'p-4', 'bg-white'))
sheet = Tailwind(utilities=('layout', 'spacing', 'color'))
JavaScript
from transcript import JS, JSFunction, JSLine, File
script = JS()
script << JSFunction('init', 'root', JSLine("root.classList.add('ready')"))
script >> File('static/app.js')
Project generate + purge
from transcript import Project, JS, tw, Div
from transcript.presets import HTML5Document
from transcript.presets.tailwind import Tailwind
project = Project('myapp')
page = HTML5Document(title='App')
page.body << Div(class_=tw('flex', 'gap-4', 'p-4'))
project.add('index.html', page)
project.add('app.scss', Tailwind(utilities=('layout', 'spacing')))
project.add('app.js', JS())
project.generate() # writes files; purges unused utility classes
Hub (prebuild store)
from transcript import Hub, JsonData
hub = Hub() # TRANSCRIPT_HUB_URL + token/api_key from .env
block = hub.get('hero-card')
hub.post(page >> JsonData(), prebuild_id='home')
See .env.example for variable names.
Documentation
Full docs live in docs/:
- Getting started
- Operators & IO
- HTML & Jinja
- SCSS / BEM / Tailwind
- JavaScript
- Project & purge
- Publishing to PyPI
Build the site locally:
pip install transcript[docs]
mkdocs serve
Development
python -m venv .venv
.venv\Scripts\activate # Windows
pip install -e ".[dev]"
pytest
License
MIT — see LICENSE.
Metadata
Release files for transcript 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| transcript-0.4.0.tar.gz | 54.4 kB | Without provenance | Details for transcript-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| transcript-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for transcript-0.4.0-py3-none-any.whl |
Total release size: 111.4 kB
Release files / transcript-0.4.0.tar.gz
| Download URL | transcript-0.4.0.tar.gz |
|---|---|
| Size | 54.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
48255400aa4f4b26d45fc8449d97f56f28ffcc302c1863327cf8aee4bea44877
|
|
BLAKE2b-256 checksum How to use checksums |
f54d9bc172c88a0fd3915d9c2d560d8797800b34d966ce74a02b39c83967caea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.1
|
Release files / transcript-0.4.0-py3-none-any.whl
| Download URL | transcript-0.4.0-py3-none-any.whl |
|---|---|
| Size | 57.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e82c59632cbbd5f976e928477a7056cff4da1f8168c424b62c06964d55adc69
|
|
BLAKE2b-256 checksum How to use checksums |
81dbcbaccaac03840e3193b42435f1a15ec5dcda36973210240f02bf38d34dc7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.1
|
Security for transcript 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.