【问题标题】:In reStructuredText, how does one do an 'inline' include of an external document fragment?在 reStructuredText 中,如何对外部文档片段进行“内联”包含?
【发布时间】:2015-06-18 17:24:51
【问题描述】:

我有一个文章超链接的项目符号列表,其中每篇文章都有一行摘要。而且,我希望我的单行摘要出现在项目符号列表中:

  • Thing1:这是一回事。
  • Thing2:这也是一回事。

因为 (1) 我的摘要非常复杂,(2) 我有很多文章,以及 (3) 更多的项目符号,所以我想将摘要放入它们自己的文档片段中,并将它们“包含”在两个项目符号中列表和文章。但是,this 在 reStructuredText 中并不适用:

* `Thing1`_: .. include:: summary-of-thing1.txt
* `Thing1`_: .. include:: summary-of-thing2.txt

文本 .. include:: summary-of-thing1.txt 最终出现在我生成的 HTML 文档中,这似乎是因为指令(如 .. include::)必须在它们自己的“段落”中,如下所示:

* `Thing1`_:

  .. include: summary-of-thing1.txt

但是,这样做会将我的文档片段放入自己的段落中,这使它看起来像这样:

什么时候,我真正想要的是让我的摘要与我的超链接出现在同一行。

【问题讨论】:

    标签: restructuredtext


    【解决方案1】:

    好的,我知道这就是 .. replace:: 的用途。可以这样说:

    * `Thing1`_: |summary-of-thing1|
    * `Thing2`_: |summary-of-thing2|
    
    .. include:: summaries.txt
    

    并将摘要放入summaries.txt,如下所示:

    .. |summary-of-thing1| replace:: This is a thing.
    .. |summary-of-thing2| replace:: This is also a thing.
    

    【讨论】:

      猜你喜欢
      • 2019-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-03
      相关资源
      最近更新 更多