texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp TODO Texinfo/Convert/Converter.pm Te...


From: Patrice Dumas
Subject: texinfo/tp TODO Texinfo/Convert/Converter.pm Te...
Date: Wed, 31 Aug 2011 22:54:52 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        11/08/31 22:54:52

Modified files:
        tp             : TODO 
        tp/Texinfo/Convert: Converter.pm XML.pm 
        tp/t           : 30sectioning.t 
        tp/t/results/coverage_braces: test_image.pl 
        tp/t/results/regions: anchor_in_copying.pl 
                              anchor_in_copying_in_footnote.pl 
        tp/t/results/sectioning: chapter_before_and_after_part.pl 
                                 part_before_section.pl 
                                 section_before_chapter.pl 
                                 section_before_top_no_node.pl 
                                 section_chapter_before_top.pl 
                                 sectioning_part_appendix.pl 
                                 top_part_chapter.pl 

Log message:
        Handle menus and other types in XML.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/TODO?cvsroot=texinfo&r1=1.161&r2=1.162
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/Converter.pm?cvsroot=texinfo&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/XML.pm?cvsroot=texinfo&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/30sectioning.t?cvsroot=texinfo&r1=1.52&r2=1.53
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage_braces/test_image.pl?cvsroot=texinfo&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/regions/anchor_in_copying.pl?cvsroot=texinfo&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/regions/anchor_in_copying_in_footnote.pl?cvsroot=texinfo&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/sectioning/chapter_before_and_after_part.pl?cvsroot=texinfo&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/sectioning/part_before_section.pl?cvsroot=texinfo&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/sectioning/section_before_chapter.pl?cvsroot=texinfo&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/sectioning/section_before_top_no_node.pl?cvsroot=texinfo&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/sectioning/section_chapter_before_top.pl?cvsroot=texinfo&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/sectioning/sectioning_part_appendix.pl?cvsroot=texinfo&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/sectioning/top_part_chapter.pl?cvsroot=texinfo&r1=1.2&r2=1.3

Patches:
Index: TODO
===================================================================
RCS file: /sources/texinfo/texinfo/tp/TODO,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -b -r1.161 -r1.162
--- TODO        25 Aug 2011 07:33:32 -0000      1.161
+++ TODO        31 Aug 2011 22:54:51 -0000      1.162
@@ -1,3 +1,6 @@
address@hidden should stop @part. Right now it do not do that.
+Cf sectioning_part_appendix.
+
 Test
 @definfoenclose headword, , :
  to define address@hidden' as an Info

Index: Texinfo/Convert/Converter.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/Converter.pm,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- Texinfo/Convert/Converter.pm        31 Aug 2011 20:42:01 -0000      1.31
+++ Texinfo/Convert/Converter.pm        31 Aug 2011 22:54:51 -0000      1.32
@@ -526,6 +526,7 @@
 {
   my $self = shift;
   my $text = shift;
+  chomp $text;
   $text =~ s/--+/-/go;
   return '<!-- ' . $text . ' -->' . "\n";
 }

Index: Texinfo/Convert/XML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/XML.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- Texinfo/Convert/XML.pm      31 Aug 2011 20:42:02 -0000      1.5
+++ Texinfo/Convert/XML.pm      31 Aug 2011 22:54:51 -0000      1.6
@@ -22,6 +22,9 @@
 #           drop the See
 #           @findex -> <findex><indexterm 
index=\"${index_name}\">${formatted_entry_reference}</indexterm>
 #           @abbr do not becomes abbrev
+#       menu comment -> menucomment
+#       menu entry description -> menudescription
+#       preformatted -> pre
 
 
 package Texinfo::Convert::XML;
@@ -163,19 +166,6 @@
   delete $xml_misc_commands{$command};
 }
 
-my %ignored_types;
-foreach my $type ('empty_line_after_command', 'preamble',
-            'empty_spaces_after_command', 'spaces_at_end',
-            'empty_spaces_before_argument', 'empty_spaces_before_paragraph',
-            'empty_spaces_after_close_brace', 
-            'empty_space_at_end_def_bracketed') {
-  $ignored_types{$type} = 1;
-}
-
-my %context_block_commands = (
-  'float' => 1,
-);
-
 my %commands_args_style = (
   'email' => ['code'],
   'anchor' => ['code'],
@@ -218,6 +208,33 @@
   }
 }
 
+my %ignored_types;
+foreach my $type ('empty_line_after_command', 'preamble',
+            'empty_spaces_after_command', 'spaces_at_end',
+            'empty_spaces_before_argument', 'empty_spaces_before_paragraph',
+            'empty_spaces_after_close_brace', 
+            'empty_space_at_end_def_bracketed',
+            # FIXME keep those? Information is lost...
+            'menu_entry_separator',
+            'menu_entry_leading_text',
+            
+  ) {
+  $ignored_types{$type} = 1;
+}
+
+my %type_elements = (
+  'paragraph' => 'para',
+  'menu_entry' => 'menuentry',
+  'menu_entry_node' => 'menunode',
+  'menu_comment' => 'menucomment',
+  'menu_entry_description' => 'menudescription',
+  'menu_entry_name' => 'menutitle',
+);
+
+my %context_block_commands = (
+  'float' => 1,
+);
+
 sub _defaults($)
 {
   return %defaults;
@@ -590,27 +607,41 @@
   #    push @contents, {'text' => "\n"};
   #    $result = convert({'contents' => address@hidden, 
_code_options($options));
   #  }
-    #$result = convert($root->{'args'}->[0], $options) if ($root->{'args'});
-  #} elsif ($root->{'type'} and $root->{'type'} eq 'menu_entry') {
-  #  foreach my $arg (@{$root->{'args'}}) {
-  #    if ($arg->{'type'} eq 'menu_entry_node') {
-  #      $result .= convert($arg, _code_options($options));
-  #    } else {
-  #      $result .= convert($arg, $options);
-  #    }
-  #  }
-  #}
+  if ($root->{'type'}) {
+    if (defined($type_elements{$root->{'type'}})) {
+      $result .= "<$type_elements{$root->{'type'}}>";
+    }
+  }
   if ($root->{'contents'}) {
+    my $in_code;
     if ($root->{'cmdname'} 
         and $Texinfo::Common::preformatted_code_commands{$root->{'cmdname'}}) {
-      #$options = _code_options($options);
+      $in_code = 1;
     }
+    $self->{'document_context'}->[-1]->{'code'}++ if ($in_code);
     if (ref($root->{'contents'}) ne 'ARRAY') {
       cluck "contents not an array($root->{'contents'}).";
     }
     foreach my $content (@{$root->{'contents'}}) {
       $result .= $self->_convert($content);
     }
+    $self->{'document_context'}->[-1]->{'code'}-- if ($in_code);
+  }
+  if ($root->{'type'} and $root->{'type'} eq 'menu_entry') {
+    foreach my $arg (@{$root->{'args'}}) {
+      my $in_code;
+      if ($arg->{'type'} eq 'menu_entry_node') {
+        $in_code = 1;
+      }
+      $self->{'document_context'}->[-1]->{'code'}++ if ($in_code);
+      $result .= $self->_convert($arg);
+      $self->{'document_context'}->[-1]->{'code'}-- if ($in_code);
+    }
+  }
+  if ($root->{'type'}) {
+    if (defined($type_elements{$root->{'type'}})) {
+      $result .= "</$type_elements{$root->{'type'}}>";
+    }
   }
   $result = '{'.$result.'}' 
      if ($root->{'type'} and $root->{'type'} eq 'bracketed'
@@ -635,6 +666,7 @@
              # the most up element is a virtual sectioning root element, this
              # condition avoids getting into it
              and $current->{'section_up'}->{'cmdname'}
+             and !$current->{'section_next'}
              and _level_corrected_section($current->{'section_up'}) ne 'top') {
         $current = $current->{'section_up'};
         $result .= '</'._level_corrected_section($current) .">\n";
@@ -703,12 +735,6 @@
 # $complex_format_map{$complex_format}->{'begin'} = "<$complex_format 
xml:space=\"preserve\">";
 #   $complex_format_map{$complex_format}->{'end'} = "</$complex_format>";
 
-#xml_menu_description
-#    return "<menucomment>$text</menucomment>\n</menuentry>";
-
-#sub xml_menu_link($$$$$$$$$$)
-#    return 
"<menuentry>\n<menunode>$menunode_normalized</menunode>\n<menutitle>$menutitle</menutitle>\n";
-
 #xml_index_entry_label
 #    return "<indexterm 
index=\"${index_name}\">${formatted_entry_reference}</indexterm>";
 

Index: t/30sectioning.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/30sectioning.t,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- t/30sectioning.t    30 Aug 2011 22:26:46 -0000      1.52
+++ t/30sectioning.t    31 Aug 2011 22:54:51 -0000      1.53
@@ -1483,8 +1483,8 @@
 'top_part_chapter', 'section_before_top_no_node', 
 'section_chapter_before_top', 'sectioning_part_appendix');
 foreach my $test (@test_cases) {
-#  push @{$test->[2]->{'test_formats'}}, 'xml' 
-#    if (grep {$_ eq $test->[0]} @xml_tests_cases_tests);
+  push @{$test->[2]->{'test_formats'}}, 'xml' 
+    if (grep {$_ eq $test->[0]} @xml_tests_cases_tests);
 }
 
 our ($arg_test_case, $arg_generate, $arg_debug);

Index: t/results/coverage_braces/test_image.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/coverage_braces/test_image.pl,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- t/results/coverage_braces/test_image.pl     19 Aug 2011 23:09:38 -0000      
1.9
+++ t/results/coverage_braces/test_image.pl     31 Aug 2011 22:54:51 -0000      
1.10
@@ -4298,8 +4298,7 @@
 <!-- Text in copying.
 address@hidden  a@<"%@  < & @ % " 
 
-In text address@hidden  a@<"%@  < & @ % " .
- -->
+In text address@hidden  a@<"%@  < & @ % " . -->
 <!-- Created by texi2html, http://www.gnu.org/software/texinfo/ -->
 <head>
 <title>Untitled Document</title>

Index: t/results/regions/anchor_in_copying.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/regions/anchor_in_copying.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- t/results/regions/anchor_in_copying.pl      19 Aug 2011 23:09:44 -0000      
1.8
+++ t/results/regions/anchor_in_copying.pl      31 Aug 2011 22:54:52 -0000      
1.9
@@ -444,7 +444,6 @@
 <html>
 <!-- 
 Copying.
-
  -->
 <!-- Created by texi2html, http://www.gnu.org/software/texinfo/ -->
 <head>

Index: t/results/regions/anchor_in_copying_in_footnote.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/regions/anchor_in_copying_in_footnote.pl,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- t/results/regions/anchor_in_copying_in_footnote.pl  19 Aug 2011 23:09:44 
-0000      1.9
+++ t/results/regions/anchor_in_copying_in_footnote.pl  31 Aug 2011 22:54:52 
-0000      1.10
@@ -494,7 +494,6 @@
 <html>
 <!-- 
 Copying.
-
  -->
 <!-- Created by texi2html, http://www.gnu.org/software/texinfo/ -->
 <head>

Index: t/results/sectioning/chapter_before_and_after_part.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/sectioning/chapter_before_and_after_part.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- t/results/sectioning/chapter_before_and_after_part.pl       9 Jul 2011 
06:35:41 -0000       1.8
+++ t/results/sectioning/chapter_before_and_after_part.pl       31 Aug 2011 
22:54:52 -0000      1.9
@@ -331,4 +331,18 @@
   Up: @chapter chapter 2
 ';
 
+
+$result_converted{'xml'}->{'chapter_before_and_after_part'} = '<chapter>
+<title>chapter</title>
+
+</chapter>
+<part>
+<title>part</title>
+
+<chapter>
+<title>chapter 2</title>
+</chapter>
+</part>
+';
+
 1;

Index: t/results/sectioning/part_before_section.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/sectioning/part_before_section.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- t/results/sectioning/part_before_section.pl 3 Jul 2011 15:19:37 -0000       
1.8
+++ t/results/sectioning/part_before_section.pl 31 Aug 2011 22:54:52 -0000      
1.9
@@ -224,4 +224,14 @@
   Up: @section section
 ';
 
+
+$result_converted{'xml'}->{'part_before_section'} = '<part>
+<title>part</title>
+
+<chapter originalcommand="section">
+<title>section</title>
+</chapter>
+</part>
+';
+
 1;

Index: t/results/sectioning/section_before_chapter.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/sectioning/section_before_chapter.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- t/results/sectioning/section_before_chapter.pl      9 Jul 2011 06:35:42 
-0000       1.6
+++ t/results/sectioning/section_before_chapter.pl      31 Aug 2011 22:54:52 
-0000      1.7
@@ -177,4 +177,14 @@
 ];
 
 
+
+$result_converted{'xml'}->{'section_before_chapter'} = '<section>
+<title>section</title>
+
+</section>
+<section originalcommand="chapter">
+<title>chapter</title>
+</section>
+';
+
 1;

Index: t/results/sectioning/section_before_top_no_node.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/sectioning/section_before_top_no_node.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- t/results/sectioning/section_before_top_no_node.pl  9 Jul 2011 06:35:42 
-0000       1.6
+++ t/results/sectioning/section_before_top_no_node.pl  31 Aug 2011 22:54:52 
-0000      1.7
@@ -175,4 +175,14 @@
 ];
 
 
+
+$result_converted{'xml'}->{'section_before_top_no_node'} = '<section>
+<title>section</title>
+
+</section>
+<unnumberedsec originalcommand="top">
+<title>top</title>
+</unnumberedsec>
+';
+
 1;

Index: t/results/sectioning/section_chapter_before_top.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/sectioning/section_chapter_before_top.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- t/results/sectioning/section_chapter_before_top.pl  9 Jul 2011 06:35:42 
-0000       1.6
+++ t/results/sectioning/section_chapter_before_top.pl  31 Aug 2011 22:54:52 
-0000      1.7
@@ -259,4 +259,18 @@
 ];
 
 
+
+$result_converted{'xml'}->{'section_chapter_before_top'} = '<section>
+<title>section</title>
+
+</section>
+<section originalcommand="chapter">
+<title>chapter</title>
+
+</section>
+<unnumberedsec originalcommand="top">
+<title>top</title>
+</unnumberedsec>
+';
+
 1;

Index: t/results/sectioning/sectioning_part_appendix.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/sectioning/sectioning_part_appendix.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- t/results/sectioning/sectioning_part_appendix.pl    30 Aug 2011 22:26:46 
-0000      1.1
+++ t/results/sectioning/sectioning_part_appendix.pl    31 Aug 2011 22:54:52 
-0000      1.2
@@ -834,4 +834,50 @@
 $result_errors{'sectioning_part_appendix'} = [];
 
 
+
+$result_converted{'xml'}->{'sectioning_part_appendix'} = '<top>
+<title>top</title>
+
+</top>
+<chapter>
+<title>chapter</title>
+
+<section>
+<title>section</title>
+
+<subsection>
+<title>subsection</title>
+
+<subsubsection>
+<title>subsubsection</title>
+
+</subsubsection>
+</subsection>
+</section>
+</chapter>
+<part>
+<title>part</title>
+
+<chapter>
+<title>chapter in part</title>
+
+</chapter>
+<chapter>
+<title>second chapter in part</title>
+
+</chapter>
+<unnumbered>
+<title>unnumbered</title>
+
+</unnumbered>
+<appendix>
+<title>appendix</title>
+
+<appendixsec>
+<title>appendixsec</title>
+</appendixsec>
+</appendix>
+</part>
+';
+
 1;

Index: t/results/sectioning/top_part_chapter.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/sectioning/top_part_chapter.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- t/results/sectioning/top_part_chapter.pl    9 Jul 2011 06:35:43 -0000       
1.2
+++ t/results/sectioning/top_part_chapter.pl    31 Aug 2011 22:54:52 -0000      
1.3
@@ -333,4 +333,18 @@
   Up: @chapter chapter
 ';
 
+
+$result_converted{'xml'}->{'top_part_chapter'} = '<top>
+<title>top</title>
+
+</top>
+<part>
+<title>part</title>
+
+<chapter>
+<title>chapter</title>
+</chapter>
+</part>
+';
+
 1;



reply via email to

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