metro icon indicating copy to clipboard operation
metro copied to clipboard

make typst 0.13 compatible

Open rossmeier opened this issue 1 year ago • 9 comments

Typst 0.13 will remove some symbols and make type and str incompatible. Adjust the relevant places in the code to be compatible with those changes.

Fixes: #27 Fixes: #28

rossmeier avatar Feb 06 '25 10:02 rossmeier

With this branch, I still got the following error:

error: cannot apply 'in' to string and none
    ┌─ @local/metro:0.3.1/src/impl/unit.typ:116:15
    │
116 │   let out = if "body" in input {
    │                ^^^^^^^^^^^^^^^

help: error occurred in this call of function `display`
    ┌─ @local/metro:0.3.1/src/impl/unit.typ:242:4
    │
242 │     display(options, parse(options, input))
    │     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `unit`
   ┌─ @local/metro:0.3.1/src/impl/qty.typ:25:12
   │
25 │       let u = unit_(
   │ ╭─────────────^
26 │ │       unit,
27 │ │       options
28 │ │     )
   │ ╰─────^

help: error occurred in this call of function `qty`
   ┌─ @local/metro:0.3.1/src/metro.typ:85:9
   │
85 │     return impl.qty(
   │ ╭──────────^
86 │ │     number,
87 │ │     units,
88 │ │     e: e,
   · │
91 │ │     combine-dict(options.named(), _state.get())
92 │ │   )
   │ ╰───^

I fixed it via this patch and it seems to work fine hten, but it feels rather ad-hoc:

diff --git a/src/impl/unit.typ b/src/impl/unit.typ
index 385fde1..30ee6df 100644
--- a/src/impl/unit.typ
+++ b/src/impl/unit.typ
@@ -110,6 +110,7 @@
 }
 
 #let display(options, input) = {
+  let input = if input == none { (:) } else { input }
   let quantity-product = options.quantity-product
   options.quantity-product = none
   display = display.with(options)

EDIT: Ah, but this only happens for

#qty(5, "%")

for me, maybe that was only accidentally supported previously either way.

amesgen avatar Feb 25 '25 11:02 amesgen

Should be noted that this is not enough to make it working with typst 0.13. Found another big regression that basically all units containing more than a single unit are broken

Edit: pushed an update fixing that. Everything seems okay for now, not sure if more might be broken

rossmeier avatar Feb 26 '25 21:02 rossmeier

@amesgen Could you check if you still have the problem? Might have been part of that regression that I found with the math parsing. At least, I can't reproduce your problem with the fix applied.

rossmeier avatar Feb 26 '25 21:02 rossmeier

@fenjalien Any chance of merging this so we don't have to rely on local packages?

w1th0utnam3 avatar Mar 05 '25 13:03 w1th0utnam3

@amesgen Could you check if you still have the problem? Might have been part of that regression that I found with the math parsing. At least, I can't reproduce your problem with the fix applied.

Indeed, can confirm that everything now works nicely with the branch from this PR :+1: Thanks!

amesgen avatar Mar 06 '25 16:03 amesgen

@fenjalien Bumping the request to merge this PR so local packages aren't necessary with 0.13

jchanes04 avatar Mar 26 '25 17:03 jchanes04

@fenjalien This fix also does work for me; a merge would really be appreciated to fix this package on typst 0.13

moinsr avatar Apr 05 '25 18:04 moinsr

Hi @rossmeier, your last commit changed the package version in typst.toml to all zeros (0.0.0). Is that a mistake?

AlexanderRitter02 avatar Aug 06 '25 11:08 AlexanderRitter02

Wuuups, sorry, that was my blunder. I updated the version to have a reproducible version for my personal projects. Shouldn't have done the PR using main :D Should be fixed now!

rossmeier avatar Aug 06 '25 16:08 rossmeier