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

Pandoc 2.13 adds YAML block support for commonmark ( and gfm) #2118

Closed
cderv opened this issue Apr 28, 2021 · 2 comments · Fixed by #2190
Closed

Pandoc 2.13 adds YAML block support for commonmark ( and gfm) #2118

cderv opened this issue Apr 28, 2021 · 2 comments · Fixed by #2190
Assignees
Labels
next to consider for next release

Comments

@cderv
Copy link
Collaborator

cderv commented Apr 28, 2021

This was first reported in tidyverse/reprex#375 and needs to be handled in rmarkdown directly.

Pandoc 2.13 added support for yaml_metadata_block to commonmark in addition to markdown: jgm/pandoc@c389211

This impact gfm and commonmark_x for which it is activated by default. The change for gfm is a breaking change as you need to use gfm-yaml_metadata_block to get the previous behavior.

Basic +yaml_metadata_block is by default, and if --standalone is passed in command line, the YAML block will be added in the output .md document. Which was not the case before this new extension.

We allow that only for markdown format I think when preserve_yaml = TRUE only. So it should probably work the same for those format too.
I think we need to update md_document() and github_document() to take that into account regarding preserve_yaml = FALSE.

Note that github_document() is not affected currently I think because we don't use the default Pandoc template for commonmark and we don't have titleblock variable in ours.
Default template is

❯ pandoc --print-default-template=gfm
$if(titleblock)$
$titleblock$

$endif$
$for(header-includes)$
$header-includes$

$endfor$
$for(include-before)$
$include-before$

$endfor$
$if(toc)$
$table-of-contents$

$endif$
$body$
$for(include-after)$

$include-after$
$endfor$
@cderv cderv changed the title Pandoc 2.13 adds YAML block support of new formats Pandoc 2.13 adds YAML block support for commonmark ( and gfm) Apr 28, 2021
@cderv cderv added the next to consider for next release label Apr 28, 2021
@cderv cderv self-assigned this Apr 28, 2021
@cderv
Copy link
Collaborator Author

cderv commented May 12, 2021

Looking more into how this works for md_document(), it seems we don't handle well markdown variants with Pandoc. Notable things are

  • Including --standalone or not will allow to add or not the metadata in the output
  • Some format includes by default some metadata header (which is the change that happened here)
  • YAML blocks are not the only metadata format. markdown_mmd support mmd_title_block for example, which I think would be better to use than YAML if we want to preserve the header for this output.

So we could fix this quickly by just handling the gfm / commonmark change in Pandoc 2.13 or try to clean the way it works. Maybe the former is better short term and we could work on the other long term with help of new Pandoc toolings maybe.

cderv added a commit that referenced this issue Jul 21, 2021
This fixes change in Pandoc 2.13 about `yaml_metadata_block` for `commonmark` based formats (fixes #2118)
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
next to consider for next release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant