如何与ReStructured文本一起使用颜色?例如,**hello**转换为<strong>hello</strong>。如何使ReStructure(rst2html.py)将 translate 转换为<font color="####">text</font>?
我想到了..raw::html,但是它引入了空行。我想插入没有空行的HTML标签。
发布于 2011-01-12 14:24:49
我发现这种方法很管用
首先,你有这个角色。
.. role:: red
An example of using :red:`interpreted text`它的翻译如下。
<p>An example of using <span class="red">interpreted text</span></p>现在,您有红色类,您可以使用CSS更改颜色。
.red {
color:red;
}发布于 2011-04-28 07:52:26
那么,我现在是一个新的用户,因此我不能评论别人的回答,因为这里的堆栈溢出的政策。https://meta.stackexchange.com/questions/51926/new-users-cant-ask-for-clarifications-except-as-answers
Sienkiew的回答是好的,但我想对它的最后一句作更正。
可以在RST文件中指定样式表。线索是在Prosseek最初的文章中,也就是..。raw::指令。
我们可以在RST文件的开头放置以下行来指定它的样式。
.. raw:: html
<style> .red {color:red} </style>发布于 2011-03-30 17:29:28
这里的另一个答案暗示了我想要做的事情,但它假设对docutils中的样式表有一些详细的了解。这里有一个烹饪书的解释:
在您的RST文件中,声明角色一次,然后使用它:
.. role:: red
This text is :red:`colored red` and so is :red:`this`那么您需要一个样式表文件。首先,使用Python将默认样式表复制到docutils包中:
python
import os.path
import shutil
import docutils.writers.html4css1 as h
shutil.copy(os.path.dirname(h.__file__)+"/html4css1.css","my.css")然后编辑my.css,在末尾添加自定义:
.red {
color: red;
}创建一个名为“docutils.conf”的docutils配置文件:
[html4css1 writer]
stylesheet-path: my.css
embed-stylesheet: yes使用rst2html.py转换文档:
rst2html.py my_document.rst > my_document.html如果不想使用docutils.conf,可以在每次运行rst2html时指定样式表:
rst2html.py --stylesheet my.css my_document.rst > my_document.htmlAFAIK,无法在RST文件中指定样式表。
https://stackoverflow.com/questions/4669689
复制相似问题