Skip to content

Commit

Permalink
remove last empty rows in the longtable enviornments
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-h21 committed Sep 30, 2024
1 parent beb060d commit 7f1915f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

- 2024/09/30

- remove last empty row in `longtable` environments.

- 2024/09/25

- added `make4ht-char-def` library to remove dependency on `char-def` from
Expand Down
17 changes: 16 additions & 1 deletion domfilters/make4ht-tablerows.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ return function(dom)
hr:remove_node()
end
end
local longrable_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
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
return
end
end
last_row:remove_node()
end
local load_css_files = function()
-- the empty rows can be styled using CSS, for example configuration for
-- Booktabs does that. We shouldn't remove such rows.
Expand All @@ -76,7 +89,9 @@ return function(dom)
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"):match("longtable") then
longrable_last_row(tbl)
end
end
return dom
end
Expand Down

0 comments on commit 7f1915f

Please sign in to comment.