diff --git a/README.md b/README.md index c52e57f..288a53f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# typst-oxifmt (v0.3.0) +# typst-oxifmt (v1.0.0) A Typst library that brings convenient string formatting and interpolation through the `strfmt` function. Its syntax is taken directly from Rust's `format!` syntax, so feel free to read its page for more information (https://doc.rust-lang.org/std/fmt/); however, this README should have enough information and examples for all expected uses of the library. Only a few things aren't supported from the Rust syntax, such as the `p` (pointer) format type, or the `.*` precision specifier. Check out the ["Examples" section](#examples) for more. @@ -9,7 +9,7 @@ A few extras (beyond the Rust-like syntax) will be added over time, though (feel ## Quick examples ```typ -#import "@preview/oxifmt:0.3.0": strfmt +#import "@preview/oxifmt:1.0.0": strfmt // "User John has 10 apples." #strfmt("User {} has {} apples.", "John", 10) @@ -17,8 +17,8 @@ A few extras (beyond the Rust-like syntax) will be added over time, though (feel // "if exp > 100 { true }" #strfmt("if {var} > {num} {{ true }}", var: "exp", num: 100) -// "1.10e2 meters" -#strfmt("{:.2e} meters", 110.0) +// "1.10e2 meters (**wow**)" +#strfmt("{:.2e} meters ({:*^7})", 110.0, "wow") // "20_000 players have more than +002,300 points." #strfmt( @@ -50,7 +50,7 @@ A few extras (beyond the Rust-like syntax) will be added over time, though (feel You can use this library through Typst's package manager (for Typst v0.6.0+): ```typ -#import "@preview/oxifmt:0.3.0": strfmt +#import "@preview/oxifmt:1.0.0": strfmt ``` For older Typst versions, download the `oxifmt.typ` file either from Releases or directly from the repository. Then, move it to your project's folder, and write at the top of your Typst file(s): @@ -64,7 +64,7 @@ Doing the above will give you access to the main function provided by this libra Its syntax is almost identical to Rust's `format!` (as specified here: https://doc.rust-lang.org/std/fmt/). You can escape formats by duplicating braces (`{{` and `}}` become `{` and `}`). Here's an example (see more examples in the file `tests/strfmt-tests.typ`): ```typ -#import "@preview/oxifmt:0.3.0": strfmt +#import "@preview/oxifmt:1.0.0": strfmt #let s = strfmt("I'm {}. I have {num} cars. I'm {0}. {} is {{cool}}.", "John", "Carl", num: 10) #assert.eq(s, "I'm John. I have 10 cars. I'm John. Carl is {cool}.") @@ -82,7 +82,7 @@ You can use `{:spec}` to customize your output. See the Rust docs linked above f - For strings, `?` (and thus `repr()`) has the effect of printing them with double quotes. For floats, this ensures a `.0` appears after it, even if it doesn't have decimal digits. For integers, this doesn't change anything. Finally, for labels, the `