[Po4a-commits] "po4a/lib/Locale/Po4a TeX.pm,1.84,1.85"
Nicolas FRANCOIS
nekral-guest at alioth.debian.org
Mon May 15 15:56:33 UTC 2006
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv10531/lib/Locale/Po4a
Modified Files:
TeX.pm
Log Message:
Use variables to match the comments.
This will ease writing the Texinfo module.
Index: TeX.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/TeX.pm,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- TeX.pm 15 May 2006 15:53:59 -0000 1.84
+++ TeX.pm 15 May 2006 15:56:31 -0000 1.85
@@ -103,6 +103,10 @@
our $ESCAPE = "\\";
# match the beginning of a verbatim block
our $RE_VERBATIM = "\\\\begin\\{(?:verbatim)\\*?\\}";
+# match the beginning of a comment.
+# NOTE: It must contain a group, with chars preceding the comment
+our $RE_PRE_COMMENT= "(?<!\\\\)(?:\\\\\\\\)*";
+our $RE_COMMENT= "\\\%";
# Space separated list of environments that should not be re-wrapped.
our $no_wrap_environments = "verbatim";
@@ -681,10 +685,10 @@
# remove comments from the buffer.
# Comments are stored in an array and shown as comments in the PO.
- while ($buffer =~ m/((?<!\\)(?:\\\\)*)%([^\n]*)(\n[ \t]*)(.*)$/s) {
+ while ($buffer =~ m/($RE_PRE_COMMENT)$RE_COMMENT([^\n]*)(\n[ \t]*)(.*)$/s) {
my $comment = $2;
my $end = "";
- if ($4 =~ m/^\n/s and $buffer !~ m/^%/s) {
+ if ($4 =~ m/^\n/s and $buffer !~ m/^$RE_COMMENT/s) {
# a line with comments, followed by an empty line.
# Keep the empty line, but remove the comment.
# This is an empirical heuristic, but seems to work;)
@@ -693,7 +697,7 @@
if (defined $comment and $comment !~ /^\s*$/s) {
push @comments, $comment;
}
- $buffer =~ s/((?<!\\)(?:\\\\)*)%([^\n]*)(\n[ \t]*)/$1$end/s;
+ $buffer =~ s/($RE_PRE_COMMENT)$RE_COMMENT([^\n]*)(\n[ \t]*)/$1$end/s;
}
@@ -1071,14 +1075,14 @@
my $opening = 0;
# FIXME: { and } should not be counted in verbatim blocks
# Remove comments
- $tmp =~ s/(?<!\\)(?:\\\\)*%.*//mg;
+ $tmp =~ s/($RE_PRE_COMMENT)$RE_COMMENT.*//mg;
while ($tmp =~ /^.*?(?<!\\)(?:\\\\)*\{(.*)$/s) {
$opening += 1;
$tmp = $1;
}
$tmp = $paragraph;
# Remove comments
- $tmp =~ s/(?<!\\)(?:\\\\)*%.*//mg;
+ $tmp =~ s/($RE_PRE_COMMENT)$RE_COMMENT.*//mg;
while ($tmp =~ /^.*?(?<!\\)(?:\\\\)*\}(.*)$/s) {
$closing += 1;
$tmp = $1;
More information about the Po4a-commits
mailing list