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

  • 相关阅读:
    一道经典的线程间通信的编程题
    Windows Live Writer代码插件整理
    Squeeze Excitation Module 对网络的改进分析
    IGC(Interleaved Group Convolutions)
    探秘移动网络模型
    sparse_softmax_cross_entropy_with_logits
    四行公式推完神经网络BP
    视觉跟踪:MDnet
    tensorflow API _ 6 (tf.gfile)
    tensorflow API _ 4 (Logging with tensorflow)
  • 原文地址:https://www.cnblogs.com/youxin/p/3654985.html
Copyright © 2011-2022 走看看