Skip to content

Commit

Permalink
Merge pull request #2 from mojavelinux/asciidoc-support
Browse files Browse the repository at this point in the history
resolve #1 - add templates for AsciiDoc processing instructions
  • Loading branch information
ge0ffrey committed Apr 15, 2013
2 parents 1c4b142 + 87c74fe commit 58043d4
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 19 deletions.
11 changes: 11 additions & 0 deletions pressgang-jdocbook-style/src/main/css/css/documentation.css
Expand Up @@ -549,3 +549,14 @@ ul li p:last-child {
margin-bottom:0em;
padding-bottom:0em;
}

.page-break {
display: none;
}

@media print {
.page-break {
display: block;
page-break-before: always;
}
}
Expand Up @@ -12,10 +12,24 @@
-->
<xsl:param name="confidential" select="0"/>

<xsl:param name="asciidoc.mode">0</xsl:param>

<!--
TOC
-->
<xsl:param name="section.autolabel" select="1"/>
<xsl:param name="section.autolabel">
<xsl:choose>
<xsl:when test="$asciidoc.mode = 0">1</xsl:when>
<xsl:when test="/processing-instruction('asciidoc-numbered')">1</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="section.autolabel.max.depth">
<xsl:choose>
<xsl:when test="$asciidoc.mode = 0">8</xsl:when>
<xsl:otherwise>2</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="section.label.includes.component.label" select="1"/>

<!--
Expand Down
Expand Up @@ -45,19 +45,46 @@

<!-- TOC: remove list of figures, list of tables, ... Only keep Table of Contents -->
<xsl:param name="generate.toc">
set toc
book toc
article toc
chapter toc
qandadiv toc
qandaset toc
sect1 nop
sect2 nop
sect3 nop
sect4 nop
sect5 nop
section toc
part toc
<xsl:choose>
<xsl:when test="$asciidoc.mode = 0">
set toc
book toc
article toc
chapter toc
qandadiv toc
qandaset toc
sect1 nop
sect2 nop
sect3 nop
sect4 nop
sect5 nop
section toc
part toc
</xsl:when>
<xsl:when test="/processing-instruction('asciidoc-toc')">
article toc,title
book toc,title,figure,table,example,equation
<xsl:if test="$generate.section.toc.level != 0">
chapter toc,title
part toc,title
preface toc,title
qandadiv toc
qandaset toc
reference toc,title
sect1 toc
sect2 toc
sect3 toc
sect4 toc
sect5 toc
section toc
set toc,title
</xsl:if>
</xsl:when>
<xsl:otherwise>
article nop
book nop
</xsl:otherwise>
</xsl:choose>
</xsl:param>

<!-- TEMPLATES -->
Expand Down Expand Up @@ -180,4 +207,19 @@

</xsl:template>

<!-- Forced line break -->
<xsl:template match="processing-instruction('asciidoc-br')">
<br/>
</xsl:template>

<!-- Forced page break -->
<xsl:template match="processing-instruction('asciidoc-pagebreak')">
<div class="page-break"/>
</xsl:template>

<!-- Horizontal ruler -->
<xsl:template match="processing-instruction('asciidoc-hr')">
<hr/>
</xsl:template>

</xsl:stylesheet>
Expand Up @@ -8,7 +8,6 @@
<!-- IMPORTS -->
<xsl:import href="http://docbook.sourceforge.net/release/xsl/1.76.1/fo/docbook.xsl"/>


<!-- INCLUDES -->
<xsl:include href="common-base.xsl"/>

Expand Down Expand Up @@ -250,9 +249,36 @@
###########################################################################################
-->
<xsl:param name="generate.toc">
set toc
book toc
article toc
<xsl:choose>
<xsl:when test="$asciidoc.mode = 0">
set toc
book toc
article toc
</xsl:when>
<xsl:when test="/processing-instruction('asciidoc-toc')">
article toc,title
book toc,title,figure,table,example,equation
<xsl:if test="$generate.section.toc.level != 0">
chapter toc,title
part toc,title
preface toc,title
qandadiv toc
qandaset toc
reference toc,title
sect1 toc
sect2 toc
sect3 toc
sect4 toc
sect5 toc
section toc
set toc,title
</xsl:if>
</xsl:when>
<xsl:otherwise>
article nop
book nop
</xsl:otherwise>
</xsl:choose>
</xsl:param>

<xsl:param name="toc.section.depth">2</xsl:param>
Expand Down Expand Up @@ -504,6 +530,7 @@
<!-- scalefit for large images -->
<xsl:param name="graphicsize.extension" select="'1'"/>
<xsl:param name="default.image.width">17.4cm</xsl:param>
<xsl:param name="default.inline.image.height">1em</xsl:param>

<!--
From: fo/graphics.xsl
Expand Down Expand Up @@ -598,7 +625,7 @@
<xsl:with-param name="default.units" select="'px'"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="not(@depth) and $default.image.width != ''">
<xsl:when test="not(@depth) and not(ancestor::inlinemediaobject) and $default.image.width != ''">
<xsl:call-template name="length-spec">
<xsl:with-param name="length" select="$default.image.width"/>
<xsl:with-param name="default.units" select="'px'"/>
Expand All @@ -620,6 +647,12 @@
<xsl:with-param name="default.units" select="'px'"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="ancestor::inlinemediaobject">
<xsl:call-template name="length-spec">
<xsl:with-param name="length" select="$default.inline.image.height"/>
<xsl:with-param name="default.units" select="'px'"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>auto</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
Expand Down Expand Up @@ -1025,4 +1058,25 @@
<xsl:attribute name="text-align">start</xsl:attribute>
</xsl:attribute-set>

<!--
AsciiDoc processing instruction handling
-->

<!-- Forced line break -->
<xsl:template match="processing-instruction('asciidoc-br')">
<fo:block/>
</xsl:template>

<!-- Forced page break -->
<xsl:template match="processing-instruction('asciidoc-pagebreak')">
<fo:block break-after="page"/>
</xsl:template>

<!-- Horizontal ruler -->
<xsl:template match="processing-instruction('asciidoc-hr')">
<fo:block space-after="1em">
<fo:leader leader-pattern="rule" rule-thickness="0.5pt" rule-style="solid" leader-length.minimum="100%"/>
</fo:block>
</xsl:template>

</xsl:stylesheet>

0 comments on commit 58043d4

Please sign in to comment.