manim/docs/source
Benjamin Hackl d999d422c9
Introduce first-class support for rendering text and markup via Typst (optional dependency) (#4681)
* feat: add TypstMobject and TypstMathMobject for first-class Typst support

Implement the initial TypstMobject proposal (see agents/typst.md):

- TypstMobject: renders arbitrary Typst markup to SVG via the 'typst'
  Python package (self-contained Rust binary, no system install needed),
  then imports through SVGMobject.
- TypstMathMobject: convenience subclass that wraps input in Typst math
  delimiters ($ ... $).

Pipeline: user string → wrap in minimal Typst document (auto-sized page,
transparent background) → write .typ file → compile to SVG via
typst.compile() → import via SVGMobject → scale/center/recolor.

Key details:
- Compilation helper in manim/utils/typst_file_writing.py with SHA-256
  content-hash caching (same scheme as the LaTeX pipeline).
- font_size property mirrors SingleStringMathTex: compile at fixed 11pt,
  scale after import using initial_height / SCALE_FACTOR_PER_FONT_POINT.
- init_colors() recolors black submobjects to self.color (Typst default
  fill is black), preserving any explicit Typst colors.
- path_string_config enables curve subdivision for smooth animation.
- 'typst' added as optional dependency group in pyproject.toml.
- 10 tests covering creation, font_size, caching, preamble, and repr.

* feat(typst): add sub-expression selection via {{ }} groups and .select()

- Override modify_xml_tree in Typst to convert data-typst-label
  attributes to id attributes before svgelements parsing (avoids
  attribute inheritance issue with data-* attributes)
- Add Typst.select(key) method accepting str labels or int indices
  to retrieve VGroup sub-expressions from id_to_vgroup_dict
- Implement {{ }} double-brace preprocessor on TypstMath:
  - {{ content }} → manimgrp("_grp-N", content) (auto-numbered)
  - {{ content : label }} → manimgrp("label", content) (named)
  - Skips {{ }} inside string literals and [...] content blocks
  - Uses math-mode call convention (no # prefix) to keep args in
    math mode
- Auto-inject manimgrp preamble when groups are detected
- Add 12 new tests covering label mapping, nesting, select(),
  error handling, and preprocessor edge cases

* Remove unneeded assert line

* Generalize some more critical hard-coded LaTeX assumptions

* Fix syntax error

* Support Typst labels in existing APIs

* Add ManimTextLabel typing alias

* Preserve Typst SVG stroke widths by default

* Calibrate Typst font sizing against TeX

* Add Typst mobject documentation

* Track Typst baseline frames

* Document Typst baseline frame tracking

* Add Typst section to text guide

* Polish Typst docs and label handling

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Improve Typst stroke scaling and docs examples

* Tune Typst SVG stroke scaling

* Restore Typst math example wording

* Fix pre-commit issues for Typst branch

* Fix number line runtime typing import

* Exclude Typst autogenerated .rst files

* Use Manim directive in docstrings and fix wrong key in Typst.select() docstring

* Fix GroupedMath comments

---------

Co-authored-by: Toon Verstraelen <Toon.Verstraelen@UGent.be>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Francisco Manríquez Novoa <49853152+chopan050@users.noreply.github.com>
Co-authored-by: Francisco Manríquez Novoa <francisco.manriquezn@usm.cl>
2026-06-11 03:54:21 +00:00
..
_static Add option to run examples directly with binder (#3427) 2023-11-10 21:52:43 +01:00
_templates Added support for Manim type aliases in Sphinx docs + Added new TypeAliases (#3484) 2023-12-29 19:04:31 +01:00
changelog Prepare new release: v0.20.1 (#4615) 2026-02-27 08:09:59 +01:00
contributing Add VectorNDLike type aliases (#4068) 2025-08-01 04:31:30 +00:00
faq Fix broken aquabeam OpenGL link using Wayback Machine (#4545) 2026-01-25 12:33:39 +00:00
guides Introduce first-class support for rendering text and markup via Typst (optional dependency) (#4681) 2026-06-11 03:54:21 +00:00
installation enhancement: optimize Docker image build and runtime footprint (#4604) 2026-02-22 17:29:18 -03:00
reference_index Add classes MethodWithArgs, SceneInteractContinue and SceneInteractRerun inside new module manim.data_structures (#4315) 2025-07-25 00:37:14 +02:00
tutorials docs(quickstart): fix incorrect terminology for SquareToCircle (#4631) 2026-03-08 09:47:57 +01:00
changelog.rst Prepare new release: v0.20.1 (#4615) 2026-02-27 08:09:59 +01:00
conduct.md Added code of conduct (#935) 2021-01-18 19:14:57 +05:30
conf.py Rework and consolidate release changelog script, add previously skipped changelog entries (#4568) 2026-02-04 10:10:39 +01:00
contributing.rst Improve documentation section about contributing to docs (#3555) 2023-12-30 00:22:24 +01:00
examples.rst Refactor Rotating and add docstrings to Mobject.rotate() and Rotating (#4147) 2025-06-22 04:15:12 +00:00
index.rst Added license information to documentation landing page (#3986) 2025-08-18 23:16:45 +02:00
installation.rst Rewrite installation instructions (#3930) 2024-12-06 18:50:18 -05:00
plugins.rst Change project management tool from poetry to uv (#4138) 2025-02-02 17:16:46 +01:00
reference.rst Added :class:.ChangeSpeed, an animation wrapper that allows to smoothly change the speed at which an animation is played (#2749) 2022-07-06 16:39:55 +02:00
robots.txt Flake8 Changes + Fixing Warnings (#1968) 2021-09-03 13:45:48 -04:00
tutorials_guides.rst Refactored structure of documentation; added :doc:FAQ section <faq/index> (#2732) 2022-05-27 08:45:31 +00:00