Generate branded Office templates from design tokens
Project description
TokenMoulds
A corporate template system for Microsoft Office and LibreOffice. Point it at a brand, get publication-quality Word, PowerPoint, Excel, and LibreOffice templates — with embedded fonts, baseline grids, OOXML compliance validation, and long-form document support for whitepapers, annual reports, manuals, and bound books.
Install
pip install tokenmoulds
Quick Start
Generate templates from brand inputs:
tokenmoulds --org-id="acme" \
--font-pair="inter-roboto" \
--primary-color="#2563EB" \
--secondary-color="#DC2626" \
--locale="GB" \
--brand-tone=0.3 \
--generate-templates --generate-odf
Or from a DTCG token file:
tokenmoulds --org-id="acme" \
--tokens-file="design.tokens.json" \
--generate-templates
What It Does
~30 brand inputs (colors, fonts, tone) produce 4,576 derived design tokens across 11 output formats. Every template ships with:
- WCAG AAA accessible contrast ratios
- Embedded fonts with ODTTF obfuscation (Word) and EOT with GSUB (PowerPoint)
- OpenType typography: contextual figures, size-dependent tracking, ligatures
- Baseline grid-snapped typography via modular type scales
- ISO 29500 (OOXML) and ODF schema compliance
- Zero macros — all styling baked into document structure
Long-Form Documents
Corporate whitepapers, annual reports, manuals, and bound books need more than a single page layout. They need sections — front matter with roman-numeral page numbers, a body with running chapter titles and decimal numbering, an appendix that continues the count. Each section with its own headers, footers, and page geometry.
TokenMoulds generates long-form structure from a small token vocabulary
and emits it consistently across both Word (.dotx) and LibreOffice
Writer (.ott) from one shared IR. Features:
- Per-section page geometry — A4, A5, B5, Letter, portrait or landscape, margins as formulas against the baseline grid
- Mirror margins — inner/outer semantics for bound documents, facing pages automatically flip
- Running headers —
STYLEREF:Heading1fields that update as the reader moves through chapters (Word) /<text:chapter>fields (Writer) - Per-section page numbering —
lowerRomanfor front matter,decimalrestart for the body, continuing counts for appendices - Odd/even headers — book-style layouts with different left-hand and right-hand page content
- First-page different — cover pages, chapter openers
- Multi-column sections — indexes, newsletters
- Cross-format parity — one IR → structurally identical
.dotxand.ott, locked down by a golden master test suite
See Long-Form Documents guide for a walkthrough with a three-section whitepaper example.
Output Formats
| Format | Extension | Highlights |
|---|---|---|
| Word | .dotx |
276 themed paragraph, character, and table styles |
| PowerPoint | .potx |
Theme colors, embedded fonts, table styles, layouts |
| Excel | .xltx |
Themed cell styles and number formats |
| Writer | .ott |
110 ODF styles with page geometry |
| Impress | .otp |
ODF presentation template |
| Calc | .ots |
ODF spreadsheet template |
| Draw | .otg |
ODF drawing template |
| Google Docs | .dotx |
Optimized for Google Workspace import |
| Theme | .thmx |
Standalone Office theme package |
MCP Server
For AI-assisted document creation via Claude, Cursor, or other MCP clients:
tokenmoulds mcp-server
28 tools for brand extraction, template generation, document creation, validation, and cache management. See the MCP tool catalog.
Python API
from tokenmoulds.pipeline import BuildConfig, build
result = build(BuildConfig(
org_id="acme",
output_formats=["potx", "dotx", "xltx"],
brand_inputs={
"font_pair": {"sans": "Inter", "serif": "Roboto Slab"},
"base_colors": {"primary": "#2563EB", "secondary": "#DC2626"},
"locale": "US",
"brand_tone": 0.5,
},
))
for fmt, data in result.artifacts.items():
open(f"acme.{fmt}", "wb").write(data)
Architecture
TokenMoulds uses a single canonical build pipeline:
Design Tokens → DesignResolutionEngine → DocumentIR → Emitters → Validated Packages
- DTCG pipeline: W3C Design Tokens Community Group format with 5-layer resolution (core/fork/org/group/personal)
- Design engine: Modular type scale, baseline grid, OpenType features, tone/density adaptation
- Document IR: Format-agnostic intermediate representation
- 11 emitters: Each produces a complete, valid package
- Validation: In-process ISO 29500 schema checking via openxml-audit
See ADR 027 for the full convergence story.
Development
git clone https://github.com/BramAlkema/TokenMoulds.git
cd TokenMoulds
python -m venv venv && source venv/bin/activate
pip install -e ".[dev]"
python -m pytest tests/ -v --tb=short # 2,060 tests
Contributing
See CONTRIBUTING.md for development guidelines, code conventions, and how to submit changes.
Documentation
License
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 tokenmoulds-3.6.4.tar.gz.
File metadata
- Download URL: tokenmoulds-3.6.4.tar.gz
- Upload date:
- Size: 603.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ff4cde17c37e7125682853abd919b6f32827fe1e8359fdde5023867036f2eba
|
|
| MD5 |
452f087c32bbf24c404981eda8f8b846
|
|
| BLAKE2b-256 |
00793b7ab67a5a07c733b72ad11746f641fb450fde2425b4e53c2c93b5faae7b
|
Provenance
The following attestation bundles were made for tokenmoulds-3.6.4.tar.gz:
Publisher:
06-publish-pypi.yml on BramAlkema/TokenMoulds
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tokenmoulds-3.6.4.tar.gz -
Subject digest:
0ff4cde17c37e7125682853abd919b6f32827fe1e8359fdde5023867036f2eba - Sigstore transparency entry: 1417518314
- Sigstore integration time:
-
Permalink:
BramAlkema/TokenMoulds@8af9ee2dcab659c9e7c6cb535184569c81b08b43 -
Branch / Tag:
refs/tags/v3.6.4 - Owner: https://github.com/BramAlkema
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
06-publish-pypi.yml@8af9ee2dcab659c9e7c6cb535184569c81b08b43 -
Trigger Event:
release
-
Statement type:
File details
Details for the file tokenmoulds-3.6.4-py3-none-any.whl.
File metadata
- Download URL: tokenmoulds-3.6.4-py3-none-any.whl
- Upload date:
- Size: 732.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9d508f472aaf84c697316ea54272a450094beb2eac311b0151003d419c88acb
|
|
| MD5 |
103d8bee222b547d94ab32c1c32a1ae8
|
|
| BLAKE2b-256 |
7acdff260723a88e2d4bb1efb2828d588d106534ea9c48c53118217935a5b12e
|
Provenance
The following attestation bundles were made for tokenmoulds-3.6.4-py3-none-any.whl:
Publisher:
06-publish-pypi.yml on BramAlkema/TokenMoulds
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tokenmoulds-3.6.4-py3-none-any.whl -
Subject digest:
a9d508f472aaf84c697316ea54272a450094beb2eac311b0151003d419c88acb - Sigstore transparency entry: 1417518431
- Sigstore integration time:
-
Permalink:
BramAlkema/TokenMoulds@8af9ee2dcab659c9e7c6cb535184569c81b08b43 -
Branch / Tag:
refs/tags/v3.6.4 - Owner: https://github.com/BramAlkema
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
06-publish-pypi.yml@8af9ee2dcab659c9e7c6cb535184569c81b08b43 -
Trigger Event:
release
-
Statement type: