latexdiff icon indicating copy to clipboard operation
latexdiff copied to clipboard

More issues with brat_n / pat_n

Open jprotze opened this issue 8 years ago • 3 comments

Closer testing after PR #120 showed that also the brat_n pattern has issues: I think, when reading the string, a backslash escapes the following backslash. Only if there is no character, that needs escaping, the backslash is read as backslash.

The regexp to match '[' is m/\[/. For the regexp, both backslash and bracket need to be escaped. When assigning $p='\[', the result in $p is actually '\['. The first backslash escapes the second, the third has nothing to escape, so character.

The regex, as currently in the script is parsed to "\[|\]" and matches backslash followed by pipe or backslash.

$pat_n = '\\\[|\\\]';
print "pat_n=".$pat_n."\n";
test('\[');
test('\|');
test('\\\\');

Attached the two test scripts, I used to test the patterns: brat_n.txt pat_n.txt

jprotze avatar Nov 08 '17 12:11 jprotze

The other point, that is unclear to me is, whether the intent of the patterns is to match pairs of escaped brackets or stand alone escaped brackets.

jprotze avatar Nov 08 '17 12:11 jprotze

Updating to Ubuntu 17/10 brought perl 5.26. This version of perl actually throws an error for the un-escaped {, glad that this is already fixed :D

jprotze avatar Nov 10 '17 12:11 jprotze

Is this still an issue in the github version. Your last comment seems to indicate it is solved and can be closed?
The point of pat_n pattern is to match any text containing matching (unquoted) {} pairs including nesting, or text containing no parentheses. It should ignore escaped {, }, i.e. treat them identically to any other character.

ftilmann avatar May 13 '18 11:05 ftilmann