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.san...@pobox.com>
---
 scripts/kernel-doc |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index e6bc9db..2be2078 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -245,6 +245,7 @@ my $dohighlight = "";
 
 my $verbose = 0;
 my $output_mode = "man";
+my $output_preformatted = 0;
 my $no_doc_sections = 0;
 my %highlights = %highlights_man;
 my $blankline = $blankline_man;
@@ -486,7 +487,9 @@ sub output_highlight {
     }
     foreach $line (split "\n", $contents) {
        if ($line eq ""){
-           print $lineprefix, local_unescape($blankline);
+           if (! $output_preformatted) {
+               print $lineprefix, local_unescape($blankline);
+           }
        } else {
            $line =~ s/\\\\\\/\&/g;
            if ($output_mode eq "man" && substr($line, 0, 1) eq ".") {
@@ -902,10 +905,12 @@ sub output_section_xml(%) {
        print "<title>$section</title>\n";
        if ($section =~ m/EXAMPLE/i) {
            print "<informalexample><programlisting>\n";
+           $output_preformatted = 1;
        } else {
            print "<para>\n";
        }
        output_highlight($args{'sections'}{$section});
+       $output_preformatted = 0;
        if ($section =~ m/EXAMPLE/i) {
            print "</programlisting></informalexample>\n";
        } else {
@@ -1208,10 +1213,12 @@ sub output_blockhead_xml(%) {
        }
        if ($section =~ m/EXAMPLE/i) {
            print "<example><para>\n";
+           $output_preformatted = 1;
        } else {
            print "<para>\n";
        }
        output_highlight($args{'sections'}{$section});
+       $output_preformatted = 0;
        if ($section =~ m/EXAMPLE/i) {
            print "</para></example>\n";
        } else {
@@ -1287,10 +1294,12 @@ sub output_function_gnome {
        print "<simplesect>\n <title>$section</title>\n";
        if ($section =~ m/EXAMPLE/i) {
            print "<example><programlisting>\n";
+           $output_preformatted = 1;
        } else {
        }
        print "<para>\n";
        output_highlight($args{'sections'}{$section});
+       $output_preformatted = 0;
        print "</para>\n";
        if ($section =~ m/EXAMPLE/i) {
            print "</programlisting></example>\n";
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to