-
Notifications
You must be signed in to change notification settings - Fork 4
Providing documentation for the asis
engine
#74
Comments
Good idea! I recently got something like this to work using another kind of workaround. I was using knitr hooks to hide the results of a chunk until a button is pressed: knitr::knit_hooks$set(
hide_button = function(before, options, envir) {
if (is.character(options$hide_button)) {
button_text = options$hide_button
} else {
button_text = "Show solution"
}
block_label <- paste0("hide_button", options$label)
if (before) {
return(paste0(sep = "\n",
'<button class="btn btn-danger" data-toggle="collapse" data-target="#', block_label, '"> ', button_text, ' </button>\n',
'<div id="', block_label, '" class="collapse">\n'))
} else {
return("</div><br />\n")
}
}
} Then you can add something like this to the Rmd:
It would be great if I did not have to use
This would also allow for varaibles to determine which parts of the rmd are shown, like:
|
Adding a knitr engine might work: |
Oh wait, it already exists, you can use the |
That was a fast resolution! Thank you! |
No problem! |
Thanks... The problem though with I have in mind being able to write markdown paragraphs that are included or not, without having to wrap each line in r code. |
I dont think you need
|
Aha... brilliant! Where can I apply to get back the time I lost on workarounds??? :-) Also, is that documented anywhere? Not here: https://yihui.name/knitr/demo/engines/ |
Haha, there is probably a form you can fill out somewhere.
Not that I saw. I had to look through the source code to find it: https://github.com/yihui/knitr/blob/dc028f4c9698f84999b53edc5f6f255b29d7e5a2/R/engine.R#L390-L392 |
Ok, so I hereby change this issue to providing documentation for the |
A related tool I was just made aware of from issue #63 is I have not used, but looks promising @jtr13! |
echo = FALSE
for text to R Markdownasis
engine
Summary: engine |
Thank you @zachary-foster ! It'll be cool to tweet this on #rstats. |
It was only documented in two places: 1) the source code in There are still many other features of knitr that are not publicly documented, and I plan to address this problem later this year by writing another book that will be free to read. |
😍 Thank you, @yihui!! |
Another of the projects that came up while discussing #42
@jtr13 wrote: "there's one small piece of the puzzle that I doubt would be hard to implement and would make a big difference. That is, having an
echo=FALSE
option for text, to provide the same flexibility for text in progress as we have with code in progress. I can think of so many uses: the ability for example to create assignments with and without solutions (... there are workarounds using comments in code chunks but that's not the same)."The text was updated successfully, but these errors were encountered: