From baa6cf8cc43ce676b806db01e390668dc4aa6790 Mon Sep 17 00:00:00 2001 From: cashmere Date: Sun, 26 Apr 2026 20:36:04 +0200 Subject: feat: add typst inline equation preview Mirrors the existing LaTeX fragment integration but uses the `typst` CLI to compile `$...$' math fragments into PNGs that are then displayed inline through the existing kitty-graphics overlay pipeline. - New section in kitty-graphics.el: customs (typst-command, ppi, text-size, preamble), SHA-1 cached PNGs under /tmp/kitty-gfx-typst, Emacs face-foreground -> typst rgb() hex conversion. - Two autoloaded commands: `kitty-gfx-typst-preview' and `kitty-gfx-typst-clear-preview', region-aware. - Regex skips backslash-escaped dollars (\\$not math\\$). - justfile with recipes: compile/lint/load + per-feature test-* and headless typst-render / typst-show. - tests/test-typst.typ fixture with inline, display, mixed and edge-case fragments. - AGENTS.md updated: test instructions, dependency note, issue marked done. Closes #7. Parent #5. --- tests/test-typst.typ | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/test-typst.typ (limited to 'tests/test-typst.typ') diff --git a/tests/test-typst.typ b/tests/test-typst.typ new file mode 100644 index 0000000..a28fcbf --- /dev/null +++ b/tests/test-typst.typ @@ -0,0 +1,31 @@ +// Test fixture for kitty-graphics.el typst inline equation preview. +// +// Usage: +// TERM=xterm-256color emacs -nw -Q -l kitty-graphics.el \ +// --eval "(kitty-graphics-mode 1)" tests/test-typst.typ +// M-x kitty-gfx-typst-preview +// M-x kitty-gfx-typst-clear-preview +// +// Inline math fragments below should each be replaced by a rendered +// PNG overlay. Escaped dollar signs (\$ ... \$) must be ignored. + += Inline samples + +Pythagoras: $a^2 + b^2 = c^2$, classic. + +Euler: $e^(i pi) + 1 = 0$ -- the famous identity. + +Display style with surrounding spaces: +$ integral_(-oo)^(+oo) e^(-x^2) dif x = sqrt(pi) $ + +Mixed line: $x = 1$ and $y = 2$ on the same line. + +Escaped dollar signs should be skipped: \$not math\$ here. + += Edge cases + +Sum: $sum_(k=0)^n binom(n, k) = 2^n$. + +Matrix: $mat(1, 2; 3, 4)$. + +Greek: $alpha + beta = gamma$. -- cgit v1.3.1