微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决..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 举报,一经查实,本站将立刻删除。