Writing terms in plural without the redundancy

北城余情 提交于 2019-12-10 04:26:51

问题


I often have the situation that I want to link a term to the glossary but state the term in plural.

So normally you do something like this in singular:

Some text before the term :term:`important word` then the stuff after the term

This is considered a completely different term:

Some text before the term :term:`important words` then the stuff after the term

This doesn't get parsed:

Some text before the term :term:`important word`s then the stuff after the term

And this is very redundant (but the only choice I have with my current knowledge):

Some text before the term :term:`important words<important word>` then the stuff after the term

Is there another way to write a term in plural without needing to state the term twice?


回答1:


I'm facing the same problem. I'm no expert, but here's what I've found (partially overlapping your own findings):

.. 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>`

While the penultimate pattern will work, kinda, the last one really is what you want. Not only does it format the plural "s" the same as the rest of the word (unlike :term:`foo`\ s, which may give you something like foos), but it works when the plural isn't just a simple concatenation. E.g. consider directory/directories, or datum/data. For these cases, a full rewrite mechanism is best.

You can make your document less verbose by defining substitutions:

.. |foos| replace:: :term:`foos<foo>`

Then anywhere you want the plural "foos", you can write the substitution reference (see the previous link) |foos|, and the document processor will treat it like :term:`foos<foo>`


References:

https://sourceforge.net/p/docutils/mailman/message/31536488/



来源:https://stackoverflow.com/questions/19403972/writing-terms-in-plural-without-the-redundancy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!