When you use inline code in an R Markdown document, the code is evaluated and the output is incorporated into the text. For example,
The sum of 2 and 2 is `r 2+2`.
This will generate the following text in the .nb.html
file:
The sum of 2 and 2 is 4.
That text is not styled or tagged in any way in the HTML output, so there is no way to apply CSS.
But I'd like to be able to see in the HTML document if text appears "as is" or if it was processed through inline code. In other words, I want to know see a difference in the appearance of the number 4 if I write
The sum of 2 and 2 is `r 2+2`.
versus
The sum of 2 and 2 is 4.
Is there any way to do this?
(The use case here is that I have students who are supposed to use inline code in their assignments, but if I'm looking at the .nb.html
file and not the .Rmd
file, I can't tell if they just manually typed in an answer without using code to generate it.)
EDIT: My original question said R Markdown, and there is a good solution to that question below. However, I need this to work in an R Notebook, and it seems that knit_hooks$set
is ignored when creating the HTML file.