- Customize XSL FO stylesheets to render a more realistic handbook format:
* B5 paper size
* chapters always start on recto
* the current chapter in indicated by the verso header and the current
section by the recto header
* render page numbers at the outer side of the foooter
* sections are automatically labelled
* bibliography entries are enumerated
* captions of figures and equations are rendered after
* captions of examples, tables and procedures are rendered before
* admonitions are highlighted with an icon and a border
* tables have a grey header with bold labels
* programlistings and screen elements are rendered with a grey background
* guibutton is also rendered with a grey background
* manpage references are real links and it is indicated with the blue color
This commit is contained in:
parent
e94dad6215
commit
44c2e15ea0
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/projects/db5/; revision=42272
1 changed files with 350 additions and 15 deletions
|
|
@ -14,28 +14,271 @@
|
|||
<!-- Include the common customizations -->
|
||||
<xsl:include href="freebsd-common.xsl"/>
|
||||
|
||||
<!-- Redefine variables, and replace templates as necessary here -->
|
||||
<!--
|
||||
FO-SPECIFIC PARAMETER SETTINGS
|
||||
-->
|
||||
|
||||
<!-- FO specific customisation goes here -->
|
||||
<!-- Paper settings -->
|
||||
<xsl:param name="paper.type">B5</xsl:param>
|
||||
<xsl:param name="double.sided" select="1"/>
|
||||
<xsl:param name="force.blank.pages" select="1"/>
|
||||
|
||||
<!--
|
||||
<xsl:param name="use.extensions" select="1"/>
|
||||
<xsl:param name="fop1.extensions" select="1"/>
|
||||
-->
|
||||
<!-- Page margins and spacing -->
|
||||
<xsl:param name="page.margin.bottom">3cm</xsl:param>
|
||||
<xsl:param name="page.margin.inner">3cm</xsl:param>
|
||||
<xsl:param name="page.margin.outer">2.5cm</xsl:param>
|
||||
<xsl:param name="page.margin.top">2.13cm</xsl:param>
|
||||
<xsl:param name="body.margin.bottom">0.5cm</xsl:param>
|
||||
<xsl:param name="body.margin.top">1.0cm</xsl:param>
|
||||
<xsl:param name="body.margin.inner">0</xsl:param>
|
||||
<xsl:param name="body.margin.outer">0</xsl:param>
|
||||
<xsl:param name="body.start.indent">0</xsl:param>
|
||||
<xsl:param name="body.end.indent">0</xsl:param>
|
||||
<xsl:param name="region.after.extent">2cm</xsl:param>
|
||||
<xsl:param name="region.before.extent">2.2cm</xsl:param>
|
||||
|
||||
<xsl:param name="hyphenate">false</xsl:param>
|
||||
<!--
|
||||
<xsl:param name="hyphenate.verbatim" select="1"/>
|
||||
-->
|
||||
<xsl:param name="header.column.widths">1 5 1</xsl:param>
|
||||
<!-- Headers and footers -->
|
||||
<xsl:param name="headers.on.blank.pages" select="0"/>
|
||||
<xsl:param name="footers.on.blank.pages" select="0"/>
|
||||
<xsl:param name="footer.rule" select="0"/>
|
||||
<xsl:param name="header.column.widths">500 1 500</xsl:param>
|
||||
<xsl:param name="footer.column.widths">500 1 500</xsl:param>
|
||||
|
||||
<!-- Sections and numbering -->
|
||||
<xsl:param name="section.autolabel" select="1"/>
|
||||
<xsl:param name="section.autolabel.max.depth" select="5"/>
|
||||
<xsl:param name="section.label.includes.component.label" select="1"/>
|
||||
<xsl:param name="bibliography.numbered" select="1"/>
|
||||
<xsl:param name="formal.title.placement">
|
||||
figure after
|
||||
example before
|
||||
equation after
|
||||
table before
|
||||
procedure before</xsl:param>
|
||||
|
||||
<!-- Admonitions -->
|
||||
<xsl:param name="admon.graphics" select="1"/>
|
||||
<xsl:param name="admon.graphics.path">/usr/local/share/xsl/docbook-ns/images/</xsl:param>
|
||||
<xsl:param name="admon.graphics.extension">.svg</xsl:param>
|
||||
|
||||
<!-- Tables -->
|
||||
<xsl:param name="default.table.frame">hsides</xsl:param>
|
||||
<xsl:param name="default.table.rules">rows</xsl:param>
|
||||
|
||||
<!-- Q & A -->
|
||||
<xsl:param name="qanda.defaultlabel">qanda</xsl:param>
|
||||
|
||||
<!-- Graphics -->
|
||||
<xsl:param name="callout.graphics.path">imagelib/callouts/</xsl:param>
|
||||
<xsl:param name="callout.graphics.extension">.png</xsl:param>
|
||||
|
||||
<!-- Use the whole viewport and scale images to fit -->
|
||||
<xsl:param name="default.image.width">400px</xsl:param>
|
||||
<xsl:param name="default.image.width">300px</xsl:param>
|
||||
<xsl:template name="image.scalefit">1</xsl:template>
|
||||
|
||||
<!-- Hyphenation -->
|
||||
<xsl:param name="hyphenate">false</xsl:param>
|
||||
<xsl:param name="hyphenate.verbatim" select="0"/>
|
||||
<xsl:param name="hyphenate.verbatim.characters"> </xsl:param>
|
||||
|
||||
<!-- Base Fonts -->
|
||||
<xsl:param name="body.font.master">9.5</xsl:param>
|
||||
|
||||
<!-- Property sets -->
|
||||
<xsl:attribute-set name="chapter.title.properties">
|
||||
<xsl:attribute name="font-size">24pt</xsl:attribute>
|
||||
<xsl:attribute name="space-before">6pt</xsl:attribute>
|
||||
<xsl:attribute name="space-after">36pt</xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
<xsl:attribute-set name="section.title.level1.properties">
|
||||
<xsl:attribute name="font-size">14pt</xsl:attribute>
|
||||
<xsl:attribute name="space-before">24pt</xsl:attribute>
|
||||
<xsl:attribute name="space-after">12pt</xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
<xsl:attribute-set name="section.title.level2.properties">
|
||||
<xsl:attribute name="font-size">11pt</xsl:attribute>
|
||||
<xsl:attribute name="space-before">12pt</xsl:attribute>
|
||||
<xsl:attribute name="space-after">6pt</xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
<xsl:attribute-set name="section.title.level3.properties">
|
||||
<xsl:attribute name="font-size">10pt</xsl:attribute>
|
||||
<xsl:attribute name="space-before">6pt</xsl:attribute>
|
||||
<xsl:attribute name="space-after">3pt</xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
<xsl:attribute-set name="section.title.properties">
|
||||
<xsl:attribute name="font-family">
|
||||
<xsl:value-of select="$title.fontset"></xsl:value-of>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="font-weight">bold</xsl:attribute>
|
||||
<xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
|
||||
<xsl:attribute name="text-align">start</xsl:attribute>
|
||||
<xsl:attribute name="start-indent"><xsl:value-of select="$title.margin.left"></xsl:value-of></xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
<xsl:attribute-set name="section.properties">
|
||||
<xsl:attribute name="font-size">9.5pt</xsl:attribute>
|
||||
<xsl:attribute name="line-height">12pt</xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
<xsl:attribute-set name="normal.para.spacing">
|
||||
<xsl:attribute name="space-before">12pt</xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
<xsl:attribute-set name="monospace.properties">
|
||||
<xsl:attribute name="font-family">
|
||||
<xsl:value-of select="$monospace.font.family"></xsl:value-of>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="font-size">8pt</xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
<xsl:attribute-set name="monospace.verbatim.properties">
|
||||
<xsl:attribute name="font-size">8pt</xsl:attribute>
|
||||
<xsl:attribute name="line-height">10pt</xsl:attribute>
|
||||
<xsl:attribute name="space-before">12pt</xsl:attribute>
|
||||
<xsl:attribute name="space-after">0</xsl:attribute>
|
||||
<xsl:attribute name="hyphenate">false</xsl:attribute>
|
||||
<xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
|
||||
<xsl:attribute name="white-space-collapse">false</xsl:attribute>
|
||||
<xsl:attribute name="white-space-treatment">preserve</xsl:attribute>
|
||||
<xsl:attribute name="linefeed-treatment">preserve</xsl:attribute>
|
||||
<xsl:attribute name="text-align">start</xsl:attribute>
|
||||
<xsl:attribute name="background-color">rgb(192,192,192)</xsl:attribute>
|
||||
<xsl:attribute name="wrap-option">wrap</xsl:attribute>
|
||||
<xsl:attribute name="hyphenation-character">◄</xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
<xsl:attribute-set name="table.caption.properties">
|
||||
<xsl:attribute name="font-size">8pt</xsl:attribute>
|
||||
<xsl:attribute name="keep-together.within-column">always</xsl:attribute>
|
||||
<xsl:attribute name="line-height">13pt</xsl:attribute>
|
||||
<xsl:attribute name="space-before">12pt</xsl:attribute>
|
||||
<xsl:attribute name="space-after">3pt</xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
<xsl:attribute-set name="table.table.properties">
|
||||
<xsl:attribute name="font-size">9.5pt</xsl:attribute>
|
||||
<xsl:attribute name="border-before-width.conditionality">retain</xsl:attribute>
|
||||
<xsl:attribute name="border-collapse">collapse</xsl:attribute>
|
||||
<xsl:attribute name="margin-top">0</xsl:attribute>
|
||||
<xsl:attribute name="margin-bottom">0</xsl:attribute>
|
||||
<xsl:attribute name="margin-left">0</xsl:attribute>
|
||||
<xsl:attribute name="margin-right">0</xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
<xsl:attribute-set name="formal.title.properties" use-attribute-sets="normal.para.spacing">
|
||||
<xsl:attribute name="font-size">8pt</xsl:attribute>
|
||||
<xsl:attribute name="font-weight">normal</xsl:attribute>
|
||||
<xsl:attribute name="keep-together.within-column">always</xsl:attribute>
|
||||
<xsl:attribute name="line-height">13pt</xsl:attribute>
|
||||
<xsl:attribute name="hyphenate">false</xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
<xsl:attribute-set name="graphical.admonition.properties">
|
||||
<xsl:attribute name="border-style">solid</xsl:attribute>
|
||||
<xsl:attribute name="border-width">1px</xsl:attribute>
|
||||
<xsl:attribute name="margin-right">0</xsl:attribute>
|
||||
<xsl:attribute name="margin-top">12pt</xsl:attribute>
|
||||
<xsl:attribute name="margin-left">0</xsl:attribute>
|
||||
<xsl:attribute name="margin-bottom">12pt</xsl:attribute>
|
||||
<xsl:attribute name="padding-right">0.5cm</xsl:attribute>
|
||||
<xsl:attribute name="padding-top">0.5cm</xsl:attribute>
|
||||
<xsl:attribute name="padding-left">0.5cm</xsl:attribute>
|
||||
<xsl:attribute name="padding-bottom">0.5cm</xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
|
||||
<!--
|
||||
FO-SPECIFIC TEMPLATE CUSTOMIZATIONS
|
||||
-->
|
||||
|
||||
<!-- Gray background for headers of HTML tables -->
|
||||
<xsl:template match="db:thead" mode="htmlTable">
|
||||
<fo:table-header start-indent="0pt" end-indent="0pt"
|
||||
background-color="rgb(192,192,192)">
|
||||
<xsl:apply-templates mode="htmlTable"/>
|
||||
</fo:table-header>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Gray background for headers of CALS tables -->
|
||||
<xsl:template match="db:thead">
|
||||
<xsl:variable name="tgroup" select="parent::*"/>
|
||||
|
||||
<fo:table-header start-indent="0pt" end-indent="0pt" background-color="rgb(192,192,192)">
|
||||
<xsl:choose>
|
||||
<!-- Use recursion if @morerows is used -->
|
||||
<xsl:when test="db:row/db:entry/@morerows|db:row/db:entrytbl/@morerows">
|
||||
<xsl:apply-templates select="db:row[1]">
|
||||
<xsl:with-param name="spans">
|
||||
<xsl:call-template name="blank.spans">
|
||||
<xsl:with-param name="cols" select="../@cols"/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
<xsl:with-param name="browserows" select="'recurse'"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="db:row">
|
||||
<xsl:with-param name="spans">
|
||||
<xsl:call-template name="blank.spans">
|
||||
<xsl:with-param name="cols" select="../@cols"/>
|
||||
</xsl:call-template>
|
||||
</xsl:with-param>
|
||||
<xsl:with-param name="browserows" select="'loop'" />
|
||||
</xsl:apply-templates>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</fo:table-header>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="db:guibutton">
|
||||
<fo:inline background-color="rgb(192,192,192)">
|
||||
<xsl:apply-templates/>
|
||||
</fo:inline>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Adjust spacing according to where the title is placed -->
|
||||
<xsl:template name="formal.object.heading">
|
||||
<xsl:param name="object" select="."/>
|
||||
<xsl:param name="placement" select="'before'"/>
|
||||
|
||||
<fo:block xsl:use-attribute-sets="formal.title.properties">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$placement = 'before'">
|
||||
<xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
|
||||
<xsl:attribute name="space-before">12pt</xsl:attribute>
|
||||
<xsl:attribute name="space-after">3pt</xsl:attribute>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="keep-with-previous.within-column">always</xsl:attribute>
|
||||
<xsl:attribute name="space-before">3pt</xsl:attribute>
|
||||
<xsl:attribute name="space-after">12pt</xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:apply-templates select="$object" mode="object.title.markup">
|
||||
<xsl:with-param name="allow-anchors" select="1"/>
|
||||
</xsl:apply-templates>
|
||||
</fo:block>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="db:citerefentry">
|
||||
<xsl:variable name="xhref">
|
||||
<xsl:text>http://www.FreeBSD.org/cgi/man.cgi?query=</xsl:text>
|
||||
<xsl:value-of select="db:refentrytitle"/>
|
||||
<xsl:text>&amp;sektion=</xsl:text>
|
||||
<xsl:value-of select="db:manvolnum"/>
|
||||
</xsl:variable>
|
||||
|
||||
<fo:basic-link external-destination="url({$xhref})">
|
||||
<fo:inline color="blue">
|
||||
<xsl:value-of select="concat(db:refentrytitle, '(', db:manvolnum, ')')"/>
|
||||
</fo:inline>
|
||||
</fo:basic-link>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="pubdate" mode="article.titlepage.recto.auto.mode"/>
|
||||
|
||||
<xsl:attribute-set name="abstract.title.properties">
|
||||
|
|
@ -82,5 +325,97 @@
|
|||
</fo:block>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
<!-- Customize header content -->
|
||||
<xsl:template name="header.content">
|
||||
<xsl:param name="pageclass" select="''"/>
|
||||
<xsl:param name="sequence" select="''"/>
|
||||
<xsl:param name="position" select="''"/>
|
||||
<xsl:param name="gentext-key" select="''"/>
|
||||
|
||||
<fo:block>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$pageclass = 'lot' and $sequence='odd' and $position='left' ">
|
||||
<xsl:call-template name="gentext">
|
||||
<xsl:with-param name="key" select="$gentext-key"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="$pageclass = 'lot' and $sequence='even' and $position='right' ">
|
||||
<xsl:call-template name="gentext">
|
||||
<xsl:with-param name="key" select="$gentext-key"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="$pageclass = 'back' and $sequence='odd' and $position='left' ">
|
||||
<xsl:apply-templates select="." mode="object.title.markup"/>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="$pageclass = 'back' and $sequence='even' and $position='right' ">
|
||||
<xsl:apply-templates select="." mode="object.title.markup"/>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="$pageclass = 'index' and $sequence='odd' and $position='left' ">
|
||||
<xsl:call-template name="gentext">
|
||||
<xsl:with-param name="key" select="$gentext-key"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="$pageclass = 'index' and $sequence='even' and $position='right' ">
|
||||
<xsl:call-template name="gentext">
|
||||
<xsl:with-param name="key" select="$gentext-key"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="$sequence='odd' and $position='left'">
|
||||
<xsl:if test="$pageclass != 'titlepage'">
|
||||
<xsl:apply-templates select="." mode="object.title.markup"/>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="$sequence='even' and $position='right'">
|
||||
<xsl:if test="$pageclass != 'titlepage'">
|
||||
<fo:retrieve-marker
|
||||
retrieve-class-name="section.head.marker"
|
||||
retrieve-position="first-including-carryover"
|
||||
retrieve-boundary="page-sequence"/>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</fo:block>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Customize footer content -->
|
||||
<xsl:template name="footer.content">
|
||||
<xsl:param name="pageclass" select="''"/>
|
||||
<xsl:param name="sequence" select="''"/>
|
||||
<xsl:param name="position" select="''"/>
|
||||
<xsl:param name="gentext-key" select="''"/>
|
||||
|
||||
<fo:block>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$sequence = 'odd' and $position='right'">
|
||||
<fo:page-number/>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:when test="$sequence = 'even' and $position='left'">
|
||||
<fo:page-number/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</fo:block>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Customize header separator -->
|
||||
<xsl:template name="head.sep.rule">
|
||||
<xsl:param name="pageclass"/>
|
||||
<xsl:param name="sequence"/>
|
||||
<xsl:param name="gentext-key"/>
|
||||
|
||||
<xsl:if test="$header.rule != 0 and $sequence != 'first' and
|
||||
$pageclass != 'front' and $pageclass != 'titlepage'">
|
||||
<xsl:attribute name="border-bottom-width">0.5pt</xsl:attribute>
|
||||
<xsl:attribute name="border-bottom-style">solid</xsl:attribute>
|
||||
<xsl:attribute name="border-bottom-color">black</xsl:attribute>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue