texinfo-commits
[Top][All Lists]
Advanced

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

texinfo tp/Texinfo/Convert/XML.pm util/txixml2t...


From: Patrice Dumas
Subject: texinfo tp/Texinfo/Convert/XML.pm util/txixml2t...
Date: Tue, 15 Jan 2013 19:31:03 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        13/01/15 19:31:03

Modified files:
        tp/Texinfo/Convert: XML.pm 
        util           : txixml2texi.pl 

Log message:
        Use the new non XML specific cleaner interface.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Convert/XML.pm?cvsroot=texinfo&r1=1.94&r2=1.95
http://cvs.savannah.gnu.org/viewcvs/texinfo/util/txixml2texi.pl?cvsroot=texinfo&r1=1.7&r2=1.8

Patches:
Index: tp/Texinfo/Convert/XML.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Convert/XML.pm,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -b -r1.94 -r1.95
--- tp/Texinfo/Convert/XML.pm   15 Jan 2013 19:10:17 -0000      1.94
+++ tp/Texinfo/Convert/XML.pm   15 Jan 2013 19:31:02 -0000      1.95
@@ -70,6 +70,7 @@
 );
 
 
+# our because it is used in the xml to texi translator
 our %commands_formatting = (
            '*' => 'linebreak',
            ' ' => ['spacecmd', 'type', 'spc'],
@@ -114,7 +115,7 @@
 );
 
 # use default XML formatting to complete the hash, removing XML
-# specific formatting.  This avoids some duplication.
+# specific formatting.  This avoids some code duplication.
 my %default_xml_commands_formatting = 
     %{$Texinfo::Convert::Converter::default_xml_commands_formatting{'normal'}};
 
@@ -256,28 +257,6 @@
   return $header;
 }
 
-sub _format_command($$)
-{
-  my $self = shift;
-  my $command = shift;
-
-  if (! ref($commands_formatting{$command})) {
-    return $self->format_atom($command);
-  } else {
-    my @spec = @{$commands_formatting{$command}};
-    my $element_name = shift @spec;
-    return $self->element($element_name, address@hidden);
-  }
-}
-
-
-# XML specific hash.  Not used directly here, but available for other modules.
-our %xml_commands_formatting;
-foreach my $command (keys(%commands_formatting)) {
-  $xml_commands_formatting{$command} = 
Texinfo::Convert::XML->_format_command($command);
-}
-
-
 # following is not format specific.  Some infos are taken from generic XML, 
but 
 # XML specific formatting is stripped.
 
@@ -289,6 +268,7 @@
  'v' => 'caron',
 );
 
+# our because it is used in the xml to texi translator
 our %accent_types = (%Texinfo::Convert::Converter::xml_accent_entities, 
%accents);
 
 # no entity
@@ -297,9 +277,6 @@
   $accent_types{$accent} = $accent;
 }
 
-# our because it is used in the xml to texi translator
-our %xml_accent_types = %accent_types;
-
 my %misc_command_line_attributes = (
   'setfilename' => 'file',
   'documentencoding' => 'encoding',
@@ -464,6 +441,20 @@
   return $result;
 }
 
+sub _format_command($$)
+{
+  my $self = shift;
+  my $command = shift;
+
+  if (! ref($commands_formatting{$command})) {
+    return $self->format_atom($command);
+  } else {
+    my @spec = @{$commands_formatting{$command}};
+    my $element_name = shift @spec;
+    return $self->element($element_name, address@hidden);
+  }
+}
+
 sub _index_entry($$)
 {
   my $self = shift;

Index: util/txixml2texi.pl
===================================================================
RCS file: /sources/texinfo/texinfo/util/txixml2texi.pl,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- util/txixml2texi.pl 21 Nov 2012 22:48:47 -0000      1.7
+++ util/txixml2texi.pl 15 Jan 2013 19:31:02 -0000      1.8
@@ -122,24 +122,26 @@
   'textlsquo' => '`',
 );
 
-foreach my $command (keys(%Texinfo::Convert::XML::xml_commands_formatting)) {
-  my $xml_output = $Texinfo::Convert::XML::xml_commands_formatting{$command};
-  if ($xml_output =~ /^&(\w+);$/) {
-    my $entity = $1;
-    $entity_texts{$entity} = command_with_braces($command);
-    #print STDERR "$xml_output $command $1\n";
-  } elsif ($xml_output =~ /^<(\w+)/) {
-    my $element = $1;
+foreach my $command (keys(%Texinfo::Convert::XML::commands_formatting)) {
+  if (!ref($Texinfo::Convert::XML::commands_formatting{$command})) {
+    $entity_texts{$Texinfo::Convert::XML::commands_formatting{$command}}
+      = command_with_braces($command);
+  } else {
+    my $spec = $Texinfo::Convert::XML::commands_formatting{$command};
+    my $element = $spec->[0];
     if ($element eq 'spacecmd') {
-      if ($xml_output =~ /^<(\w+) type="(\w+)"/) {
-        $element_at_commands{$element}->{"type"}->{$2} 
+      if ($spec->[1] eq 'type') {
+        $element_at_commands{$element}->{"type"}->{$spec->[2]}
           = command_with_braces($command); 
+      } else {
+        die "BUG, bad spacecmd specification";
       }
     } else {
       $element_at_commands{$element} = command_with_braces($command);
     }
   }
 }
+
 $element_at_commands{'accent'} = 0;
 
 my %arg_elements;
@@ -152,8 +154,8 @@
 }
 
 my %accent_type_command;
-foreach my $accent_command (keys(%Texinfo::Convert::XML::xml_accent_types)) {
-  
$accent_type_command{$Texinfo::Convert::XML::xml_accent_types{$accent_command}} 
+foreach my $accent_command (keys(%Texinfo::Convert::XML::accent_types)) {
+  $accent_type_command{$Texinfo::Convert::XML::accent_types{$accent_command}} 
     = $accent_command;
 }
 



reply via email to

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