Skip to main content

多格式文档样式管理工具:提取、修改并重应用 Word/Typst/LaTeX 模板样式

Project description

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

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

doctyler-0.5.0.tar.gz (55.8 kB view details)

Uploaded Source

Built Distribution

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

doctyler-0.5.0-py3-none-any.whl (62.6 kB view details)

Uploaded Python 3

File details

Details for the file doctyler-0.5.0.tar.gz.

File metadata

  • Download URL: doctyler-0.5.0.tar.gz
  • Upload date:
  • Size: 55.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for doctyler-0.5.0.tar.gz
Algorithm Hash digest
SHA256 0ffa8b142f0675eb6642991eed46d967f025b3ee7b5c3e90257b29f608437e47
MD5 f4e4e8766005991b01e9ec64135de241
BLAKE2b-256 f07f9cf814ae215c180470c076fc37ea678160329c4f3ee38c7436195751bd24

See more details on using hashes here.

File details

Details for the file doctyler-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: doctyler-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 62.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for doctyler-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c45601da15e8b44befbce5275de09c1e852cae2d562e7d88cda8ee8fbce0e58
MD5 2731b205a47c3c90f343ed5d6c70aff8
BLAKE2b-256 19fe4f54e5d11dd86f08bcbabe0f620205c2594df7eeda0bdbf8e3a5d5e2b797

See more details on using hashes here.

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