Skip to content

Commit 1f5d9da

Browse files
author
Sanders Kleinfeld
committed
No label generated for empty figure caption or table caption.
1 parent 84f12f2 commit 1f5d9da

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

htmlbook-xsl/common.xsl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@
241241
</xsl:choose>
242242
</xsl:template>
243243

244+
<!-- No label markup for figures or tables with empty captions -->
245+
<xsl:template match="h:figure[h:figcaption[normalize-space(.) = '']]|
246+
h:table[h:caption[normalize-space(.) = '']]"
247+
mode="label.markup"/>
248+
244249
<xsl:template match="*" mode="label.markup"/>
245250

246251
<!-- Intralabel punctuation templates.

htmlbook-xsl/xspec/common.xspec

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,97 @@ sect5:none
690690
</x:scenario>
691691
</x:scenario>
692692

693+
<x:scenario label="When generating a label for a figure with empty caption">
694+
<x:context select="(//h:figure)[2]" mode="label.markup">
695+
<section data-type="chapter">
696+
<h1>Look! A Chapter!</h1>
697+
<p>Figure with a caption!</p>
698+
<figure>
699+
<figcaption>Image of Budapest skyline</figcaption>
700+
<img src="budapest.png"/>
701+
</figure>
702+
<p>Figure with empty caption!</p>
703+
<figure>
704+
<img src="helsinki.png"/>
705+
<figcaption/>
706+
</figure>
707+
</section>
708+
</x:context>
709+
<x:scenario label="With label.formal.with.ancestor disabled">
710+
<x:context>
711+
<x:param name="label.formal.with.ancestor" select="0"/>
712+
</x:context>
713+
<x:expect label="Don't return any text" select="()"/>
714+
</x:scenario>
715+
716+
<x:scenario label="With label.formal.with.ancestor enabled">
717+
<x:context>
718+
<x:param name="label.formal.with.ancestor" select="1"/>
719+
</x:context>
720+
<x:expect label="Don't return any text" select="()"/>
721+
</x:scenario>
722+
</x:scenario>
723+
724+
<x:scenario label="When generating a label for a table with empty caption">
725+
<x:context select="(//h:table)[2]" mode="label.markup">
726+
<section data-type="chapter">
727+
<h1>Look! A Chapter!</h1>
728+
<p>Table with a caption!</p>
729+
<table>
730+
<caption>Recent US Presidents' pets</caption>
731+
<thead>
732+
<tr>
733+
<th>President</th>
734+
<th>Pet</th>
735+
</tr>
736+
</thead>
737+
<tbody>
738+
<tr>
739+
<td>Barack Obama</td>
740+
<td>Bo</td>
741+
</tr>
742+
<tr>
743+
<td>George W. Bush</td>
744+
<td>Miss Beazley</td>
745+
</tr>
746+
<tr>
747+
<td>Bill Clinton</td>
748+
<td>Socks</td>
749+
</tr>
750+
</tbody>
751+
</table>
752+
<p>Table with empty caption!</p>
753+
<table>
754+
<caption> </caption>
755+
<tr>
756+
<th>Food</th>
757+
<th>Calories<span data-type="footnote">Stats via Google</span></th>
758+
</tr>
759+
<tr>
760+
<td>slice of pizza</td>
761+
<td>285</td>
762+
</tr>
763+
<tr>
764+
<td>stalk of celery</td>
765+
<td>6</td>
766+
</tr>
767+
</table>
768+
</section>
769+
</x:context>
770+
<x:scenario label="With label.formal.with.ancestor disabled">
771+
<x:context>
772+
<x:param name="label.formal.with.ancestor" select="0"/>
773+
</x:context>
774+
<x:expect label="Don't return any text" select="()"/>
775+
</x:scenario>
776+
777+
<x:scenario label="With label.formal.with.ancestor enabled">
778+
<x:context>
779+
<x:param name="label.formal.with.ancestor" select="1"/>
780+
</x:context>
781+
<x:expect label="Don't return any text" select="()"/>
782+
</x:scenario>
783+
</x:scenario>
693784

694785
<x:pending>
695786

0 commit comments

Comments
 (0)