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

Add an option to opt-out using header-attrs HTML dependency in html_document_base() #2227

Merged
merged 4 commits into from
Oct 4, 2021

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Oct 4, 2021

Currently we use a JS script in a custom html_dependency_header_attrs() so that we can "fix" breaking pandoc behavior from change in 2.8. We do that when Pandoc 2.9+ is used.

With rmarkdown we currently use pandoc's --section-div flag by default. This will create a <div> to encapsulate header. When attributes are added on header, they are moved to this section div. Behavior changed in Pandoc 2.8

  • Text to convert using pandoc --to html4 --section-div

    # hello {.anchor #id attr='val'}
  • With Pandoc 2.7.3 - nothing added on header itself - all move to section div

    <div id="id" class="section level1 anchor" lang="en">
    <h1>hello</h1>
    </div>
  • With Pandoc 2.8 - breaking change - class is not moved anymore

    <div id="id" class="section level1">
    <h1 class="anchor" lang="en">hello</h1>
    </div>
  • With Pandoc 2.9 to 2.13 - only id is moved now.

    <div id="id" class="section level1 anchor" lang="en">
    <h1 class="anchor" lang="en">hello</h1>
    </div>

The change of Pandoc regarding class was breaking some tools (#1723, #1732) and so it was added a JS script to remove the class on header.

This could no be desired always like rstudio/bookdown#865 and r-lib/pkgdown#1538.

So this PR adds an option to opt-out including the HTML dependency. This would solve the two issue above IMO

Copy link
Member

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks!

NEWS.md Outdated Show resolved Hide resolved
@yihui yihui merged commit 0ed2349 into main Oct 4, 2021
@yihui yihui deleted the header-attr-optout branch October 4, 2021 14:48
jonathan-g added a commit to jonathan-g/rmarkdown that referenced this pull request Oct 30, 2021
Merge remote-tracking branch 'rstudio_origin/main' into jg-tree-fix

# By Christophe Dervieux (2) and Yihui Xie (1)
# Via Christophe Dervieux
* rstudio_origin/main:
  Add class to book cover to size using CSS
  fix the syntax highlighting of |> in LaTeX/PDF output: rstudio/bookdown#1157 (rstudio#2228)
  Add an option to opt-out the header-attrs HTML dependency in `html_document_base()` (rstudio#2227)

# Conflicts:
#	NEWS.md
jonathan-g added a commit to jonathan-g/rmarkdown that referenced this pull request Nov 29, 2021
Merge branch 'jg-tree-fix' into jg-devel

* jg-tree-fix:
  Use latest Pandoc  in GHA and update workflow (rstudio#2244)
  Add class to book cover to size using CSS
  fix the syntax highlighting of |> in LaTeX/PDF output: rstudio/bookdown#1157 (rstudio#2228)
  Add an option to opt-out the header-attrs HTML dependency in `html_document_base()` (rstudio#2227)
  Clean up NEWS.md.

# Conflicts:
#	DESCRIPTION
#	NEWS.md
jonathan-g added a commit to jonathan-g/rmarkdown that referenced this pull request Nov 29, 2021
* jg-devel: (35 commits)
  Use latest Pandoc  in GHA and update workflow (rstudio#2244)
  Add class to book cover to size using CSS
  fix the syntax highlighting of |> in LaTeX/PDF output: rstudio/bookdown#1157 (rstudio#2228)
  Add an option to opt-out the header-attrs HTML dependency in `html_document_base()` (rstudio#2227)
  Clean up NEWS.md.
  Updated autogenerated documentation.
  Fixed conflicts with rstudio main version.
  Update documentation for html_document.
  Add self (JG) as a contributor in DESCRIPTION.
  Resolve conflicts with new updates to RStudio main branch.
  Clean up a few things from the merge.
  Fix problem building with GitHub Actions because of `mathjax: local` in the testthat tests.
  Revert unnecessary formatting change to code in render.R.
  Revert an unnecessary formatting change to comments in render.R.
  Update NEWS.md.
  revert inadevertent change from accidental merge with jg-tree-fix.
  Removed unnecessary references to `allow_uptree_lib_dir` in `ioslides_presentation` and `slidy_presentation`.
  Prepare for PR to RStudio.
  Updated documentation for new parameter in output_format().
  Removed packages.bib from tests/testthat.
  ...
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants