[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7535] changes to match XSParagraph
From: |
gavinsmith0123 |
Subject: |
[7535] changes to match XSParagraph |
Date: |
Sat, 3 Dec 2016 16:50:32 +0000 (UTC) |
Revision: 7535
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7535
Author: gavin
Date: 2016-12-03 16:50:32 +0000 (Sat, 03 Dec 2016)
Log Message:
-----------
changes to match XSParagraph
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/Convert/ParagraphNonXS.pm
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2016-11-26 15:35:28 UTC (rev 7534)
+++ trunk/ChangeLog 2016-12-03 16:50:32 UTC (rev 7535)
@@ -1,3 +1,20 @@
+2016-12-03 Gavin Smith <address@hidden>
+
+ * tp/Texinfo/Convert/ParagraphNonXS.pm
+ (add_text): Do not remove end-of-sentence flag here, as adding
+ more spaces later on would cancel the doubled space.
+ When adding spaces, leave existing spaces untouched.
+ Do not handle end-of-sentence disinhibition in this
+ function, as it is dealt with in '_add_next'.
+ Use 'last_char' value from before calling '_add_next' to
+ decide whether we've reached the end of a sentence, along with a
+ different regular expression.
+ (_add_next): Remove any backspace marker characters, not just
+ the last one.
+
+ These changes are intended to match the implementation under
+ tp/Texinfo/Convert/XSParagraph.
+
2016-11-26 Gavin Smith <address@hidden>
* tp/Texinfo/Structuring.pm (_do_index_keys, do_index_keys):
Modified: trunk/tp/Texinfo/Convert/ParagraphNonXS.pm
===================================================================
--- trunk/tp/Texinfo/Convert/ParagraphNonXS.pm 2016-11-26 15:35:28 UTC (rev
7534)
+++ trunk/tp/Texinfo/Convert/ParagraphNonXS.pm 2016-12-03 16:50:32 UTC (rev
7535)
@@ -180,7 +180,7 @@
return _add_next($paragraph, $word, $transparent);
}
-# add a word
+# add a word (without wrapping).
sub _add_next($;$$$)
{
my $paragraph = shift;
@@ -191,10 +191,12 @@
if (defined($word)) {
my $disinhibit = 0;
- # Reverse the insertion of the control character in Plaintext.pm.
- if ($word =~ s/\x08$//) {
+ # Reverse the insertion of any control characters in Plaintext.pm.
+ if ($word =~ /\x08$/) {
$disinhibit = 1;
}
+ $word =~ s/\x08//g;
+
if (!defined($paragraph->{'word'})) {
$paragraph->{'word'} = '';
$paragraph->{'last_char'} = '';
@@ -374,7 +376,6 @@
$all_spaces =~ s/[\n\r]/ /g;
$all_spaces .= ' ' x (2 - length($all_spaces));
$paragraph->{'space'} = $all_spaces;
- delete $paragraph->{'end_sentence'};
} else {
# if there is only one space, we let it accumulate
my $new_space = $spaces;
@@ -382,10 +383,13 @@
$paragraph->{'space'} = $new_space;
}
} else {
- $paragraph->{'space'} = substr($spaces, 0, 1);
- if ($paragraph->{'space'} eq "\n"
- or $paragraph->{'space'} eq "\r") {
- $paragraph->{'space'} = " ";
+ # Only save the first space
+ if (length($paragraph->{'space'}) < 1) {
+ $paragraph->{'space'} = substr($spaces, 0, 1);
+ if ($paragraph->{'space'} eq "\n"
+ or $paragraph->{'space'} eq "\r") {
+ $paragraph->{'space'} = " ";
+ }
}
}
}
@@ -402,14 +406,10 @@
$result .= _end_line($paragraph);
}
} elsif (defined $added_word) {
- # Whether a sentence end is permitted in spite of a preceding
- # upper case letter.
- my $disinhibit = 0;
-
- # Reverse the insertion of the control character in Plaintext.pm.
- if ($added_word =~ s/\x08(?=[$end_sentence_character]
- [$after_punctuation_characters]*$)//x) {
- $disinhibit = 1;
+ my $tmp = $added_word;
+ if (defined $paragraph->{'last_char'}) {
+ # Use 'last_char' here because _add_next overwrites it.
+ $tmp = $paragraph->{'last_char'} . $tmp;
}
$result .= _add_next($paragraph, $added_word, undef,
@@ -421,11 +421,10 @@
if (defined($paragraph->{'end_sentence'})
and $added_word =~ /^[$after_punctuation_characters]*$/o) {
# do nothing in the case of a continuation of
after_punctuation_characters
- } elsif (($disinhibit
- or !$paragraph->{'last_char'}
- or $paragraph->{'last_char'} !~ /[[:upper:]]/)
- and $added_word =~ /[$end_sentence_character]
- [$after_punctuation_characters]*$/x) {
+ } elsif ($tmp =~
+ /(^|[^[:upper:]$after_punctuation_characters$end_sentence_character])
+ [$after_punctuation_characters]*[$end_sentence_character]
+ [$end_sentence_character\x08$after_punctuation_characters]*$/x) {
if ($paragraph->{'frenchspacing'}) {
$paragraph->{'end_sentence'} = -1;
} else {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7535] changes to match XSParagraph,
gavinsmith0123 <=