[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5283] * tp/Texinfo/Convert/Plaintext.pm: output ^L in ignorable
From: |
Patrice Dumas |
Subject: |
[5283] * tp/Texinfo/Convert/Plaintext.pm: output ^L in ignorable |
Date: |
Wed, 07 Aug 2013 22:53:19 +0000 |
Revision: 5283
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5283
Author: pertusus
Date: 2013-08-07 22:53:18 +0000 (Wed, 07 Aug 2013)
Log Message:
-----------
* tp/Texinfo/Convert/Plaintext.pm: output ^L in ignorable
spaces.
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/DebugTexinfo/DebugCount.pm
trunk/tp/Texinfo/Common.pm
trunk/tp/Texinfo/Convert/Plaintext.pm
trunk/tp/t/results/coverage_braces/form_feed_in_brace_commands.pl
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2013-08-07 18:59:06 UTC (rev 5282)
+++ trunk/ChangeLog 2013-08-07 22:53:18 UTC (rev 5283)
@@ -1,3 +1,8 @@
+2013-08-08 Patrice Dumas <address@hidden>
+
+ * tp/Texinfo/Convert/Plaintext.pm: output ^L in ignorable
+ spaces.
+
2013-08-07 Patrice Dumas <address@hidden>
* tp/Texinfo/Convert/HTML.pm(_default_protect_text),
Modified: trunk/tp/DebugTexinfo/DebugCount.pm
===================================================================
--- trunk/tp/DebugTexinfo/DebugCount.pm 2013-08-07 18:59:06 UTC (rev 5282)
+++ trunk/tp/DebugTexinfo/DebugCount.pm 2013-08-07 22:53:18 UTC (rev 5283)
@@ -43,6 +43,7 @@
$command_type .= ":text";
my $text = $root->{'text'};
$text =~ s/\n/\\n/g;
+ $text =~ s/\f/\\f/g;
$command_type .= "|$text|";
}
my $string_before = ' ' x $self->{'level'}. "$command_nr $number_before
$command_type\n";
Modified: trunk/tp/Texinfo/Common.pm
===================================================================
--- trunk/tp/Texinfo/Common.pm 2013-08-07 18:59:06 UTC (rev 5282)
+++ trunk/tp/Texinfo/Common.pm 2013-08-07 22:53:18 UTC (rev 5283)
@@ -1587,6 +1587,11 @@
return length(Encode::encode($encoding, $string));
} else {
return length($string);
+ #my $length = length($string);
+ #$string =~ s/\n/\\n/g;
+ #$string =~ s/\f/\\f/g;
+ #print STDERR "Count($length): $string\n";
+ #return $length;
}
# FIXME is the following required for correct count of end of lines?
#if ($encoding) {
Modified: trunk/tp/Texinfo/Convert/Plaintext.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Plaintext.pm 2013-08-07 18:59:06 UTC (rev
5282)
+++ trunk/tp/Texinfo/Convert/Plaintext.pm 2013-08-07 22:53:18 UTC (rev
5283)
@@ -229,17 +229,26 @@
'var' => 1
);
-my %ignored_types;
-foreach my $type ('empty_line_after_command', 'preamble',
- 'preamble_before_setfilename',
+my %ignorable_space_types;
+foreach my $type ('empty_line_after_command',
'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;
+ $ignorable_space_types{$type} = 1;
+}
+
+my %ignored_types;
+foreach my $type ('preamble',
+ 'preamble_before_setfilename') {
$ignored_types{$type} = 1;
}
+my %ignorable_types = %ignorable_space_types;
+foreach my $ignored_type(keys(%ignored_types)) {
+ $ignorable_types{$ignored_type} = 1;
+}
+
# All those commands run with the text.
my %style_map = (
'strong' => '*',
@@ -350,6 +359,7 @@
'locations' => []};
%{$self->{'ignored_types'}} = %ignored_types;
+ %{$self->{'ignorable_space_types'}} = %ignorable_space_types;
%{$self->{'ignored_commands'}} = %ignored_commands;
# this is dynamic because raw formats may either be full commands if
# isolated, or simple text if in a paragraph
@@ -1434,6 +1444,14 @@
return ('', 0);
}
+sub _get_form_feeds($)
+{
+ my $form_feeds = shift;
+ $form_feeds =~ s/^[^\f]*//;
+ $form_feeds =~ s/[^\f]$//;
+ return $form_feeds;
+}
+
sub _convert($$);
sub _convert($$)
@@ -1472,9 +1490,7 @@
}
}
- if (($root->{'type'} and $self->{'ignored_types'}->{$root->{'type'}}
- and ($root->{'type'} ne 'empty_spaces_before_paragraph'
- or $self->get_conf('paragraphindent') ne 'asis'))
+ if (($root->{'type'} and $self->{'ignored_types'}->{$root->{'type'}})
or ($root->{'cmdname'}
and ($self->{'ignored_commands'}->{$root->{'cmdname'}}
or ($inline_format_commands{$root->{'cmdname'}}
@@ -1485,6 +1501,18 @@
}
my $result = '';
+ # in ignorable spaces, keep only form feeds.
+ if ($root->{'type'} and $self->{'ignorable_space_types'}->{$root->{'type'}}
+ and ($root->{'type'} ne 'empty_spaces_before_paragraph'
+ or $self->get_conf('paragraphindent') ne 'asis')) {
+ if ($root->{'text'} =~ /\f/) {
+ $result = _get_form_feeds($root->{'text'});
+ }
+ $self->_add_text_count($result);
+ print STDERR "IGNORABLE SPACE: ($result)\n" if ($self->{'debug'});
+ return $result;
+ }
+
# First handle empty lines. This has to be done before the handling
# of text below to be sure that an empty line is always processed
# especially
@@ -1501,10 +1529,7 @@
or
$self->{'preformatted_context_commands'}->{$self->{'context'}->[-1]}) {
$result = "\n";
if ($root->{'text'} =~ /\f/) {
- my $form_feeds = $root->{'text'};
- $form_feeds =~ s/^[^\f]*//;
- $form_feeds =~ s/[^\f]$//;
- $result = $form_feeds .$result;
+ $result = _get_form_feeds($root->{'text'}) .$result;
}
$self->_add_text_count($result);
$self->_add_lines_count(1);
@@ -1571,7 +1596,7 @@
foreach my $following_content (@$parent_content) {
unless (($following_content->{'type'}
and ($following_content->{'type'} eq 'empty_line'
- or $ignored_types{$following_content->{'type'}}))
+ or $ignorable_types{$following_content->{'type'}}))
or ($following_content->{'cmdname'}
and ($following_content->{'cmdname'} eq 'c'
or $following_content->{'cmdname'} eq 'comment'))) {
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-07 18:59:06 UTC (rev 5282)
+++ trunk/tp/t/results/coverage_braces/form_feed_in_brace_commands.pl
2013-08-07 22:53:18 UTC (rev 5283)
@@ -310,9 +310,9 @@
---------- Footnotes ----------
- (1) f1
+ (1) f1
- (2) gg
+ (2) gg
jj
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5283] * tp/Texinfo/Convert/Plaintext.pm: output ^L in ignorable,
Patrice Dumas <=