[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5277] * util/texinfo.dtd, util/txixml2texi.pl,
From: |
Patrice Dumas |
Subject: |
[5277] * util/texinfo.dtd, util/txixml2texi.pl, |
Date: |
Tue, 06 Aug 2013 19:55:48 +0000 |
Revision: 5277
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5277
Author: pertusus
Date: 2013-08-06 19:55:47 +0000 (Tue, 06 Aug 2013)
Log Message:
-----------
* util/texinfo.dtd, util/txixml2texi.pl,
tp/Texinfo/Convert/TexinfoXML.pm(_protect_text): output form-feed
as entity in XML, when possible. Handle form-feeds in
txixml2texi.pl too.
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/Convert/TexinfoXML.pm
trunk/tp/t/03coverage_braces.t
trunk/tp/t/50value.t
trunk/tp/t/results/coverage_braces/form_feed_in_brace_commands.pl
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 18:08:31 UTC (rev 5276)
+++ trunk/ChangeLog 2013-08-06 19:55:47 UTC (rev 5277)
@@ -1,6 +1,10 @@
2013-08-06 Patrice Dumas <address@hidden>
* Texinfo/Parser.pm: keep form-feed in @set value.
+ * util/texinfo.dtd, util/txixml2texi.pl,
+ tp/Texinfo/Convert/TexinfoXML.pm(_protect_text): output form-feed
+ as entity in XML, when possible. Handle form-feeds in
+ txixml2texi.pl too.
2013-08-06 Karl Berry <address@hidden>
Modified: trunk/tp/Texinfo/Convert/TexinfoXML.pm
===================================================================
--- trunk/tp/Texinfo/Convert/TexinfoXML.pm 2013-08-06 18:08:31 UTC (rev
5276)
+++ trunk/tp/Texinfo/Convert/TexinfoXML.pm 2013-08-06 19:55:47 UTC (rev
5277)
@@ -141,7 +141,7 @@
{
my $self = shift;
my $string = shift;
- return $self->xml_protect_text($string);
+ return $self->_protect_text($string);
}
sub _xml_attributes($$)
@@ -153,7 +153,11 @@
}
my $result = '';
for (my $i = 0; $i < scalar(@$attributes); $i += 2) {
- $result .= "
$attributes->[$i]=\"".$self->xml_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//g;
+ $result .= " $attributes->[$i]=\"".$text."\"";
}
return $result;
}
@@ -212,12 +216,22 @@
return $self->xml_comment($string);
}
+# form feed is not accepted in xml, replace it.
+sub _protect_text($$)
+{
+ my $self = shift;
+ my $text = shift;
+ my $result = $self->xml_protect_text($text);
+ $result =~ s/\f/&formfeed;/g;
+ return $result;
+}
+
# format specific
sub format_text($$)
{
my $self = shift;
my $root = shift;
- my $result = $self->xml_protect_text($root->{'text'});
+ my $result = $self->_protect_text($root->{'text'});
if (! defined($root->{'type'}) or $root->{'type'} ne 'raw') {
if (!$self->{'document_context'}->[-1]->{'monospace'}->[-1]) {
$result =~ s/``/&textldquo;/g;
@@ -550,6 +564,7 @@
{
my $text = shift;
$text =~ s/\n/\\n/g;
+ $text =~ s/\f/\\f/g;
return $text;
}
@@ -626,7 +641,7 @@
if (defined($spaces[1])) {
chomp($spaces[1]);
if ($spaces[1] ne '') {
- return ('trailingspaces', $spaces[1]);
+ return ('trailingspaces', _protect_end_of_lines($spaces[1]));
}
}
return ();
@@ -658,7 +673,7 @@
if (defined($spaces[1])) {
chomp($spaces[1]);
if ($spaces[1] ne '') {
- push @result, ('trailingspaces', $spaces[1]);
+ push @result, ('trailingspaces', _protect_end_of_lines($spaces[1]));
}
}
return @result;
Modified: trunk/tp/t/03coverage_braces.t
===================================================================
--- trunk/tp/t/03coverage_braces.t 2013-08-06 18:08:31 UTC (rev 5276)
+++ trunk/tp/t/03coverage_braces.t 2013-08-06 19:55:47 UTC (rev 5277)
@@ -242,7 +242,7 @@
['form_feed_in_brace_commands',
'@option{ aa} @anchor{aa}something @email{aaa, address@hidden
f1 } @footnote{ ggjj}.
-']
+', {'test_formats' => ['xml']}]
);
my @test_invalid = (
Modified: trunk/tp/t/50value.t
===================================================================
--- trunk/tp/t/50value.t 2013-08-06 18:08:31 UTC (rev 5276)
+++ trunk/tp/t/50value.t 2013-08-06 19:55:47 UTC (rev 5277)
@@ -339,7 +339,7 @@
@set ll
@address@hidden @value{hh}. @value{ll}}.
-']
+', {'test_formats' => ['xml']}]
);
our ($arg_test_case, $arg_generate, $arg_debug);
Modified: trunk/tp/t/results/coverage_braces/form_feed_in_brace_commands.pl
===================================================================
--- trunk/tp/t/results/coverage_braces/form_feed_in_brace_commands.pl
2013-08-06 18:08:31 UTC (rev 5276)
+++ trunk/tp/t/results/coverage_braces/form_feed_in_brace_commands.pl
2013-08-06 19:55:47 UTC (rev 5277)
@@ -300,6 +300,10 @@
+$result_converted{'xml'}->{'form_feed_in_brace_commands'} = '<para><option>
&formfeed;aa</option> <anchor
name="aa">aa</anchor></para>&formfeed;<para>something <email
spaces="\\f"><emailaddress>aaa</emailaddress><emailname spaces=" \\f
">fff</emailname></email><footnote spaces=" \\n">&formfeed; <para>f1
</para>&formfeed;</footnote> <footnote spaces=" \\f
"><para>gg</para>&formfeed;<para>jj</para></footnote>.
+</para>';
+
+
$result_converted{'plaintext'}->{'form_feed_in_brace_commands'} = '\' aa\'
something fff <aaa>(1) (2).
Modified: trunk/tp/t/results/value/set_form_feed.pl
===================================================================
--- trunk/tp/t/results/value/set_form_feed.pl 2013-08-06 18:08:31 UTC (rev
5276)
+++ trunk/tp/t/results/value/set_form_feed.pl 2013-08-06 19:55:47 UTC (rev
5277)
@@ -162,4 +162,12 @@
];
+
+$result_converted{'xml'}->{'set_form_feed'} = '<set name="gg" line=" gg 
aa">&formfeed; aa</set>
+<set line=" hh"></set>
+<set name="ll" line=" ll ">&formfeed;</set>
+
+<para><code>&formfeed; aa. . &formfeed;</code>.
+</para>';
+
1;
Modified: trunk/util/texinfo.dtd
===================================================================
--- trunk/util/texinfo.dtd 2013-08-06 18:08:31 UTC (rev 5276)
+++ trunk/util/texinfo.dtd 2013-08-06 19:55:47 UTC (rev 5277)
@@ -151,7 +151,7 @@
<!ENTITY % Inline.reference "xref | ref | pxref | inforef | email | uref |
url">
<!ENTITY % Inline.misc "click | clicksequence | logo | punct | spacecmd | today
| linebreak | accent | dotless | ctrl | inlineraw
- | inlinefmt | infoenclose">
+ | inlinefmt | infoenclose | noeos | formfeed ">
<!-- on lines -->
<!ENTITY % Inline.linetext "%Inline.emphasize; | %Inline.misc; | %Inline.fonts;
@@ -1220,6 +1220,7 @@
<!ELEMENT logo (#PCDATA)>
<!ELEMENT linebreak EMPTY>
<!ELEMENT noeos EMPTY>
+<!ELEMENT formfeed EMPTY>
<!ENTITY tex "<logo>TeX</logo>">
<!ENTITY latex "<logo>LaTeX</logo>">
@@ -1252,6 +1253,7 @@
<!ENTITY rsaquo "›">
<!ENTITY textmdash "—">
<!ENTITY textndash "–">
+<!ENTITY formfeed "<formfeed/>">
<!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 18:08:31 UTC (rev 5276)
+++ trunk/util/txixml2texi.pl 2013-08-06 19:55:47 UTC (rev 5277)
@@ -120,6 +120,7 @@
'textndash' => '--',
'textrsquo' => "'",
'textlsquo' => '`',
+ 'formfeed' => "\f",
);
foreach my $command (keys(%Texinfo::Convert::TexinfoXML::commands_formatting))
{
@@ -357,6 +358,7 @@
if (defined($reader->getAttribute('spaces'))) {
my $spaces = $reader->getAttribute('spaces');
$spaces =~ s/\\n/\n/g;
+ $spaces =~ s/\\f/\f/g;
print $spaces;
}
if (defined($reader->getAttribute('leadingtext'))) {
@@ -418,7 +420,9 @@
}
if ($reader->hasAttributes()
and defined($reader->getAttribute('trailingspaces'))) {
- print $reader->getAttribute('trailingspaces');
+ my $trailingspaces = $reader->getAttribute('trailingspaces');
+ $trailingspaces =~ s/\\f/\f/g;
+ print $trailingspaces;
}
} elsif ($reader->nodeType() eq XML_READER_TYPE_ENTITY_REFERENCE) {
if (defined($entity_texts{$name})) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5277] * util/texinfo.dtd, util/txixml2texi.pl,,
Patrice Dumas <=