How to escape the "`" backtick character in a .rst file?

Viewed 1718

I want to write the following sentence:

Don't forget to escape the :code:`\`` character, it will be interpreted as code mark

But I don't know how to escape the "`" backtick character. Is it even possible?

2 Answers

You cannot escape backticks within interpreted text, as backticks themselves define what gets interpreted.

There are at least two options. The latter yields the same result as if you code use :code: with escaping the backtick.

No formatting

Don't forget to escape the \` character, it will be interpreted as code mark

With formatting

.. |bt| raw:: html

    <code class="code docutils literal notranslate">`</code>

Don't forget to escape the |bt| character, it will be interpreted as code mark

Above examples rendered

rendered examples

A pair of backticks define Interpreted Text:

Interpreted Text

Doctree element: depends on the explicit or implicit role and processing.

Start-string = end-string = "`".

Interpreted text is text that is meant to be related, indexed, linked, summarized, or otherwise processed, but the text itself is typically left alone. Interpreted text is enclosed by single backquote characters:

This is interpreted text.

The specific role in the question named :code:. What should be noted is that how the Interpreted Text is processed depends on the specific role that accompanies it (roles can be general reST or Sphinx specific).

The "role" of the interpreted text determines how the text is interpreted. (...) A role marker is either a prefix or a suffix to the interpreted text

:role:`interpreted text`
`interpreted text`:role:

Because Interpreted Text has the noteworthy property that its corresponding Doctree element depends on the role:

Doctree element: depends on the explicit or implicit role and processing

The general rule for escaping in reST is given in Escaping Mechanism which consists simply of using a \ backlash character. However this also has broader implications, see the remaining Inline Markup recognition rules.

A convenient summary is given in Inline Markup and Escaping with Backslashes - Quick reStructuredText a cheat-sheet for reStructuredText.

Related