首页 > Web开发 > 详细

sphinx插入css

时间:2014-04-09 23:19:30      阅读:834      评论:0      收藏:0      [点我收藏+]

使用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

sphinx插入css,布布扣,bubuko.com

sphinx插入css

原文:http://www.cnblogs.com/youxin/p/3654985.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!