Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/docs/changelog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
- **TikZ SVGs embed fonts** — `dvisvgm` no longer runs with `--no-fonts`, so
diagram text stays selectable and searchable; it falls back to outlined
paths only when the TeX fonts are unavailable.
- **TikZ compilation no longer times out** — the fixed 60-second per-step
limit is removed; large or slow diagrams (pgfplots surfaces, heavy
`foreach` loops) compile for as long as they need.

### Changed

Expand Down
2 changes: 2 additions & 0 deletions docs/docs/changelog/index.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
tkz-euclide 已随 `texlive-pictures` 提供。
- **TikZ SVG 内嵌字体** —— `dvisvgm` 不再使用 `--no-fonts`,图表文字保持
可选中、可搜索;仅在 TeX 字体不可用时回退为轮廓路径。
- **TikZ 编译不再超时** —— 移除了每步固定 60 秒的限制;大型或慢速图表
(pgfplots 曲面、大量 `foreach` 循环)可以按需编译任意时长。

### 变更

Expand Down
17 changes: 5 additions & 12 deletions docsforge/tikz.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

log = logging.getLogger("docsforge.tikz")

LATEX_TIMEOUT = 60

# Default preamble for bare diagram sources (files without a \documentclass).
# Only the tikzpicture / tikzcd / axis body needs to be written; the math
# diagram toolchain (pgfplots, tikz-cd, tkz-euclide, amsmath/amssymb) is
Expand Down Expand Up @@ -75,8 +73,7 @@ def _run_dvisvgm(input_file: Path, output_path: Path, cwd: Path, name: str) -> b
cwd=cwd,
capture_output=True,
text=True,
timeout=LATEX_TIMEOUT,
)
)
if result.returncode == 0:
if extra:
log.warning(
Expand Down Expand Up @@ -140,8 +137,7 @@ def _compile_tex_to_svg(
cwd=tmpdir,
capture_output=True,
text=True,
timeout=LATEX_TIMEOUT,
)
)
if result.returncode != 0:
err = result.stderr[:500] if result.stderr else result.stdout[:500]
log.warning(f"latex failed for {tex_path.name}: {err}")
Expand All @@ -162,8 +158,7 @@ def _compile_tex_to_svg(
cwd=tmpdir,
capture_output=True,
text=True,
timeout=LATEX_TIMEOUT,
)
)
if result.returncode != 0:
log.warning(f"pdflatex failed for {tex_path.name}: {result.stderr[:200]}")
return False
Expand All @@ -177,8 +172,7 @@ def _compile_tex_to_svg(
["pdf2svg", str(pdf_file), str(output_path)],
capture_output=True,
text=True,
timeout=LATEX_TIMEOUT,
)
)
if result.returncode != 0:
log.warning(f"pdf2svg failed for {tex_path.name}: {result.stderr[:200]}")
return False
Expand All @@ -190,8 +184,7 @@ def _compile_tex_to_svg(
cwd=tmpdir,
capture_output=True,
text=True,
timeout=LATEX_TIMEOUT,
)
)
if result.returncode != 0:
log.warning(f"pdflatex failed for {tex_path.name}: {result.stderr[:200]}")
return False
Expand Down