Feat/d2 diagrams#16
Merged
Merged
Conversation
REGISTRY_REPO still targeted the old JheisonMB/texforge-templates, which only resolved via GitHub's 301 redirect. Point it at UniverLab/texforge-templates. Verified template list --all and template add download from the new registry. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diagram pipeline (src/diagrams/mod.rs):
- Cache rendered PNGs by content hash ({env}-{hash}.png), skipping re-render of
unchanged diagrams across rebuilds (notably under --watch).
- Build the resvg font database once via a shared OnceLock instead of per diagram
(scanning /mnt/c/Windows/Fonts over WSL 9P was slow).
- Raise rasterization from 1.5x to 3x (~300 dpi at \linewidth) for print quality.
- Fix invalid default \includegraphics[\linewidth] -> width=\linewidth.
Windows / TLS:
- Use TECTONIC_BIN (tectonic.exe on Windows) for the managed binary path so the
installed tectonic is actually located and executable.
- Switch reqwest off aws-lc-rs to rustls+ring (rustls-no-provider + ring provider
installed in main), removing the C-toolchain dependency that broke Windows/musl
builds. Verified aws-lc-sys leaves the tree and HTTPS downloads still work.
Build/assets:
- Output the PDF as <title>.pdf in the project root from a temp build dir.
- Unify sanitize_filename in utils; clean removes the output PDF + legacy build/.
- mirror_assets symlinks nested assets next to .tex files (absolute targets).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add a \begin{d2}...\end{d2} environment that renders like mermaid and graphviz:
same options (width, height, scale, pos, caption, label, keepaspectratio),
same hash-based PNG caching, same figure output.
- Render via d2-little (pure-Rust port of the d2lang pipeline, MPL-2.0) to SVG,
then through the existing svg_to_png path. No external binary, matching the
self-contained philosophy of the mermaid/graphviz renderers.
- D2 embeds its fonts as @font-face WOFF, which usvg ignores, so its text relies
entirely on the sans-serif fallback. Harden configure_sans_serif_family to fall
back to any available family so D2 text never silently disappears.
- Linter checks \begin{d2} blocks for unclosed envs and invalid pos, like the
other diagram types.
- Verified end to end: D2 renders node/edge labels and the figure embeds in the
compiled PDF (Image XObject), alongside mermaid in the same document.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
add d2 diagrams support