tydo 0.1.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.
- tydo-0.1.0/.github/workflows/ci.yml +50 -0
- tydo-0.1.0/.github/workflows/publish.yml +98 -0
- tydo-0.1.0/.gitignore +8 -0
- tydo-0.1.0/LICENSE +21 -0
- tydo-0.1.0/PKG-INFO +107 -0
- tydo-0.1.0/README.md +77 -0
- tydo-0.1.0/SUPPORT.md +240 -0
- tydo-0.1.0/examples/drawings.typ +37 -0
- tydo-0.1.0/examples/font-gallery.typ +87 -0
- tydo-0.1.0/examples/package-diagrams.typ +35 -0
- tydo-0.1.0/examples/paper-editable.docx +0 -0
- tydo-0.1.0/examples/paper-features.typ +111 -0
- tydo-0.1.0/examples/paper.typ +187 -0
- tydo-0.1.0/examples/references.bib +27 -0
- tydo-0.1.0/examples/results.json +195 -0
- tydo-0.1.0/examples/risk-curve.png +0 -0
- tydo-0.1.0/examples/stress.typ +124 -0
- tydo-0.1.0/pyproject.toml +58 -0
- tydo-0.1.0/src/tydo/__init__.py +19 -0
- tydo-0.1.0/src/tydo/__main__.py +3 -0
- tydo-0.1.0/src/tydo/_drawings.py +178 -0
- tydo-0.1.0/src/tydo/_equations.py +197 -0
- tydo-0.1.0/src/tydo/_figures.py +332 -0
- tydo-0.1.0/src/tydo/_fonts.py +209 -0
- tydo-0.1.0/src/tydo/_html.py +233 -0
- tydo-0.1.0/src/tydo/_layout.py +395 -0
- tydo-0.1.0/src/tydo/_media.py +189 -0
- tydo-0.1.0/src/tydo/_package.py +84 -0
- tydo-0.1.0/src/tydo/_prepare.py +253 -0
- tydo-0.1.0/src/tydo/_sections.py +632 -0
- tydo-0.1.0/src/tydo/_semantic.py +352 -0
- tydo-0.1.0/src/tydo/_source.py +874 -0
- tydo-0.1.0/src/tydo/_styles.py +430 -0
- tydo-0.1.0/src/tydo/_svg_html.py +86 -0
- tydo-0.1.0/src/tydo/_table_styles.py +250 -0
- tydo-0.1.0/src/tydo/_tables.py +207 -0
- tydo-0.1.0/src/tydo/_toolchain.py +48 -0
- tydo-0.1.0/src/tydo/_xml.py +59 -0
- tydo-0.1.0/src/tydo/cli.py +241 -0
- tydo-0.1.0/src/tydo/converter.py +353 -0
- tydo-0.1.0/src/tydo/model.py +46 -0
- tydo-0.1.0/tests/test_api.py +588 -0
- tydo-0.1.0/tests/test_fonts.py +225 -0
- tydo-0.1.0/tests/test_integration.py +504 -0
- tydo-0.1.0/tests/test_media.py +240 -0
- tydo-0.1.0/tests/test_relative_layout.py +164 -0
- tydo-0.1.0/uv.lock +284 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
env:
|
|
15
|
+
TYPST_VERSION: "0.15.1"
|
|
16
|
+
PANDOC_VERSION: "3.14"
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Set up uv
|
|
21
|
+
uses: astral-sh/setup-uv@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: "3.12"
|
|
24
|
+
enable-cache: true
|
|
25
|
+
|
|
26
|
+
- name: Install Typst and Pandoc
|
|
27
|
+
run: |
|
|
28
|
+
mkdir -p "$HOME/.local/bin"
|
|
29
|
+
curl -fsSL "https://github.com/typst/typst/releases/download/v${TYPST_VERSION}/typst-x86_64-unknown-linux-musl.tar.xz" \
|
|
30
|
+
| tar -xJ --strip-components=1 -C "$HOME/.local/bin" "typst-x86_64-unknown-linux-musl/typst"
|
|
31
|
+
curl -fsSL "https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz" \
|
|
32
|
+
| tar -xz --strip-components=2 -C "$HOME/.local/bin" "pandoc-${PANDOC_VERSION}/bin/pandoc"
|
|
33
|
+
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
|
34
|
+
|
|
35
|
+
- name: Verify toolchain
|
|
36
|
+
run: |
|
|
37
|
+
typst --version
|
|
38
|
+
pandoc --version | head -n 2
|
|
39
|
+
|
|
40
|
+
- name: Install dependencies
|
|
41
|
+
run: uv sync --locked
|
|
42
|
+
|
|
43
|
+
- name: Lint
|
|
44
|
+
run: uv run ruff check
|
|
45
|
+
|
|
46
|
+
- name: Test
|
|
47
|
+
run: uv run pytest -q
|
|
48
|
+
|
|
49
|
+
- name: Build distributions
|
|
50
|
+
run: uv build
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
target:
|
|
9
|
+
description: "Publish target"
|
|
10
|
+
type: choice
|
|
11
|
+
default: testpypi
|
|
12
|
+
options:
|
|
13
|
+
- testpypi
|
|
14
|
+
- pypi
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
build:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- name: Set up uv
|
|
26
|
+
uses: astral-sh/setup-uv@v5
|
|
27
|
+
with:
|
|
28
|
+
python-version: "3.12"
|
|
29
|
+
enable-cache: true
|
|
30
|
+
|
|
31
|
+
- name: Verify release tag matches pyproject.toml version
|
|
32
|
+
if: github.event_name == 'release'
|
|
33
|
+
env:
|
|
34
|
+
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
|
35
|
+
run: |
|
|
36
|
+
uv run --no-project python - <<'PY'
|
|
37
|
+
import os, tomllib
|
|
38
|
+
with open("pyproject.toml", "rb") as f:
|
|
39
|
+
version = tomllib.load(f)["project"]["version"]
|
|
40
|
+
tag = os.environ["RELEASE_TAG"].removeprefix("v")
|
|
41
|
+
if tag != version:
|
|
42
|
+
raise SystemExit(f"Release tag ({os.environ['RELEASE_TAG']}) does not match pyproject.toml version ({version})")
|
|
43
|
+
print(f"Verified version {version}")
|
|
44
|
+
PY
|
|
45
|
+
|
|
46
|
+
- name: Lint
|
|
47
|
+
run: |
|
|
48
|
+
uv sync --locked
|
|
49
|
+
uv run ruff check
|
|
50
|
+
|
|
51
|
+
- name: Build sdist and wheel
|
|
52
|
+
run: uv build
|
|
53
|
+
|
|
54
|
+
- name: Upload distribution artifacts
|
|
55
|
+
uses: actions/upload-artifact@v4
|
|
56
|
+
with:
|
|
57
|
+
name: release-dists
|
|
58
|
+
path: dist/
|
|
59
|
+
|
|
60
|
+
publish-pypi:
|
|
61
|
+
needs: build
|
|
62
|
+
if: github.event_name == 'release' || inputs.target == 'pypi'
|
|
63
|
+
runs-on: ubuntu-latest
|
|
64
|
+
environment:
|
|
65
|
+
name: pypi
|
|
66
|
+
url: https://pypi.org/p/tydo
|
|
67
|
+
permissions:
|
|
68
|
+
id-token: write
|
|
69
|
+
steps:
|
|
70
|
+
- name: Download distribution artifacts
|
|
71
|
+
uses: actions/download-artifact@v4
|
|
72
|
+
with:
|
|
73
|
+
name: release-dists
|
|
74
|
+
path: dist/
|
|
75
|
+
|
|
76
|
+
- name: Publish package distributions to PyPI
|
|
77
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
78
|
+
|
|
79
|
+
publish-testpypi:
|
|
80
|
+
needs: build
|
|
81
|
+
if: github.event_name == 'workflow_dispatch' && inputs.target == 'testpypi'
|
|
82
|
+
runs-on: ubuntu-latest
|
|
83
|
+
environment:
|
|
84
|
+
name: testpypi
|
|
85
|
+
url: https://test.pypi.org/p/tydo
|
|
86
|
+
permissions:
|
|
87
|
+
id-token: write
|
|
88
|
+
steps:
|
|
89
|
+
- name: Download distribution artifacts
|
|
90
|
+
uses: actions/download-artifact@v4
|
|
91
|
+
with:
|
|
92
|
+
name: release-dists
|
|
93
|
+
path: dist/
|
|
94
|
+
|
|
95
|
+
- name: Publish package distributions to TestPyPI
|
|
96
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
97
|
+
with:
|
|
98
|
+
repository-url: https://test.pypi.org/legacy/
|
tydo-0.1.0/.gitignore
ADDED
tydo-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ZiceWang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
tydo-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: tydo
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Convert Typst documents to editable Word files with a conversion audit
|
|
5
|
+
Project-URL: Homepage, https://github.com/ZiceWang/tydo
|
|
6
|
+
Project-URL: Repository, https://github.com/ZiceWang/tydo
|
|
7
|
+
Project-URL: Documentation, https://github.com/ZiceWang/tydo/blob/main/SUPPORT.md
|
|
8
|
+
Project-URL: Issues, https://github.com/ZiceWang/tydo/issues
|
|
9
|
+
Author: ZiceWang
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: academic,converter,docx,pandoc,typst,word
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Education
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Documentation
|
|
23
|
+
Classifier: Topic :: Text Processing
|
|
24
|
+
Classifier: Topic :: Text Processing :: Markup
|
|
25
|
+
Requires-Python: >=3.12
|
|
26
|
+
Requires-Dist: lxml<7,>=6
|
|
27
|
+
Requires-Dist: python-docx<2,>=1.2
|
|
28
|
+
Requires-Dist: rich<15,>=14
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# tydo
|
|
32
|
+
|
|
33
|
+
Convert Typst projects to editable Word documents.
|
|
34
|
+
|
|
35
|
+
## Why another Typst-to-DOCX converter?
|
|
36
|
+
|
|
37
|
+
I built this for my own papers. The converters I found covered only part of
|
|
38
|
+
what I needed for Word review. I wanted two-column layouts, editable equations
|
|
39
|
+
and grids, and working cross-references, including in documents assembled
|
|
40
|
+
with custom Typst functions.
|
|
41
|
+
|
|
42
|
+
The earlier `sghng/typ2docx` used a PDF-to-Word pipeline with a separate pass
|
|
43
|
+
for equations. It focused on preserving math for academic submissions, and
|
|
44
|
+
its repository is now archived. [Project README](https://github.com/sghng/typ2docx#readme)
|
|
45
|
+
|
|
46
|
+
I wanted to start from first principles. Let Typst evaluate the source,
|
|
47
|
+
then ask which parts Word can represent natively. This converter combines
|
|
48
|
+
Typst's HTML with evaluated layout and text properties. Pandoc writes the
|
|
49
|
+
initial DOCX, and `tydo` adds Word sections, numbering, cross-references,
|
|
50
|
+
and formatting for the supported subset.
|
|
51
|
+
|
|
52
|
+
Each export includes an audit of known approximations and unsupported
|
|
53
|
+
features. Word reflows the document, so line breaks, page breaks, and float
|
|
54
|
+
positions can differ from Typst.
|
|
55
|
+
See the [support matrix](https://github.com/ZiceWang/tydo/blob/main/SUPPORT.md) for coverage and limitations.
|
|
56
|
+
|
|
57
|
+
## Quick start
|
|
58
|
+
|
|
59
|
+
Install Python 3.12+, Typst 0.15.1+, and Pandoc 3.14+. With Typst and Pandoc on
|
|
60
|
+
`PATH`, install `tydo` from PyPI:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
uv tool install tydo
|
|
64
|
+
# or: pip install tydo
|
|
65
|
+
tydo paper.typ -o draft.docx
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Or install from a local checkout:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
uv tool install .
|
|
72
|
+
tydo examples/paper-features.typ -o work/paper-features.docx
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The command writes a DOCX and an adjacent `.audit.json`. Without `-o`,
|
|
76
|
+
`tydo paper.typ` writes `paper-editable.docx` beside the source. Pass
|
|
77
|
+
`--strict` to stop before writing if a known conversion loss is reported.
|
|
78
|
+
Interactive terminals show a summary. Pipes and redirects receive JSON, and
|
|
79
|
+
`--json` selects JSON explicitly. See `tydo --help` for options.
|
|
80
|
+
|
|
81
|
+
Typst resolves imports and assets relative to the project. Use `--root` to
|
|
82
|
+
set the project root, and `--typst` or `--pandoc` to override the executable
|
|
83
|
+
paths. See [configuration](https://github.com/ZiceWang/tydo/blob/main/SUPPORT.md#configuration) for template overrides
|
|
84
|
+
and tool discovery.
|
|
85
|
+
|
|
86
|
+
## Python API
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from tydo import ConversionOptions, convert
|
|
90
|
+
|
|
91
|
+
result = convert("paper.typ", "draft.docx", options=ConversionOptions(strict=True))
|
|
92
|
+
print(result.output, result.report)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Examples and tests
|
|
96
|
+
|
|
97
|
+
- [Two-column paper](https://github.com/ZiceWang/tydo/blob/main/examples/paper-features.typ) with wide figures and tables,
|
|
98
|
+
editable equations, and footnotes.
|
|
99
|
+
- [Font gallery](https://github.com/ZiceWang/tydo/blob/main/examples/font-gallery.typ) with Latin and CJK type specimens.
|
|
100
|
+
- [Stress test](https://github.com/ZiceWang/tydo/blob/main/examples/stress.typ) with long tables, merged cells, and mixed
|
|
101
|
+
column layouts.
|
|
102
|
+
|
|
103
|
+
Run `uv sync --locked`, `uv run ruff check`, and `uv run pytest` from the checkout.
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
[MIT](https://github.com/ZiceWang/tydo/blob/main/LICENSE).
|
tydo-0.1.0/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# tydo
|
|
2
|
+
|
|
3
|
+
Convert Typst projects to editable Word documents.
|
|
4
|
+
|
|
5
|
+
## Why another Typst-to-DOCX converter?
|
|
6
|
+
|
|
7
|
+
I built this for my own papers. The converters I found covered only part of
|
|
8
|
+
what I needed for Word review. I wanted two-column layouts, editable equations
|
|
9
|
+
and grids, and working cross-references, including in documents assembled
|
|
10
|
+
with custom Typst functions.
|
|
11
|
+
|
|
12
|
+
The earlier `sghng/typ2docx` used a PDF-to-Word pipeline with a separate pass
|
|
13
|
+
for equations. It focused on preserving math for academic submissions, and
|
|
14
|
+
its repository is now archived. [Project README](https://github.com/sghng/typ2docx#readme)
|
|
15
|
+
|
|
16
|
+
I wanted to start from first principles. Let Typst evaluate the source,
|
|
17
|
+
then ask which parts Word can represent natively. This converter combines
|
|
18
|
+
Typst's HTML with evaluated layout and text properties. Pandoc writes the
|
|
19
|
+
initial DOCX, and `tydo` adds Word sections, numbering, cross-references,
|
|
20
|
+
and formatting for the supported subset.
|
|
21
|
+
|
|
22
|
+
Each export includes an audit of known approximations and unsupported
|
|
23
|
+
features. Word reflows the document, so line breaks, page breaks, and float
|
|
24
|
+
positions can differ from Typst.
|
|
25
|
+
See the [support matrix](https://github.com/ZiceWang/tydo/blob/main/SUPPORT.md) for coverage and limitations.
|
|
26
|
+
|
|
27
|
+
## Quick start
|
|
28
|
+
|
|
29
|
+
Install Python 3.12+, Typst 0.15.1+, and Pandoc 3.14+. With Typst and Pandoc on
|
|
30
|
+
`PATH`, install `tydo` from PyPI:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
uv tool install tydo
|
|
34
|
+
# or: pip install tydo
|
|
35
|
+
tydo paper.typ -o draft.docx
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or install from a local checkout:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
uv tool install .
|
|
42
|
+
tydo examples/paper-features.typ -o work/paper-features.docx
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The command writes a DOCX and an adjacent `.audit.json`. Without `-o`,
|
|
46
|
+
`tydo paper.typ` writes `paper-editable.docx` beside the source. Pass
|
|
47
|
+
`--strict` to stop before writing if a known conversion loss is reported.
|
|
48
|
+
Interactive terminals show a summary. Pipes and redirects receive JSON, and
|
|
49
|
+
`--json` selects JSON explicitly. See `tydo --help` for options.
|
|
50
|
+
|
|
51
|
+
Typst resolves imports and assets relative to the project. Use `--root` to
|
|
52
|
+
set the project root, and `--typst` or `--pandoc` to override the executable
|
|
53
|
+
paths. See [configuration](https://github.com/ZiceWang/tydo/blob/main/SUPPORT.md#configuration) for template overrides
|
|
54
|
+
and tool discovery.
|
|
55
|
+
|
|
56
|
+
## Python API
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from tydo import ConversionOptions, convert
|
|
60
|
+
|
|
61
|
+
result = convert("paper.typ", "draft.docx", options=ConversionOptions(strict=True))
|
|
62
|
+
print(result.output, result.report)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Examples and tests
|
|
66
|
+
|
|
67
|
+
- [Two-column paper](https://github.com/ZiceWang/tydo/blob/main/examples/paper-features.typ) with wide figures and tables,
|
|
68
|
+
editable equations, and footnotes.
|
|
69
|
+
- [Font gallery](https://github.com/ZiceWang/tydo/blob/main/examples/font-gallery.typ) with Latin and CJK type specimens.
|
|
70
|
+
- [Stress test](https://github.com/ZiceWang/tydo/blob/main/examples/stress.typ) with long tables, merged cells, and mixed
|
|
71
|
+
column layouts.
|
|
72
|
+
|
|
73
|
+
Run `uv sync --locked`, `uv run ruff check`, and `uv run pytest` from the checkout.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
[MIT](https://github.com/ZiceWang/tydo/blob/main/LICENSE).
|
tydo-0.1.0/SUPPORT.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# Compatibility and support
|
|
2
|
+
|
|
3
|
+
`tydo` combines Typst's HTML and paged evaluation with Pandoc. It writes
|
|
4
|
+
sections, captions, numbering, and cross-references as native Word structures.
|
|
5
|
+
|
|
6
|
+
## General Typst documents
|
|
7
|
+
|
|
8
|
+
Pass the entry `.typ` file. Typst evaluates its functions and templates, and
|
|
9
|
+
the converter reads page and layout properties from that evaluation. A legacy
|
|
10
|
+
template can declare a Word profile. The `--style` option can override it.
|
|
11
|
+
|
|
12
|
+
| Typst source | Word result |
|
|
13
|
+
| --- | --- |
|
|
14
|
+
| `title`, headings, and `outline` | Word heading styles and a clickable static outline. General mode uses left-aligned black bold headings with a size hierarchy. Ordinary opening paragraphs retain their body style. |
|
|
15
|
+
| Lists, terms, block quotes, and code | List levels, definitions, quotations, and code indentation. |
|
|
16
|
+
| Inline formatting | Bold, italic, underline, strikethrough, superscript, subscript, and yellow highlighting. |
|
|
17
|
+
| Fonts and sizes | General mode defaults to 11 pt Libertinus Serif. `set text` and local `text` settings can become Word character styles, including explicit `latin-in-cjk` font pairs and plain Latin + CJK fallback lists (mapped to `ascii`/`hAnsi` and `eastAsia`). Same-script fallback lists use the primary font. The font audit records complex coverage rules and local fonts in captions and links. |
|
|
18
|
+
| Text color | General mode uses black by default. Solid opaque fills are applied to body text, headings, cells, footnotes, captions, and links. The audit records gradient, pattern, and transparent fills under `fonts.unsupported_fills`. Formula color is outside the current mapping. |
|
|
19
|
+
| `table` and `grid` appearance | Common fixed, percentage, and `fr` tracks, uniform absolute insets, ordinary solid borders, `table.hline` / `grid.hline` horizontal rules (such as three-line tables), and static column alignment. Tables default to the left. Cell content defaults to the top left. Exact row heights, grid gaps, and complex decoration can differ. |
|
|
20
|
+
| `table.header` and `table.cell` spans | Native merged cells and repeating multirow headers. Tables without a source header retain their original rows. |
|
|
21
|
+
| `grid` | Editable tables for grids in body text, plain blocks, and top-level figures. Supports merged cells, explicit `x` and `y` coordinates, one repeating header at the start, and partial final rows. Fixed, percentage, and `fr` widths can be mixed. The converter estimates `auto` tracks in regular grids. Cells can include emphasis, soft line breaks, and inline math. |
|
|
22
|
+
| Math | Native Word equations, including equations in table cells. |
|
|
23
|
+
| `bibliography` | Static entries and citation links with the citation numbers produced by Typst. |
|
|
24
|
+
| Uniform page setup and paragraph layout | Page size, orientation, absolute or percentage margins, one to four columns (including `columns(n, body)` blocks), column gaps, and body `set par(justify, first-line-indent)`. Percentage gaps use the body width and may include an absolute component. Templates and functions can set these values. |
|
|
25
|
+
| Page numbers, `pagebreak()`, and `colbreak()` | Native fields for consecutive decimal page numbers, including the starting number. Ordinary top-level page and column breaks become native Word breaks. |
|
|
26
|
+
| Horizontal `align` | Left, center, or right alignment for paragraphs with text, emphasis, or inline math in the body or a plain block. |
|
|
27
|
+
| Fixed headers and footers | Constant plain text in native Word headers and footers, with Word's placement and paragraph styles. |
|
|
28
|
+
|
|
29
|
+
## Figures and academic layout
|
|
30
|
+
|
|
31
|
+
| Feature | Word result |
|
|
32
|
+
| --- | --- |
|
|
33
|
+
| Wide figures and tables | A single-column section holds the wide object and its caption. The original column layout resumes afterward. Wide tables retain editable cells and can have more than three columns. |
|
|
34
|
+
| Captions and cross-references | Figures and tables use separate `SEQ` sequences. Caption placement above or below the object follows the source. Standard decimal cross-references use `REF`. |
|
|
35
|
+
| Three-rule tables | Academic profiles use a 1 pt top and bottom rule and a 0.5 pt header rule, with no vertical rules or cell shading. |
|
|
36
|
+
| Long tables | Header rows can repeat across pages and individual rows stay together. |
|
|
37
|
+
| Equation numbering | Standard decimal numbering uses `SEQ` and `REF`. Unnumbered equations stay outside the sequence. |
|
|
38
|
+
| Footnotes | Native Word footnotes numbered consecutively from 1. |
|
|
39
|
+
| Images | Images scale proportionally to the current column and retain alternative text. Body and footnote SVGs stay vector, with a PNG fallback generated by Typst when needed. |
|
|
40
|
+
| Drawing commands | Supported evaluated `rect`, `square`, `circle`, `ellipse`, `line`, `polygon`, and `curve` elements export as SVG. Figures with captions can retain references. |
|
|
41
|
+
| Composite drawings from custom functions | Supported drawing elements, brief labels, and unlabeled inline math can share one SVG. This covers `stack`, transforms, and `place` in fixed-size blocks. Compositions with headings, lists, or display equations can be reported as unsupported. |
|
|
42
|
+
| CeTZ and Fletcher | [Package examples](examples/package-diagrams.typ) include a CeTZ 0.5.3 bar chart and a Fletcher 0.6.0 flowchart. Both export as SVG with Word caption and reference fields. Typst downloads the dependencies on the first run. |
|
|
43
|
+
|
|
44
|
+
The [two-column example](examples/paper-features.typ) combines a wide figure,
|
|
45
|
+
a seven-column table with a caption above it, a single-column figure,
|
|
46
|
+
numbered and unnumbered equations, and a footnote.
|
|
47
|
+
|
|
48
|
+
### Wide figures and tables
|
|
49
|
+
|
|
50
|
+
Use `scope: "parent"` with a floating `placement` such as `top`. Typst
|
|
51
|
+
evaluates the figure before the converter reads its properties, so functions
|
|
52
|
+
and show rules that produce standard figures can use the same mapping.
|
|
53
|
+
[Typst figure reference](https://typst.app/docs/reference/model/figure/)
|
|
54
|
+
|
|
55
|
+
```typst
|
|
56
|
+
#figure(
|
|
57
|
+
image("overview.png", width: 100%, alt: "Workflow overview"),
|
|
58
|
+
scope: "parent",
|
|
59
|
+
placement: top,
|
|
60
|
+
caption: [Overview of the workflow.],
|
|
61
|
+
) <fig-overview>
|
|
62
|
+
|
|
63
|
+
See @fig-overview for the workflow.
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```typst
|
|
67
|
+
#show figure.where(kind: table): set figure.caption(position: top)
|
|
68
|
+
|
|
69
|
+
#figure(
|
|
70
|
+
table(
|
|
71
|
+
columns: 4,
|
|
72
|
+
stroke: none,
|
|
73
|
+
table.hline(y: 0, stroke: 1pt),
|
|
74
|
+
table.header([Method], [Parameter], [Error], [Runtime]),
|
|
75
|
+
table.hline(y: 1, stroke: 0.5pt),
|
|
76
|
+
[Method A], [10], [0.12], [1.5 s],
|
|
77
|
+
[Method B], [20], [0.09], [2.1 s],
|
|
78
|
+
table.hline(stroke: 1pt),
|
|
79
|
+
),
|
|
80
|
+
scope: "parent",
|
|
81
|
+
placement: top,
|
|
82
|
+
caption: [Comparison of the two methods.],
|
|
83
|
+
) <tab-comparison>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Word column widths reflect the available body width and cell contents. In
|
|
87
|
+
academic profiles, ordinary two- and three-column tables use legacy width
|
|
88
|
+
ratios. Per-cell border fidelity depends on the source HTML.
|
|
89
|
+
|
|
90
|
+
### Updating fields in Word
|
|
91
|
+
|
|
92
|
+
Press `Ctrl+A` and `F9` to update existing equation, figure, and table numbers
|
|
93
|
+
and references. New numbered items need `SEQ` fields, and new references need
|
|
94
|
+
the corresponding bookmarks. Editing the Typst source and exporting again
|
|
95
|
+
regenerates both.
|
|
96
|
+
|
|
97
|
+
## Configuration
|
|
98
|
+
|
|
99
|
+
The entry file is a positional argument. By default the DOCX is written beside
|
|
100
|
+
it as `NAME-editable.docx`, along with `NAME-editable.audit.json`. Use
|
|
101
|
+
`--root` for the Typst project root and `--report` for a custom audit path.
|
|
102
|
+
|
|
103
|
+
Select executables with `--typst` and `--pandoc`, or set
|
|
104
|
+
`TYDO_TYPST` and `TYDO_PANDOC`. On Windows the command also checks
|
|
105
|
+
`%LOCALAPPDATA%\tydo\bin` if it cannot find a suitable executable on
|
|
106
|
+
`PATH`. The wheel requires separate Typst and Pandoc installations. Academic
|
|
107
|
+
profiles use Times New Roman, Cambria Math, SimSun, SimHei, and KaiTi.
|
|
108
|
+
|
|
109
|
+
A template can declare a profile with
|
|
110
|
+
`#metadata("ieee") <tw-docx-profile>`. The converter also recognizes the
|
|
111
|
+
journal header marker used by the legacy psychology template. Explicit
|
|
112
|
+
`--style`, `--columns`, `--margin-mm`, and `--gutter-mm` override
|
|
113
|
+
automatically selected settings.
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
tydo paper.typ --wide-placement page
|
|
117
|
+
tydo paper.typ --margin-mm 20 --gutter-mm 8
|
|
118
|
+
tydo paper.typ --columns 1
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Existing `data-tw` section and page markers are supported. A template can
|
|
122
|
+
emit an explicit HTML page break as follows.
|
|
123
|
+
|
|
124
|
+
```typst
|
|
125
|
+
#show pagebreak: it => context if target() == "html" {
|
|
126
|
+
html.elem("div", attrs: ("data-tw": "page-break"))[]
|
|
127
|
+
} else {
|
|
128
|
+
it
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Python callers can read `StrictConversionError.audit` after a strict-mode
|
|
133
|
+
failure. Each call uses its own temporary files and resolves relative paths
|
|
134
|
+
from the current working directory.
|
|
135
|
+
|
|
136
|
+
In the general profile, a standalone Typst `page(...)` in the document
|
|
137
|
+
flow becomes a native Word page section. Each section retains its evaluated
|
|
138
|
+
paper dimensions, orientation, and margins. Local `columns(...)` and
|
|
139
|
+
`colbreak()` use native Word section and column breaks. Tables and pictures
|
|
140
|
+
are sized against the available width of their own section or column.
|
|
141
|
+
Changes made by `set page(...)` also create native sections when the new
|
|
142
|
+
settings begin on a separate Typst page and the HTML flow exposes a matching
|
|
143
|
+
block boundary. This includes switching between one and two page columns
|
|
144
|
+
without writing conversion markup.
|
|
145
|
+
The automatic page bridge includes calls returned by custom functions in
|
|
146
|
+
the evaluated document flow. A function that emits differing structures
|
|
147
|
+
for the paged and HTML targets can link the two with an explicit boundary.
|
|
148
|
+
|
|
149
|
+
```typst
|
|
150
|
+
#let sheet(id, body, ..settings) = context if target() == "html" {
|
|
151
|
+
html.elem("div", attrs: ("data-tw": "page", "data-tw-page-id": id), body)
|
|
152
|
+
} else {
|
|
153
|
+
page(..settings, [
|
|
154
|
+
#metadata((id: id, edge: "start")) <tw-docx-page-boundary>
|
|
155
|
+
#body
|
|
156
|
+
#metadata((id: id, edge: "end")) <tw-docx-page-boundary>
|
|
157
|
+
])
|
|
158
|
+
}
|
|
159
|
+
#sheet("appendix", flipped: true)[Editable appendix]
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Use `data-tw="front-page"` for leading unnumbered pages.
|
|
163
|
+
`data-tw-page-start` sets the body page number after the front matter and
|
|
164
|
+
defaults to 1. An unanchored front page uses the document's geometry.
|
|
165
|
+
`front_pages` counts those logical pages. `first_body_section` is the
|
|
166
|
+
one-based Word section index where the body begins. A logical front page
|
|
167
|
+
can contain several Word sections or overflow onto several rendered pages.
|
|
168
|
+
|
|
169
|
+
A `div` marked `data-tw="paragraph"` can pass an object as
|
|
170
|
+
`data-tw-paragraph` JSON. Supported properties include `align`,
|
|
171
|
+
`first_indent_pt`, `space_before_pt`, `space_after_pt`, `line_spacing`,
|
|
172
|
+
`keep_together`, `size_pt`, and a `font` pair for Latin and East Asian
|
|
173
|
+
scripts. Wrap a table in `data-tw="keep-table"` when its rows should stay
|
|
174
|
+
together. These markers apply to the wrapped content regardless of its text.
|
|
175
|
+
|
|
176
|
+
## Audit and limits
|
|
177
|
+
|
|
178
|
+
The adjacent `.audit.json` records actual page settings in
|
|
179
|
+
`layout.applied_mm`, layout losses in `layout.issues`, Pandoc warnings,
|
|
180
|
+
unresolved references, and counts of wide objects, math, and fields. Typst
|
|
181
|
+
diagnostics include source locations where available and a `mapped` or
|
|
182
|
+
`unmapped` status. Strict mode stops before writing the DOCX when a known
|
|
183
|
+
loss is reported. Recovered diagnostics and the experimental HTML notice are
|
|
184
|
+
informational.
|
|
185
|
+
|
|
186
|
+
Word recalculates line breaks, pagination, column balance, and float placement.
|
|
187
|
+
Wide objects use continuous section breaks by default and are inserted at
|
|
188
|
+
their logical source position. Use `--wide-placement page` to start wide
|
|
189
|
+
objects on a new page. Footnotes near continuous section breaks can add a
|
|
190
|
+
page in Word or LibreOffice despite the compatibility setting.
|
|
191
|
+
[Word sections](https://python-docx.readthedocs.io/en/latest/user/sections.html)
|
|
192
|
+
· [Microsoft's notes on footnotes and section breaks](https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/8a382070-ad9b-4723-98f9-49f0277f56cd)
|
|
193
|
+
|
|
194
|
+
`layout.page_scopes` records evaluated page settings and their Typst physical
|
|
195
|
+
page ranges. If a change cannot be matched to a flow boundary, the audit
|
|
196
|
+
reports the loss and the converter falls back to the first sampled body layout.
|
|
197
|
+
Repeated page rules with identical settings preserve their page breaks when
|
|
198
|
+
the compiler's break events can be matched to editable block boundaries. A
|
|
199
|
+
break emitted exclusively by the paged target can be matched the same way.
|
|
200
|
+
Automatic pagination remains in Word. Five or more columns, columns nested inside
|
|
201
|
+
another column, mirrored margins, dynamic headers and footers, odd/even
|
|
202
|
+
breaks, explicit weak breaks, and compound alignment fall outside this subset.
|
|
203
|
+
When a `stack` or `place` is recovered as editable content in the document flow,
|
|
204
|
+
the audit identifies the lost spacing, direction, coordinates, or layering.
|
|
205
|
+
The audit also reports wide grid scaling and unsupported features
|
|
206
|
+
such as nested grids, middle or multi-level headers, footers, decorative
|
|
207
|
+
separators, and combinations of `auto` widths with merges or explicit coordinates.
|
|
208
|
+
|
|
209
|
+
Figure and table numbering `"1"` and equation numbering `"(1)"` or `"1"`
|
|
210
|
+
can become live fields. Where Typst supplies custom numbering as text, it
|
|
211
|
+
stays static with clickable references. The audit flags equation-numbering
|
|
212
|
+
functions that return unsupported rich content. Section numbering,
|
|
213
|
+
bibliography entries, and citations are static. Nested figures, independent
|
|
214
|
+
subfigure counters, algorithm environments, arbitrary diagram plugins, and
|
|
215
|
+
complex wrapping fall outside the current mapping. Templates can provide an
|
|
216
|
+
HTML-compatible branch where they depend on paged output.
|
|
217
|
+
[Typst HTML export](https://typst.app/docs/reference/html/)
|
|
218
|
+
|
|
219
|
+
The DOCX package uses stable entry ordering and timestamps. Byte-for-byte
|
|
220
|
+
reproducibility depends on the same tool versions, fonts, resources, inputs,
|
|
221
|
+
and evaluated document content, including any dates the source reads.
|
|
222
|
+
|
|
223
|
+
## Regression checks
|
|
224
|
+
|
|
225
|
+
Run `uv run --locked pytest` to check generated documents for column widths,
|
|
226
|
+
section breaks, fields, footnotes, native math, and bookmark targets. For
|
|
227
|
+
visual checks, render the exported DOCX and compare its pages with the source.
|
|
228
|
+
|
|
229
|
+
The [stress example](examples/stress.typ) exercises a clickable outline,
|
|
230
|
+
three columns, explicit breaks, full-width objects, two numbering patterns,
|
|
231
|
+
footnotes, merged headers, and a long table. Edge mode switches to four
|
|
232
|
+
columns and includes weak and odd-page breaks, fixed header text, and grids
|
|
233
|
+
with different widths and alignments.
|
|
234
|
+
|
|
235
|
+
```sh
|
|
236
|
+
uv run tydo examples/stress.typ --strict
|
|
237
|
+
uv run tydo examples/stress.typ --typst-input rows=480 -o work/stress-large.docx --strict
|
|
238
|
+
uv run tydo examples/stress.typ --typst-input mode=edge --typst-input rows=12 -o work/stress-edge.docx
|
|
239
|
+
uv run tydo examples/font-gallery.typ -o work/font-gallery.docx --strict
|
|
240
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// User-defined diagrams become one native picture per composition in Word.
|
|
2
|
+
#set document(title: "Typst function drawings", date: none)
|
|
3
|
+
#set page(columns: 2)
|
|
4
|
+
|
|
5
|
+
#let node(label, fill) = rect(width: 23mm, height: 10mm, fill: fill, radius: 2pt)[#label]
|
|
6
|
+
#let pipeline() = stack(dir: ltr, spacing: 3mm,
|
|
7
|
+
node([Input], aqua),
|
|
8
|
+
line(length: 7mm),
|
|
9
|
+
node([Output], yellow),
|
|
10
|
+
)
|
|
11
|
+
#let canvas() = block(width: 75mm, height: 20mm)[
|
|
12
|
+
#align(top)[
|
|
13
|
+
#place(top + left, dx: 3mm, dy: 3mm, node([
|
|
14
|
+
#set text(weight: "bold")
|
|
15
|
+
First
|
|
16
|
+
], aqua))
|
|
17
|
+
#place(top + left, dx: 40mm, dy: 4mm, circle(radius: 5mm, fill: red))
|
|
18
|
+
]
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
= Composed drawings
|
|
22
|
+
|
|
23
|
+
#figure(pipeline(), kind: image, caption: [Composition made with a user-defined stack]) <pipeline>
|
|
24
|
+
|
|
25
|
+
See @pipeline for the first diagram.
|
|
26
|
+
|
|
27
|
+
#figure(canvas(), kind: image, caption: [Composition using a fixed-size canvas]) <canvas>
|
|
28
|
+
|
|
29
|
+
See @canvas for the second diagram. A small #circle(radius: 2mm, fill: blue) marker remains inline.
|
|
30
|
+
|
|
31
|
+
#figure(
|
|
32
|
+
rotate(12deg, node([Tilted], lime), reflow: true),
|
|
33
|
+
kind: image,
|
|
34
|
+
caption: [Composition using rotation],
|
|
35
|
+
) <tilted>
|
|
36
|
+
|
|
37
|
+
The rotation is shown in @tilted.
|