Skip to content

Instantly share code, notes, and snippets.

@Dragonink
Created February 13, 2025 11:47
Show Gist options
  • Save Dragonink/2c50e4b9ed8ba071060f15b1977aa05c to your computer and use it in GitHub Desktop.
Save Dragonink/2c50e4b9ed8ba071060f15b1977aa05c to your computer and use it in GitHub Desktop.
How to Typst + PanDiff

How to Typst + PanDiff

  1. Prepare a diff.typ source file as shown in this Gist.
  2. Provided you have two Typst SOURCE files named a.typ and b.typ, execute:
    pandiff --from typst --to typst a.typ b.typ > diff.content.typ
  3. Compile the diff.typ file:
    typst compile diff.typ
#let INS_RE = regex(`\{\+{2}(.+)\+{2}\}`.text)
#show INS_RE: this => {
let (contents,) = this.text.match(INS_RE).captures
box(outset: 0.25em, fill: green.transparentize(85%), underline(text(fill: green, contents)))
}
#let DEL_RE = regex(`\{(?:-{2}|–)(.+)(?:-{2}|–)}`.text)
#show DEL_RE: this => {
let (contents,) = this.text.match(DEL_RE).captures
box(outset: 0.25em, fill: red.transparentize(85%), strike(text(fill: red, contents)))
}
#include "diff.content.typ"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment