PgBiel / typst-tablex

More powerful and customizable tables in Typst
MIT License
370 stars 12 forks source link

Handle Typst 0.11.0 length repr change #92

Closed PgBiel closed 8 months ago

PgBiel commented 8 months ago

https://github.com/typst/typst/pull/2936 appears to have broken the parsing code introduced by #84 (the commit before that PR to Typst doesn't generate any problems). We seem to get the following error (0.1.0-dev, https://github.com/PgBiel/typst-tablex/commit/0caa364fe7858ceaa9762217e404812d3e480ad3):

error: cannot divide relative length by ratio
    ┌─ src/utilities.typ:185:6
    │
185 │     ((len / 1%) / 100) * page-size + 0pt  // e.g. 100% / 1% = 100; / 100 = 1; 1 * page-size
    │       ^^^^^^^^

help: error occurred in this call of function `convert-ratio-type-to-pt`
    ┌─ src/utilities.typ:254:8
    │
254 │         convert-ratio-type-to-pt(ratio-part, page-size)
    │         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `convert-relative-type-to-pt`
    ┌─ src/utilities.typ:286:8
    │
286 │         convert-relative-type-to-pt(len, styles, page-size: page-size)
    │         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `convert-length-to-pt`
    ┌─ tablex-test.typ:797:21
    │  
797 │           let actual = convert-length-to-pt(
    │ ╭──────────────────────^
798 │ │             len,
799 │ │             styles: styles,
800 │ │             page-size: page-size,
801 │ │             frac-amount: frac-amount,
802 │ │             frac-total: frac-total,
803 │ │         )
    │ ╰─────────^

On the backported version (3f55e0dcac71bb9c2c3b385d8bc6098d64fa79e0):

error: cannot divide relative length by ratio
    ┌─ tablex.typ:449:6
    │
449 │     ((len / 1%) / 100) * page-size + 0pt  // e.g. 100% / 1% = 100; / 100 = 1; 1 * page-size
    │       ^^^^^^^^

help: error occurred in this call of function `convert-ratio-type-to-pt`
    ┌─ tablex.typ:518:8
    │
518 │         convert-ratio-type-to-pt(ratio-part, page-size)
    │         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `convert-relative-type-to-pt`
    ┌─ tablex.typ:550:8
    │
550 │         convert-relative-type-to-pt(len, styles, page-size: page-size)
    │         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `convert-length-to-pt`
    ┌─ tablex-test.typ:795:21
    │  
795 │           let actual = convert-length-to-pt(
    │ ╭──────────────────────^
796 │ │             len,
797 │ │             styles: styles,
798 │ │             page-size: page-size,
799 │ │             frac-amount: frac-amount,
800 │ │             frac-total: frac-total,
801 │ │         )
    │ ╰─────────^