我正在使用ReStructuredText (ReST)格式编写一些文档,以供以后使用Sphinx生成网页时使用,而且我无法找到一种方法来编写一些“粗体斜体”文本。
有所谓的“强调”(斜体)和“强强调”(粗体)文本的标记。分别为*italic text*和**bold text**。我还在一些关于这种格式的文档中看到,这些格式标记不能简单地“嵌套”。也就是说,***text*** (或** *text* **)不生成粗体斜体文本。
尽管如此,也许还是应该有一些方法来产生一份用粗体和斜体标记都强调的文本,因为用这种方式标记文本是一种普遍的做法。
发布于 2012-08-16 10:02:04
尽管Markdown支持嵌套粗体和斜体,但reStructuredText不支持(这是Markdown功能更强大的罕见情况之一,因为无法用reStructuredText表示粗体斜体)。
发布于 2014-04-05 19:42:59
HTML输出的配方。
my.rst
.. role:: red
:class: red
.. role:: bolditalic
:class: bolditalic
:red:`WARNING` :bolditalic:`Don't be stupid!`my.css
.red { color: red; }
.bolditalic {
font-weight: bold;
font-style: italic;
}通过下列方式建造:
rst2html --strip-comments --halt warning --stylesheet=my.css my.rst my.html发布于 2012-10-10 08:44:05
在sphinx中,这可以通过自定义角色来实现:您可以在css中创建样式,并创建指向该样式的角色。下面是带下划线文本的完整示例:sphinx-dev线程。
编辑
下面是一个很好的例子:ReST截取
编辑2
这个sphinx链接不再可用,下面是要点,它非常类似于上面的清除链接:
CSS:
span.underlined {
text-decoration: underline;
}在RST中的注册角色:
.. role:: underlined
:class: underlined稍后将其用作
:underlined:`test`所有这些都可以放在一个RST文档中:
.. raw:: html
<style type="text/css">
span.underlined {
text-decoration: underline;
}
</style>
.. role:: underlined
:class: underlined
:underlined:`test`用以下方法测试:
rst2html5.py test01.rst test01.htmlhttps://stackoverflow.com/questions/11984652
复制相似问题