在 reStructuredText 中格式化链接中的文本
如何格式化 reStructuredText 中指定链接内的文本?
具体来说,我希望从我的第一个代码生成以下 HTML:
<a href="http://docs.python.org/library/optparse.html"><tt>optparse.OptionParser</tt> documentation documentation</a>
结果应如下所示:
,其中“optparse.OptionParser”部分采用固定宽度字体。
但是我尝试
```optparse.OptionParser`` <http://docs.python.org/library/optparse.html>`_
过,这
<tt class="docutils literal">`optparse.OptionParser</tt> documentation <<a class="reference external" href="http://docs.python.org/library/optparse.html">http://docs.python.org/library/optparse.html</a>>`_
看起来像这样
``optparse.OptionParser<代码> 文档
\_
How do you format text within a denoted link in reStructuredText?
Specifically, I wish to generate the following HTML from my rst:
<a href="http://docs.python.org/library/optparse.html"><tt>optparse.OptionParser</tt> documentation documentation</a>
The result should look like this:
where the "optparse.OptionParser" portion is in fixed-width font.
I tried
```optparse.OptionParser`` <http://docs.python.org/library/optparse.html>`_
however, this gave
<tt class="docutils literal">`optparse.OptionParser</tt> documentation <<a class="reference external" href="http://docs.python.org/library/optparse.html">http://docs.python.org/library/optparse.html</a>>`_
which looks like this
``optparse.OptionParser
_
documentation
<http://docs.python.org/library/optparse.html>\
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这个构造:
生成这个 HTML(添加了一些换行符):
我意识到这并不完全是您所要求的,但也许它已经足够接近了。另请参阅http://docutils.sourceforge.net/FAQ.html #is-nested-inline-markup-possible。
This construct:
produces this HTML (some linebreaks added):
I realize that this is not exactly what you asked for, but maybe it's close enough. See also http://docutils.sourceforge.net/FAQ.html#is-nested-inline-markup-possible.
您尝试过 intersphinx 吗?使用该扩展,以下标记:
生成此 HTML:
使用 Python 2.6 和 Sphinx 1.0.5 进行测试。
Have you tried intersphinx? Using that extension, the following markup:
produces this HTML:
Tested with Python 2.6 and Sphinx 1.0.5.
摘自 mzjn 引用的同一常见问题解答页面:
理论上应该可以用 RST 做不到的复杂事情。
Taking from the same FAQ page referenced by mzjn:
It should in theory be possible to do complicated things with that that can't be done with RST.
如果您想本质上
使用 Sphinx 获得与 reStructuredText 中的 HTML/CSS 等效的内容,您可以通过创建一个角色来实现:
然后像这样使用它:
应该只有一个刻度线
`
上面那行的末尾。当然,您必须将其包含
在 CSS 文件中。
If you want to essentially do get HTML/CSS equivalent of
in reStructuredText using Sphinx, you can do this by creating a role:
Then you use it like this:
There should be only one tick mark
`
at the end of the line above.You, of course, have to have
in your CSS file.