ChHecker / unify

Format numbers, units, and ranges in Typst correctly.
MIT License
23 stars 17 forks source link

Allow plain negative numbers #13

Closed linuxrider closed 7 months ago

linuxrider commented 10 months ago

str() converts minus - to unicode \u2212 which prevents the regex to match. This is fixed by replacing it again with -.

ChHecker commented 8 months ago

Could you provide an example that doesn't work? E.g. #num("-2.5") works perfectly for me.

linuxrider commented 8 months ago

If you do calculations or use variables it works for positive numbers but not for negative numbers. The proposed change allows to directly use numbers as is and not in a string, which enhances convenience for the user.

#import "@preview/unify:0.4.3": num
#let x = -2
#let y = 3

// #num(x) // does not work
// #num(str(x)) // does not work

#num(y) // works

#num(str(y)) // works

#num(calc.exp(1)) // works

// #num(-calc.exp(1)) // does not work
ChHecker commented 7 months ago

Thank you for your contribution!