dpvc/pg — pull request #7 by dpvc (2014-10-05 17:45:21+00:00)
Title: Fix general_math_ev3 so that it doesn't escape % when it is already is

The `general_math_ev3` function manipulates the TeX string that it receives, and (among other things), it puts backslashes in front of percent signs. This "fixes up" bad TeX entered by problem authors, but it also messes up good TeX created by MathObjects.

This patch prevents the escaping of `%` when it already is escaped (i.e. is preceded by an even, possibly 0, number of backslashes).

A test case for this is:

```
DOCUMENT();

loadMacros(
"PGstandard.pl",
"PGML.pl",
);

BEGIN_PGML
[`10%`] and [`10\%`]
END_PGML

BEGIN_TEXT
\(10%\) and \(10\%\)
END_TEXT

ENDDOCUMENT();
```

Without the patch, it will produce two copies of `10% and 10`, and with the patch, it should be two copies of `10% and 10%`.

My own feeling is that the code that puts out the proper math for the current displayMode should be factored out so that it can be called *without* having such modifications made to it. Math that is already properly formatted may be damaged (as in the case of the percent), and currently there is no way to avoid this (other than to modify the math so that it doesn't match the patterns). There should be a way to get math output that is unmodified.