doctyler 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- doctyler-0.5.0/PKG-INFO +142 -0
- doctyler-0.5.0/README.md +129 -0
- doctyler-0.5.0/pyproject.toml +27 -0
- doctyler-0.5.0/setup.cfg +4 -0
- doctyler-0.5.0/src/doctyler/__init__.py +1 -0
- doctyler-0.5.0/src/doctyler/cli.py +524 -0
- doctyler-0.5.0/src/doctyler/context_builder.py +832 -0
- doctyler-0.5.0/src/doctyler/core/__init__.py +0 -0
- doctyler-0.5.0/src/doctyler/core/config_manager.py +74 -0
- doctyler-0.5.0/src/doctyler/core/filter_generator.py +120 -0
- doctyler-0.5.0/src/doctyler/core/font_fallback.py +5 -0
- doctyler-0.5.0/src/doctyler/core/units.py +30 -0
- doctyler-0.5.0/src/doctyler/core/units_ext.py +192 -0
- doctyler-0.5.0/src/doctyler/diff_styles.py +87 -0
- doctyler-0.5.0/src/doctyler/docx_builder.py +428 -0
- doctyler-0.5.0/src/doctyler/extension_builder.py +88 -0
- doctyler-0.5.0/src/doctyler/latex_builder.py +162 -0
- doctyler-0.5.0/src/doctyler/pptx_builder.py +418 -0
- doctyler-0.5.0/src/doctyler/presets/context-notes/context-template.tex.jinja +106 -0
- doctyler-0.5.0/src/doctyler/presets/context-notes/doctyler-config.json +129 -0
- doctyler-0.5.0/src/doctyler/presets/gbt9704/doctyler-config.json +100 -0
- doctyler-0.5.0/src/doctyler/presets/gbt9704/filters/title-promotion.json +9 -0
- doctyler-0.5.0/src/doctyler/presets/gbt9704/filters/title-promotion.lua +40 -0
- doctyler-0.5.0/src/doctyler/presets/gbt9704/gbt9704.cls +137 -0
- doctyler-0.5.0/src/doctyler/presets/gbt9704/gbt9704.cls.jinja +28 -0
- doctyler-0.5.0/src/doctyler/presets/gbt9704/gbt9704.typ +191 -0
- doctyler-0.5.0/src/doctyler/presets/gbt9704/pptx/doctyler-config.json +99 -0
- doctyler-0.5.0/src/doctyler/presets/gbt9704/pptx/doctyler-config.yaml +119 -0
- doctyler-0.5.0/src/doctyler/presets/pandoc-default/doctyler-config.json +124 -0
- doctyler-0.5.0/src/doctyler/presets/pandoc-default/reference-pandoc-default.docx +0 -0
- doctyler-0.5.0/src/doctyler/quarto_generator.py +115 -0
- doctyler-0.5.0/src/doctyler/typst_builder.py +233 -0
- doctyler-0.5.0/src/doctyler.egg-info/PKG-INFO +142 -0
- doctyler-0.5.0/src/doctyler.egg-info/SOURCES.txt +36 -0
- doctyler-0.5.0/src/doctyler.egg-info/dependency_links.txt +1 -0
- doctyler-0.5.0/src/doctyler.egg-info/entry_points.txt +2 -0
- doctyler-0.5.0/src/doctyler.egg-info/requires.txt +4 -0
- doctyler-0.5.0/src/doctyler.egg-info/top_level.txt +1 -0
doctyler-0.5.0/PKG-INFO
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: doctyler
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: 多格式文档样式管理工具:提取、修改并重应用 Word/Typst/LaTeX 模板样式
|
|
5
|
+
Author: Doctyler Team
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: click>=8.0
|
|
10
|
+
Requires-Dist: python-docx>=0.8.11
|
|
11
|
+
Requires-Dist: python-pptx>=0.6.21
|
|
12
|
+
Requires-Dist: pyyaml>=6.0
|
|
13
|
+
|
|
14
|
+
# Doctyler v0.4.3
|
|
15
|
+
|
|
16
|
+
**Doctyler** 让文档样式可配置、可迁移。
|
|
17
|
+
内置 GB/T 9704 公文标准预设,支持 Word、Typst、LaTeX、ConTeXt、Quarto。
|
|
18
|
+
|
|
19
|
+
## 功能
|
|
20
|
+
|
|
21
|
+
- `doctyler docx init` – 初始化 Word 模板和配置
|
|
22
|
+
- `doctyler docx build` – 构建 reference 模板
|
|
23
|
+
- `doctyler docx extract` – 从 .docx 提取样式与页面设置
|
|
24
|
+
- `doctyler docx apply` – 用 JSON 配置反向修正 .docx 样式
|
|
25
|
+
- `doctyler pptx init` – 初始化 PowerPoint 模板和配置(基于 pandoc 默认)
|
|
26
|
+
- `doctyler pptx build` – 构建 GB/T 9704 主题模板
|
|
27
|
+
- `doctyler pptx extract` – 从 .pptx 提取主题色、字体、幻灯片尺寸
|
|
28
|
+
- `doctyler pptx apply` – 用 JSON 配置反向修正 .pptx 主题
|
|
29
|
+
- `doctyler docx dump` – 从 docx 提取样式 (JSON)
|
|
30
|
+
- `doctyler typst generate` – 生成 Typst 模板
|
|
31
|
+
- `doctyler typst extract` – 从 Typst 模板提取参数
|
|
32
|
+
- `doctyler typst apply` – 用配置更新 Typst 模板参数
|
|
33
|
+
- `doctyler latex generate` – 生成 LaTeX 文档骨架
|
|
34
|
+
- `doctyler latex extract` – 从 .cls 文件提取关键样式
|
|
35
|
+
- `doctyler latex apply` – 生成覆盖样式的 doctyler-custom.cls
|
|
36
|
+
- `doctyler context extract` – 从 ConTeXt 源文件提取配置
|
|
37
|
+
- `doctyler context apply` – 将配置应用到 ConTeXt 源文件
|
|
38
|
+
- `doctyler context generate` – 从配置生成 ConTeXt 环境文件
|
|
39
|
+
- `doctyler quarto generate` – 生成 .qmd 文件
|
|
40
|
+
- `doctyler filter list/create/show/use` – Lua 过滤器管理
|
|
41
|
+
- `doctyler extension create/use` – Quarto 扩展管理
|
|
42
|
+
- `doctyler diff-styles` – 从两个 docx 差异提取样式规则
|
|
43
|
+
- `doctyler copy` – 复制生成的模板到目标目录
|
|
44
|
+
- `doctyler config list/add/use/remove` – 配置版本管理
|
|
45
|
+
|
|
46
|
+
## 快速开始
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install .
|
|
50
|
+
doctyler docx init
|
|
51
|
+
doctyler docx build
|
|
52
|
+
doctyler quarto generate --body-file content.md
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## 样式迁移
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# 从上级来文提取样式
|
|
59
|
+
doctyler docx extract incoming.docx -o style.json
|
|
60
|
+
# 修改 style.json 中一级标题字号
|
|
61
|
+
doctyler docx apply incoming.docx -c style.json -o fixed.docx
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 过滤器
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# 列出可用过滤器
|
|
68
|
+
doctyler filter list
|
|
69
|
+
# 基于 title-promotion 创建新过滤器
|
|
70
|
+
doctyler filter create my-filter --based-on title-promotion
|
|
71
|
+
# 激活过滤器
|
|
72
|
+
doctyler filter use my-filter
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 扩展管理
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# 创建 Quarto 扩展
|
|
79
|
+
doctyler extension create gbt9704
|
|
80
|
+
# 安装扩展到项目
|
|
81
|
+
doctyler extension use gbt9704
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 样式差异分析
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# 比较两个 docx 的样式差异,生成规则
|
|
88
|
+
doctyler diff-styles base.docx styled.docx -o diff-rules.json
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## 模板复制
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# 复制所有模板到交付目录
|
|
95
|
+
doctyler copy --type all --target ./release --rename-with-version
|
|
96
|
+
# 仅复制 docx
|
|
97
|
+
doctyler copy --type docx --version gb9704 --target ../project
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 跨格式样式值解析
|
|
101
|
+
|
|
102
|
+
`units_ext` 模块自动处理多格式语义值,无需手工转换:
|
|
103
|
+
|
|
104
|
+
| 输入值 | 格式来源 | 解析结果 |
|
|
105
|
+
|---|---|---|
|
|
106
|
+
| `"2line"` | ConTeXt `\blank[2*line]` | 33.6pt |
|
|
107
|
+
| `"1.5"` | CSS 行距倍数 | 18pt |
|
|
108
|
+
| `"2em"` | CSS / ConTeXt 缩进 | 24pt |
|
|
109
|
+
| `"darkred"` | ConTeXt svg 颜色 | `8B0000` |
|
|
110
|
+
| `"C00000"` | OOXML 十六进制 | `C00000`(原样) |
|
|
111
|
+
|
|
112
|
+
支持 25 种命名颜色,ConTeXt 和 DOCX 配置可共用同一份 JSON。
|
|
113
|
+
|
|
114
|
+
## ConTeXt 样式提取
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# 从 ConTeXt 环境文件提取样式
|
|
118
|
+
doctyler context extract src/doc-env.tex -o notes-style.json
|
|
119
|
+
|
|
120
|
+
# 生成 DOCX 模板(配置中的 ConTeXt 值自动转换)
|
|
121
|
+
doctyler docx init
|
|
122
|
+
cp notes-style.json doctyler-config.json
|
|
123
|
+
doctyler docx build
|
|
124
|
+
|
|
125
|
+
# 或用一键脚本
|
|
126
|
+
python scripts/extract_contex_style.py
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
详细指南见 `scripts/context-extract-guide.md`。
|
|
130
|
+
|
|
131
|
+
## 预设
|
|
132
|
+
|
|
133
|
+
| 预设 | 路径 | 用途 |
|
|
134
|
+
|---|---|---|
|
|
135
|
+
| gbt9704 | `presets/gbt9704/` | GB/T 9704 公文标准(Word/Typst/LaTeX) |
|
|
136
|
+
| gbt9704/pptx | `presets/gbt9704/pptx/` | GB/T 9704 公文标准(PowerPoint) |
|
|
137
|
+
| context-notes | `presets/context-notes/` | ConTeXt-notes 书籍风格 |
|
|
138
|
+
| pandoc-default | `presets/pandoc-default/` | pandoc 默认模板参考 |
|
|
139
|
+
|
|
140
|
+
## 许可
|
|
141
|
+
|
|
142
|
+
MIT
|
doctyler-0.5.0/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Doctyler v0.4.3
|
|
2
|
+
|
|
3
|
+
**Doctyler** 让文档样式可配置、可迁移。
|
|
4
|
+
内置 GB/T 9704 公文标准预设,支持 Word、Typst、LaTeX、ConTeXt、Quarto。
|
|
5
|
+
|
|
6
|
+
## 功能
|
|
7
|
+
|
|
8
|
+
- `doctyler docx init` – 初始化 Word 模板和配置
|
|
9
|
+
- `doctyler docx build` – 构建 reference 模板
|
|
10
|
+
- `doctyler docx extract` – 从 .docx 提取样式与页面设置
|
|
11
|
+
- `doctyler docx apply` – 用 JSON 配置反向修正 .docx 样式
|
|
12
|
+
- `doctyler pptx init` – 初始化 PowerPoint 模板和配置(基于 pandoc 默认)
|
|
13
|
+
- `doctyler pptx build` – 构建 GB/T 9704 主题模板
|
|
14
|
+
- `doctyler pptx extract` – 从 .pptx 提取主题色、字体、幻灯片尺寸
|
|
15
|
+
- `doctyler pptx apply` – 用 JSON 配置反向修正 .pptx 主题
|
|
16
|
+
- `doctyler docx dump` – 从 docx 提取样式 (JSON)
|
|
17
|
+
- `doctyler typst generate` – 生成 Typst 模板
|
|
18
|
+
- `doctyler typst extract` – 从 Typst 模板提取参数
|
|
19
|
+
- `doctyler typst apply` – 用配置更新 Typst 模板参数
|
|
20
|
+
- `doctyler latex generate` – 生成 LaTeX 文档骨架
|
|
21
|
+
- `doctyler latex extract` – 从 .cls 文件提取关键样式
|
|
22
|
+
- `doctyler latex apply` – 生成覆盖样式的 doctyler-custom.cls
|
|
23
|
+
- `doctyler context extract` – 从 ConTeXt 源文件提取配置
|
|
24
|
+
- `doctyler context apply` – 将配置应用到 ConTeXt 源文件
|
|
25
|
+
- `doctyler context generate` – 从配置生成 ConTeXt 环境文件
|
|
26
|
+
- `doctyler quarto generate` – 生成 .qmd 文件
|
|
27
|
+
- `doctyler filter list/create/show/use` – Lua 过滤器管理
|
|
28
|
+
- `doctyler extension create/use` – Quarto 扩展管理
|
|
29
|
+
- `doctyler diff-styles` – 从两个 docx 差异提取样式规则
|
|
30
|
+
- `doctyler copy` – 复制生成的模板到目标目录
|
|
31
|
+
- `doctyler config list/add/use/remove` – 配置版本管理
|
|
32
|
+
|
|
33
|
+
## 快速开始
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install .
|
|
37
|
+
doctyler docx init
|
|
38
|
+
doctyler docx build
|
|
39
|
+
doctyler quarto generate --body-file content.md
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 样式迁移
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# 从上级来文提取样式
|
|
46
|
+
doctyler docx extract incoming.docx -o style.json
|
|
47
|
+
# 修改 style.json 中一级标题字号
|
|
48
|
+
doctyler docx apply incoming.docx -c style.json -o fixed.docx
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 过滤器
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# 列出可用过滤器
|
|
55
|
+
doctyler filter list
|
|
56
|
+
# 基于 title-promotion 创建新过滤器
|
|
57
|
+
doctyler filter create my-filter --based-on title-promotion
|
|
58
|
+
# 激活过滤器
|
|
59
|
+
doctyler filter use my-filter
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 扩展管理
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# 创建 Quarto 扩展
|
|
66
|
+
doctyler extension create gbt9704
|
|
67
|
+
# 安装扩展到项目
|
|
68
|
+
doctyler extension use gbt9704
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 样式差异分析
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# 比较两个 docx 的样式差异,生成规则
|
|
75
|
+
doctyler diff-styles base.docx styled.docx -o diff-rules.json
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 模板复制
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# 复制所有模板到交付目录
|
|
82
|
+
doctyler copy --type all --target ./release --rename-with-version
|
|
83
|
+
# 仅复制 docx
|
|
84
|
+
doctyler copy --type docx --version gb9704 --target ../project
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 跨格式样式值解析
|
|
88
|
+
|
|
89
|
+
`units_ext` 模块自动处理多格式语义值,无需手工转换:
|
|
90
|
+
|
|
91
|
+
| 输入值 | 格式来源 | 解析结果 |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| `"2line"` | ConTeXt `\blank[2*line]` | 33.6pt |
|
|
94
|
+
| `"1.5"` | CSS 行距倍数 | 18pt |
|
|
95
|
+
| `"2em"` | CSS / ConTeXt 缩进 | 24pt |
|
|
96
|
+
| `"darkred"` | ConTeXt svg 颜色 | `8B0000` |
|
|
97
|
+
| `"C00000"` | OOXML 十六进制 | `C00000`(原样) |
|
|
98
|
+
|
|
99
|
+
支持 25 种命名颜色,ConTeXt 和 DOCX 配置可共用同一份 JSON。
|
|
100
|
+
|
|
101
|
+
## ConTeXt 样式提取
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# 从 ConTeXt 环境文件提取样式
|
|
105
|
+
doctyler context extract src/doc-env.tex -o notes-style.json
|
|
106
|
+
|
|
107
|
+
# 生成 DOCX 模板(配置中的 ConTeXt 值自动转换)
|
|
108
|
+
doctyler docx init
|
|
109
|
+
cp notes-style.json doctyler-config.json
|
|
110
|
+
doctyler docx build
|
|
111
|
+
|
|
112
|
+
# 或用一键脚本
|
|
113
|
+
python scripts/extract_contex_style.py
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
详细指南见 `scripts/context-extract-guide.md`。
|
|
117
|
+
|
|
118
|
+
## 预设
|
|
119
|
+
|
|
120
|
+
| 预设 | 路径 | 用途 |
|
|
121
|
+
|---|---|---|
|
|
122
|
+
| gbt9704 | `presets/gbt9704/` | GB/T 9704 公文标准(Word/Typst/LaTeX) |
|
|
123
|
+
| gbt9704/pptx | `presets/gbt9704/pptx/` | GB/T 9704 公文标准(PowerPoint) |
|
|
124
|
+
| context-notes | `presets/context-notes/` | ConTeXt-notes 书籍风格 |
|
|
125
|
+
| pandoc-default | `presets/pandoc-default/` | pandoc 默认模板参考 |
|
|
126
|
+
|
|
127
|
+
## 许可
|
|
128
|
+
|
|
129
|
+
MIT
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64", "click", "python-docx", "pyyaml"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "doctyler"
|
|
7
|
+
version = "0.5.0"
|
|
8
|
+
description = "多格式文档样式管理工具:提取、修改并重应用 Word/Typst/LaTeX 模板样式"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [{name = "Doctyler Team"}]
|
|
11
|
+
license = "MIT"
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"click>=8.0",
|
|
15
|
+
"python-docx>=0.8.11",
|
|
16
|
+
"python-pptx>=0.6.21",
|
|
17
|
+
"pyyaml>=6.0"
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
doctyler = "doctyler.cli:main"
|
|
22
|
+
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
where = ["src"]
|
|
25
|
+
|
|
26
|
+
[tool.setuptools.package-data]
|
|
27
|
+
doctyler = ["presets/**/*"]
|
doctyler-0.5.0/setup.cfg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.4.2"
|