- Prepare a
diff.typsource file as shown in this Gist. - Provided you have two Typst SOURCE files named
a.typandb.typ, execute:pandiff --from typst --to typst a.typ b.typ > diff.content.typ - Compile the
diff.typfile:typst compile diff.typ
Last active
May 27, 2025 17:23
-
-
Save Dragonink/2c50e4b9ed8ba071060f15b1977aa05c to your computer and use it in GitHub Desktop.
How to Typst + PanDiff
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
| #let diff-box(color, contents) = box( | |
| outset: 0.25em, | |
| fill: color.transparentize(85%), | |
| text(fill: color, contents), | |
| ) | |
| #let INSERT_RE = regex(`\{\+{2}(.+?)\+{2}\}`.text) | |
| #show INSERT_RE: this => { | |
| let (contents,) = this.text.match(INSERT_RE).captures | |
| diff-box(green, underline(contents)) | |
| } | |
| #let DELETE_RE = regex(`\{(?:-{2}|–)(.+?)(?:-{2}|–)\}`.text) | |
| #show DELETE_RE: this => { | |
| let (contents,) = this.text.match(DELETE_RE).captures | |
| diff-box(red, strike(contents)) | |
| } | |
| #let REPLACE_RE = regex(`\{(?:~{2})(.+?)~>(.+?)(?:~{2})\}`.text) | |
| #show REPLACE_RE: this => { | |
| let (old, new) = this.text.match(REPLACE_RE).captures | |
| diff-box(orange)[ | |
| #strike(old) | |
| #underline(new) | |
| ] | |
| } | |
| #include "diff.content.typ" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment