我正在使用asciidoctor和书籍的docbook后端。过去我写了DocBook,它使我可以声明整本书中使用的命名实体:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE book [
<!ENTITY class "Galactic TOP SECRET">
<!ENTITY project "World Domination">
<!ENTITY product "Illuminati Mind Control Chemtrail Spray System CSS-2020">
]>
<book ...>
...
What about our &class; &project;?
Is our &product; working?
...
</book>
:-)
我还没有找到一种方法来告诉asciidoctor在XML处理指令和DOCTYPE
元素之间插入<book>
声明。因此,我求助于--no-header-footer
,并在页眉和页脚行之前添加。有一个更好的方法吗?类似于命名实体定义指令?包含机制?
答案 0 :(得分:1)
您是否必须使用Docbook实体声明? Asciidoctor具有可用于相同目的的“属性”:https://asciidoctor.org/docs/user-manual/#attributes
例如,您可以在文档中定义属性:
:class: Galactic TOP SECRET
然后在文档的后面,可以使用属性:
"Billy, come up to the front and address the {class}." said the teacher.
将文档转换为Docbook时,您会看到:
<simpara>"Billy, come up to the front and address the Galactic TOP SECRET."
said the teacher.</simpara>
如果必须使用Docbook实体声明,则可以使用一些XSL将获得的XML转换为所需的XML。