..code 中的颜色文本:: - reStructuredText 中的环境 - 文件.rst

问题描述

我已经按照 here 提供的答案在 .rst - 文档(即与它们相关联的 HTML-preview)中实现彩色文本。

然而,在代码环境中,它不起作用:

vs-code-rst-colored-text

如何在代码环境中使用彩色文本?

我的整个 .rst - 文件代码是:

.. raw:: html

    <style> .red {color:red} </style>

.. role:: red



Amazon States Language
======================

Source: https://states-language.net/spec.html


Key-facts
----------

1) JSON-based language used to describe state machines declaratively
2) State Machine are represented by a JSON Object(s) == "states"
3) State machines thus defined may be executed by software ("the interpreter")


Hello-World
---------------------

An example of using :red:`interpreted text`

.. code:: JSON

    {
        "Comment": "A simple minimal example of the States language",//:red:`optional`
        "Version": "1.0",//:red:`optional`
        "TimeoutSeconds": 10,//:red:`optional`
        "StartAt": "Hello World",//required
        "States": {  //required
            "Hello World": {
                "Type": "Task","Resource": "arn:aws:lambda:us-east-1:123456789012:function:HelloWorld","End": true
            }
        }
    }

关于尝试变通方法(失败)的 PS:

1.前面的空格字符:
// 和 e.g. 之间放置一个空格字符:red:'optional' 没有解决问题。后来我意识到 inserting a space character in front of the colored text piece 可以使事情顺利进行,但如果您不想在前面有一个空间怎么办?

2.带有 !important 的 CSS 内联:
它不会导致输出 HTML 的任何差异。

.. raw:: html

    <style> .red {color: red !important} </style>
    <style> .green {color: green !important} </style>

.. role:: red
.. role:: green

3.更改为支持注释的编程语言 (Python):
它也不起作用,也不显示任何颜色。代码如下:

.. code:: python

    {
        "Comment":
        "A simple minimal example of the States language",# :green:`optional`
        "Version": "1.0",# :green:`optional`
        "TimeoutSeconds": 10,# :green:`optional`
        "StartAt": "Hello World",# :red:`required`
        "States": {  # :red:`required`
            "Hello World": {  # :red:`must be unique within state machine`
                "Type": "Task",# :red:`required`
                "Resource":
                "arn:aws:lambda:us-east-1:123456789012:function:HelloWorld","End": true,# terminal state
                "Comment":
                "Executes the HelloWorld Lambda function"  # :green:`optional`
            }
        }
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)