Skip to content

Commit

Permalink
fixed tablerows for large longtables
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-h21 committed Nov 9, 2024
1 parent 7489523 commit 8bf64a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

- 2024/11/09

- fixed `tablerows` for longtables longer than 200 rows.
https://tex.stackexchange.com/a/730466/2891

- 2024/10/22

- version `0.4b` released.
Expand Down
9 changes: 5 additions & 4 deletions domfilters/make4ht-tablerows.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ return function(dom)
hr:remove_node()
end
end
local longrable_last_row = function(tbl)
local longtable_last_row = function(tbl)
-- longtable contains last row of empty cells
local rows= tbl:query_selector("tr")
local last_row = rows[#rows]
if not last_row then return end
if not last_row or last_row:get_attribute("class") == "hline" then return end
for _, cell in ipairs(last_row:query_selector("td")) do
-- loop over cells in the last row a and detect that they are empty. break processing if they are not.
if has_child_elements(cell) or not cell:get_text():match("^%s*$") then
Expand Down Expand Up @@ -85,12 +85,13 @@ return function(dom)
local css = load_css_files()
for _, tbl in ipairs(dom:query_selector("table")) do
-- find the empty rows
for _, row in ipairs(tbl:query_selector("tr")) do
local rows = tbl:query_selector("tr")
for count, row in ipairs(rows) do
if is_empty_row(row) and is_not_styled(row, css) then row:remove_node() end
hline_hr(row)
end
if tbl:get_attribute("class") and tbl:get_attribute("class"):match("longtable") then
longrable_last_row(tbl)
longtable_last_row(tbl)
end
end
return dom
Expand Down

0 comments on commit 8bf64a3

Please sign in to comment.