fix(typst): deduplicate cell-level line entries in hlines/vlines - #665
Merged
vincentarelbundock merged 1 commit intoJul 11, 2026
Merged
Conversation
typst_hlines() and typst_vlines() emitted fragmented chains of
table.hline()/table.vline() segments covering the same span whenever
@style_lines contained duplicate (i, j, line, color, width) tuples.
These duplicates arise routinely: theme_tinytable() adds
style_tt(i = 0, line = "b", ...) and so does the user; the lazy style
system records both calls and expands them to identical per-cell entries
in @style_lines. typst_split_chunks() then saw phantom breaks in
diff(x) != 1 and produced one chunk per duplicated j value.
Minimal repro before the fix:
tt(mtcars[1:5, 1:5]) |>
style_tt(i = 0, line = "b", line_color = "black", line_width = 0.05) |>
save_tt("typst")
emitted 6 fragmented table.hline(y: 1, ...) segments covering sub-ranges
of [0, 5). After the fix, it emits a single
table.hline(y: 1, start: 0, end: 5, ...).
Also visible in test-typst.R's typst-issue592.typ snapshot, where the
x:0 vline was previously split into 5 overlapping fragments
(0-1, 0-2, 1-7, 6-12, 11-16). The snapshot is regenerated to reflect
the correct single-segment output.
Fix: deduplicate identical rows of k inside the lapply() bodies of
typst_hlines() and typst_vlines(), after the split() grouping. Other
backends (html, latex/tabularray, markdown/grid) are unaffected —
they either aggregate per cell (html) or build ranges that absorb
duplicates (tabularray).
Tests:
- Regenerate inst/tinytest/_tinysnapshot/typst-issue592.typ
- Add regression tests in inst/tinytest/test-bugfix.R covering both
"user re-declares theme line" and "user adds the same line twice"
Owner
|
Does this maintain visible "gutters" between lines under spanning Colum headers? |
Contributor
Author
vincentarelbundock
merged commit Jul 11, 2026
c6702c6
into
vincentarelbundock:main
2 of 3 checks passed
Owner
|
thanks, got a chance to check it out and it's a nice improvement. merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

NOTE: This PR and the code changes are entirely "vibe coded" using GLM-5.2.
typst_hlines()andtypst_vlines()emitted fragmented chains oftable.hline()/table.vline()segments covering the same span whenever@style_linescontained duplicate (i, j, line, color, width) tuples.These duplicates arise routinely:
theme_tinytable()addsstyle_tt(i = 0, line = "b", ...)and so does the user; the lazy style system records both calls and expands them to identical per-cell entries in@style_lines.typst_split_chunks()then saw phantom breaks indiff(x) != 1and produced one chunk per duplicated j value.Minimal repro before the fix:
emitted 6 fragmented
table.hline(y: 1, ...)segments covering sub-ranges of [0, 5). After the fix, it emits a singletable.hline(y: 1, start: 0, end: 5, ...).Also visible in test-typst.R's typst-issue592.typ snapshot, where the x:0 vline was previously split into 5 overlapping fragments (0-1, 0-2, 1-7, 6-12, 11-16). The snapshot is regenerated to reflect the correct single-segment output.
Fix: deduplicate identical rows of k inside the
lapply()bodies oftypst_hlines()andtypst_vlines(), after thesplit()grouping. Other backends (html, latex/tabularray, markdown/grid) are unaffected — they either aggregate per cell (html) or build ranges that absorb duplicates (tabularray).Tests:
inst/tinytest/_tinysnapshot/typst-issue592.typinst/tinytest/test-bugfix.Rcovering both "user re-declares theme line" and "user adds the same line twice"