ChHecker / unify

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

Add imperial and custom units #22

Closed schmic41 closed 6 months ago

schmic41 commented 6 months ago

This PR has two parts: a .csv file containing common imperial measurements for length, weight, and volume; and changes to the unit and qty functions to accommodate switching between units.

SI and imperial units are automatically loaded from their appropriate .csv files. The unit and qty functions now have an optional units parameter. The units parameter takes a string equal to either "SI", "Imperial", or the name of a local .csv file containing custom units.

Since the default units parameter is "SI", this should not affect any existing code.

Possible problems with this implementation:

ChHecker commented 6 months ago

Hi, thanks for your pull request!

It seems @SergeyGorchakov and yourself created two conflicting pull requests at the same time. That means I have to prioritize one of them. Since the idea of this package is to be similar to LaTeX's siunitx, I'd generally prioritize metrics units over imperial (for now). Sorry.

If you want to adapt your PR to @SergeyGorchakov's mechanism after I merged it, we could talk about unifying the way of switching languages and units.

schmic41 commented 6 months ago

No problem, I understand! I'll take a look at Sergey's changes and see what I can do. Thanks for taking a look at this.