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

后端 未结 7 1605
抹茶落季
抹茶落季 2020-12-13 13:37

How can I use color with ReStructured Text? For example, **hello** translates into hello. How can I make ReStructure(r

7条回答
  •  Happy的楠姐
    2020-12-13 14:25

    Sphinx already supports colors with the s5defs.txt standard definition file intended for inclusion (but is missing the CSS file):

    1. Create/append this text to the value of rst_epilog sphinx configuration, in your docs/conf.py file:

      rst_prolog = """
      .. include:: 
      .. default-role::
      
      """
      
    2. Follow Sphinx's instructions to add a css with the colors (e.g. adopt the hack.css from @Næreen's answer):

      • Place your css file into e.g. _static/css/s4defs-roles.css;
      • append it's path into shtml_css_files sphinx configuration:

        html_css_files = [
            'css/s4defs-roles.css',
        ]
        

    You may then use:

    Some :red:`colored text` at last!
    

    TIP: Read this SO if you also want the styling to appear in Latex output.

提交回复
热议问题