texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

texinfo/tp Texinfo/Convert/HTML.pm t/html_tests...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Convert/HTML.pm t/html_tests...
Date: Thu, 14 Jul 2011 07:42:23 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/07/14 07:42:22

Modified files:
        tp/Texinfo/Convert: HTML.pm 
        tp/t           : html_tests.t 
Added files:
        tp/t/include   : file_with_xml_chars.texi 
        tp/t/results/html_tests: xml_protected_in_verb.pl 

Log message:
        Handle correctly protection in @verb and @verbatim.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/HTML.pm?cvsroot=texinfo&r1=1.105&r2=1.106
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/html_tests.t?cvsroot=texinfo&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/include/file_with_xml_chars.texi?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/html_tests/xml_protected_in_verb.pl?cvsroot=texinfo&rev=1.1

Patches:
Index: Texinfo/Convert/HTML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/HTML.pm,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -b -r1.105 -r1.106
--- Texinfo/Convert/HTML.pm     13 Jul 2011 22:13:18 -0000      1.105
+++ Texinfo/Convert/HTML.pm     14 Jul 2011 07:42:21 -0000      1.106
@@ -132,6 +132,12 @@
   return $self->{'document_context'}->[-1]->{'context'}->[-1]->{'string'};
 }
 
+sub in_verbatim($)
+{
+  my $self = shift;
+  return $self->{'document_context'}->[-1]->{'context'}->[-1]->{'verbatim'};
+}
+
 sub paragraph_number($)
 {
   my $self = shift;
@@ -3196,6 +3202,10 @@
   my $command = shift;
   my $text = shift;
 
+  # do that first because in verb and verbatim, type is 'raw'
+  if ($self->in_verbatim()) {
+    return $self->xml_protect_text($text);
+  }
   return $text if ($type and $type eq 'raw');
   $text = uc($text) if ($self->in_upper_case());
   $text = $self->xml_protect_text($text);
@@ -5941,6 +5951,7 @@
   }
 
   if ($self->get_conf('DEBUG')) {
+    $explanation = 'NO EXPLANATION' if (!defined($explanation));
     print STDERR "ROOT($explanation):$root 
(".join('|',@{$self->{'document_context'}->[-1]->{'context'}})."), ->";
     print STDERR " cmd: $root->{'cmdname'}," if ($root->{'cmdname'});
     print STDERR " type: $root->{'type'}" if ($root->{'type'});
@@ -6046,6 +6057,9 @@
           or $command_name eq 'menu' and $self->get_conf('SIMPLE_MENU')) {
         push @{$self->{'document_context'}->[-1]->{'preformatted_context'}}, 
$command_name;
       }
+      if ($command_name eq 'verb' or $command_name eq 'verbatim') {
+        $self->{'document_context'}->[-1]->{'context'}->[-1]->{'verbatim'}++;
+      }
       if ($code_style_commands{$command_name} or 
           $preformatted_code_commands{$command_name}) {
         $self->{'document_context'}->[-1]->{'context'}->[-1]->{'code'}++;
@@ -6152,6 +6166,9 @@
       } elsif ($align_commands{$command_name}) {
         pop @{$self->{'document_context'}->[-1]->{'context'}->[-1]->{'align'}};
       }
+      if ($command_name eq 'verb' or $command_name eq 'verbatim') {
+        $self->{'document_context'}->[-1]->{'context'}->[-1]->{'verbatim'}--;
+      }
       if (exists($block_commands{$command_name})) {
         pop @{$self->{'document_context'}->[-1]->{'formats'}};
       }

Index: t/html_tests.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/html_tests.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- t/html_tests.t      13 Jul 2011 20:58:55 -0000      1.3
+++ t/html_tests.t      14 Jul 2011 07:42:21 -0000      1.4
@@ -29,6 +29,15 @@
 <i>
 @end html
 '],
+['xml_protected_in_verb',
+'@verbatim
+<a>
address@hidden verbatim
+
address@hidden <i> .}.
+
address@hidden file_with_xml_chars.texi
+'],
 );
 
 foreach my $test (@test_cases) {

Index: t/include/file_with_xml_chars.texi
===================================================================
RCS file: t/include/file_with_xml_chars.texi
diff -N t/include/file_with_xml_chars.texi
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/include/file_with_xml_chars.texi  14 Jul 2011 07:42:22 -0000      1.1
@@ -0,0 +1 @@
+<bidule truc="ff &amp;"> & </bidule>

Index: t/results/html_tests/xml_protected_in_verb.pl
===================================================================
RCS file: t/results/html_tests/xml_protected_in_verb.pl
diff -N t/results/html_tests/xml_protected_in_verb.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/results/html_tests/xml_protected_in_verb.pl       14 Jul 2011 07:42:22 
-0000      1.1
@@ -0,0 +1,239 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors 
+   %result_elements %result_directions_text);
+
+use utf8;
+
+$result_trees{'xml_protected_in_verb'} = {
+  'contents' => [
+    {
+      'cmdname' => 'verbatim',
+      'contents' => [
+        {
+          'extra' => {
+            'command' => {}
+          },
+          'parent' => {},
+          'text' => '
+',
+          'type' => 'empty_line_after_command'
+        },
+        {
+          'parent' => {},
+          'text' => '<a>
+',
+          'type' => 'raw'
+        }
+      ],
+      'line_nr' => {
+        'file_name' => '',
+        'line_nr' => 1,
+        'macro' => ''
+      },
+      'parent' => {}
+    },
+    {
+      'extra' => {
+        'command' => {}
+      },
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line_after_command'
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line'
+    },
+    {
+      'contents' => [
+        {
+          'args' => [
+            {
+              'contents' => [
+                {
+                  'parent' => {},
+                  'text' => ' <i> ',
+                  'type' => 'raw'
+                }
+              ],
+              'parent' => {},
+              'type' => 'brace_command_arg'
+            }
+          ],
+          'cmdname' => 'verb',
+          'contents' => [],
+          'line_nr' => {
+            'file_name' => '',
+            'line_nr' => 5,
+            'macro' => ''
+          },
+          'parent' => {},
+          'type' => '.'
+        },
+        {
+          'parent' => {},
+          'text' => '.
+'
+        }
+      ],
+      'parent' => {},
+      'type' => 'paragraph'
+    },
+    {
+      'parent' => {},
+      'text' => '
+',
+      'type' => 'empty_line'
+    },
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'extra' => {
+                'command' => {}
+              },
+              'parent' => {},
+              'text' => ' ',
+              'type' => 'empty_spaces_after_command'
+            },
+            {
+              'parent' => {},
+              'text' => 'file_with_xml_chars.texi'
+            },
+            {
+              'parent' => {},
+              'text' => '
+',
+              'type' => 'spaces_at_end'
+            }
+          ],
+          'parent' => {},
+          'type' => 'misc_line_arg'
+        }
+      ],
+      'cmdname' => 'verbatiminclude',
+      'extra' => {
+        'text_arg' => 'file_with_xml_chars.texi'
+      },
+      'line_nr' => {
+        'file_name' => '',
+        'line_nr' => 7,
+        'macro' => ''
+      },
+      'parent' => {}
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'xml_protected_in_verb'}{'contents'}[0]{'contents'}[0]{'extra'}{'command'}
 = $result_trees{'xml_protected_in_verb'}{'contents'}[0];
+$result_trees{'xml_protected_in_verb'}{'contents'}[0]{'contents'}[0]{'parent'} 
= $result_trees{'xml_protected_in_verb'}{'contents'}[0];
+$result_trees{'xml_protected_in_verb'}{'contents'}[0]{'contents'}[1]{'parent'} 
= $result_trees{'xml_protected_in_verb'}{'contents'}[0];
+$result_trees{'xml_protected_in_verb'}{'contents'}[0]{'parent'} = 
$result_trees{'xml_protected_in_verb'};
+$result_trees{'xml_protected_in_verb'}{'contents'}[1]{'extra'}{'command'} = 
$result_trees{'xml_protected_in_verb'}{'contents'}[0];
+$result_trees{'xml_protected_in_verb'}{'contents'}[1]{'parent'} = 
$result_trees{'xml_protected_in_verb'};
+$result_trees{'xml_protected_in_verb'}{'contents'}[2]{'parent'} = 
$result_trees{'xml_protected_in_verb'};
+$result_trees{'xml_protected_in_verb'}{'contents'}[3]{'contents'}[0]{'args'}[0]{'contents'}[0]{'parent'}
 = 
$result_trees{'xml_protected_in_verb'}{'contents'}[3]{'contents'}[0]{'args'}[0];
+$result_trees{'xml_protected_in_verb'}{'contents'}[3]{'contents'}[0]{'args'}[0]{'parent'}
 = $result_trees{'xml_protected_in_verb'}{'contents'}[3]{'contents'}[0];
+$result_trees{'xml_protected_in_verb'}{'contents'}[3]{'contents'}[0]{'parent'} 
= $result_trees{'xml_protected_in_verb'}{'contents'}[3];
+$result_trees{'xml_protected_in_verb'}{'contents'}[3]{'contents'}[1]{'parent'} 
= $result_trees{'xml_protected_in_verb'}{'contents'}[3];
+$result_trees{'xml_protected_in_verb'}{'contents'}[3]{'parent'} = 
$result_trees{'xml_protected_in_verb'};
+$result_trees{'xml_protected_in_verb'}{'contents'}[4]{'parent'} = 
$result_trees{'xml_protected_in_verb'};
+$result_trees{'xml_protected_in_verb'}{'contents'}[5]{'args'}[0]{'contents'}[0]{'extra'}{'command'}
 = $result_trees{'xml_protected_in_verb'}{'contents'}[5];
+$result_trees{'xml_protected_in_verb'}{'contents'}[5]{'args'}[0]{'contents'}[0]{'parent'}
 = $result_trees{'xml_protected_in_verb'}{'contents'}[5]{'args'}[0];
+$result_trees{'xml_protected_in_verb'}{'contents'}[5]{'args'}[0]{'contents'}[1]{'parent'}
 = $result_trees{'xml_protected_in_verb'}{'contents'}[5]{'args'}[0];
+$result_trees{'xml_protected_in_verb'}{'contents'}[5]{'args'}[0]{'contents'}[2]{'parent'}
 = $result_trees{'xml_protected_in_verb'}{'contents'}[5]{'args'}[0];
+$result_trees{'xml_protected_in_verb'}{'contents'}[5]{'args'}[0]{'parent'} = 
$result_trees{'xml_protected_in_verb'}{'contents'}[5];
+$result_trees{'xml_protected_in_verb'}{'contents'}[5]{'parent'} = 
$result_trees{'xml_protected_in_verb'};
+
+$result_texis{'xml_protected_in_verb'} = '@verbatim
+<a>
address@hidden verbatim
+
address@hidden <i> .}.
+
address@hidden file_with_xml_chars.texi
+';
+
+
+$result_texts{'xml_protected_in_verb'} = '<a>
+
+ <i> .
+
+';
+
+$result_errors{'xml_protected_in_verb'} = [];
+
+
+
+$result_converted{'html'}->{'xml_protected_in_verb'} = '<!DOCTYPE html PUBLIC 
"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd";>
+<html>
+<!-- Created by texi2html, http://www.gnu.org/software/texinfo/ -->
+<head>
+<title>Untitled Document</title>
+
+<meta name="description" content="Untitled Document">
+<meta name="keywords" content="Untitled Document">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="texi2html">
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<style type="text/css">
+<!--
+a.summary-letter {text-decoration: none}
+blockquote.smallquotation {font-size: smaller}
+div.display {margin-left: 3.2em}
+div.example {margin-left: 3.2em}
+div.lisp {margin-left: 3.2em}
+div.smalldisplay {margin-left: 3.2em}
+div.smallexample {margin-left: 3.2em}
+div.smalllisp {margin-left: 3.2em}
+pre.display {font-family: serif}
+pre.format {font-family: serif}
+pre.menu-comment {font-family: serif}
+pre.menu-preformatted {font-family: serif}
+pre.smalldisplay {font-family: serif; font-size: smaller}
+pre.smallexample {font-size: smaller}
+pre.smallformat {font-family: serif; font-size: smaller}
+pre.smalllisp {font-size: smaller}
+span.nocodebreak {white-space:pre}
+span.nolinebreak {white-space:pre}
+span.roman {font-family:serif; font-weight:normal}
+span.sansserif {font-family:sans-serif; font-weight:normal}
+ul.no-bullet {list-style: none}
+-->
+</style>
+
+
+</head>
+
+<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" 
vlink="#800080" alink="#FF0000">
+
+<pre class="verbatim">&lt;a&gt;
+</pre>
+<p><tt> &lt;i&gt; </tt>.
+</p>
+<pre class="verbatim">&lt;bidule truc=&quot;ff &amp;amp;&quot;&gt; &amp; 
&lt;/bidule&gt;
+</pre><p>
+
+
+</p>
+</body>
+</html>
+';
+
+$result_converted_errors{'html'}->{'xml_protected_in_verb'} = [
+  {
+    'error_line' => 'warning: Must specify a title with a title command or @top
+',
+    'text' => 'Must specify a title with a title command or @top',
+    'type' => 'warning'
+  }
+];
+
+
+1;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]