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

use yaml_metadata_block for preserve_yaml feature when possible #2190

Merged
merged 10 commits into from
Jul 21, 2021

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Jul 20, 2021

This will fix #2118 and modify a bit how md_document() is working internally

  • We use a standalone (--standalone) document if preserve_yaml = TRUE
  • We try to add / remove the extension yaml_metadata_block depending on the value of variant and preserve_yaml. This is because some formats have the extension set or unset by default, and also depending of the pandoc version.
  • We add some mechanism to handle parsing and setting those extensions. They could be externalize at some point to be used in other functions.

Doing this should handle correctly most of the case. Let's add that --standalone flag will produce this header, and that some format will have special header if not yaml:

  • markdown will have a pandoc_title_block if not a YAML block
  • markdown_mmd will have mmd_title_block if YAML block is unset.

For now, this is the behavior we apply for all variants:

  • md_document(preserve_yaml = TRUE) will always produce a YAML block.
  • md_document(preserve_yaml = FALSE) will always produce no YAML block.

And this is currently not working which is the main issue of #2118

Should we do something simpler or does it seems like a right thing to do ?

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!

R/md_document.R Show resolved Hide resolved
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.

Please feel free to merge after adding a news item. Thanks!

@cderv
Copy link
Collaborator Author

cderv commented Jul 21, 2021

Do we want to merge this for the next release mid-august planned for the IDE ?
We discussed last time to only release current change.

I am hesitant as there would not be much time for this to live in dev version in case I missed something.
How do you feel about that ?

@yihui
Copy link
Member

yihui commented Jul 21, 2021

I don't feel this is a risky change that would affect users widely, so I'm okay with merging it into the next release.

@cderv cderv merged commit 0af6b35 into master Jul 21, 2021
@cderv cderv deleted the preserve-yml-md branch July 21, 2021 20:50
@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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pandoc 2.13 adds YAML block support for commonmark ( and gfm)
2 participants