-
-
Notifications
You must be signed in to change notification settings - Fork 982
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
Allow 'pre_knit' hooks to return new file to be used for knit? #974
Comments
It looks like if we had the As regards the union of |
Tangential to this discussion, I recently discovered an alternative strategy to comment out sections of Rmd documents, which works for both text and chunks,
I find it much nicer (with Ctrl+Shift+C) than the html comment tags, but it still doesn't prevent knitr from over-doing it with inline chunks. |
So is it possible to do some preprocessing before knitting? I think this would be worthwhile as @jjallaire alluded to above. This would be helpful because otherwise you can't really preprocess the .Rmd/md file (such as stripping out sensitive information or something else tagged). Using I used to be able to do this by using Hacked something together in the I may be missing something, but I'm trying to help our users use the convenient |
I agree this would be a nice feature to have. Currently my workflowr package uses a hack to change the value of the internal variable |
this is a different approach with HTML comments <!-- --> (rstudio/rmarkdown#974)
This feature still has not been implemented, but I just came up with another solution to comment out arbitrary content (including code chunks) in R Markdown, i.e., via the
|
That is very clever 😄 I love it! |
The |
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. |
Motivation: currently, HTML comments are not really properly handled by R Markdown or knitr. For example, with the following document:
Even though the R chunk below is within an HTML comment, that chunk still gets executed, and thus included and processed by Pandoc.
When rendering such a document in
html_document
mode, those comment markers survive, and so the generated output is not shown in the document, giving the user the impression that the commented chunk was ignored.However, with
html_notebook
, we're not so lucky -- the closing comment tag is actually HTML-escaped, and so the comment never actually functions as expected -- we end up seeing the chunk output in the rendered document.Correct me if I am wrong, but since the current experience is as though HTML comments in R Markdown documents are supported, we need to do something extra to ensure that this works for HTML notebooks.
My initial thought would be that the
pre_knit
hook could return a file path that would then be passed on toknitr::knit()
, and that thepre_knit
hook could be in charge of e.g. replacing comments with a placeholder (and later restoring the placeholders in e.g. apost_process
hook). However, this is not currently possible because of how thepre_knit
hooks are overlaid (the union of return values seems to be returned?)Is this something that could be made possible?
The text was updated successfully, but these errors were encountered: