我经常遇到这样的情况:我想将一个术语与词汇表联系起来,但是用复数表示这个术语.
所以通常你会做一些这样的单数:
Some text before the term :term:`important word` then the stuff after the term
Run Code Online (Sandbox Code Playgroud)
这被认为是一个完全不同的术语:
Some text before the term :term:`important words` then the stuff after the term
Run Code Online (Sandbox Code Playgroud)
这不会被解析:
Some text before the term :term:`important word`s then the stuff after the term
Run Code Online (Sandbox Code Playgroud)
这是非常多余的(但是我对现有知识的唯一选择):
Some text before the term :term:`important words<important word>` then the stuff after the term
Run Code Online (Sandbox Code Playgroud)
还有另一种方法可以用复数形式写一个术语,而不需要两次说明这个术语吗?
goo*_*ami 14
我面临着同样的问题.我不是专家,但这是我发现的(部分重叠你自己的发现):
.. won't resolve to "foo"
:term:`foos`
.. reST doesn't parse the string
:term:`foo`s
.. ugly markup and gives different formatting for "foo" and "s"
:term:`foo`\ s
.. redundant and verbose, but most versatile
:term:`foos<foo>`
Run Code Online (Sandbox Code Playgroud)
虽然倒数第二种模式可行,但有点,最后一种确实是你想要的.它不仅将复数"s"的格式设置为与单词的其余部分相同(不像:term:`foo`\ s,这可能会给你类似foo的东西),但是当复数不仅仅是一个简单的连接时它起作用.例如,考虑目录/目录或数据/数据.对于这些情况,完全重写机制是最好的.
您可以通过定义替换来使您的文档更简洁:
.. |foos| replace:: :term:`foos<foo>`
Run Code Online (Sandbox Code Playgroud)
然后你想要复数"foos"的任何地方,你可以编写替换参考(参见上一个链接)|foos|,文档处理器将把它当作:term:`foos<foo>`
参考文献:
https://sourceforge.net/p/docutils/mailman/message/31536488/
| 归档时间: |
|
| 查看次数: |
518 次 |
| 最近记录: |