rmarkdown-cookbook icon indicating copy to clipboard operation
rmarkdown-cookbook copied to clipboard

How to display an inner reference as initial text in a verbatim block?

Open piiskop opened this issue 1 year ago • 1 comments

i'm writing a manual and struggling with the reference part. i have a reference like:

(ref:a-reference) whatever

i want to show as verbatim how to use it:

```{verbatim}
I'm referring to (ref:a-reference).

```

The output should be:

I'm referring to (ref:a-reference).

Instead, the output is:

I'm referring to whatever.

This is because (ref:...) will be evaluated before the verbatim block and the value of that will be put into, not the string itself. Actually, as it's a verbatim block, there must only be the initial, not evaluated string. How to do that?

piiskop avatar Jul 27 '22 05:07 piiskop

bookdown currently only ignore replacement when the reference is in a verbatim inline code

I'm referring to `(ref:a-reference)`.

In any other case, the text reference will be replaced. This would be a feature request in bookdown if this is possible.

However, not as easy as the mechanism does not parse the text as block but by line so the context of the verbatim code block is not known by the text reference feature.

cderv avatar Aug 22 '22 08:08 cderv