Skip to main content

Doctyler v0.4.3

Doctyler 让文档样式可配置、可迁移。 内置 GB/T 9704 公文标准预设,支持 Word、Typst、LaTeX、ConTeXt、Quarto。

功能

  • doctyler docx init – 初始化 Word 模板和配置
  • doctyler docx build – 构建 reference 模板
  • doctyler docx extract – 从 .docx 提取样式与页面设置
  • doctyler docx apply – 用 JSON 配置反向修正 .docx 样式
  • doctyler pptx init – 初始化 PowerPoint 模板和配置(基于 pandoc 默认)
  • doctyler pptx build – 构建 GB/T 9704 主题模板
  • doctyler pptx extract – 从 .pptx 提取主题色、字体、幻灯片尺寸
  • doctyler pptx apply – 用 JSON 配置反向修正 .pptx 主题
  • doctyler docx dump – 从 docx 提取样式 (JSON)
  • doctyler typst generate – 生成 Typst 模板
  • doctyler typst extract – 从 Typst 模板提取参数
  • doctyler typst apply – 用配置更新 Typst 模板参数
  • doctyler latex generate – 生成 LaTeX 文档骨架
  • doctyler latex extract – 从 .cls 文件提取关键样式
  • doctyler latex apply – 生成覆盖样式的 doctyler-custom.cls
  • doctyler context extract – 从 ConTeXt 源文件提取配置
  • doctyler context apply – 将配置应用到 ConTeXt 源文件
  • doctyler context generate – 从配置生成 ConTeXt 环境文件
  • doctyler quarto generate – 生成 .qmd 文件
  • doctyler filter list/create/show/use – Lua 过滤器管理
  • doctyler extension create/use – Quarto 扩展管理
  • doctyler diff-styles – 从两个 docx 差异提取样式规则
  • doctyler copy – 复制生成的模板到目标目录
  • doctyler config list/add/use/remove – 配置版本管理

快速开始

pip install .
doctyler docx init
doctyler docx build
doctyler quarto generate --body-file content.md

样式迁移

# 从上级来文提取样式
doctyler docx extract incoming.docx -o style.json
# 修改 style.json 中一级标题字号
doctyler docx apply incoming.docx -c style.json -o fixed.docx

过滤器

# 列出可用过滤器
doctyler filter list
# 基于 title-promotion 创建新过滤器
doctyler filter create my-filter --based-on title-promotion
# 激活过滤器
doctyler filter use my-filter

扩展管理

# 创建 Quarto 扩展
doctyler extension create gbt9704
# 安装扩展到项目
doctyler extension use gbt9704

样式差异分析

# 比较两个 docx 的样式差异,生成规则
doctyler diff-styles base.docx styled.docx -o diff-rules.json

模板复制

# 复制所有模板到交付目录
doctyler copy --type all --target ./release --rename-with-version
# 仅复制 docx
doctyler copy --type docx --version gb9704 --target ../project

跨格式样式值解析

units_ext 模块自动处理多格式语义值,无需手工转换:

输入值 格式来源 解析结果
"2line" ConTeXt \blank[2*line] 33.6pt
"1.5" CSS 行距倍数 18pt
"2em" CSS / ConTeXt 缩进 24pt
"darkred" ConTeXt svg 颜色 8B0000
"C00000" OOXML 十六进制 C00000(原样)

支持 25 种命名颜色,ConTeXt 和 DOCX 配置可共用同一份 JSON。

ConTeXt 样式提取

# 从 ConTeXt 环境文件提取样式
doctyler context extract src/doc-env.tex -o notes-style.json

# 生成 DOCX 模板(配置中的 ConTeXt 值自动转换)
doctyler docx init
cp notes-style.json doctyler-config.json
doctyler docx build

# 或用一键脚本
python scripts/extract_contex_style.py

详细指南见 scripts/context-extract-guide.md。

预设

预设 路径 用途
gbt9704 presets/gbt9704/ GB/T 9704 公文标准(Word/Typst/LaTeX)
gbt9704/pptx presets/gbt9704/pptx/ GB/T 9704 公文标准(PowerPoint)
context-notes presets/context-notes/ ConTeXt-notes 书籍风格
pandoc-default presets/pandoc-default/ pandoc 默认模板参考

许可

MIT

Metadata

Release files for doctyler 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for doctyler 0.5.0
File Size Uploaded Provenance Actions
doctyler-0.5.0.tar.gz 55.8 kB Without provenance Details for doctyler-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for doctyler 0.5.0
File Interpreter ABI Platform Actions
doctyler-0.5.0-py3-none-any.whl Python 3 none any Details for doctyler-0.5.0-py3-none-any.whl

Total release size: 118.4 kB

Release files / doctyler-0.5.0.tar.gz

Download URL doctyler-0.5.0.tar.gz
Size 55.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0ffa8b142f0675eb6642991eed46d967f025b3ee7b5c3e90257b29f608437e47
BLAKE2b-256 checksum
How to use checksums
f07f9cf814ae215c180470c076fc37ea678160329c4f3ee38c7436195751bd24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / doctyler-0.5.0-py3-none-any.whl

Download URL doctyler-0.5.0-py3-none-any.whl
Size 62.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c45601da15e8b44befbce5275de09c1e852cae2d562e7d88cda8ee8fbce0e58
BLAKE2b-256 checksum
How to use checksums
19fe4f54e5d11dd86f08bcbabe0f620205c2594df7eeda0bdbf8e3a5d5e2b797
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Security for doctyler 0.5.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.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page