diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..162c945 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# You may support tablex by sponsoring the account(s) below + +github: PgBiel diff --git a/.github/workflows/tests-compile-ci.yml b/.github/workflows/tests-compile-ci.yml new file mode 100644 index 0000000..65f4537 --- /dev/null +++ b/.github/workflows/tests-compile-ci.yml @@ -0,0 +1,61 @@ +# ================================================================================================= +# This does not perform complete checks of the test output, only tests if tablex-test.typ compiles. +# ================================================================================================= + +name: Tests Compile CI + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the branches below + push: + branches: [ "main", "0.1.0-dev" ] + pull_request: + branches: [ "main", "0.1.0-dev" ] + + # Allows one to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + strategy: + matrix: + # Test for the following Typst versions + # 0.2.0 (earliest supported), 0.6.0 (first version with package management), + # 0.10.0 (latest supported) + typst-version: [v0.2.0, v0.6.0, v0.10.0] + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v4 + + - name: ⚠️ CI Disclaimer + run: | + cat < new_hline` and `map-vlines: v => new_vline`. This includes any automatically generated lines. For example: ```typ -#import "@preview/tablex:0.0.6": tablex, colspanx, rowspanx +#import "@preview/tablex:0.0.7": tablex, colspanx, rowspanx #tablex( columns: 3, @@ -272,7 +277,7 @@ Additionally, instead of specifying content to the cell, you can specify a funct For example: ```typ -#import "@preview/tablex:0.0.6": tablex, cellx, colspanx, rowspanx +#import "@preview/tablex:0.0.7": tablex, cellx, colspanx, rowspanx #tablex( columns: 3, @@ -304,7 +309,7 @@ To customize multiple cells at once, you have a few options: Example: ```typ -#import "@preview/tablex:0.0.6": tablex, colspanx, rowspanx +#import "@preview/tablex:0.0.7": tablex, colspanx, rowspanx #tablex( columns: 4, @@ -627,6 +632,22 @@ Another example (summing columns): ## Changelog +### v0.0.7 + +I have begun [work on bringing many tablex improvements to built-in Typst tables](https://github.com/PgBiel/typst-improv-tables-planning)! In that regard, [you can now sponsor my work on tablex and improving Typst tables via GitHub Sponsors! Consider taking a look :)](https://github.com/sponsors/PgBiel) + +- Allow gradients and patterns in fills (https://github.com/PgBiel/typst-tablex/pull/87) +- Fixed a critical bug where `line` in tablex cells would misbehave (https://github.com/PgBiel/typst-tablex/issues/80) + - CeTZ and drawing in general should now work properly within tablex cells (see https://github.com/johannes-wolf/cetz/issues/345). + - Also fixes a problem with nested tables (https://github.com/PgBiel/typst-tablex/issues/34) +- Fixed negative line expansion within a single cell (https://github.com/PgBiel/typst-tablex/pull/84) + - Negative line expansion across multiple cells isn't yet supported. + - Thanks GitHub user @dixslyf for the great work on fixing and testing this! +- Made internal length calculation procedures more robust (https://github.com/PgBiel/typst-tablex/issues/92, https://github.com/PgBiel/typst-tablex/issues/94) + - Fixes a potential incompatibility with (currently unreleased) Typst 0.11.0 +- Added missing support for boolean types in Typst 0.8.0+ (https://github.com/PgBiel/typst-tablex/issues/73) +- Added some keywords to tablex's `typst.toml` for better discoverability (https://github.com/PgBiel/typst-tablex/issues/91) + ### v0.0.6 - Added support for RTL tables with `rtl: true` (https://github.com/PgBiel/typst-tablex/issues/58). diff --git a/tablex-test.pdf b/tablex-test.pdf index 6ec19d7..98c09e9 100644 Binary files a/tablex-test.pdf and b/tablex-test.pdf differ diff --git a/tablex-test.typ b/tablex-test.typ index ea9705c..9970cba 100644 --- a/tablex-test.typ +++ b/tablex-test.typ @@ -761,3 +761,244 @@ Combining em and pt (with a stroke object): ) #stack(dir: ttb, mapstuff(false), 1em, $arrow.b$, 1em, mapstuff(true)) ] + +*Lines in tables from issue \#80* +#table( + columns: 2, + [A #box(line(length: 50pt)) B], [A #line(length: 50pt) B], + [C], [D], + style(styles => { + measure(line(length: 40pt), styles) + }), + [E] +) +#tablex( + columns: 2, + [A #box(line(length: 50pt)) B], [A #line(length: 50pt) B], + [C], [D], + style(styles => { + measure(line(length: 40pt), styles) + }), + [E] +) + +*Length to pt conversion* + +#let convert-length-to-pt-test( + len, expected, + page-size: 100pt, // Set 1% to 1pt + frac-amount: 10, // Set 1fr to 1pt + frac-total: 10pt, +) = { + set text(size: 1pt) // Set 1em to 1pt + style(styles => { + let actual = convert-length-to-pt( + len, + styles: styles, + page-size: page-size, + frac-amount: frac-amount, + frac-total: frac-total, + ) + + assert(type(actual) == _length_type) + assert(expected == actual) + }) +} + +// `length` tests +#convert-length-to-pt-test(0pt, 0pt) +#convert-length-to-pt-test(1pt, 1pt) +#convert-length-to-pt-test(1em, 1pt) +#convert-length-to-pt-test(-1pt, -1pt) +#convert-length-to-pt-test(-1em, -1pt) +#convert-length-to-pt-test(0.005pt, 0.005pt) +#convert-length-to-pt-test(0.005em, 0.005pt) +#convert-length-to-pt-test(-0.005pt, -0.005pt) +#convert-length-to-pt-test(-0.005em, -0.005pt) +#convert-length-to-pt-test(0.005pt + 0.005em, 0.01pt) +#convert-length-to-pt-test(0.005pt - 0.005em, 0pt) +#convert-length-to-pt-test(-0.005pt + 0.005em, 0pt) +#convert-length-to-pt-test(-0.005pt - 0.005em, -0.01pt) + +// `ratio` tests +#convert-length-to-pt-test(1%, 1pt) +#convert-length-to-pt-test(-1%, -1pt) +#convert-length-to-pt-test(0.5%, 0.5pt) +#convert-length-to-pt-test(-0.5%, -0.5pt) + +// `fraction` tests +#convert-length-to-pt-test(1fr, 1pt) +#convert-length-to-pt-test(-1fr, -1pt) +#convert-length-to-pt-test(0.5fr, 0.5pt) +#convert-length-to-pt-test(-0.5fr, -0.5pt) + +// `relative` tests +#convert-length-to-pt-test(0% + 0pt + 0em, 0pt) +#convert-length-to-pt-test(0% + 0pt + 1em, 1pt) +#convert-length-to-pt-test(0% + 1pt + 0em, 1pt) +#convert-length-to-pt-test(0% + 1pt + 1em, 2pt) +#convert-length-to-pt-test(1% + 0pt + 0em, 1pt) +#convert-length-to-pt-test(1% + 0pt + 1em, 2pt) +#convert-length-to-pt-test(1% + 1pt + 0em, 2pt) +#convert-length-to-pt-test(1% + 1pt + 1em, 3pt) + +#convert-length-to-pt-test(0% + 0pt + 0.005em, 0.005pt) +#convert-length-to-pt-test(0% + 0.005pt + 0em, 0.005pt) +#convert-length-to-pt-test(0% + 0.005pt + 0.005em, 0.01pt) +#convert-length-to-pt-test(0.005% + 0pt + 0em, 0.005pt) +#convert-length-to-pt-test(0.005% + 0pt + 0.005em, 0.01pt) +#convert-length-to-pt-test(0.005% + 0.005pt + 0em, 0.01pt) +#convert-length-to-pt-test(0.005% + 0.005pt + 0.005em, 0.015pt) + +#convert-length-to-pt-test(0% + 0pt - 0.005em, -0.005pt) +#convert-length-to-pt-test(0% - 0.005pt + 0em, -0.005pt) +#convert-length-to-pt-test(0% - 0.005pt - 0.005em, -0.01pt) +#convert-length-to-pt-test(-0.005% + 0pt + 0em, -0.005pt) +#convert-length-to-pt-test(-0.005% + 0pt - 0.005em, -0.01pt) +#convert-length-to-pt-test(-0.005% - 0.005pt + 0em, -0.01pt) +#convert-length-to-pt-test(-0.005% - 0.005pt - 0.005em, -0.015pt) + +*Line expansion - issue \#74:* + +#let wrap-for-linex-expansion-test(tabx) = { + set text(size: 1pt) // Set 1em to 1pt + box( + width: 100pt, // Set 1% to 1pt + height: 100pt, + tabx + ) +} + +- Positive single-cell hlinex expansion + +#wrap-for-linex-expansion-test( + tablex( + columns: 3pt, + auto-lines: false, + hlinex(), + [], + hlinex(expand: 3pt), + [], + hlinex(expand: 3em), + [], + hlinex(expand: 3%), + [], + hlinex(expand: 1% + 1pt + 1em), + ) +) + +- Positive multi-cell hlinex expansion + +#wrap-for-linex-expansion-test( + tablex( + columns: (1pt, 1pt, 1pt), + auto-lines: false, + hlinex(), + [], [], [], + hlinex(expand: 3pt), + [], [], [], + hlinex(expand: 3em), + [], [], [], + hlinex(expand: 3%), + [], [], [], + hlinex(expand: 1% + 1pt + 1em), + ) +) + +- Negative single-cell hlinex expansion + +#wrap-for-linex-expansion-test( + tablex( + columns: 15pt, + auto-lines: false, + hlinex(), + [], + hlinex(expand: -6pt), + [], + hlinex(expand: -6em), + [], + hlinex(expand: -6%), + [], + hlinex(expand: -(2% + 2pt + 2em)), + ) +) + +// TODO: currently does not work as intended (https://github.com/PgBiel/typst-tablex/issues/85) +- Negative multi-cell hlinex expansion + +#wrap-for-linex-expansion-test( + tablex( + columns: (5pt, 5pt, 5pt), + auto-lines: false, + hlinex(), + [], [], [], + hlinex(expand: -6pt), + [], [], [], + hlinex(expand: -6em), + [], [], [], + hlinex(expand: -6%), + [], [], [], + hlinex(expand: -(2% + 2pt + 2em)), + ) +) + +- Positive single-cell vlinex expansion + +#wrap-for-linex-expansion-test( + tablex( + columns: 5, + rows: 3pt, + auto-lines: false, + vlinex(), + vlinex(expand: 3pt), + vlinex(expand: 3em), + vlinex(expand: 3%), + vlinex(expand: 1% + 1pt + 1em), + ) +) + +- Positive multi-cell vlinex expansion + +#wrap-for-linex-expansion-test( + tablex( + columns: 5, + rows: (1pt, 1pt, 1pt), + auto-lines: false, + vlinex(), + vlinex(expand: 3pt), + vlinex(expand: 3em), + vlinex(expand: 3%), + vlinex(expand: 1% + 1pt + 1em), + ) +) + +- Negative single-cell vlinex expansion + +#wrap-for-linex-expansion-test( + tablex( + columns: 5, + rows: 15pt, + auto-lines: false, + vlinex(), + vlinex(expand: -6pt), + vlinex(expand: -6em), + vlinex(expand: -6%), + vlinex(expand: -(2% + 2pt + 2em)), + ) +) + +// TODO: currently does not work as intended (https://github.com/PgBiel/typst-tablex/issues/85) +- Negative multi-cell vlinex expansion + +#wrap-for-linex-expansion-test( + tablex( + columns: 5, + rows: (5pt, 5pt, 5pt), + auto-lines: false, + vlinex(), + vlinex(expand: -6pt), + vlinex(expand: -6em), + vlinex(expand: -6%), + vlinex(expand: -(2% + 2pt + 2em)), + ) +) diff --git a/tablex.typ b/tablex.typ index 661c17e..99a1a75 100644 --- a/tablex.typ +++ b/tablex.typ @@ -1,6 +1,6 @@ // Welcome to tablex! // Feel free to contribute with any features you think are missing. -// Version: v0.0.6 +// Version: v0.0.7 // -- table counter -- @@ -16,6 +16,7 @@ // (0.2.0-0.7.0: they're strings; 0.8.0+: they're proper types) #let _array_type = type(()) #let _dict_type = type((a: 5)) +#let _bool_type = type(true) #let _str_type = type("") #let _color_type = type(red) #let _stroke_type = type(red + 5pt) @@ -195,6 +196,11 @@ type(len) in (_ratio_type, _fraction_type, _rel_len_type, _length_type) and "inf" in repr(len) } +// Check if this is a valid color (color, gradient or pattern). +#let is-color(val) = { + type(val) == _color_type or str(type(val)) in ("gradient", "pattern") +} + #let validate-cols-rows(columns, rows, items: ()) = { if type(columns) == _int_type { assert(columns >= 0, message: "Error: Cannot have a negative amount of columns.") @@ -367,88 +373,186 @@ previous } -// Convert a certain (non-relative) length to pt +// Typst 0.9.0 uses a minus sign ("−"; U+2212 MINUS SIGN) for negative numbers. +// Before that, it used a hyphen minus ("-"; U+002D HYPHEN MINUS), so we use +// regex alternation to match either of those. +#let NUMBER-REGEX-STRING = "(−|-)?\\d*\\.?\\d+" + +// Check if the given length has type '_length_type' and no 'em' component. +#let is-purely-pt-len(len) = { + type(len) == _length_type and "em" not in repr(len) +} + +// Measure a length in pt by drawing a line and using the measure() function. +// This function will work for negative lengths as well. +// +// Note that for ratios, the measurement will be 0pt due to limitations of +// the "draw and measure" technique (wrapping the line in a box still returns 0pt; +// not sure if there is any viable way to measure a ratio). This also affects +// relative lengths — this function will only be able to measure the length component. // // styles: from style() -// page_size: equivalent to 100% -// frac_amount: amount of 'fr' specified -// frac_total: total space shared by fractions -#let convert-length-to-pt( - len, - styles: none, page_size: none, frac_amount: none, frac_total: none -) = { - page_size = 0pt + page_size +#let measure-pt(len, styles) = { + let measured-pt = measure(box(width: len), styles).width + + // If the measured length is positive, `len` must have overall been positive. + // There's nothing else to be done, so return the measured length. + if measured-pt > 0pt { + return measured-pt + } + + // If we've reached this point, the previously measured length must have been `0pt` + // (drawing a line with a negative length will draw nothing, so measuring it will return `0pt`). + // Hence, `len` must either be `0pt` or negative. + // We multiply `len` by -1 to get a positive length, draw a line and measure it, then negate + // the measured length. This nicely handles the `0pt` case as well. + measured-pt = -measure(box(width: -len), styles).width + return measured-pt +} - if is-infinite-len(len) { - 0pt // avoid the destruction of the universe - } else if type(len) == _length_type { - if "em" in repr(len) { - if styles == none { - panic("Cannot convert length to pt ('styles' not specified).") - } +// Convert a length of type length to pt. +// +// styles: from style() +#let convert-length-type-to-pt(len, styles: none) = { + // repr examples: "1pt", "1em", "0.5pt", "0.5em", "1pt + 1em", "-0.5pt + -0.5em" + if "em" not in repr(len) { + // No need to do any conversion because it must already be in pt. + return len + } - measure(line(length: len), styles).width + 0pt - } else { - len + 0pt // mm, in, pt - } - } else if type(len) == _ratio_type { - if page_size == none { - panic("Cannot convert ratio to pt ('page_size' not specified).") - } + // At this point, we will need to draw a line for measurement, + // so we need the styles. + if styles == none { + panic("Cannot convert length to pt ('styles' not specified).") + } - if is-infinite-len(page_size) { - return 0pt // page has 'auto' size => % should return 0 - } + return measure-pt(len, styles) +} - ((len / 1%) / 100) * page_size + 0pt // e.g. 100% / 1% = 100; / 100 = 1; 1 * page_size - } else if type(len) == _fraction_type { - if frac_amount == none { - panic("Cannot convert fraction to pt ('frac_amount' not specified).") - } +// Convert a ratio type length to pt +// +// page-size: equivalent to 100% +#let convert-ratio-type-to-pt(len, page-size) = { + assert( + is-purely-pt-len(page-size), + message: "'page-size' should be a purely pt length" + ) - if frac_total == none { - panic("Cannot convert fraction to pt ('frac_total' not specified).") - } + if page-size == none { + panic("Cannot convert ratio to pt ('page-size' not specified).") + } - if frac_amount <= 0 or is-infinite-len(frac_total) { - return 0pt - } + if is-infinite-len(page-size) { + return 0pt // page has 'auto' size => % should return 0 + } - let len_per_frac = frac_total / frac_amount + ((len / 1%) / 100) * page-size + 0pt // e.g. 100% / 1% = 100; / 100 = 1; 1 * page-size +} - (len_per_frac * (len / 1fr)) + 0pt - } else if type(len) == _rel_len_type { - if styles == none { - panic("Cannot convert relative length to pt ('styles' not specified).") - } +// Convert a fraction type length to pt +// +// frac-amount: amount of 'fr' specified +// frac-total: total space shared by fractions +#let convert-fraction-type-to-pt(len, frac-amount, frac-total) = { + assert( + is-purely-pt-len(frac-total), + message: "'frac-total' should be a purely pt length" + ) + + if frac-amount == none { + panic("Cannot convert fraction to pt ('frac-amount' not specified).") + } - let ratio_regex = regex("^\\d+%") - let ratio = repr(len).find(ratio_regex) + if frac-total == none { + panic("Cannot convert fraction to pt ('frac-total' not specified).") + } - if ratio == none { // 2em + 5pt (doesn't contain 100% or something) - measure(line(length: len), styles).width - } else { // 100% + 2em + 5pt --> extract the "100%" part - if page_size == none { - panic("Cannot convert relative length to pt ('page_size' not specified).") - } + if frac-amount <= 0 or is-infinite-len(frac-total) { + return 0pt + } - // SAFETY: guaranteed to be a ratio by regex - let ratio_part = eval(ratio) - assert(type(ratio_part) == _ratio_type, message: "Eval didn't return a ratio") + let len-per-frac = frac-total / frac-amount - let other_part = len - ratio_part // get the (2em + 5pt) part + (len-per-frac * (len / 1fr)) + 0pt +} - let ratio_part_pt = if is-infinite-len(page_size) { 0pt } else { ((ratio_part / 1%) / 100) * page_size } - let other_part_pt = 0pt +// Convert a relative type length to pt +// +// styles: from style() +// page-size: equivalent to 100% (optional because the length may not have a ratio component) +#let convert-relative-type-to-pt(len, styles, page-size: none) = { + // We will need to draw a line for measurement later, + // so we need the styles. + if styles == none { + panic("Cannot convert relative length to pt ('styles' not specified).") + } - if other_part < 0pt { - other_part_pt = -measure(line(length: -other_part), styles).width - } else { - other_part_pt = measure(line(length: other_part), styles).width - } + if eval(repr(0.00005em)) != 0.00005em { + // em repr changed in 0.11.0 => can safely use fields here + return convert-ratio-type-to-pt(len.ratio, page-size) + convert-length-type-to-pt(len.length, styles: styles) + } - ratio_part_pt + other_part_pt + 0pt - } + // Note on precision: the `repr` for em components is precise, unlike + // other length components, which are rounded to a precision of 2. + // This is true up to Typst 0.9.0 and possibly later versions. + let em-regex = regex(NUMBER-REGEX-STRING + "em") + let em-part-repr = repr(len).find(em-regex) + + // Calculate the length minus its em component. + // E.g., 1% + 1pt + 1em -> 1% + 1pt + let (em-part, len-minus-em) = if em-part-repr == none { + (0em, len) + } else { + // SAFETY: guaranteed to be a purely em length by regex + let em-part = eval(em-part-repr) + (em-part, len - em-part) + } + + // This will give only the pt part of the length. + // E.g., 1% + 1pt -> 1pt + // See the documentation on measure-pt for more information. + let pt-part = measure-pt(len-minus-em, styles) + + // Since we have the values of the em and pt components, + // we can calculate the ratio part. + let ratio-part = len-minus-em - pt-part + let ratio-part-pt = if ratio-part == 0% { + // No point doing `convert-ratio-type-to-pt` if there's no ratio component. + 0pt + } else { + convert-ratio-type-to-pt(ratio-part, page-size) + } + + // The length part is the pt part + em part. + // Note: we cannot use `len - ratio-part` as that returns a `_rel_len_type` value, + // not a `_length_type` value. + let length-part-pt = convert-length-type-to-pt(pt-part + em-part, styles: styles) + + ratio-part-pt + length-part-pt +} + +// Convert a certain (non-relative) length to pt +// +// styles: from style() +// page-size: equivalent to 100% +// frac-amount: amount of 'fr' specified +// frac-total: total space shared by fractions +#let convert-length-to-pt( + len, + styles: none, page-size: none, frac-amount: none, frac-total: none +) = { + page-size = 0pt + page-size + + if is-infinite-len(len) { + 0pt // avoid the destruction of the universe + } else if type(len) == _length_type { + convert-length-type-to-pt(len, styles: styles) + } else if type(len) == _ratio_type { + convert-ratio-type-to-pt(len, page-size) + } else if type(len) == _fraction_type { + convert-fraction-type-to-pt(len, frac-amount, frac-total) + } else if type(len) == _rel_len_type { + convert-relative-type-to-pt(len, styles, page-size: page-size) } else { panic("Cannot convert '" + type(len) + "' to length.") } @@ -462,7 +566,7 @@ convert-length-to-pt(stroke, styles: styles) } else if type(stroke) in (_rel_len_type, _ratio_type) { panic(no-ratio-error) - } else if type(stroke) == _color_type { + } else if is-color(stroke) { 1pt } else if type(stroke) == _stroke_type { // support: @@ -920,7 +1024,7 @@ } } - if cell_fill != none and type(cell_fill) != _color_type { + if cell_fill != none and not is-color(cell_fill) { panic("Tablex error: Invalid fill specified (must be either a function (column, row) -> fill, a color, an array of valid fill values, or 'none').") } @@ -1190,7 +1294,7 @@ #let determine-column-sizes(grid: (), page_width: 0pt, styles: none, columns: none, inset: none, align: auto, col-gutter: none) = { let columns = columns.map(c => { if type(c) in (_length_type, _rel_len_type, _ratio_type) { - convert-length-to-pt(c, styles: styles, page_size: page_width) + convert-length-to-pt(c, styles: styles, page-size: page_width) } else if c == none { 0pt } else { @@ -1333,7 +1437,7 @@ #let determine-row-sizes(grid: (), page_height: 0pt, styles: none, columns: none, rows: none, align: auto, inset: none, row-gutter: none) = { let rows = rows.map(r => { if type(r) in (_length_type, _rel_len_type, _ratio_type) { - convert-length-to-pt(r, styles: styles, page_size: page_height) + convert-length-to-pt(r, styles: styles, page-size: page_height) } else { r } @@ -1604,7 +1708,7 @@ // -- drawing -- #let parse-stroke(stroke) = { - if type(stroke) == _color_type { + if is-color(stroke) { stroke + 1pt } else if type(stroke) in (_length_type, _rel_len_type, _ratio_type, _stroke_type, _dict_type) or stroke in (none, auto) { stroke @@ -1884,9 +1988,6 @@ let row_gutter_dy = default-if-none(gutter.row, 0pt) - // move lines down by the height of the added header - show line: place.with(top + left, dy: added_header_height) - let first_x = none let first_y = none let rightmost_x = none @@ -1951,6 +2052,10 @@ let draw-hline = draw-hline.with(initial_x: first_x, initial_y: first_y, rightmost_x: rightmost_x, rtl: rtl) let draw-vline = draw-vline.with(initial_x: first_x, initial_y: first_y, rightmost_x: rightmost_x, rtl: rtl) + // ensure the lines are drawn absolutely, after the header + let draw-hline = (..args) => place(top + left, dy: added_header_height, draw-hline(..args)) + let draw-vline = (..args) => place(top + left, dy: added_header_height, draw-vline(..args)) + let header_last_y = if first-row-group != none { first-row-group.row_group.y_span.at(1) } else { @@ -2213,7 +2318,7 @@ panic("'expand' argument to lines must be a pair (length, length).") } - convert-length-to-pt(e, styles: styles, page_size: page-size) + convert-length-to-pt(e, styles: styles, page-size: page-size) } }) } @@ -2258,11 +2363,11 @@ row-gutter = default-if-auto(row-gutter, 0pt) if type(col-gutter) in (_length_type, _rel_len_type, _ratio_type) { - col-gutter = convert-length-to-pt(col-gutter, styles: styles, page_size: page-width) + col-gutter = convert-length-to-pt(col-gutter, styles: styles, page-size: page-width) } if type(row-gutter) in (_length_type, _rel_len_type, _ratio_type) { - row-gutter = convert-length-to-pt(row-gutter, styles: styles, page_size: page-width) + row-gutter = convert-length-to-pt(row-gutter, styles: styles, page-size: page-width) } (col: col-gutter, row: row-gutter) @@ -2423,7 +2528,7 @@ repeat-header = default-if-auto(default-if-none(repeat-header, false), false) - if type(repeat-header) not in ("boolean", _int_type, _array_type) { + if type(repeat-header) not in (_bool_type, _int_type, _array_type) { panic("Tablex error: 'repeat-header' must be a boolean (true - always repeat the header, false - never), an integer (amount of pages for which to repeat the header), or an array of integers (relative pages in which the header should repeat).") } else if type(repeat-header) == _array_type and repeat-header.any(i => type(i) != _int_type) { panic("Tablex error: 'repeat-header' cannot be an array of anything other than integers!") @@ -2437,7 +2542,7 @@ ) = { header-hlines-have-priority = default-if-auto(default-if-none(header-hlines-have-priority, true), true) - if type(header-hlines-have-priority) != "boolean" { + if type(header-hlines-have-priority) != _bool_type { panic("Tablex error: 'header-hlines-have-priority' option must be a boolean.") } diff --git a/typst.toml b/typst.toml index ffe3bd0..a6a84a4 100644 --- a/typst.toml +++ b/typst.toml @@ -1,8 +1,9 @@ [package] name = "tablex" -version = "0.0.6" +version = "0.0.7" authors = ["PgBiel "] license = "MIT" description = "More powerful and customizable tables in Typst." entrypoint = "tablex.typ" repository = "https://github.com/PgBiel/typst-tablex" +keywords = ["formatting", "table", "tables", "customization"]