Skip to content

Commit 4ae0370

Browse files
authored
Convert an empty book/preface/title into abstract (#752)
When you have a <preface> with an empty <title>, this should not stay as a <preface>, but moved into <info> inside an <abstract>.
1 parent b106e4c commit 4ae0370

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

daps-xslt/asciidoc/postprocess.xsl

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@
298298
</xsl:if>
299299
</xsl:template>
300300

301-
302301
<!-- HINT: Turn a <orderedlist role="procedure"> into a real <procedure>
303302
304303
In ADoc you use this syntax:
@@ -385,4 +384,32 @@
385384
<xsl:apply-templates select="." />
386385
</xsl:template>
387386

387+
<!-- Structure -->
388+
389+
<xsl:template match="d:book[normalize-space(d:preface/d:title) = '']">
390+
<xsl:copy>
391+
<xsl:copy-of select="@*" />
392+
<info>
393+
<xsl:apply-templates select="d:info/node()"/>
394+
<xsl:apply-templates select="d:preface" mode="book-preface" />
395+
</info>
396+
<xsl:apply-templates select="node()[not(self::d:info)]" />
397+
</xsl:copy>
398+
</xsl:template>
399+
400+
<xsl:template match="*" mode="book-preface">
401+
<xsl:copy>
402+
<xsl:apply-templates select="@* | node()" mode="book-preface" />
403+
</xsl:copy>
404+
</xsl:template>
405+
<xsl:template match="d:preface/d:title" mode="book-preface" />
406+
<xsl:template match="d:preface" mode="book-preface">
407+
<abstract>
408+
<xsl:apply-templates mode="book-preface" />
409+
</abstract>
410+
</xsl:template>
411+
412+
<xsl:template match="d:book[normalize-space(d:preface/d:title) = '']/d:preface" />
413+
414+
388415
</xsl:stylesheet>

0 commit comments

Comments
 (0)