Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare Docbook XSL-Stylesheets #334

Draft
wants to merge 10 commits into
base: stable
Choose a base branch
from
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ set(JAPANESE_GOTHIC_TTF "ume-tmo3.ttf" CACHE STRING "Gothic TrueType font used f
set(japanese_fontdir "${CMAKE_SOURCE_DIR}/fonts/truetype" CACHE STRING "Directory to search for Japanese fonts")

# Set the default XSL file path
set(BASE_XSLT_HTML "${CMAKE_SOURCE_DIR}/xsl/general-customization.xsl")
set(BASE_XSLT_PDF "${CMAKE_SOURCE_DIR}/xsl/general-fo-customization.xsl")
set(BASE_XSLT_EPUB "${CMAKE_SOURCE_DIR}/xsl/general-epub-customization.xsl")
set(BASE_XSLT_CHM "${CMAKE_SOURCE_DIR}/xsl/general-chm-customization.xsl")
set(BASE_XSLT_HTML "${CMAKE_SOURCE_DIR}/xsl/gnc-custom-html.xsl")
set(BASE_XSLT_PDF "${CMAKE_SOURCE_DIR}/xsl/gnc-custom-pdf.xsl")
set(BASE_XSLT_EPUB "${CMAKE_SOURCE_DIR}/xsl/gnc-custom-epub.xsl")
set(BASE_XSLT_CHM "${CMAKE_SOURCE_DIR}/xsl/gnc-custom-chm.xsl")

# Buildtime destination directories for our generated documentation
set(DATADIR_BUILD "${CMAKE_BINARY_DIR}/share")
Expand Down
1 change: 0 additions & 1 deletion cmake/AddHtmlTarget.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function (add_html_target targetbase lang entities figures xslt_file)
COMMAND ${CMAKE_COMMAND} -E make_directory "${BUILD_DIR}/stylesheet"
COMMAND ${XSLTPROC} ${XSLTPROCFLAGS} ${XSLTPROCFLAGS_HTML}
-o "${BUILD_DIR}/"
--param use.id.as.filename "1"
--stringparam chunker.output.encoding UTF-8
"${xslt_file}"
"${CMAKE_CURRENT_SOURCE_DIR}/index.docbook"
Expand Down
17 changes: 1 addition & 16 deletions cmake/AddPdfTarget.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@ function (add_pdf_target targetbase lang entities figures xslt_file)

set(BUILD_DIR "${DOCDIR_BUILD}/${lang}")

# Determine paper format depending on language (which maps to the document's directory name)
# * for language "C" (fallback language) determine paper format based on current locale
# * all others use A4.
set (XSLTFLAGS_FO "--stringparam paper.type A4")
if (lang STREQUAL "C")
# For the fallback language determine paper format depending on locale
# Only US or C will be set to letter. All others use A4.
set (ENV_LANG $ENV{LANG})
if (ENV_LANG AND ENV_LANG MATCHES ".*_us.*|C") # Replacing ENV_LANG here with if ($ENV{LANG}) won't work.
set (XSLTFLAGS_FO "--stringparam paper.type letter")
endif()
endif()

if (NOT IS_ABSOLUTE ${xslt_file})
set(xslt_file "${CMAKE_CURRENT_SOURCE_DIR}/${xslt_file}")
endif()
Expand All @@ -28,9 +15,7 @@ function (add_pdf_target targetbase lang entities figures xslt_file)
COMMAND ${CMAKE_COMMAND} -E make_directory "${BUILD_DIR}"
COMMAND ${XSLTPROC} ${XSLTPROCFLAGS} ${XSLTPROCFLAGS_FO}
-o "${CMAKE_CURRENT_BINARY_DIR}/${fofile}"
--stringparam fop1.extensions 1
--stringparam variablelist.as.blocks 1
--stringparam glosslist.as.blocks 1
--stringparam gnc.lang ${lang}
"${xslt_file}"
"${CMAKE_CURRENT_SOURCE_DIR}/index.docbook"
DEPENDS ${entities} "index.docbook" "${CMAKE_SOURCE_DIR}/docbook/gnc-docbookx.dtd")
Expand Down
54 changes: 54 additions & 0 deletions xsl/fo-lists.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version='1.0'?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xlink='http://www.w3.org/1999/xlink'
exclude-result-prefixes="xlink"
version='1.0'>

<!-- ******************* formatting several lists *******************-->


<xsl:param name="variablelist.as.blocks">1</xsl:param>
<xsl:param name="glosslist.as.blocks">1</xsl:param>

<!-- adjust the distance between number and content -->
<xsl:param name="orderedlist.label.width">1.6em</xsl:param>

<!-- Custom template to make the term tag bold.-->
<xsl:template match="varlistentry/term">
<fo:inline font-weight="bold">
<xsl:call-template name="anchor"/>
<xsl:call-template name="simple.xlink">
<xsl:with-param name="content">
<xsl:apply-templates/>
</xsl:with-param>
</xsl:call-template>
</fo:inline>
<xsl:choose>
<xsl:when test="not(following-sibling::term)"/> <!-- do nothing -->
<xsl:otherwise>
<!-- * if we have multiple terms in the same varlistentry, generate -->
<!-- * a separator (", " by default) and/or an additional line -->
<!-- * break after each one except the last -->
<fo:inline><xsl:value-of select="$variablelist.term.separator"/></fo:inline>
<xsl:if test="not($variablelist.term.break.after = '0')">
<fo:block/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- Set list spacing always compact -->
<xsl:attribute-set name="list.block.spacing">
<xsl:attribute name="space-before.optimum">0.0em</xsl:attribute>
<xsl:attribute name="space-before.minimum">0.0em</xsl:attribute>
<xsl:attribute name="space-before.maximum">0.2em</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="list.item.spacing">
<xsl:attribute name="space-before.optimum">0.0em</xsl:attribute>
<xsl:attribute name="space-before.minimum">0.0em</xsl:attribute>
<xsl:attribute name="space-before.maximum">0.2em</xsl:attribute>
</xsl:attribute-set>

</xsl:stylesheet>
69 changes: 69 additions & 0 deletions xsl/fo-titlepage.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="exsl"
version="1.0">

<!-- This stylesheet was created by template/titlepage.xsl-->

<xsl:template name="book.titlepage.recto">

<xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/title"/>

<xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/edition"/>

<xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo//revision[1]/date"/>

<xsl:apply-templates mode="book.titlepage.recto.auto.mode" select="bookinfo/authorgroup"/>
</xsl:template>


<xsl:attribute-set name="book.titlepage.recto.style">
<xsl:attribute name="font-family">
<xsl:value-of select="$title.fontset"/>
</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="font-size">24pt</xsl:attribute>
<xsl:attribute name="text-align">center</xsl:attribute>
</xsl:attribute-set>

<xsl:template match="title" mode="book.titlepage.recto.auto.mode">
<fo:inline font-weight="bold" font-size="24pt" text-align="center">
<fo:external-graphic width="auto" height="auto" content-width="24pt" src="url(../../stylesheet/gnucash-icon.png)"/>
<xsl:call-template name="gentext.space"/>
<xsl:apply-templates mode="book.titlepage.recto.style"/>
</fo:inline>
</xsl:template>


<xsl:template match="edition" mode="book.titlepage.recto.auto.mode">
<fo:block xsl:use-attribute-sets="article.titlepage.recto.style" space-before="5em">
<xsl:attribute name="font-size">20pt</xsl:attribute>
<xsl:attribute name="text-align">center</xsl:attribute>
<xsl:call-template name="gentext">
<xsl:with-param name="key" select="'Revision'"/>
</xsl:call-template>
<xsl:call-template name="gentext.space"/>
<xsl:text>:</xsl:text>
<xsl:call-template name="gentext.space"/>
<xsl:apply-templates mode="titlepage.mode"/>
</fo:block>
</xsl:template>

<xsl:template match="date" mode="book.titlepage.recto.auto.mode">
<fo:block xsl:use-attribute-sets="article.titlepage.recto.style" space-before="5em">
<xsl:attribute name="font-size">20pt</xsl:attribute>
<xsl:attribute name="text-align">center</xsl:attribute>
<xsl:call-template name="gentext">
<xsl:with-param name="key" select="'pubdate'"/>
</xsl:call-template>
<xsl:call-template name="gentext.space"/>
<xsl:text>:</xsl:text>
<xsl:call-template name="gentext.space"/>
<xsl:apply-templates mode="titlepage.mode"/>
</fo:block>
</xsl:template>


</xsl:stylesheet>
13 changes: 0 additions & 13 deletions xsl/general-chm-customization.xsl

This file was deleted.

13 changes: 0 additions & 13 deletions xsl/general-epub-customization.xsl

This file was deleted.

13 changes: 0 additions & 13 deletions xsl/general-fo-customization.xsl

This file was deleted.

19 changes: 19 additions & 0 deletions xsl/gnc-custom-chm.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'>

<!-- Importing the Norman Walsh's stylesheet as the basis. -->
<xsl:import href="1.79.2/htmlhelp/htmlhelp.xsl"/>
<!-- see NOTE ABOUT PATHS in README file for details -->

<!--####################### CHM Parameters ####################-->



<!--####################### Files to Include ####################-->

<!-- GnuCash common customization for HTML, PDF and so on. -->
<!-- This must be the last entry -->
<xsl:include href="gnc-custom-common.xsl" />

</xsl:stylesheet>
25 changes: 25 additions & 0 deletions xsl/gnc-custom-common.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'>

<!--####################### Common Parameters ####################-->


<!--####################### Files to Include ####################-->

<!-- Bolds the <sgmltag>application</sgmltag>. -->
<xsl:include href="application.xsl"/>

<!-- Bolds the <sgmltag>emphasis</sgmltag>. -->
<xsl:include href="emphasis.xsl"/>

<!-- Bolds the <sgmltag>guimenu</sgmltag>. -->
<xsl:include href="guimenu.xsl"/>

<!-- Navigation Header and Footer customization. -->
<xsl:include href="navigation.xsl"/>

<!-- This makes part title to be shown as "Part I. Basics", rather than "Basics" -->
<xsl:include href="parttitle.xsl"/>

</xsl:stylesheet>
19 changes: 19 additions & 0 deletions xsl/gnc-custom-epub.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'>

<!-- Importing the Norman Walsh's stylesheet as the basis. -->
<xsl:import href="1.79.2/epub/docbook.xsl"/>
<!-- see NOTE ABOUT PATHS in README file for details -->

<!--####################### epub Parameters ####################-->



<!--####################### Files to Include ####################-->

<!-- GnuCash common customization for HTML, PDF and so on. -->
<!-- This must be the last entry -->
<xsl:include href="gnc-custom-common.xsl" />

</xsl:stylesheet>
Loading