Search code examples
python-sphinxrestructuredtextdocutils

Is it possible to insert hyperlinks in an ReST literal block?


I know this kind of defeat the purpose of a literal block, however I was wondering if there was any workaround to achieve this. My use case is to put an hyperlink in a block literal of pseudo code, in order to reference details elsewhere in the document.

Example :

Look at this JSON pseudo code
-----------------------------

::

  {
    "id": <number>,
    "name": <string>,
    "big_property": <see schema of big_object_>
  }

And the details of big object
-----------------------------

.. _big_object:

::

  {
     <another_schema>
  }

I would like that in the first literal block, big_object_ becomes an hyperlink.


Solution

  • You can use the parsed-literal directive for this:

    .. parsed-literal::
    
      {
        "id": <number>,
        "name": <string>,
        "big_property": <see schema of big_object_>
      }