I use docutils in order to produce documents via rst file.
In my document, I need to add and highlight some source code. Also I use cross referencing to make some keywords (section names) hyperlink to the respective section. So, simply append an underline to the end of the word, e.g mysection_
which refers to:
mysection
---------
Some text...
The problem occurs when I use the format of code highlighting. That is, if I use .. code:: C
and then a block of C code, cross referencing in the source code does not work:
.. code:: C
#include "example.h"
int main()
{
printf("My Section is:");
mysection_();
return 0;
}
So, how can I have both code highlighting and cross referencing?
Update:
The same situation might happen also in Stackoverflow. When you put a code in a block of code sample, then some features like referencing are disabled! Is there any solution to enable referencing in a code sample?
For example in the following, referencing does not work:
# This hello world example was copied from [C-HowTo website][1]
# As you noticed, links do not work here, but you see below code block,
# the same link works.
# Also link to [Stackoverflow](http://stackoverflow.com) does not work!
#include<stdio.h>
int main() {
printf("Hello World\n");
return 0;
}