Skip to content

Commit 95e5efc

Browse files
bk2204gitster
authored andcommitted
Documentation: add XSLT to fix DocBook for Texinfo
There are two ways to create a section in a reference document (i.e., manpage) in DocBook 4: refsection elements and refsect, refsect2, and refsect3 elements. Either form is acceptable as of DocBook 4.2, but they cannot be mixed. Prior to DocBook 4.2, only the numbered forms were acceptable. docbook2texi only accepts the numbered forms, and this has not generally been a problem, since AsciiDoc produces the numbered forms. Asciidoctor, on the other hand, uses a shared backend for DocBook 4 and 5, and uses the unnumbered refsection elements instead. If we don't convert the unnumbered form to the numbered form, docbook2texi omits section headings, which is undesirable. Add an XSLT stylesheet to transform the unnumbered forms to the numbered forms automatically, and preprocess the DocBook XML as part of the transformation to Texinfo format. Note that this transformation is only necessary for Texinfo, since docbook2texi provides its own stylesheets. The DocBook stylesheets, which we use for other formats, provide the full range of DocBook 4 and 5 compatibility, and don't have this issue. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c4abba4 commit 95e5efc

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

Documentation/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,11 @@ user-manual.pdf: user-manual.xml
371371
$(DBLATEX) -o $@+ -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty $< && \
372372
mv $@+ $@
373373

374-
gitman.texi: $(MAN_XML) cat-texi.perl
374+
gitman.texi: $(MAN_XML) cat-texi.perl texi.xsl
375375
$(QUIET_DB2TEXI)$(RM) $@+ $@ && \
376-
($(foreach xml,$(sort $(MAN_XML)),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
377-
--to-stdout $(xml) &&) true) > $@++ && \
376+
($(foreach xml,$(sort $(MAN_XML)),xsltproc -o $(xml)+ texi.xsl $(xml) && \
377+
$(DOCBOOK2X_TEXI) --encoding=UTF-8 --to-stdout $(xml)+ && \
378+
rm $(xml)+ &&) true) > $@++ && \
378379
$(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
379380
rm $@++ && \
380381
mv $@+ $@

Documentation/texi.xsl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!-- texi.xsl:
2+
convert refsection elements into refsect elements that docbook2texi can
3+
understand -->
4+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5+
version="1.0">
6+
7+
<xsl:output method="xml"
8+
encoding="UTF-8"
9+
doctype-public="-//OASIS//DTD DocBook XML V4.5//EN"
10+
doctype-system="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" />
11+
12+
<xsl:template match="//refsection">
13+
<xsl:variable name="element">refsect<xsl:value-of select="count(ancestor-or-self::refsection)" /></xsl:variable>
14+
<xsl:element name="{$element}">
15+
<xsl:apply-templates select="@*|node()" />
16+
</xsl:element>
17+
</xsl:template>
18+
19+
<!-- Copy all other nodes through. -->
20+
<xsl:template match="node()|@*">
21+
<xsl:copy>
22+
<xsl:apply-templates select="@*|node()" />
23+
</xsl:copy>
24+
</xsl:template>
25+
26+
</xsl:stylesheet>

0 commit comments

Comments
 (0)