Closed ntjess closed 7 months ago
This is expected behavior, as it's how Rust does it, and this package aims to be as close as possible to Rust's format!
function. You could use something such as
#let old-strfmt = strfmt
#let strfmt(..args) = {
let result = old-strfmt(..args)
if result == "-0" { "0" } else { result }
}
We could consider adding some sort of custom flag which just does that, but I'm not sure if it's worth it... So I'll be closing the issue for now, but thanks for bringing this up.
Thanks for the explanation, I should've checked before submitting the issue. Typst itself also formats in this way.
However, note that "-" is different from MINUS (0x2212) so you may want to change the char code such that it aligns with non-special cases:
Thanks @ntjess, I hadn't noticed the character was different until now! For now, I've elected a normal hyphen to be displayed in all cases instead. Perhaps we can change this in the future if needed.
#strfmt("{:.0}", -0.1)
displays as-0
, where0
would be more appropriate