diff --git a/src/col-row-size.typ b/src/col-row-size.typ index d46108f..55988b3 100644 --- a/src/col-row-size.typ +++ b/src/col-row-size.typ @@ -65,7 +65,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').") } diff --git a/src/lines.typ b/src/lines.typ index 3f4826b..f0ca0ac 100644 --- a/src/lines.typ +++ b/src/lines.typ @@ -12,7 +12,7 @@ // -- end imports -- #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 diff --git a/src/type-validators.typ b/src/type-validators.typ index dc66875..ce9a5d7 100644 --- a/src/type-validators.typ +++ b/src/type-validators.typ @@ -103,6 +103,11 @@ type(len) == _length_type and "em" not 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.") diff --git a/src/utilities.typ b/src/utilities.typ index 92621dd..ba5e456 100644 --- a/src/utilities.typ +++ b/src/utilities.typ @@ -297,7 +297,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: