Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escape special characters in reStructuredText Sphinx

For my documentation, I want escape special characters.

Example :

.. code-block:: terminal

    $ php bin/console test:user

    Press <return> for continue

For Sphinx, it's an external URL <return> and I want escape that.

Screenshot :

enter image description here

like image 424
Gary Houbre Avatar asked Jan 18 '26 12:01

Gary Houbre


1 Answers

See Escaping Mechanism:

A backslash followed by any character (except whitespace characters in non-URI contexts) escapes that character. The escaped character represents the character itself, and is prevented from playing a role in any markup interpretation. The backslash is removed from the output.

To answer your question, you can use various markup techniques.

Escape the opening and closing brackets.

Press \<return\> for continue

Use inline literal markup.

Press ``<return>`` for continue

Use semantic markup with the kbd role:

Press :kbd:`<return>` for continue

IMO, the last option is the most appropriate for this situation. The first option is the least appropriate.

like image 136
Steve Piercy Avatar answered Jan 21 '26 08:01

Steve Piercy