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

html tables rendered from markdown don't look right with latest pandoc (3.3) #2567

Closed
therealgenna opened this issue Aug 9, 2024 · 3 comments
Labels
theme: pandoc concerns upstream pandoc

Comments

@therealgenna
Copy link

I am running rmarkdown within R. In the end it's calling pandoc to create html output. The command printed on the console is like that:

PANDOC=<path>/env/bin/pandoc
$PANDOC +RTS -K512m -RTS \
  run.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash \
  --output run.html \
  --lua-filter $ENV/lib/R/library/rmarkdown/rmarkdown/lua/pagebreak.lua \
  --lua-filter $ENV/lib/R/library/rmarkdown/rmarkdown/lua/latex-div.lua \
  --embed-resources --standalone --variable bs3=TRUE --section-divs \
  --table-of-contents --toc-depth 3 --variable toc_float=1 --variable toc_selectors=h1,h2,h3 --variable toc_collapsed=1 \
  --variable toc_smooth_scroll=1 --variable toc_print=1 \
  --template $ENV/lib/R/library/rmarkdown/rmd/h/default.html \
  --no-highlight --variable highlightjs=1 --variable theme=bootstrap \
  --css leftjustify.css \
  --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' \
  --include-in-header /tmp/RtmpnvLnyX/rmarkdown-str16204b65985cf3.html \
  --variable code_folding=hide --variable code_menu=1

I have two environments, an old one with pandoc 3.1.3 and a new one with 3.3. Both environments produce I believe a valid .md file with a table that looks like

Table: Original cell counts

|Sample | Freq|
|:------|----:|
|Leah1  | 2938|
|Leah3  | 5847|
|Leah4  | 5307|
|Leah6  | 5757|
|Leah7  | 5897|
|Leah8  | 5536|
|T1     | 8703|
|T2     | 9052|

However, the new pandoc (3.3) makes ugly html tables, e.g.:
image

While the older one is what I expect:
image

I've tracked the problem to the change in pandoc 3.2.1, I believe.
It got rid of header, odd, even classes on tr (jgm/pandoc#9376) in version 3.2.1 (linked from https://pandoc.org/releases.html). If I add these "classes" manually back to the final html, it then looks fine.

Here on the left is new version, without "classes", and on the right it's my manual edits, adding "classes":

<table>                                                         <table>
<caption>Original cell counts</caption>                         <caption>Original cell counts</caption>
<thead>                                                         <thead>
<tr>                                                          | <tr class="header">
<th align="left">Sample</th>                                    <th align="left">Sample</th>
<th align="right">Freq</th>                                     <th align="right">Freq</th>
</tr>                                                           </tr>
</thead>                                                        </thead>
<tbody>                                                         <tbody>
<tr>                                                          | <tr class="odd">
<td align="left">Leah1</td>                                     <td align="left">Leah1</td>
<td align="right">2938</td>                                     <td align="right">2938</td>
</tr>                                                           </tr>
<tr>                                                          | <tr class="even">
<td align="left">Leah3</td>                                     <td align="left">Leah3</td>
<td align="right">5847</td>                                     <td align="right">5847</td>
</tr>                                                           </tr>
<tr>                                                          | <tr class="odd">
<td align="left">Leah4</td>                                     <td align="left">Leah4</td>
<td align="right">5307</td>                                     <td align="right">5307</td>
</tr>                                                           </tr>
...                                                             ...

Adding the classes back, as on the right, fixes the issue and the table looks good in the web browsers.

I've first submitted this issue to pandoc developers (jgm/pandoc#10073) however they said that I "may need to consult with RMarkdown maintainers, who will know more about how the CSS is applied; they will need to update things, probably, to work with the new pandoc defaults.". This is what I'm doing now.

Also, it might be that this is related to #2566

Pandoc version 3.3 (on Linux)
rmarkdown 2.27
knitr 1.48

@yihui yihui added the theme: pandoc concerns upstream pandoc label Aug 9, 2024
@yihui yihui closed this as completed in 0d8eabd Aug 9, 2024
@yihui
Copy link
Member

yihui commented Aug 9, 2024

Should be fixed now. Thanks for the report! You can test the development version via

remotes::install_github('rstudio/rmarkdown')

@franceskoi
Copy link

Thanks for the post. My Pandoc version is 3.2.1.

@yihui
Copy link
Member

yihui commented Aug 10, 2024

@franceskoi The fix applies to Pandoc >= 3.2.1, so you need to install the dev version mentioned above. Thanks!

jonathan-g added a commit to jonathan-g/rmarkdown that referenced this issue Oct 17, 2024
Merge remote-tracking branch 'rstudio/main' into jg-devel

# By Yihui Xie (4) and others
# Via GitHub
* rstudio/main:
  parameters with `choices` and `multiple = TRUE` should use a `select` input (rstudio#2576)
  Add support for `child=c("child.Rmd")` in find_external_resources() (rstudio#2575)
  Support new Pandoc 3.4 behavior with GFM math (rstudio#2573)
  consistent dev install instructions (rstudio#2571)
  Update actions/checkout to v4 (rstudio#2570)
  start the next version
  CRAN release v2.28
  update tests for lua filters accordingly
  fix rstudio#2567: add classes `odd`, `even`, and `header` back to table rows for Pandoc >= 3.2.1

# Conflicts:
#	DESCRIPTION
#	NEWS.md
jonathan-g added a commit to jonathan-g/rmarkdown that referenced this issue Oct 17, 2024
* jg-devel:
  parameters with `choices` and `multiple = TRUE` should use a `select` input (rstudio#2576)
  Add support for `child=c("child.Rmd")` in find_external_resources() (rstudio#2575)
  Support new Pandoc 3.4 behavior with GFM math (rstudio#2573)
  consistent dev install instructions (rstudio#2571)
  Update actions/checkout to v4 (rstudio#2570)
  start the next version
  CRAN release v2.28
  update tests for lua filters accordingly
  fix rstudio#2567: add classes `odd`, `even`, and `header` back to table rows for Pandoc >= 3.2.1
jonathan-g added a commit to jonathan-g/rmarkdown that referenced this issue Oct 17, 2024
* rstudio-main:
  parameters with `choices` and `multiple = TRUE` should use a `select` input (rstudio#2576)
  Add support for `child=c("child.Rmd")` in find_external_resources() (rstudio#2575)
  Support new Pandoc 3.4 behavior with GFM math (rstudio#2573)
  consistent dev install instructions (rstudio#2571)
  Update actions/checkout to v4 (rstudio#2570)
  start the next version
  CRAN release v2.28
  update tests for lua filters accordingly
  fix rstudio#2567: add classes `odd`, `even`, and `header` back to table rows for Pandoc >= 3.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: pandoc concerns upstream pandoc
Projects
None yet
Development

No branches or pull requests

3 participants