-
-
Notifications
You must be signed in to change notification settings - Fork 872
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
kable: values with newlines break tables #2255
Comments
This has been reported a few times before, e.g., #1319 #1328 #1768 #2021 Your case is relatively easy to deal with, since the newline is meaningless and can be safely removed, but a more general solution will require more work in |
Agreed -- my case is straightforward; I just need to remove the newlines (because I know they are meaningless in this case). ap$Imports <- gsub("\\n", " ", ap$Imports)
ap$Suggests <- gsub("\\n", " ", ap$Suggests)
ap$LinkingTo <- gsub("\\n", " ", ap$LinkingTo) The more general case is more complicated (values that use multiple newlines to separate chunks of text, for example), but isn't easily expressed with Markdown tables constructed using pipe separators. Are there cases where embedded newlines can produce valid tables? |
To support newlines in Markdown tables, I think we must use other table formats. Pipe tables require each row to be a single line. Only multiline tables and grid tables support newlines: https://pandoc.org/MANUAL.html#tables These types of tables will require some substantial work in |
That's what thought, too. In other words: If kable is opinionated about how it produces tables, and always uses pipes, then converting newlines to whitespace (when There are lots of other table-building options if folks want rich content within the cells. I'm also fine if you decide to won't-fix this; I looked at open issues but neglected to search for closed issues when filing this one. |
You can use |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
Given the Quarto document:
the rendered result:
This is because the
Imports
column contains embedded newlines.It appears as if
escape=TRUE
(the default) is not rewriting the newlines and, as a result, the table formatting is broken.Workaround: Rewrite values to remove newlines.
Verified that this is an issue even as of 58e7879 (current CRAN is knitr-1.42).
Using the most recent IDE daily: 2023.05.0-daily+325
By filing an issue to this repo, I promise that
xfun::session_info('knitr')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/knitr')
.I understand that my issue may be closed if I don't fulfill my promises.
The text was updated successfully, but these errors were encountered: