texinfo-commits
[Top][All Lists]
Advanced

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

[5278] * tp/Texinfo/Convert/TexinfoXML.pm(_xml_attributes),


From: Patrice Dumas
Subject: [5278] * tp/Texinfo/Convert/TexinfoXML.pm(_xml_attributes),
Date: Tue, 06 Aug 2013 20:52:38 +0000

Revision: 5278
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5278
Author:   pertusus
Date:     2013-08-06 20:52:37 +0000 (Tue, 06 Aug 2013)
Log Message:
-----------
        * tp/Texinfo/Convert/TexinfoXML.pm(_xml_attributes),
        util/texinfo.dtd, util/txixml2texi.pl: protect form-feed in
        attributes by using an entity that becomes a literal \f. 
        Double \ in attributes too.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tp/Texinfo/Convert/TexinfoXML.pm
    trunk/tp/t/50value.t
    trunk/tp/t/results/value/set_form_feed.pl
    trunk/util/texinfo.dtd
    trunk/util/txixml2texi.pl

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2013-08-06 19:55:47 UTC (rev 5277)
+++ trunk/ChangeLog     2013-08-06 20:52:37 UTC (rev 5278)
@@ -5,6 +5,10 @@
        tp/Texinfo/Convert/TexinfoXML.pm(_protect_text): output form-feed
        as entity in XML, when possible.  Handle form-feeds in 
        txixml2texi.pl too.
+       * tp/Texinfo/Convert/TexinfoXML.pm(_xml_attributes),
+       util/texinfo.dtd, util/txixml2texi.pl: protect form-feed in
+       attributes by using an entity that becomes a literal \f. 
+       Double \ in attributes too.
 
 2013-08-06  Karl Berry  <address@hidden>
 

Modified: trunk/tp/Texinfo/Convert/TexinfoXML.pm
===================================================================
--- trunk/tp/Texinfo/Convert/TexinfoXML.pm      2013-08-06 19:55:47 UTC (rev 
5277)
+++ trunk/tp/Texinfo/Convert/TexinfoXML.pm      2013-08-06 20:52:37 UTC (rev 
5278)
@@ -153,10 +153,17 @@
   }
   my $result = '';
   for (my $i = 0; $i < scalar(@$attributes); $i += 2) {
+    # this cannot be used, because of formfeed, as in 
+    # attribute < which is substituted from &formfeed; is not allowed
+    #my $text = $self->_protect_text($attributes->[$i+1]);
     my $text = $self->xml_protect_text($attributes->[$i+1]);
     # in fact form feed is not allowed at all in XML, even protected
-    # but there isn't much else to do
-    $text =~ s/\f/&#12;/g;
+    # and even in xml 1.1 in contrast to what is said on internet.
+    # maybe this is a limitation of libxml?
+    #$text =~ s/\f/&#12;/g;
+    $text =~ s/\f/&attrformfeed;/g;
+    # &attrformfeed; resolves to \f so \ are doubled
+    $text =~ s/\\/\\\\/g;
     $result .= " $attributes->[$i]=\"".$text."\"";
   }
   return $result;

Modified: trunk/tp/t/50value.t
===================================================================
--- trunk/tp/t/50value.t        2013-08-06 19:55:47 UTC (rev 5277)
+++ trunk/tp/t/50value.t        2013-08-06 20:52:37 UTC (rev 5278)
@@ -334,7 +334,7 @@
 @end table
 '],
 ['set_form_feed',
-'@set gg  aa
+'@set gg  a\\a\\f\\\\
 @set hh
 @set ll 
 

Modified: trunk/tp/t/results/value/set_form_feed.pl
===================================================================
--- trunk/tp/t/results/value/set_form_feed.pl   2013-08-06 19:55:47 UTC (rev 
5277)
+++ trunk/tp/t/results/value/set_form_feed.pl   2013-08-06 20:52:37 UTC (rev 
5278)
@@ -16,17 +16,17 @@
         },
         {
           'parent' => {},
-          'text' => ' aa',
+          'text' => ' a\\a\\f\\\\',
           'type' => 'misc_arg'
         }
       ],
       'cmdname' => 'set',
       'extra' => {
-        'arg_line' => ' gg  aa
+        'arg_line' => ' gg  a\\a\\f\\\\
 ',
         'misc_args' => [
           'gg',
-          ' aa'
+          ' a\\a\\f\\\\'
         ]
       },
       'parent' => {}
@@ -77,7 +77,7 @@
               'contents' => [
                 {
                   'parent' => {},
-                  'text' => ' aa. '
+                  'text' => ' a\\a\\f\\\\. '
                 },
                 {
                   'cmdname' => 'value',
@@ -128,16 +128,16 @@
 $result_trees{'set_form_feed'}{'contents'}[4]{'contents'}[1]{'parent'} = 
$result_trees{'set_form_feed'}{'contents'}[4];
 $result_trees{'set_form_feed'}{'contents'}[4]{'parent'} = 
$result_trees{'set_form_feed'};
 
-$result_texis{'set_form_feed'} = '@set gg  aa
+$result_texis{'set_form_feed'} = '@set gg  a\\a\\f\\\\
 @set hh
 @set ll 
 
address@hidden aa. @value{hh}. }.
address@hidden a\\a\\f\\\\. @value{hh}. }.
 ';
 
 
 $result_texts{'set_form_feed'} = '
- aa. . .
+ a\\a\\f\\\\. . .
 ';
 
 $result_errors{'set_form_feed'} = [
@@ -163,11 +163,11 @@
 
 
 
-$result_converted{'xml'}->{'set_form_feed'} = '<set name="gg" line=" gg &#12; 
aa">&formfeed; aa</set>
-<set line=" hh&#12;"></set>
-<set name="ll" line=" ll &#12;">&formfeed;</set>
+$result_converted{'xml'}->{'set_form_feed'} = '<set name="gg" line=" gg 
&attrformfeed; a\\\\a\\\\f\\\\\\\\">&formfeed; a\\a\\f\\\\</set>
+<set line=" hh&attrformfeed;"></set>
+<set name="ll" line=" ll &attrformfeed;">&formfeed;</set>
 
-<para><code>&formfeed; aa. . &formfeed;</code>.
+<para><code>&formfeed; a\\a\\f\\\\. . &formfeed;</code>.
 </para>';
 
 1;

Modified: trunk/util/texinfo.dtd
===================================================================
--- trunk/util/texinfo.dtd      2013-08-06 19:55:47 UTC (rev 5277)
+++ trunk/util/texinfo.dtd      2013-08-06 20:52:37 UTC (rev 5278)
@@ -1254,6 +1254,7 @@
 <!ENTITY textmdash      "&#x2014;">
 <!ENTITY textndash      "&#x2013;">
 <!ENTITY formfeed       "<formfeed/>">
+<!ENTITY attrformfeed   "\f">
 <!ENTITY period     "<punct end-of-sentence='no'>.</punct>">
 <!ENTITY eosperiod  "<punct end-of-sentence='yes'>.</punct>">
 <!ENTITY quest      "<punct end-of-sentence='no'>?</punct>">

Modified: trunk/util/txixml2texi.pl
===================================================================
--- trunk/util/txixml2texi.pl   2013-08-06 19:55:47 UTC (rev 5277)
+++ trunk/util/txixml2texi.pl   2013-08-06 20:52:37 UTC (rev 5278)
@@ -121,6 +121,9 @@
   'textrsquo' => "'",
   'textlsquo' => '`',
   'formfeed' => "\f",
+  # this is not used in pratice, as attrformfeed appears in an 
+  # attribute and thus is already expanded to text.
+  'attrformfeed' => "\f",
 );
 
 foreach my $command (keys(%Texinfo::Convert::TexinfoXML::commands_formatting)) 
{
@@ -301,7 +304,11 @@
       }
       print "address@hidden";
       if ($reader->hasAttributes() and defined($reader->getAttribute('line'))) 
{
-        print $reader->getAttribute('line');
+        my $line = $reader->getAttribute('line');
+        $line =~ s/\\\\/\x{1F}/g;
+        $line =~ s/\\f/\f/g;
+        $line =~ s/\x{1F}/\\/g;
+        print $line;
       }
       if ($name eq 'set' or $name eq 'clickstyle') {
         skip_until_end($reader, $name);




reply via email to

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