zoukankan      html  css  js  c++  java
  • sphinx插入css

    使用role指令达到目的。

    We can put following lines at the beginning of our RST file to specify its style.

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

    然后使用role指令:
    .. role:: red
       :class: red

    调用role指令:
    This is an :red:`inline text`.
    

    which translates into a html rendering of

    .. This is an <span class="red">inline text</span>.  ..
    如何分离css:

    I found the other answers very helpful. I am not very familiar with Sphinx but I am using it for a project. I too wanted the strike-through ability and have got it working based on the previous answers. To be clear, I added my strikethrough role as gozzilli mentioned but I saved it inside my conf.py using the rst_prolog variable as discussed in the stack overflow thread here. This means that this role is available to all of your rest files.

    I then extended the base html template as described above by creating layout.htmlwithin _templatesinside my source directory. The contents of this file are:

    {% extends "!layout.html" %}
    {% set css_files = css_files + ["_static/myStyle.css"] %}
    

    This basically includes a custom css file to all your built default html docs.

    Finally, in my _static directory within my source directory I included the file myStyle.css which contains:

    .strike {
      text-decoration: line-through;
    }
    

    Which the other answers have already provided.

    I am merely writing this answer as it wasn't obvious to me with my limited Sphinx experience which files to edit.

    参考了:

    http://stackoverflow.com/questions/6518788/rest-strikethrough

    http://stackoverflow.com/questions/4669689/how-to-use-color-in-text-with-restructured-text-rst2html-py-or-how-to-insert-h

    http://stackoverflow.com/questions/9698702/custom-css-styles-in-sphinx

  • 相关阅读:
    eclipse建立工作集管理项目
    echarts-x
    GeoJSON
    mysql 5.7 root password 过期
    kubernetes centos7
    JestClient
    树莓派镜像制作
    docker run elasticsearch
    vm.max_map_count
    远程访问jupyter notebook
  • 原文地址:https://www.cnblogs.com/youxin/p/3654985.html
Copyright © 2011-2022 走看看