Repository navigation
Add output_format_dependency() - #2462
Conversation
852a4dd to
63fd7e2
Compare
|
An example Rmd Details |
|
Wow this is an interesting idea - I need to look into that closer so it could be not right now as I am currently focus on Quarto 1.3 release. But as soon as I can make time for some rmarkdown work (which is completely due and should happen soon), I'll give this a try. Maybe @yihui will have more time before. Anyhow, generalized approach needs more thoughts than simple PR. Your contribution is really appreciated and I wanted to be honest with you with current situation so that you don't think this PR is ignored! Thank you very much for this @atusy ! |
|
No worries! I'm not hurry. |
cderv
left a comment
There was a problem hiding this comment.
That is really clever way to generalize that ! Thank you.
Should we completely make all the output_format argument available that way ? it seems something possible.
At least, I would like to see if we can add a specific handling for some of the pandoc component. args and lua_filters are among the content one would want to modify
I wonder if we shouldn't extend this also to the knitr and pandoc component currently set as knitr = NULL and pandoc = list()
This would mean being possible to do something like
output_format_dependency <- function(name,
pre_processor = NULL,
post_processor = NULL,
file_scope = NULL,
on_exit = NULL,
knitr = list(),
pandoc = list())so that one can do
output_format_dependency(pandoc = list(lua_filters = "example.lua"))Did you try making that works ?
Obviously we need to add some unit test for this so that we are sure it merges as we expect, and we don't break it in the future.
Otherwise, all good ! Really exciting work ! Thanks again !
|
Thank you so much for your review! I am excited by your reactions! I will try adding the pandoc argument and unit tests in this or next week.
About the above comment,
|
Oh indeed. I missed that. I was too exited by the new feature probably ! 😄
Interesting 🤔 - initial issue was to have a way to add Lua filter more easily as a dependency. I thought we could somehow add to the Otherwise, it is easy enough to do a wrapper of this new function, as lua_filters can be added in pre_processor as you did. But I did it another for some reason (I think to add a format lua filter last or something like that). I let you look into this and we'll see if we can change things to make it happen. |
|
Okay, I confirmed Rmdstdout from render()So the last task is to add tests. |
cderv
left a comment
There was a problem hiding this comment.
Awesome !
Need to be AFK but I'll rebase later if you haven't done it and then I'll merge
Thank you
|
rebased and added news. |
[skip ci]
* rstudio/main: start the next version CRAN release v2.24 shinyrmd: Safer dependency extraction from pre-rendered HTML (rstudio#2500) quote the version number per CRAN's request Add output_format_dependency() (rstudio#2462) file_scope is now correctly merged when creating output_format (rstudio#2488) Correctly run some tests only on CI start the next version CRAN release v2.23 remove broken links suggest cleanrmd for e499bf7 add news comparing version numbers with numbers is no longer allowed: https://bugs.r-project.org/show_bug.cgi?id=18548 `find_external_resources` works with custom format using `theme` (rstudio#2494) start the next version CRAN release v2.22 S3 generic/method consistency Change the code-folding button text from "Code" to "Show" (rstudio#2489) fix: bump jquery-ui to v1.13.2 to fix multiple CVEs (rstudio#2477) detecting external resources needs to consider css argument (rstudio#2486)
Merge remote-tracking branch 'rstudio/main' into jg-devel # By Yihui Xie (13) and others # Via Yihui Xie * rstudio/main: start the next version CRAN release v2.24 shinyrmd: Safer dependency extraction from pre-rendered HTML (rstudio#2500) quote the version number per CRAN's request Add output_format_dependency() (rstudio#2462) file_scope is now correctly merged when creating output_format (rstudio#2488) Correctly run some tests only on CI start the next version CRAN release v2.23 remove broken links suggest cleanrmd for e499bf7 add news comparing version numbers with numbers is no longer allowed: https://bugs.r-project.org/show_bug.cgi?id=18548 `find_external_resources` works with custom format using `theme` (rstudio#2494) start the next version CRAN release v2.22 S3 generic/method consistency Change the code-folding button text from "Code" to "Show" (rstudio#2489) fix: bump jquery-ui to v1.13.2 to fix multiple CVEs (rstudio#2477) detecting external resources needs to consider css argument (rstudio#2486) # Conflicts: # DESCRIPTION
* jg-devel: (21 commits) Updated NEWS. Patched `merge_output_format_dependency` to ensure that named elements remain in the correct order. start the next version CRAN release v2.24 shinyrmd: Safer dependency extraction from pre-rendered HTML (rstudio#2500) quote the version number per CRAN's request Add output_format_dependency() (rstudio#2462) file_scope is now correctly merged when creating output_format (rstudio#2488) Correctly run some tests only on CI start the next version CRAN release v2.23 remove broken links suggest cleanrmd for e499bf7 add news comparing version numbers with numbers is no longer allowed: https://bugs.r-project.org/show_bug.cgi?id=18548 `find_external_resources` works with custom format using `theme` (rstudio#2494) start the next version CRAN release v2.22 S3 generic/method consistency Change the code-folding button text from "Code" to "Show" (rstudio#2489) fix: bump jquery-ui to v1.13.2 to fix multiple CVEs (rstudio#2477) ...
|
@atusy Do you have time to write a short blog post on this new feature? One or two examples would be enough. I feel many people will be interested in this feature. Feel free to publish the post in your own blog (https://blog.atusy.net), and we can help promote it. Thanks! |
|
Yeah sure. I would post one in the next week! |
This PR is an attempt to solve #2347, but in a more generalized way.
In the issue #2347, I suggested
pandoc_dependency(), however, this function needs to follow the updates of Pandoc's API changes.Instead, this PR implements
output_format_dependency(), which allows defining some of the arguments inoutput_formatfrom within a Rmd file.Supported arguments are
pre_processor,post_processor,file_scope,on_exit.The others are not because dependency can be solved after
post_knit, which finalizesknit_meta.Fortunately,
pre_processorcan return extra arguments to pass to pandoc, so we can dynamically add lua filters, which covers the motivation of #2347.Also, this PR should be helpful in the situations like #2314.
In #2314, the issue author suggests
knitfiled in the YAML front matter to modify therender()function.This is a powerful solution, but limited to RStudio users...
My proposal is available for R users on any environments.
Note that there is a remaining work to implement
attach_output_format_dependencies(), likehtmltools::attachDependencies(), but this can be a future work.