Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect the code in case xml_tpart() returns NULL #790

Merged
merged 2 commits into from
Feb 1, 2024
Merged

Conversation

dmurdoch
Copy link
Collaborator

@dmurdoch dmurdoch commented Dec 4, 2023

There should never be a NULL result for the "tbody" calls, but it can happen for "thead" when tables are produced from a list of dataframes.

This PR protects both, but it needs some work. It no longer produces errors as described in #699, but it produces inconsistent results for LaTeX and HTML. For example, this code:

kbl(list(mtcars[1:2, 1:2], mtcars[3:4, 3:4]), format="latex") |>
    column_spec(1, include_thead = TRUE, background="green")

highlights the whole first table in HTML but only the upper left cell in PDF, and this code

kbl(list(A = mtcars[1:2, 1:2], B = mtcars[3:4, 3:4])) |>
    row_spec(0, background="red")

highlights nothing with a warning in HTML, but highlights the first row of the first table in PDF. I don't know which is the correct behaviour.

xml_tpart() calls return NULL.  This should never happen for the "tbody"
calls, but can happen for "thead" when tables are produced from a list of dataframes.
Still has consistency issues.

Merge branch 'master' into protect_xml

# Conflicts:
#	R/util.R
@haozhu233 haozhu233 merged commit 27e82f8 into master Feb 1, 2024
5 of 9 checks passed
@haozhu233
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants