I've followed along the answers presented here as to achieving colored text in .rst
- documents (i.e. the HTML
-preview associated with them).
Yet, inside a code-environment, it does not work:
How can I make colored text work inside the code-environment?
The code of my entire .rst
- file is:
.. 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 on trying out workarounds (which failed):
1. Space character in front:
Putting a space character between the //
and e.g. :red:'optional'
did not resolve the problem. I realized later that inserting a space character in front of the colored text piece makes things work, but what if you do not want a space in front?
2. CSS-inline with !important
:
It did not lead to any difference in the output HTML
.
.. raw:: html
<style> .red {color: red !important} </style>
<style> .green {color: green !important} </style>
.. role:: red
.. role:: green
3. Change to programming language which supports comments (Python):
It also does not work, no colors are displayed either. The code is the following:
.. 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`
}
}
}