Skip to content
New issue

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

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

Already on GitHub? # to your account

Long titles are split into h1 and p tags #345

Closed
3 tasks done
ellessenne opened this issue Mar 8, 2022 · 5 comments
Closed
3 tasks done

Long titles are split into h1 and p tags #345

ellessenne opened this issue Mar 8, 2022 · 5 comments
Labels

Comments

@ellessenne
Copy link
Contributor

Hi,
I am having some weird issues with the title of the presentation being split into a h1 and p tag if the title is long.
For instance, the following YAML header (without any content)

---
title: "This is a very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very long title."
output: xaringan::moon_reader
---

is rendered to this:

<div class="remark-slide">
  <div class="remark-slide-content center middle inverse title-slide hljs-default">
    <h1 id="this-is-a-very-very-very-very-very-very-very-very-very-very-">This is a very, very, very, very, very, very, very, very, very, very,</h1>
    <p>very, very, very, very, very, very, very, very, very long title.</p>
    <div class="remark-slide-number">1 / 2</div>
  </div>
</div>

My guess is that the id of h1 would be too long, but is there any way around this?
Thanks!

Alessandro

P.s.: this is my xfun::session_info('rmarkdown') info:

R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.2.1, RStudio 2022.2.0.443

Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8

Package version:
  base64enc_0.1.3 bslib_0.3.1     digest_0.6.29  
  evaluate_0.15   fastmap_1.1.0   fs_1.5.2       
  glue_1.6.2      graphics_4.1.2  grDevices_4.1.2
  highr_0.9       htmltools_0.5.2 jquerylib_0.1.4
  jsonlite_1.8.0  knitr_1.37      magrittr_2.0.2 
  methods_4.1.2   R6_2.5.1        rappdirs_0.3.3 
  rlang_1.0.2     rmarkdown_2.12  sass_0.4.0.9000
  stats_4.1.2     stringi_1.7.6   stringr_1.4.0  
  tinytex_0.37    tools_4.1.2     utils_4.1.2    
  xfun_0.30       yaml_2.3.5     

Pandoc version: 2.17.1.1

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('xaringan'). 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/xaringan').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@cderv
Copy link
Collaborator

cderv commented Mar 8, 2022

I believe this is related to your other issue #346 and this is due to Pandoc change related to how lines are wrapped.
It seems it does not play well with remark.js to have some HTML line wrapped to column length and raw HTML is not parsed correctly then.

Related to rstudio/bookdown#1304 also.

@ellessenne as a workaround for now you could just add this to your YAML

output: 
  xaringan::moon_reader:
    pandoc_args: --wrap=none

@yihui I believe we should set --wrap=preserve or --wrap=none for all Pandoc versions, or at least just the ones above 2.17.1 which introduce the change. It seems we don't do that in rmarkdown and we do it only in bookdown.

So we could just add that argument in xaringan but maybe we should do it in rmarkdown so that past behavior before pandoc 2.17.1 is the same. is adding that to rmarkdown directly too much ?

@ellessenne
Copy link
Contributor Author

Hi @cderv, thanks for the quick feedback and for the workaround.
I did try it out for both this issue and #346, and telling pandoc not to wrap HTML output did in fact fix it, FYI.
Many thanks again!

Alessandro

@yihui
Copy link
Owner

yihui commented Mar 8, 2022

is adding that to rmarkdown directly too much ?

@cderv You can try it in a PR and see if it breaks anything. It might break tests, but I don't think it would affect the rendered output (.html, .pdf, etc) since line-wrapping usually doesn't have any semantic meaning.

Of course, we could add --wrap=none|preserve to xaringan first (edit: done in a8eb18b), no matter if we will do that in rmarkdown or not.

@yihui yihui closed this as completed in a8eb18b Mar 8, 2022
@yihui
Copy link
Owner

yihui commented Mar 8, 2022

@ellessenne Should be fixed now. You can test the development version via

remotes::install_github('yihui/xaringan')

Thanks for the report!

@ellessenne
Copy link
Contributor Author

Hi @yihui, tested this with {xaringan} 0.23 and it worked like a charm, both for this issue and #346. Thanks very much for the super quick fix!

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

No branches or pull requests

3 participants