Hello,
One of the patches was uploaded. The other one (\n preceded by an even
number of \) is more complicated.
This issue appears in unescape_text (\\n is not tranlated to an end of
line, which causes formatting issues) and in quote_text (in no-wrap mode,
no newline is added after a \\n, but I think it has no implication on the
output document).
There may also be the same issue in unquote_text, but I could not find a
way to trigger it.
My solution is maybe too complicated:
+ # unescape newlines
+ # NOTE on \G:
+ # The following regular expression introduce newlines.
+ # Thus, ^ doesn't match all beginnings of lines.
+ # \G is a zero-width assertion that matches the position
+ # of the previous substitution with s///g. As every
+ # substitution ends by a newline, it always matches a
+ # position just after a newline.
+ $text =~ s/( # $1:
+ (\G|[^\\]) # beginning of the line or any char
+ # different from '\'
+ (\\\\)* # followed by any even number of '\'
+ )\\n # and followed by an escaped newline
+ /$1\n/sgx; # single string, match globally, allow comments
+ # unescape tabulations
+ $text =~ s/( # $1:
+ (^|[^\\]) # beginning of the line or any char
+ # different from '\'
+ (\\\\)* # followed by any even number of '\'
+ )\\t # and followed by an escaped tabulation
+ /$1\t/mgx; # multilines string, match globally, allow comments
Do you have another idea to avoid using (and documenting) \G?
In canonize, I don't thing it is needed to protect \n against a preceding \,
and I'm wondering if
$text =~ s/([^\\])\n/$1 /gm;
$text =~ s/ \n/ /gm;
$text =~ s/([^\\])\n/$1 /gm;
should not simply be changed to:
$text =~ s/\n/ /gm if ($text ne "\n");
(do not do anything if ($text eq "\n"), because it mess up the first
string - the header)
Regards,
--
Nekral