Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up
By filing an issue to this repo, I promise that
xfun::session_info('rmarkdown'). 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('rstudio/rmarkdown').Note: Sorry for the strange line wrapping below. I used the output format
github_document(), but apparently GitHub markdown now respects line breaks. I manually fixed a few of the more egregious breaks below.I have created a custom output format that extends
html_document(). Inoticed that the argument
keep_mdis not properly inherited.My first thought was that both the arguments
keep_mdanddf_printmight have issues since they are arguments for both
output_format()and
html_document(), but somehowdf_printis properly inherited.Here is a minimal example to demonstrate the issue. The function below
is a trivial output format that wraps
html_document(), but doesn’tchange anything.
If a user runs
render()on an R Markdown file with the following YAMLheader:
then this would result in the following call to
create_output_format():This inherits the default values from
html_document()as expected:However, if a user runs
render()on an R Markdown file with thefollowing YAML header:
then this would result in the following call to
create_output_format()(line 378):tocis inherited as expected:df_printis inherited not only in the environment of thepre_knit()function, but the value of the output format is also inherited:
Unfortunately,
keep_mdis only updated in the environment of thepre_knit()function, where it has no effect.When
render()addsrmarkdown.keep_mdtoknitr::opts_knit, it usesoutput_format$keep_md(line 500).When
render()decides to keep the md file, it again usesoutput_format$keep_md(line 869).Potentially related Issues include #842 and #928.
Note that
bookdown::html_document2()does not have this issue.But it is unclear to me what part of its code would change the
inheritance of
keep_md.It appears to be directly editing the base output format instead of
inheriting from it using
output_format(base_format = ), which is whatthe documentation recommends.
What is the recommended method for passing all arguments provided to a
custom output format to the base output format that it extends?
I realize that I could hard-code a work-around for the custom output
format to handle
keep_md, but this is fragile. If a future release ofrmarkdown added a new argument to
output_format()/html_document(), Iwould have to update my code and also put a restriction on the minimum
version of rmarkdown that is compatible.