Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Restructuredtext StructuredText中的内联代码高亮显示_Restructuredtext - Fatal编程技术网

Restructuredtext StructuredText中的内联代码高亮显示

Restructuredtext StructuredText中的内联代码高亮显示,restructuredtext,Restructuredtext,我知道StructuredText有这个指令: .. code:: bash gedit pohl.m 它呈现一个代码块。是否有某种方法可以获得以下内联代码段的语法高亮显示: Do edit the file, type ``gedit pohl.m`` into a terminal. 背景标记将其标记为代码,但我想用类似块的pygments来突出显示它。这是可能的吗?在进一步研究之后,我偶然发现了该文档。从本文件中: 解释文本在文本周围使用反引号。显式角色标记可以选择显示在文本

我知道StructuredText有这个指令:

.. code:: bash

    gedit pohl.m
它呈现一个代码块。是否有某种方法可以获得以下内联代码段的语法高亮显示:

Do edit the file, type ``gedit pohl.m`` into a terminal.

背景标记将其标记为代码,但我想用类似块的pygments来突出显示它。这是可能的吗?

在进一步研究之后,我偶然发现了该文档。从本文件中:

解释文本在文本周围使用反引号。显式角色标记可以选择显示在文本之前或之后,并用冒号分隔。例如:

This is `interpreted text` using the default role.

This is :title:`interpreted text` using an explicit role.
似乎有一个,所以你可以简单地键入

:code:`a = b + c`
渲染内联代码块。要获得语法突出显示,可以定义自定义角色。比如说

.. role:: bash(code)
   :language: bash
然后您可以这样使用:

Here is some awesome bash code :bash:`a = b + c`.
请注意,角色定义必须放在对角色的引用之前


注意,我链接到的文档没有提到它所引用的docutils版本。docutils 0.8.1中没有代码角色,这是我必须测试的唯一版本。

反勾号将文本的该部分标记为,而不是代码块。通常,这将以单空格字体发布。恐怕我不确定如何突出显示内联代码语法片段。请在使用sphinx时注意此问题: