Releases: PgBiel/typst-oxifmt
Releases · PgBiel/typst-oxifmt
v1.0.0
oxifmt
is two years old!
What's Changed
- Breaking change: Replacement names can no longer contain braces for consistency with Rust. (Issue #17)
- That is,
{a {{ b}
and{a }} b}
are now errors. - Braces inside replacement names cannot be escaped, and
}
ends the name eagerly. - Leads to less apparent ambiguity in some cases, and is also what Rust does.
- That is,
- Breaking change: Private symbols are now hidden. This package's entrypoint now only exports the
strfmt
function. (PR #26)- Technically not a breaking change as these weren't intended for public usage, but worth giving some attention to anyway.
- Added variably-sized thousands for insertion of separators through
fmt-thousands-count: (group 1 size, group 2 size, ..., remaining group sizes)
. This may be useful for certain numbering systems used in India. (Issue #21)- For instance, one may have a digit group of size 3 followed by any amount of size 2 groups using
strfmt("1000000", fmt-thousands-count: (3, 2), fmt-thousands-separator: ",")
, which outputs10,00,000
(note that groups go from right to left, similarly to the numbers themselves).
- For instance, one may have a digit group of size 3 followed by any amount of size 2 groups using
- Fixed an inconsistency with Rust where
{
and}
would not be valid padding characters in format specifiers. The following is now valid:{:{<5}
i.e. pad to 5 characters to the left with{
(similarly for}
). (Issue #28) - Fixed an inconsistency with Rust where center-aligned padding could result in more than the specified width as padding was forced to be equal on both sides for perfect centering. Now,
strfmt("{:_^4}", "a")
will output"_a__"
(exactly 4 characters, even if not perfectly centered) instead of"__a__"
(5 characters). (Issue #29) - Fixed a bug with scientific notation conversion for fixed-point
decimal
where certain digits would not be displayed. (Issue #23)
Full Changelog: v0.3.0...v1.0.0
v0.3.0
What's Changed
- Breaking change: Named replacements prefixed with
fmt-
are now an error. Those are reserved for futureoxifmt
options. (Issue #15)- For example, instead of
strfmt("{fmt-x}", fmt-x: 10)
, writestrfmt("{_fmt-x}, _fmt-x: 10")
instead (or some other name with a different prefix).
- For example, instead of
- Added thousands separator support, configurable with
strfmt(format, fmt-thousands-count: 3, fmt-thousands-separator: "")
. The first option defines how many digits should appear between each separator, and the second option controls the separator itself (default is empty string, disabling it). (Issue #5)- For example,
strfmt("{}", 2000, fmt-thousands-separator: ",")
displays"2,000"
. - Within the same example, adding
fmt-thousands-count: 2
would display20,00
instead. - Numeric systems with irregular thousands separator distances will be supported in a future release.
- For example,
- Added support for numeric formatting of fixed-point
decimal
numbers. They support the same format specifiers as floats, e.g.{:e}
for exponential notation,{:.3}
for a fixed precision and so on. (Issue #11) - oxifmt is now dual-licensed as MIT or Apache-2.0 (previously just MIT).
- Fixed some bugs when formatting
inf
andNaN
. - Fixed a rare case of wrong usage of types in strings in internal code, which could cause oxifmt to generate an error in upcoming Typst v0.14. It is recommended to upgrade oxifmt to avoid this problem.
- However, this was only triggered when a very rare formatting option was used (dynamic precision specifiers, which have a dollar sign
$
, e.g.{:.prec$}
), so existing code is unlikely to be affected. Still a good idea to upgrade, though.
- However, this was only triggered when a very rare formatting option was used (dynamic precision specifiers, which have a dollar sign
- Fixed exponential notation formatting with very large numbers. Note that they might need rounding to look good (e.g.
strfmt("{:.2e}", number)
instead of just{:e}
), but they will no longer cause an error. (Issue #16)
Full Changelog: v0.2.1...v0.3.0
v0.2.1
- Fixed formatting of UTF-8 strings. Before, strings with multi-byte UTF-8 codepoints would cause formatting inconsistencies or even crashes. (Issue #6)
- Fixed an inconsistency in negative number formatting. Now, it will always print a regular hyphen (e.g. '-2'), which is consistent with Rust's behavior; before, it would occasionally print a minus sign instead (as observed in a comment to Issue #4).
- Added compatibility with Typst 0.8.0's new type system.
Full Changelog: v0.2.0...v0.2.1
v0.2.0
- The package's name is now
oxifmt
(previouslytypst-strfmt
)! oxifmt:0.2.0
is now available through Typst's Package Manager! You can now write#import "@preview/oxifmt:0.2.0": strfmt
to use the library.- Greatly improved the README, adding a section for common examples.
- Fixed negative numbers being formatted with two minus signs.
- Fixed custom precision of floats not working when they are exact integers.
Full Changelog: v0.1.0...v0.2.0
v0.1.0 - Initial Release
Initial release (adds the strfmt
function).