Git Product home page Git Product logo

unify's People

Contributors

chhecker avatar gkend avatar jarrod-angove avatar linuxrider avatar loewe1000 avatar nycex avatar rungecc avatar scrouthtv avatar sergeygorchakov avatar szsdk avatar ydx-2147483647 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

unify's Issues

Allow unicode exponents

It would be nice if unicode exponents could be used to write units.
normal:
#qty("2.5", "J mol^-1 K^-1")
unicode:
#qty("2.5", "J mol⁻¹ K⁻¹")

[unify package] Set decimal separator manually

It should be possible to set the default decimal separator. I tried doing

#set _format-float(decsep: ",")

$ num("2.0") $

as I prefer to leave the numbers in code with dots (yet want it to show up as 2,0), but it throws a syntax error. Any way to set that in another way?

(originally typst/packages#188)

Typo in units.csv and request for times multiplication symbol

Hi.
Sorry to disturb you.
When I tried to use the coulomb measurement ubit, it didn't work.
I realized, as in the attachement, that there was a typo in the unit.csv file, probabbly it is necessary to remove the character ".
By the way, in LaTeX SIunits, when you type the scientific notation the multiplication sign is a times and not a dot. Could it be possible to have the possibility tto choice between a dot or times symbol also in your package (I attach a file to be clearer).
Thank a lot and sorry for my bad English.
Best regards,
Roberto
units.csv.pdf
Generic.pdf

Result of `#unit("Hz")` is confusing

  • #unit("hz")h (hecto ?)
  • #unit("Hz")zH (zepto Henry)

Results of #qty is similar.

I am using v0.4.2 and I've verified this issue on current main (d2ab4c3).

Workaround

Don't use units-short: #unit("hertz") works as expected.

Reason

  • h is a valid prefix (hecto or 100).
  • H is a valid unit (Henry).
  • z is a valid prefix (zepto or $10^{-21}$).

Therefore the checks pass, and we try to parse z and fail. However, we don't #panic and let it go…

Possible Fix

In #format-unit-short, remove the else if in the for loop…

unify/lib.typ

Lines 230 to 232 in d2ab4c3

} else if acc.len() == quantity.len() {
panic("invalid unit: " + quantity)
}

…and add the following immediately after the loop.

    if acc.len() > 0 {
      panic("invalid unit: " + quantity)
    }

This will make #unit("hz") into error: panicked with: "invalid unit: hz".

In the same for loop, add and unit == none in this if, because the prefix must appear before the unit:

unify/lib.typ

Lines 223 to 225 in d2ab4c3

if acc in prefixes-short and prefix == none {
prefix = prefixes-short.at(acc)
acc = ""

This will make #unit("Hz") into error: panicked with: "invalid unit: Hz".

Warning

This does NOT make #unit("Hz")Hz, because #format-unit-short is eager — it consumes H as Henry first.

A Bigger Refactor?

I suggest a bigger refactor of the parsing logic in #format-unit-short

  1. If quantity in units-short, unit = units-short.at(quantity), ✓.
  2. If not, divide quantitiy into two parts, if the first part is a prefix and the second is a unit, ✓.
  3. If not, try to divide at other positions.
  4. If all division fail, panic.

How do you think so? If you agree but are busy, I can try to work out a PR.

Leading thin space

There is an additional thin space at the beginning when using uncertainties, that shouldn't be there:

#import "@preview/unify:0.4.2": qty, num

#qty("200+-5", "m") \
#num("200+-5")

$(200 plus.minus 5)$ // How it should look

image

(Using web app, 0.8.0)

Space before temperature units

Typically, the only units you don't use spaces before are a lone-standing degree symbol and primes. This means there should be one if the unit is "°C", "°F" etc., since the "°" has a "suffix" (see e.g. [https://german.stackexchange.com/a/322]).

Custom units without `@local`

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.