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

Fixing issues with variable lists presented as panel sets #517

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/guide/xml/ref-modes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2008,5 +2008,27 @@ depth of sections in the ToC.
</refsection>
</refentry>

<refentry xml:id="m_panelset">
<?db filename="m_panelset"?>
<refmeta>
<refentrytitle>m:panelset</refentrytitle>
<refmiscinfo>{http://docbook.org/ns/docbook/modes}panelset</refmiscinfo>
<refmiscinfo class="version">2.2.2</refmiscinfo>
</refmeta>
<refnamediv>
<refname>m:panelset</refname>
<refpurpose>Process variable list elements for a panel set</refpurpose>
<refclass>mode</refclass>
</refnamediv>
<refsection>
<title>Description</title>
<para>When <tag>variablelist</tag> elements are processed for a
<parameter>variablelist-panelset</parameter>, they are processed in this mode.
This mode makes it possible to override the templates for selected elements.
Be aware, however, that the HTML markup is quite constrained for panel sets.
</para>
</refsection>
</refentry>

</reference>

21 changes: 18 additions & 3 deletions src/main/xslt/modules/lists.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -361,26 +361,41 @@
<xsl:apply-templates select="." mode="m:attributes"/>
<xsl:apply-templates select="." mode="m:generate-titlepage"/>
<xsl:apply-templates select="* except db:varlistentry"/>

<xsl:variable name="button-set" select="'tabs_' || f:id(.)"/>

<div class="panelset">
<xsl:for-each select="db:varlistentry">
<!-- inline style so that the radio button is not displayed -->
<!-- even if the CSS is missing -->
<input type="radio" name="tabs" id="{f:id(.)}" style="display:none">
<input type="radio" name="{$button-set}" id="{f:id(.)}" style="display:none">
<xsl:if test="position() = 1">
<xsl:attribute name="checked" select="'checked'"/>
</xsl:if>
</input>
<label for="{f:id(.)}">
<xsl:apply-templates select="db:term/node()"/>
<xsl:apply-templates select="db:term" mode="m:panelset"/>
</label>
<div class="paneltab">
<xsl:apply-templates select="db:listitem/node()"/>
<xsl:apply-templates select="." mode="m:panelset"/>
</div>
</xsl:for-each>
</div>
</div>
</xsl:template>

<xsl:template match="db:term" mode="m:panelset">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="db:varlistentry" mode="m:panelset">
<xsl:apply-templates select="db:listitem" mode="m:panelset"/>
</xsl:template>

<xsl:template match="db:listitem" mode="m:panelset">
<xsl:apply-templates/>
</xsl:template>

<!-- ============================================================ -->

<xsl:template match="db:segmentedlist">
Expand Down
6 changes: 3 additions & 3 deletions src/test/resources/expected/panelset.001.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" class="no-js"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script><title>Unit Test: panelset.001</title><link href="./css/pygments.css" rel="stylesheet"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="https://purl.org/dc/elements/1.1/" rel="schema.dc"/><meta content="2011-04-22T17:02:00-06:00" name="dc.modified"/><meta content="DocBook xslTNG" name="generator"/><link href="./css/docbook.css" rel="stylesheet" media="screen"/><script src="./js/copy-verbatim.js" defer="defer"></script></head><body class="home"><nav class="top"></nav><main><article class="article component"><header><h1>Unit Test: panelset.001</h1></header><p>This unit test is an experiment in providing a “panel set” presentation
for a variable list.</p><div class="panelset variablelist"><div class="panelset"><input type="radio" name="tabs" id="R_variablelist1_varlistentry1" style="display:none" checked="checked"/><label for="R_variablelist1_varlistentry1">docbook.py</label><div class="paneltab"><div class="pre-wrap highlight" db-startinglinenumber="1" db-numberoflines="17"><pre class="language-python long numbered programlisting verbatim verblines"><span class="line" db-line="1"><span class="ln"> 1 <span class="nsep">|</span></span><span class="ld"><code><span class="ch">#!/usr/bin/env python3</span></code></span></span>
for a variable list.</p><div class="panelset variablelist"><div class="panelset"><input type="radio" name="tabs_R_variablelist1" id="R_variablelist1_varlistentry1" style="display:none" checked="checked"/><label for="R_variablelist1_varlistentry1">docbook.py</label><div class="paneltab"><div class="pre-wrap highlight" db-startinglinenumber="1" db-numberoflines="17"><pre class="language-python long numbered programlisting verbatim verblines"><span class="line" db-line="1"><span class="ln"> 1 <span class="nsep">|</span></span><span class="ld"><code><span class="ch">#!/usr/bin/env python3</span></code></span></span>
<span class="line" db-line="2"><span class="ln"> <span class="nsep">|</span></span><span class="ld"><code> </code></span></span>
<span class="line" db-line="3"><span class="ln"> <span class="nsep">|</span></span><span class="ld"><code><span class="sd">"""This is a wrapper script around the Saxon command line interface.</span></code></span></span>
<span class="line" db-line="4"><span class="ln"> <span class="nsep">|</span></span><span class="ld"><code><span class="sd">It attempts to make sure that the classpath is correct and that third</span></code></span></span>
Expand All @@ -16,7 +16,7 @@
<span class="line" db-line="15"><span class="ln">15 <span class="nsep">|</span></span><span class="ld"><code> </code></span></span>
<span class="line" db-line="16"><span class="ln"> <span class="nsep">|</span></span><span class="ld"><code><span class="k">class</span> <span class="nc">JavaClassRunnerException</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span></code></span></span>
<span class="line" db-line="17"><span class="ln"> <span class="nsep">|</span></span><span class="ld"><code><span class="w"> </span><span class="sd">"""Subclass of Exception for errors raised by the runner."""</span></code></span></span>
</pre></div><p>And so on, for another 600 lines or so.</p></div><input type="radio" name="tabs" id="R_variablelist1_varlistentry2" style="display:none"/><label for="R_variablelist1_varlistentry2">linkcheck.py</label><div class="paneltab"><div class="pre-wrap highlight" db-startinglinenumber="1" db-numberoflines="19"><pre class="language-python long numbered programlisting verbatim verblines"><span class="line" db-line="1"><span class="ln"> 1 <span class="nsep">|</span></span><span class="ld"><code><span class="ch">#!/usr/bin/env python3</span></code></span></span>
</pre></div><p>And so on, for another 600 lines or so.</p></div><input type="radio" name="tabs_R_variablelist1" id="R_variablelist1_varlistentry2" style="display:none"/><label for="R_variablelist1_varlistentry2">linkcheck.py</label><div class="paneltab"><div class="pre-wrap highlight" db-startinglinenumber="1" db-numberoflines="19"><pre class="language-python long numbered programlisting verbatim verblines"><span class="line" db-line="1"><span class="ln"> 1 <span class="nsep">|</span></span><span class="ld"><code><span class="ch">#!/usr/bin/env python3</span></code></span></span>
<span class="line" db-line="2"><span class="ln"> <span class="nsep">|</span></span><span class="ld"><code> </code></span></span>
<span class="line" db-line="3"><span class="ln"> <span class="nsep">|</span></span><span class="ld"><code><span class="sd">"""This is yet another link checker. Was it better to write my own</span></code></span></span>
<span class="line" db-line="4"><span class="ln"> <span class="nsep">|</span></span><span class="ld"><code><span class="sd">than find an existing cross-platform version? Maybe not, but it</span></code></span></span>
Expand All @@ -35,5 +35,5 @@
<span class="line" db-line="17"><span class="ln"> <span class="nsep">|</span></span><span class="ld"><code> <span class="n">importOk</span> <span class="o">=</span> <span class="kc">True</span></code></span></span>
<span class="line" db-line="18"><span class="ln"> <span class="nsep">|</span></span><span class="ld"><code><span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span></code></span></span>
<span class="line" db-line="19"><span class="ln"> <span class="nsep">|</span></span><span class="ld"><code> <span class="n">importOk</span> <span class="o">=</span> <span class="kc">False</span></code></span></span>
</pre></div><p>And so on for another 150 lines or so.</p></div><input type="radio" name="tabs" id="R_variablelist1_varlistentry3" style="display:none"/><label for="R_variablelist1_varlistentry3">Something else</label><div class="paneltab"><p>More things.</p><div class="admonition note"><div><div class="icon">ⓘ</div><div class="body"><header><div class="title">Note</div></header><div><p>The content of an individual panel is just ordinary
</pre></div><p>And so on for another 150 lines or so.</p></div><input type="radio" name="tabs_R_variablelist1" id="R_variablelist1_varlistentry3" style="display:none"/><label for="R_variablelist1_varlistentry3">Something else</label><div class="paneltab"><p>More things.</p><div class="admonition note"><div><div class="icon">ⓘ</div><div class="body"><header><div class="title">Note</div></header><div><p>The content of an individual panel is just ordinary
DocBook <code>listitem</code> content.</p></div></div></div></div></div></div></div></article></main><nav class="bottom"></nav></body></html>
3 changes: 3 additions & 0 deletions src/test/resources/expected/panelset.002.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" class="no-js"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script><title>Unit Test: panelset.002</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><link href="https://purl.org/dc/elements/1.1/" rel="schema.dc"/><meta content="2011-04-22T17:02:00-06:00" name="dc.modified"/><meta content="DocBook xslTNG" name="generator"/><link href="./css/docbook.css" rel="stylesheet" media="screen"/></head><body class="home"><nav class="top"></nav><main><article class="article component"><header><h1>Unit Test: panelset.002</h1></header><p>This unit test is an experiment in providing a “panel set” presentation
for a variable list. This test checks that multiple panel sets on the same page
function correctly.</p><div class="panelset variablelist"><div class="panelset"><input type="radio" name="tabs_R_variablelist1" id="R_variablelist1_varlistentry1" style="display:none" checked="checked"/><label for="R_variablelist1_varlistentry1">A</label><div class="paneltab"><p>One</p></div><input type="radio" name="tabs_R_variablelist1" id="R_variablelist1_varlistentry2" style="display:none"/><label for="R_variablelist1_varlistentry2">B</label><div class="paneltab"><p>Two</p></div><input type="radio" name="tabs_R_variablelist1" id="R_variablelist1_varlistentry3" style="display:none"/><label for="R_variablelist1_varlistentry3">C</label><div class="paneltab"><p>Three</p></div></div></div><p>And another:</p><div class="panelset variablelist"><div class="panelset"><input type="radio" name="tabs_R_variablelist2" id="R_variablelist2_varlistentry1" style="display:none" checked="checked"/><label for="R_variablelist2_varlistentry1">D</label><div class="paneltab"><p>Four</p></div><input type="radio" name="tabs_R_variablelist2" id="R_variablelist2_varlistentry2" style="display:none"/><label for="R_variablelist2_varlistentry2">E</label><div class="paneltab"><p>Five</p></div><input type="radio" name="tabs_R_variablelist2" id="R_variablelist2_varlistentry3" style="display:none"/><label for="R_variablelist2_varlistentry3">F</label><div class="paneltab"><p>Six</p></div></div></div></article></main><nav class="bottom"></nav></body></html>
56 changes: 56 additions & 0 deletions src/test/resources/xml/panelset.002.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<article xmlns="http://docbook.org/ns/docbook" version="5.0"
xmlns:xlink="http://www.w3.org/1999/xlink">
<info>
<title>Unit Test: panelset.002</title>
</info>

<para>This unit test is an experiment in providing a “panel set” presentation
for a variable list. This test checks that multiple panel sets on the same page
function correctly.</para>

<variablelist role="panelset">
<varlistentry>
<term>A</term>
<listitem>
<para>One</para>
</listitem>
</varlistentry>
<varlistentry>
<term>B</term>
<listitem>
<para>Two</para>
</listitem>
</varlistentry>
<varlistentry>
<term>C</term>
<listitem>
<para>Three</para>
</listitem>
</varlistentry>
</variablelist>

<para>And another:</para>

<variablelist role="panelset">
<varlistentry>
<term>D</term>
<listitem>
<para>Four</para>
</listitem>
</varlistentry>
<varlistentry>
<term>E</term>
<listitem>
<para>Five</para>
</listitem>
</varlistentry>
<varlistentry>
<term>F</term>
<listitem>
<para>Six</para>
</listitem>
</varlistentry>
</variablelist>

</article>
Loading