docs/parse-support-md: Correctly handle footnotes for non-leaf sections
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 17 Apr 2018 13:34:36 +0000 (14:34 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 23 Apr 2018 12:58:42 +0000 (13:58 +0100)
Non-leaf sections with footnotes must have a row of their own, for
just that section, because footnotes only appear if there is status
information.

In that case, the footnote applies to only the rows for that section
in the markdown document, ie that RealSect.

And of course for a leaf section that is true too.

So for footnoes we always want to use a rowspan of the number of
Status elements in the section.  So (i) calculate this in
count_rows_sectlist and (ii) use it, instead of the total number of
rows including all the subsections', when writing out the footnote
ref.

This bug has been present in this script since the beginning.

Also, while we're here, suppress the rowspan if it would be 1.

Reported-by: Lars Kurth <lars.kurth@citrix.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
docs/parse-support-md

index bbbb615b1abe0ffca4e358b1c89e538c50cfe85c..218e12baa41e4caffc9216ee7ea22dc7929f608e 100755 (executable)
@@ -296,7 +296,11 @@ sub count_rows_sectlist ($);
 sub count_rows_sectnode ($) {
     my ($sectnode) = @_;
     my $rows = 0;
-    $rows++ if $sectnode->{Status};
+    $sectnode->{RealSect}{OwnRows} //= 0;
+    if ($sectnode->{Status}) {
+        $rows++;
+        $sectnode->{RealSect}{OwnRows}++;
+    }
     $rows += count_rows_sectlist $sectnode->{Children};
     $sectnode->{Rows} = $rows;
     $sectnode->{RealSect}{Rows} = $rows;
@@ -306,6 +310,7 @@ sub count_rows_sectnode ($) {
 # Now we have
 #   $sectnode->{Rows}
 #   $sectnode->{RealSect}{Rows}
+#   $sectnode->{RealSect}{OwnRows}
 
 sub count_rows_sectlist ($) {
     my ($sectlist) = @_;
@@ -388,8 +393,10 @@ sub write_output_row ($) {
             $colspan= ' colspan="2"';
             if ($sectnode->{RealSect}{HasCaveat}[$i] && $st
                 && $sectnode->{RealSect}{Anchor}) {
-                my $rows = $sectnode->{RealSect}{Rows};
-                $nextcell = sprintf '<td rowspan=%d>', $rows;
+                my $rows = $sectnode->{RealSect}{OwnRows};
+                $nextcell = '<td';
+                $nextcell .= sprintf ' rowspan=%d', $rows if $rows>1;
+                $nextcell .= '>';
                 $nextcell .= docref_a $i, $sectnode->{RealSect};
                 $nextcell .= '[*]</a>';
                 $nextcell .= '</td>';