Skip to content

Instantly share code, notes, and snippets.

@ckunte
Created April 18, 2024 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckunte/ab1993fbba0a2c31e240c64382558dca to your computer and use it in GitHub Desktop.
Save ckunte/ab1993fbba0a2c31e240c64382558dca to your computer and use it in GitHub Desktop.
Turn uppercase words into smallcaps in Typst
// Small caps ( see: https://github.com/typst/typst/discussions/3927 )
// Turn uppercase letters to small caps: use #sc([WORDINCAPS])
// for those that escape the REGEX match
#let sc(content) = text(features: ("c2sc",))[#content]
// For testing, comment the above line, and uncomment the line below
// let sc(content) = text(features: ("c2sc",))[#highlight(content)]
// Turn all uppercase words (any 2 or more grouping of A-Z
// ASCII characters) into small caps
#show regex("[A-Z]{2,}"): match => {
sc(match)
}
// NOTE: When adding this to a template, but not to document, directly,
// exclude the `#` preceding `let`, `show`, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment