sphinx,restructuredtext:为单个词设置颜色 [英] sphinx, restructuredtext: set color for a single word
问题描述
有没有办法在狮身人面像上设置单个单词(或字符)的颜色?我很确定应该有一些标记标记,例如HTML的 font
标记。
在这个例子中改编自在rst2pdf手册中,我应用了现有的红色风格,它在我使用的后端是红色的:
<$ c $红色之前。
..角色::标题
我喜欢颜色:标题:`rubric`。
红色后。
单词的实际外观将取决于您在样式表中如何定义样式在生成文档时使用。
如果您想要蓝色文本,请使用蓝色文本样式并从普通文本样式中派生。
样式表是特定于后端的,您可能正在使用默认值。
要打印rst2pdf.py的默认值,请执行此操作(来自rst2pdf手册):
rst2pdf --print -stylesheet
继续rst2pdf样式表的示例,将其添加到您的样式表中以获得蓝色文本样式:
bluetext:
父:bodytext
textColor:蓝
在文档中,您可以引用此样式以获取蓝字。
请注意,这是一般性的,如果您在html或任何后端的样式表中定义了蓝色样式,它应该是蓝色的。
在蓝色之前。
.. role :: bluetext
我喜欢color:bluetext:`blue`。
蓝色后。
生成的pdf有以下颜色字:
Is there a way to set the color of single words (or characters) in sphinx? I'm pretty sure there should be some markup tag, like HTML's font
tag.
If you want to do this without being tied to html, try applying a different style than normal body text to your word.
In this example adapted from the rst2pdf manual, I apply the existing rubric style which is red in the backend that I am using:
Before red.
.. role:: rubric
I like color :rubric:`rubric`.
After red.
The actual look of the word will depend on how the style you choose is defined in the stylesheet that you use when generating your document. If you want blue text, make a blue text style and derive it from the normal text style. The stylsheet is backend-specific and you may be using the default. To print the default for rst2pdf.py, do this (from the rst2pdf manual):
rst2pdf --print-stylesheet
Continuing the example for a rst2pdf stylesheet, add this to your stylesheet to have a blue text style:
bluetext:
parent: bodytext
textColor: blue
In the document you can reference this style to get a blue word. Note this bit is generic, and should make blue text if you define a blue style in your html or whatever backend's stylesheet.
Before blue.
.. role:: bluetext
I like color :bluetext:`blue`.
After blue.
The generated pdf has the coloured words:
这篇关于sphinx,restructuredtext:为单个词设置颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!