Skip to content

Commit

Permalink
Merge pull request #407 from ndw/v218
Browse files Browse the repository at this point in the history
DocBook xslTNG version 2.1.8
  • Loading branch information
ndw authored Aug 17, 2023
2 parents 621c426 + 0d6c7c2 commit 30762c2
Show file tree
Hide file tree
Showing 25 changed files with 189 additions and 25 deletions.
4 changes: 2 additions & 2 deletions properties.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
ext {
xslTNGtitle = 'DocBook xslTNG'
xslTNGbaseName = 'docbook-xslTNG'
xslTNGversion = '2.1.7'
guideVersion = '2.1.7'
xslTNGversion = '2.1.8'
guideVersion = '2.1.8'
guidePrerelease = false

docbookVersion = '5.2CR5'
Expand Down
2 changes: 1 addition & 1 deletion src/guide/xml/ch04.xml
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ you’ll have to update the <varname>v:standard-transforms</varname>
variable.)</para>

<note>
<para>Transformations in <varname>v:transform-after</varname> will be processing
<para>Transformations in <varname>transform-after</varname> will be processing
the <emphasis>HTML</emphasis> result of applying the “main” DocBook transformation.</para>
</note>

Expand Down
51 changes: 51 additions & 0 deletions src/guide/xml/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,57 @@ be of interest to users of the stylesheets. See the commits and pull requests on
<link xlink:href="https://github.com/docbook/xslTNG/">the repository</link> for
finer detail.</para>

<section xml:id="r218">
<info>
<title>Changes in version 2.1.8</title>
<productnumber>2.1.8</productnumber>
<date>2023-08-17</date>
</info>
<itemizedlist>
<listitem>
<para>Added <mode>m:head-additions</mode> mode for customizers. This allows a customization
layer to add information to the HTML <tag>head</tag>.</para>
</listitem>
<listitem>
<para>Added tunnel parameters to the list of titles templates. This allows a customization
to determine the parent element of the list of titles. (For example, to format the table of contents
for a <tag>set</tag> differently than for the contained <tag>book</tag>s.)
</para>
</listitem>
<listitem>
<para>When formatting a <tag>part</tag> with a <tag>partintro</tag> and a list of titles,
move the <tag>partintro</tag> before the list of titles. (This is technically backwards incompatible,
but it seems so obviously superior to the current behavior that I’m calling the current behavior
a bug.)
</para>
</listitem>
<listitem>
<para>Removed incorrect use of <code>v:</code> prefix in the documentation; fixed
<link xlink:href="https://github.com/docbook/xslTNG/issues/406">#406</link>.
</para>
</listitem>
<listitem>
<para>Added a <parameter>inline-xlink-href</parameter> parameter to control whether or not
XLink href attributes are printed after the link in the paged media stylesheets;
fixed <link xlink:href="https://github.com/docbook/xslTNG/issues/404">#404</link>.
Previously, this was handled in two different ways: for simple
links, the links where always printed; for extended links, the text
were actually added by CSS. Now they’re both controlled by the
parameter and CSS is no longer involved.
</para>
</listitem>
<listitem>
<para>Hacked PrismJS a bit; added support for ABNF and my own attempt at an
Invisible XML highlighter.
</para>
</listitem>
<listitem>
<para>Added CSS for lists of titles in <tag>set</tag>s.
</para>
</listitem>
</itemizedlist>
</section>

<section xml:id="r217">
<info>
<title>Changes in version 2.1.7</title>
Expand Down
20 changes: 20 additions & 0 deletions src/guide/xml/ref-modes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,26 @@ For example, in the English localization, it would generate:</para>
</refsection>
</refentry>

<refentry xml:id="m_head-additions">
<?db filename="m_head-additions"?>
<refmeta>
<refentrytitle>m:head-additions</refentrytitle>
<refmiscinfo>{http://docbook.org/ns/docbook/modes}head-additions</refmiscinfo>
</refmeta>
<refnamediv>
<refname>m:head-additions</refname>
<refpurpose>Additional head items</refpurpose>
<refclass>mode</refclass>
</refnamediv>
<refsection>
<title>Description</title>
<para>This mode can be used by a customization layer to add additional items to the
HTML
<tag namespace="http://www.w3.org/1999/xhtml">head</tag> element.
</para>
</refsection>
</refentry>

<refentry xml:id="m_headline">
<?db filename="m_headline"?>
<refmeta>
Expand Down
22 changes: 22 additions & 0 deletions src/guide/xml/ref-params.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5486,4 +5486,26 @@ CSS file will be added to the document.</para>
</refsection>
</refentry>

<refentry>
<refmeta>
<fieldsynopsis>
<type>xs:string</type>
<varname>inline-xlink-href</varname>
<initializer>'false'</initializer>
</fieldsynopsis>
</refmeta>
<refnamediv>
<refpurpose>Output href values after links?</refpurpose>
</refnamediv>
<refsection>
<title>Description</title>
<para>If this parameter <glossterm>is true</glossterm>, when a linking element
is rendered (one that uses an explicit <tag class="attribute">xlink:href</tag> attribute),
the link will be printed after the reference. This setting is enabled
by default in the paged media stylesheets. It currently has no effect
in the online stylesheets (but might in the future).</para>
</refsection>
</refentry>


</reference>
3 changes: 3 additions & 0 deletions src/main/scss/media-all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ cite.title {
font-family: inherit;
}

.set > .list-of-titles > .lot > .title,
.book > .list-of-titles > .lot > .title,
.part > .list-of-titles > .lot > .title {
font-weight: 400;
Expand Down Expand Up @@ -483,6 +484,7 @@ header .authorgroup {
border-radius: 0.5em;
}

.set > header,
.book > header {
margin-bottom: 2rem;
margin-top: 1rem;
Expand All @@ -494,6 +496,7 @@ header .authorgroup {
border-radius: 0.5em;
}

.set > header h1,
.book > header h1 {
margin-top: 0;
}
Expand Down
4 changes: 0 additions & 4 deletions src/main/scss/media-paged.scss
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ span.error.broken-link::after {
display: inline;
}

.nhrefs .arc a::after {
content: " (" attr(href) ")";
}

.admonition {
background-color: inherit;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/web/js/prism.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/xslt/docbook-paged.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

<xsl:template match="*[@xlink:href]" mode="m:docbook">
<xsl:next-match/>
<xsl:if test="exists(node()) and string(.) != @xlink:href">
<xsl:if test="f:is-true($inline-xlink-href) and exists(node()) and string(.) != @xlink:href">
<xsl:text> (</xsl:text>
<xsl:value-of select="@xlink:href"/>
<xsl:text>)</xsl:text>
Expand Down
8 changes: 8 additions & 0 deletions src/main/xslt/docbook.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@
map { xs:QName('vp:starting-base-uri'): $starting-base-uri })"/>
</xsl:variable>

<!--
<xsl:result-document href="/tmp/out.xml" method="xml" indent="yes">
<xsl:apply-templates select="$document" mode="m:docbook">
<xsl:with-param name="vp:loop-count" select="1" tunnel="yes"/>
</xsl:apply-templates>
</xsl:result-document>
-->

<xsl:variable name="result" as="document-node()">
<xsl:call-template name="t:chunk-cleanup">
<xsl:with-param name="docbook" select="$document"/>
Expand Down
11 changes: 10 additions & 1 deletion src/main/xslt/modules/chunk-cleanup.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@

<xsl:variable name="head" select="/h:html/h:head"/>

<xsl:variable name="heads" as="element(h:head)+">
<xsl:for-each select="ancestor-or-self::*">
<xsl:sequence select="h:head"/>
</xsl:for-each>
</xsl:variable>

<!-- If the chunk selected for previous or next navigation is an
annotation and annotations are being handled by JavaScript,
then disregard the chunk identified. -->
Expand Down Expand Up @@ -231,18 +237,21 @@
</xsl:if>

<xsl:sequence select="$scripts[not(@type) or contains(@type,'javascript')]"/>
<xsl:sequence select="$heads[position() gt 1]/node()"/>
</head>
<body>
<xsl:variable name="class-list" as="xs:string*">
<xsl:if test="parent::h:html">
<xsl:sequence select="'home'"/>
</xsl:if>
<xsl:sequence select="$docbook/*/@status/string()"/>
<xsl:sequence select="tokenize(@class, '\s+')"/>
</xsl:variable>
<xsl:if test="exists($class-list)">
<xsl:attribute name="class"
select="normalize-space(string-join($class-list, ' '))"/>
select="normalize-space(string-join(distinct-values($class-list), ' '))"/>
</xsl:if>

<nav class="top">
<xsl:if test="(empty(@db-navigation)
or f:is-true(@db-navigation))
Expand Down
5 changes: 5 additions & 0 deletions src/main/xslt/modules/chunk-output.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@
select="if ($chunk/h:body/h:main/h:div/@id = $id)
then ''
else @href/string()"/>

<xsl:if test="count($target/ancestor-or-self::h:html[@db-chunk][1]/@db-chunk) gt 1">
<xsl:message select="'Multiple chunks identified for ''' || $id || ''''"/>
</xsl:if>

<xsl:sequence
select="substring-after(
$target/ancestor-or-self::h:html[@db-chunk][1]/@db-chunk/string(),
Expand Down
3 changes: 2 additions & 1 deletion src/main/xslt/modules/divisions.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
<article>
<xsl:apply-templates select="." mode="m:attributes"/>
<xsl:apply-templates select="." mode="m:generate-titlepage"/>
<xsl:apply-templates select="db:partintro"/>
<xsl:apply-templates select="." mode="m:toc"/>
<xsl:apply-templates/>
<xsl:apply-templates select="node() except db:partintro"/>
<xsl:if test="self::db:set|self::db:book">
<xsl:apply-templates select="." mode="m:back-cover"/>
</xsl:if>
Expand Down
3 changes: 3 additions & 0 deletions src/main/xslt/modules/head.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@
<xsl:template match="*" mode="m:html-head-last">
</xsl:template>

<xsl:template match="*" mode="m:head-additions">
</xsl:template>

<xsl:template match="*" mode="m:html-body-script">
<xsl:param name="rootbaseuri" as="xs:anyURI" required="yes"/>
<xsl:param name="chunkbaseuri" as="xs:anyURI" required="yes"/>
Expand Down
5 changes: 5 additions & 0 deletions src/main/xslt/modules/info.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

<xsl:template match="db:info">
<xsl:apply-templates select="db:indexterm"/>
<xsl:where-populated>
<head>
<xsl:apply-templates select=".." mode="m:head-additions"/>
</head>
</xsl:where-populated>
</xsl:template>

<xsl:template match="db:copyright">
Expand Down
7 changes: 3 additions & 4 deletions src/main/xslt/modules/lists.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,9 @@
<xsl:for-each select="tokenize(normalize-space(@arearefs), '\s+')">
<xsl:variable name="id" select="."/>
<xsl:variable name="area" select="key('id', $id, root($context))"/>
<xsl:variable name="area"
select="if (empty($area))
then root($context)//*[@xml:id = $id]
else $area"/>
<xsl:if test="count($area) gt 1">
<xsl:message select="'Multiple areas with the same id: ' || $id"/>
</xsl:if>

<xsl:choose>
<xsl:when test="$area/parent::db:areaset
Expand Down
33 changes: 28 additions & 5 deletions src/main/xslt/modules/toc.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
<xsl:template match="*" mode="m:toc">
<xsl:param name="placed-by-author" select="false()"/>
<xsl:if test="$placed-by-author">
<xsl:call-template name="tp:toc"/>
<xsl:call-template name="tp:toc">
<xsl:with-param name="persistent" select="false()" tunnel="yes"/>
<xsl:with-param name="root-element" select="." tunnel="yes"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

Expand All @@ -31,7 +34,10 @@
<xsl:if test="$placed-by-author
or (f:is-true($auto-toc)
and not(db:toc|processing-instruction('db-toc')))">
<xsl:call-template name="tp:toc"/>
<xsl:call-template name="tp:toc">
<xsl:with-param name="persistent" select="false()" tunnel="yes"/>
<xsl:with-param name="root-element" select="." tunnel="yes"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

Expand All @@ -41,12 +47,21 @@
<xsl:template match="text()|processing-instruction()|comment()" mode="m:persistent-toc"/>
<xsl:template match="/db:article|db:set|db:book|db:part|db:reference"
mode="m:persistent-toc">
<xsl:call-template name="tp:toc"/>
<xsl:call-template name="tp:toc">
<xsl:with-param name="persistent" select="true()" tunnel="yes"/>
<xsl:with-param name="root-element" select="." tunnel="yes"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="tp:toc">
<xsl:param name="persistent" as="xs:boolean" tunnel="yes"/>
<xsl:param name="root-element" as="element()" tunnel="yes"/>

<xsl:variable name="entries" as="element()*">
<xsl:apply-templates mode="m:toc-entry"/>
<xsl:apply-templates mode="m:toc-entry">
<xsl:with-param name="persistent" select="$persistent" tunnel="yes"/>
<xsl:with-param name="root-element" select="$root-element" tunnel="yes"/>
</xsl:apply-templates>
</xsl:variable>

<xsl:variable name="lists-of-titles" as="element()*">
Expand Down Expand Up @@ -93,6 +108,8 @@
|db:section|db:sect1|db:sect2|db:sect3|db:sect4|db:sect5
|db:topic
">
<xsl:param name="persistent" as="xs:boolean" tunnel="yes"/>
<xsl:param name="root-element" as="element()" tunnel="yes"/>
<li>
<a href="#{f:id(.)}">
<xsl:apply-templates select="." mode="m:headline">
Expand All @@ -101,7 +118,10 @@
</a>
<xsl:where-populated>
<ul class="toc">
<xsl:apply-templates mode="m:toc-nested"/>
<xsl:apply-templates mode="m:toc-nested">
<xsl:with-param name="persistent" select="$persistent" tunnel="yes"/>
<xsl:with-param name="root-element" select="$root-element" tunnel="yes"/>
</xsl:apply-templates>
</ul>
</xsl:where-populated>
</li>
Expand Down Expand Up @@ -176,6 +196,9 @@
<xsl:template match="db:section|db:sect1|db:sect2|db:sect3|db:sect4|db:sect5
|db:refsection|db:refsect1|db:refsect2|db:refsect3"
mode="m:toc-nested">
<xsl:param name="persistent" as="xs:boolean" tunnel="yes"/>
<xsl:param name="root-element" as="element()" tunnel="yes"/>

<xsl:variable name="depth" as="xs:integer">
<xsl:choose>
<xsl:when test="self::db:section">
Expand Down
2 changes: 1 addition & 1 deletion src/main/xslt/modules/variable.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
<xsl:variable name="v:olink-databases" as="element(h:targetdb)*">
<xsl:if test="normalize-space($olink-databases) != ''">
<xsl:for-each select="tokenize($olink-databases, ',\s*') ! normalize-space(.)">
<xsl:variable name="db" select="."/>
<xsl:variable name="db" select="resolve-uri(., static-base-uri())"/>
<xsl:try>
<xsl:variable name="olinkdb" select="doc($db)/h:targetdb"/>
<xsl:if test="empty($olinkdb)">
Expand Down
5 changes: 5 additions & 0 deletions src/main/xslt/modules/xlink.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@
</xsl:otherwise>
</xsl:choose>
</a>
<xsl:if test="f:is-true($inline-xlink-href)">
<xsl:text> (</xsl:text>
<xsl:value-of select="@xlink:href"/>
<xsl:text>)</xsl:text>
</xsl:if>
</span>
</xsl:for-each>
<span class="xlink-arc-delim after">
Expand Down
1 change: 1 addition & 0 deletions src/main/xslt/print.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
<xsl:import href="docbook-paged.xsl"/>

<xsl:param name="output-media" select="'print'"/>
<xsl:param name="inline-xlink-href" select="'false'"/>

</xsl:stylesheet>
Loading

0 comments on commit 30762c2

Please sign in to comment.