Version 0.1.0
%-style (printf) str format for typst
Getting Started
Simplest example:
#import "@preview/sprintf:0.1.0": *
#sprintf("%s", "Tom")
Another example:
Usage
A more in-depth description of usage:
Just use as if using Python’s % of str
#import "@preview/sprintf:0.1.0": *
#let s-example = sprintf("%s-%.1f", "asd", 1.23)
Additional Documentation and Acknowledgments
- This package is based on: https://pyformats.nimpylib.org/pyformats/percent
pyformats/percentis an implementation in Nim of Python’s printf-style string formatting: https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting- This package also exposes
sprintf-map, which formats strings using a mapping of names to values. Example:sprintf-map("name=%(name)s", (name: "Alice"))
Development
This section is for developers or advanced users only
To build this package locally, there is the guide to show how to get the development environment up and running.
Firstly, install Nim.
Then, compile plugin via:
$ cd lib
$ nimble run
$ cd ..
Afterward, entrypoint src/lib.typ along with its dependency src/lib.wasm shall be generated.