Skip to content

Commit e314ba3

Browse files
daniel-santostorvalds
authored andcommitted
kernel-doc: bugfix - empty line in Example section
If you have a section named "Example" that contains an empty line, attempting to generate htmldocs give you the error: /path/Documentation/DocBook/kernel-api.xml:3455: parser error : Opening and ending tag mismatch: programlisting line 3449 and para </para><para> ^ /path/Documentation/DocBook/kernel-api.xml:3473: parser error : Opening and ending tag mismatch: para line 3467 and programlisting </programlisting></informalexample> ^ /path/Documentation/DocBook/kernel-api.xml:3678: parser error : Opening and ending tag mismatch: programlisting line 3672 and para </para><para> ^ /path/Documentation/DocBook/kernel-api.xml:3701: parser error : Opening and ending tag mismatch: para line 3690 and programlisting </programlisting></informalexample> ^ unable to parse /path/Documentation/DocBook/kernel-api.xml Essentially, the script attempts to close a <programlisting> with a closing tag for a <para> block. This patch corrects the problem by simply not outputting anything extra when we're dumping pre-formatted text, since the empty line will be rendered correctly anyway. Signed-off-by: Daniel Santos <daniel.santos@pobox.com> Cc: Randy Dunlap <rdunlap@xenotime.net> Cc: Michal Marek <mmarek@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6547842 commit e314ba3

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

scripts/kernel-doc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ my $dohighlight = "";
230230

231231
my $verbose = 0;
232232
my $output_mode = "man";
233+
my $output_preformatted = 0;
233234
my $no_doc_sections = 0;
234235
my %highlights = %highlights_man;
235236
my $blankline = $blankline_man;
@@ -460,7 +461,9 @@ sub output_highlight {
460461

461462
foreach $line (split "\n", $contents) {
462463
if ($line eq ""){
463-
print $lineprefix, local_unescape($blankline);
464+
if (! $output_preformatted) {
465+
print $lineprefix, local_unescape($blankline);
466+
}
464467
} else {
465468
$line =~ s/\\\\\\/\&/g;
466469
if ($output_mode eq "man" && substr($line, 0, 1) eq ".") {
@@ -643,10 +646,12 @@ sub output_section_xml(%) {
643646
print "<title>$section</title>\n";
644647
if ($section =~ m/EXAMPLE/i) {
645648
print "<informalexample><programlisting>\n";
649+
$output_preformatted = 1;
646650
} else {
647651
print "<para>\n";
648652
}
649653
output_highlight($args{'sections'}{$section});
654+
$output_preformatted = 0;
650655
if ($section =~ m/EXAMPLE/i) {
651656
print "</programlisting></informalexample>\n";
652657
} else {
@@ -949,10 +954,12 @@ sub output_blockhead_xml(%) {
949954
}
950955
if ($section =~ m/EXAMPLE/i) {
951956
print "<example><para>\n";
957+
$output_preformatted = 1;
952958
} else {
953959
print "<para>\n";
954960
}
955961
output_highlight($args{'sections'}{$section});
962+
$output_preformatted = 0;
956963
if ($section =~ m/EXAMPLE/i) {
957964
print "</para></example>\n";
958965
} else {
@@ -1028,10 +1035,12 @@ sub output_function_gnome {
10281035
print "<simplesect>\n <title>$section</title>\n";
10291036
if ($section =~ m/EXAMPLE/i) {
10301037
print "<example><programlisting>\n";
1038+
$output_preformatted = 1;
10311039
} else {
10321040
}
10331041
print "<para>\n";
10341042
output_highlight($args{'sections'}{$section});
1043+
$output_preformatted = 0;
10351044
print "</para>\n";
10361045
if ($section =~ m/EXAMPLE/i) {
10371046
print "</programlisting></example>\n";

0 commit comments

Comments
 (0)