DocBook 宏?

发布于 2024-08-28 20:34:39 字数 139 浏览 2 评论 0原文

有没有办法在 DocBook 文档中定义宏(如 tex 宏或 Latex 定义)?

DocBook 非常冗长,宏会很有帮助。我没有找到他们 在快速入门教程中。

如果是这样,有人可以提供一个简单的例子或链接吗?

谢谢

Is there any way of defining macros (like tex macros o latex defines) in DocBook documents?

DocBook is very verbose, and macros would help a lot. I didn't find them
in quickstart tutorials.

If so, could anyone provide a simple example or a link to?

Thanks

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

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

发布评论

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

评论(3

巷雨优美回忆 2024-09-04 20:34:39

不确定,这是否正是您想要的/是否完全满足您的要求,但我正在考虑实体。您可以在(XML 文档的顶部,所以一般的 XML,没有 DocBook 特定的内容)定义它们。如此处所示的“doc.release.number”和“doc.release.date”。但它们也可以通过单独的文件包含在内。如第三实体行所示。这里的 SYSTEM 表示来自另一个文件“entities.ent”。

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
    "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [

  <!ENTITY  doc.release.number                 "1.0.0.beta-1"       >
  <!ENTITY  doc.release.date                   "April 2010"         >

  <!ENTITY  %   entities  SYSTEM  "entities.ent" >

  %entities;

]>

<!--  This document is based on http://readyset.tigris.org/nonav/templates/userguide.html  -->
<article  lang="en">
  <articleinfo>
    <title>&project.impl.title; - User Manual</title>
    <subtitle></subtitle>
    <date>&project.impl.release.date;</date>
    <copyright>
      <year>doc.release.year</year>
      <holder>Team - &project.impl.title;</holder>
    </copyright>
    <releaseinfo>&doc.release.number;</releaseinfo>
  </articleinfo>

  <section>
    <title>Introduction</title>
    <para>
    The &project.impl.title; has been created to clean up (X)HTML and XML documents as part of 


    </para>
  <section>
</article>

在文档中,您通过起始 & 和结束 ; 引用实体,如 &project.impl.title;

在文件 ' Entity.ent' 您可以以类似的方式指定 ENTITY 元素:

<?xml version="1.0" encoding="UTF-8"?>

<!ENTITY  project.impl.title            'Maven Tidy Plug-in'    >
<!ENTITY  project.impl.group-id         'net.sourceforge.docbook-utils.maven-plugin'    >
<!ENTITY  project.impl.artifact-id      'maven-tidy-plugin'     >
<!ENTITY  project.impl.release.number   '1.0.0.beta-1'          >
<!ENTITY  project.impl.release.date     'April 2010'            >
<!ENTITY  project.impl.release.year     '2010'                  >
<!ENTITY  project.impl.url              '../'                   >
<!ENTITY  project.spec.title            ''  >
<!ENTITY  project.spec.release.number   ''  >
<!ENTITY  project.spec.release.date     ''  >
<!ENTITY  doc.release.year              '2010'                  >  

Not sure, if this is exactly what you want / if it full fills your requirements, but I'm thinking of ENTITYs. You can define them at the top (of your XML document, so general XML, nothing DocBook specific). As seen here for the 'doc.release.number' and 'doc.release.date'. But they can also be included through an separate file. As seen in the 3th ENTITY row. Here the SYSTEM means, comming from another file 'entities.ent'.

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
    "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [

  <!ENTITY  doc.release.number                 "1.0.0.beta-1"       >
  <!ENTITY  doc.release.date                   "April 2010"         >

  <!ENTITY  %   entities  SYSTEM  "entities.ent" >

  %entities;

]>

<!--  This document is based on http://readyset.tigris.org/nonav/templates/userguide.html  -->
<article  lang="en">
  <articleinfo>
    <title>&project.impl.title; - User Manual</title>
    <subtitle></subtitle>
    <date>&project.impl.release.date;</date>
    <copyright>
      <year>doc.release.year</year>
      <holder>Team - &project.impl.title;</holder>
    </copyright>
    <releaseinfo>&doc.release.number;</releaseinfo>
  </articleinfo>

  <section>
    <title>Introduction</title>
    <para>
    The &project.impl.title; has been created to clean up (X)HTML and XML documents as part of 


    </para>
  <section>
</article>

In the document you reference the entities through a starting & and ending ; as in &project.impl.title;

In the file 'entities.ent' you specify the ENTITY elements in a similar way:

<?xml version="1.0" encoding="UTF-8"?>

<!ENTITY  project.impl.title            'Maven Tidy Plug-in'    >
<!ENTITY  project.impl.group-id         'net.sourceforge.docbook-utils.maven-plugin'    >
<!ENTITY  project.impl.artifact-id      'maven-tidy-plugin'     >
<!ENTITY  project.impl.release.number   '1.0.0.beta-1'          >
<!ENTITY  project.impl.release.date     'April 2010'            >
<!ENTITY  project.impl.release.year     '2010'                  >
<!ENTITY  project.impl.url              '../'                   >
<!ENTITY  project.spec.title            ''  >
<!ENTITY  project.spec.release.number   ''  >
<!ENTITY  project.spec.release.date     ''  >
<!ENTITY  doc.release.year              '2010'                  >  
像你 2024-09-04 20:34:39

不完全符合您的要求,但可能对您的某些情况有帮助:您可以在包装样式表中定义模板,在其中定义 fo 命令。一些示例:

代码:

<xsl:template match="symbolchar">
  <fo:inline font-family="Symbol">
    <xsl:choose>
      <xsl:when test=".='ge'">≥</xsl:when>
      <xsl:when test=".='le'">≤</xsl:when>
      <xsl:when test=".='sqrt'">√</xsl:when>
      <xsl:otherwise>?!?</xsl:otherwise>
    </xsl:choose>
  </fo:inline>
</xsl:template>

用法:

<symbolchar>le</symbolchar>

代码:

<xsl:template match="processing-instruction('linebreak')">
  <fo:block/>
</xsl:template>

用法:

<?linebreak?>

Not exactly what you asked for, but perhaps helpful for some of your cases: you can define templates in your wrapper stylesheet where you define fo commands. Some examples:

Code:

<xsl:template match="symbolchar">
  <fo:inline font-family="Symbol">
    <xsl:choose>
      <xsl:when test=".='ge'">≥</xsl:when>
      <xsl:when test=".='le'">≤</xsl:when>
      <xsl:when test=".='sqrt'">√</xsl:when>
      <xsl:otherwise>?!?</xsl:otherwise>
    </xsl:choose>
  </fo:inline>
</xsl:template>

Usage:

<symbolchar>le</symbolchar>

Code:

<xsl:template match="processing-instruction('linebreak')">
  <fo:block/>
</xsl:template>

Usage:

<?linebreak?>
陌若浮生 2024-09-04 20:34:39

您是否考虑过从其他格式生成 DocBook(例如 reStructuredText?)

我发现它对于文档来说非常好。

另外,您可能可以很快编写一个宏预处理器(或查看 m4)。如果您使用 DocBook 的 XML 版本,则简单的 XSLT 就可以了。只需制作一些标签并对其进行改造即可。自动添加样板内容。准备好对 XSLT 感到非常愤怒吧。因为没有成为一切可能的样子。为了让你的思维扭曲。

Have you considered generating DocBook from another format (like reStructuredText?)

I found it quite nice for documentation.

Also, you could probably write a macro preprocessor (or look into m4) pretty quickly. If you are using the XML version of DocBook, a simple XSLT will do. Just make up some tags and transform them. Have boilerplate stuff added automatically. And get ready to be really angry at XSLT. For not being all it could be. For making your thinking warp.

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