ChHecker / unify

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

Custom units without `@local` #7

Open lumpiluk opened 12 months ago

lumpiluk commented 12 months ago

I'm looking for a way to add custom units (e.g., "hours") while importing unify from @preview. According to the Readme:

The possible values of the three latter parts are loaded at runtime from prefixes.csv, units.csv, and postfixes.csv (in the library directory). There, you can also add your own units.

However, when importing from @preview, these CSVs aren't available to me.

Would it make sense to either

ChHecker commented 8 months ago

You're right, the current unit storage is not as flexible as I'd like.

Storing the units in a CSV instead of in the code was not a choice I felt was the most usable, but rather the one lying in my abilities. Keeping track of global variables in Typst is really hard because you have multiple passes over the file. I am always to pull requests, though.

Would the second idea work? I'd assume that the path is relative to the main file where the library is imported, such that you can't easily find the bundled CSVs.