Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom units without @local #7

Open
lumpiluk opened this issue Oct 26, 2023 · 1 comment
Open

Custom units without @local #7

lumpiluk opened this issue Oct 26, 2023 · 1 comment

Comments

@lumpiluk
Copy link

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

  • maintain the corresponding dictionaries like units, units-short, etc., as state and add a function for easily adding a new unit, prefix, or postfix; or
  • add parameters of the same names as those dictionaries to _format-unit defaulting to the existing dictionaries, which should allow users to use set rules to specify the extended dictionaries?
@ChHecker
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants