复制段落内容

发布于 2024-08-30 23:09:20 字数 466 浏览 2 评论 0原文

在我的 DocBook 文档中,我有几个部分,它们遵循以下模式:

  • 部分名称
  • 简短描述
  • 详细描述

我想创建这些部分的索引。但我需要它是一个表格,其格式如下:

| link_with_section_name | 简短描述 |
|章节名称 1 |简短描述 1 |
|章节名称2 |简短描述 2 |

我不喜欢重复简短描述的想法。我想在第二列中创建某种参考,以便直接从参考部分获取简短描述。我可能可以使用 endterm 属性创建一个 xterm 引用,但我不想在第二列创建链接。我只想复制包含简短描述的段落中的内容。

在DocBook中有什么办法可以做到这一点吗?

In my DocBook document I have several sections, which follow this pattern:

  • the section name
  • the short description
  • the long description

I'd like to create an index of these sections. But I need it to be a table, which is formatted the following way:

| link_with_section_name | short_description |
| <link id="section1_id">the section name 1</link> | the short description 1 |
| <link id="section2_id">the section name 2</link> | the short description 2 |

I don't like the idea of duplicating the short description. I would like to create some kind of reference in the second column, so that the short description would be taken directly from the referenced section. I could probably create an xterm reference, with the endterm attribute, but I don't want to create a link at the second column. I just want to copy the content from the paragraph which contains the short description.

Is there any way to do it in DocBook?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

·深蓝 2024-09-06 23:09:20

这就是 XSLT 发挥作用的地方。

您需要使用 XPATH 规则创建表格模板,以便从现有文档填充表格。

您需要将该表包含在适当的位置。

然后,您需要使用 Ant(或 Make、Maven 或 SCONS)来 (1) 运行转换来生成表,然后 (2) 运行普通的 DocBook 转换。

我使用的另一种方法是使用 ElementTree XML 解析器在 Python 中编写转换。

本秘籍的基本部分是构建表格,这只是从 DocBook 构建 HTML 或 LaTeX 的一个步骤。

This is where XSLT can be made to work.

You need to create the table's template with XPATH rules for filling the table from your existing document.

You need to include that table at the appropriate place.

You then need to use an Ant (or Make or Maven or SCONS) to (1) run your transform to generate your table, then (2) run your ordinary DocBook transforms.

An alternative that I've used is to write the transformation in Python using ElementTree XML parser.

The essential part of this recipe is to build the table just one step in building HTML or LaTeX from your DocBook.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文