Reputation: 91480
How can I get code (monospace) text that is bold in rst (I'm using Sphinx)? Anything in ::
seems to be rendered literally, as with ``, so ``**bold**`` doesn't work.
Upvotes: 10
Views: 6496
Reputation: 1238
Actually using raw
for code is a very bad thing to do as it ignores the beautiful Pygments highlighting and complicates things to extreme. First thing to do is to play with different Pygments highlighting styles. You can find a functional demo here. Then you may set the appropriate highlighting in conf.py
. If none of the styles make the desired part of your code bold, you may consider creating your own Pygments theme, which is unfamiliar territory for me, but shouldn't be that hard.
There is third thing to try though, you could look up the class of the word you need to highlight and add a rule to your CSS. Pygments produce this seemingly gibberish classes like nv
, ls
, etc for every type of the highlighted words. But keep in mind, that every instance of this type will be highlighted. If your chosen word is a class definition - all class definitions will be highlighted.
Only if none of these options apply should you consider using something as atrocious as raw
, because every time someone uses raw
, Sphinx dies a little. Do you really want Sphinx to die?
Upvotes: 2
Reputation: 50947
In general, nested inline markup is not possible in reStructuredText. There are more or less ugly workarounds, such as using raw HTML. Like this:
.. raw:: html
<div>Some stuff <pre>some <b>bold</b> text</pre>...</div>
Upvotes: 7
Reputation: 83348
Most likely restructured text does not support formatting options you are asking for.
However you are free to add your own ::
admonition directives which have custom CSS styling over them.
Example for a custom block and CSS styling. RST:
.. admonition:: foobar
My custom text here
CSS:
.admonition-foobar {
font-weight: bold;
}
Upvotes: 1