Skip to content

Commit 345a45e

Browse files
author
Chris Pappas
committed
Adding handing for part-num-title and app-num-title data-xrefstyling
1 parent 5df16b8 commit 345a45e

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

htmlbook-xsl/localizations/en.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@
517517
<l:template name="equation" text="Equation %n, “%t”"/>
518518
<l:template name="example" text="Example %n, “%t”"/>
519519
<l:template name="figure" text="Figure %n, “%t”"/>
520-
<l:template name="part" text="Part %n, “%t”"/>
520+
<l:template name="part" text="Part %n, %t"/>
521521
<l:template name="procedure" text="Procedure %n, “%t”"/>
522522
<l:template name="productionset" text="Production %n, “%t”"/>
523523
<l:template name="qandadiv" text="Q &amp; A %n, “%t”"/>

htmlbook-xsl/xrefgen.xsl

+5-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@
586586

587587
</xsl:template>
588588

589-
<xsl:template match="h:section[contains(@data-type, 'chapter') or contains(@data-type, 'appendix')]" mode="insert.title.markup">
589+
<xsl:template match="h:section[contains(@data-type, 'chapter') or contains(@data-type, 'appendix')] | h:div[contains(@data-type, 'part')]" mode="insert.title.markup">
590590
<xsl:param name="purpose"/>
591591
<xsl:param name="xrefstyle"/>
592592
<xsl:param name="title"/>
@@ -763,6 +763,10 @@
763763
contains(substring-after($data-xrefstyle-attr, 'select:'), 'labelnumber')">template:%n</xsl:when>
764764
<!-- chap-num-title -->
765765
<xsl:when test="$data-xrefstyle-attr = 'chap-num-title'">xref-number-and-title</xsl:when>
766+
<!-- app-num-title -->
767+
<xsl:when test="$data-xrefstyle-attr = 'app-num-title'">xref-number-and-title</xsl:when>
768+
<!-- part-num-title -->
769+
<xsl:when test="$data-xrefstyle-attr = 'part-num-title'">xref-number-and-title</xsl:when>
766770
</xsl:choose>
767771
</xsl:template>
768772

htmlbook-xsl/xspec/xrefgen.xspec

+32
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,13 @@ sidebar
13221322
<x:scenario label="When an XREF is matched with data-xrefstyle...">
13231323
<x:context>
13241324
<body>
1325+
<div data-type="part" id="awesome_part">
1326+
<h1>I'm Part of the Solution!</h1>
1327+
<section data-type="appendix" id="awesome_app">
1328+
<h1>Appendix Title</h1>
1329+
<p>Some text</p>
1330+
</section>
1331+
</div>
13251332
<section data-type="chapter" id="awesome_chap">
13261333
<h1>AWESOME CHAPTER</h1>
13271334
<p>Check out this pic:</p>
@@ -1336,6 +1343,8 @@ sidebar
13361343
</figure>
13371344
<p>See <a href="#awesome_squared_fig" id="labelnumber-xref" data-type="xref" data-xrefstyle="select: labelnumber"/> for lots of awesomeness.</p>
13381345
<p>See <a href="#awesome_chap" id="chap-num-title-xref" data-type="xref" data-xrefstyle="chap-num-title"/> for awesomeness.</p>
1346+
<p>See <a href="#awesome_app" id="app-num-title-xref" data-type="xref" data-xrefstyle="app-num-title"/> for app awesomeness.</p>
1347+
<p>See <a href="#awesome_part" id="part-num-title-xref" data-type="xref" data-xrefstyle="part-num-title"/> for part awesomeness.</p>
13391348
<p>See <a href="#awesome_sect1" id="nopage-xref" data-type="xref" data-xrefstyle="select:nopage"/> for yet more awesomeness</p>
13401349
<section id="awesome_sect1" data-type="sect1">
13411350
<h1>AWESOME SUBSECTION</h1>
@@ -1355,6 +1364,16 @@ sidebar
13551364
<x:expect label="it should return chapter label, number, and title"><a href="#awesome_chap" id="chap-num-title-xref" data-type="xref" data-xrefstyle="chap-num-title" data-xref-pagenum-style="...">Chapter&#xa0;1, <em>AWESOME CHAPTER</em></a></x:expect>
13561365
</x:scenario>
13571366

1367+
<x:scenario label="of 'app-num-title'">
1368+
<x:context select="//h:a[@id='app-num-title-xref']"/>
1369+
<x:expect label="it should return appendix label, number, and title"><a href="#awesome_app" id="app-num-title-xref" data-type="xref" data-xrefstyle="app-num-title" data-xref-pagenum-style="...">Appendix&#xa0;A, <em>Appendix Title</em></a></x:expect>
1370+
</x:scenario>
1371+
1372+
<x:scenario label="of 'part-num-title'">
1373+
<x:context select="//h:a[@id='part-num-title-xref']"/>
1374+
<x:expect label="it should return part label, number, and title"><a href="#awesome_part" id="part-num-title-xref" data-type="xref" data-xrefstyle="part-num-title" data-xref-pagenum-style="...">Part&#xa0;I, <em>I'm Part of the Solution!</em></a></x:expect>
1375+
</x:scenario>
1376+
13581377
<x:scenario label="of 'select:nopage'">
13591378
<x:context select="//h:a[@id='nopage-xref']">
13601379
<x:param name="xref.elements.pagenum.in.class">sect1</x:param>
@@ -1491,6 +1510,19 @@ sidebar
14911510
<x:expect label="Proper template should be generated">xref-number-and-title</x:expect>
14921511
</x:scenario>
14931512

1513+
<x:scenario label="If calculate-xrefstyle is called on xrefstyle of app-num-title">
1514+
<x:call template="calculate-xrefstyle">
1515+
<x:param name="data-xrefstyle-attr">app-num-title</x:param>
1516+
</x:call>
1517+
<x:expect label="Proper template should be generated">xref-number-and-title</x:expect>
1518+
</x:scenario>
1519+
1520+
<x:scenario label="If calculate-xrefstyle is called on xrefstyle of part-num-title">
1521+
<x:call template="calculate-xrefstyle">
1522+
<x:param name="data-xrefstyle-attr">part-num-title</x:param>
1523+
</x:call>
1524+
<x:expect label="Proper template should be generated">xref-number-and-title</x:expect>
1525+
</x:scenario>
14941526
<x:scenario label="If calculate-xrefstyle is called on xrefstyle that does not match an enumerated pattern">
14951527
<x:call template="calculate-xrefstyle">
14961528
<x:param name="data-xrefstyle-attr">bogus_xrefstyle_yo</x:param>

0 commit comments

Comments
 (0)