rmarkdown verbatim in line code

Hi! I am struggling to create a verbatim in-line code chunk.

My goal is to display (and not evaluate)

 `r chunk_reveal("walrus", title = "## Walrus operator")` 

in an rmarkdown document (chunk_reveal is from flipbookr).

The closest I've been able to get is

which renders as

which I am sharing as a screenshot b/c it isn't quite rendering fully here either.

I've read through the articles below, but I'm not able to find the magic combination. What am I missing?

r ''chunk_reveal("walrus", title = "## Walrus operator")`
do it?

Thanks for the suggestion! I think some the syntax rendered here as well, so here are screenshots (apologies!) of what I tried based on what I think your suggestion was, and the knitted output.

So yes, the syntax renders without error! But I'm also not displaying backtick r in front of the chunk_reveal, closed by another backtick.

Here is the screen shot of what I submitted and the result.

Argh, my stupidity.

This might work.

 `r ''`\`chunk_reveal("walrus", title = "## Walrus operator")\`

Thanks for the updated attempt!

Got this this time:

Following the recipe you linked to, where knitr::inline_expr usage is shown, should have work:

title: "Test inline expr"
output: html_document

To use `chunk_reveal("walrus", title = "## Walrus operator")` inline, you can wrap it in R inline chunk like this `` `r knitr::inline_expr('chunk_reveal("walrus", title = "## Walrus operator")')` ``

Did that not work for you ?

  • Using knitr::inline_expr()
  • Using double backtick at both side to wrap the inline chunk

I let you try and tell me if that works for you.

Okay, there must be something different is our settings as I am not seeing the "". I am not sure that what I am getting is what you wast but it is different from your results.

I am outputting to an html_document.

Woohoo, success with knitr::inline_expr solution! Thank you both so much!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.