Search code examples
htmlrestructuredtextrst2html.py

How to use color in text with ReStructured Text (rst2html.py) or how to insert HTML tags without blank lines?


How can I use color with ReStructured Text? For example, **hello** translates into <strong>hello</strong>. How can I make ReStructure(rst2html.py) translate something into <font color="####">text</font>?

I thought about ..raw:: html, but it introduces blank lines. I want to insert HTML tags without blank lines.


Solution

  • I found this method working

    First, you have the role.

    .. role:: red
    
    An example of using :red:`interpreted text`
    

    It translates into as follows.

    <p>An example of using <span class="red">interpreted text</span></p>
    

    Now, you have the red class, you can use CSS for changing colors.

    .red {
        color:red;
    }