Author: felipe.sanches
Description:
This is related to enhancement bug 8954: Visual coloured math diffs.
Here, I propose a framework for a visually rich diff engine that would treat bug
8954(enh) as a particular case.
Each extension, or code that implements parsing of a particular tag (such as
<math> in the bug 8954 particular case) should register a regular expression and
a highlighter callback. If these are not registered, then the default ones would
be used.
Currently, the default regex is '/ ( [^\S\n]+ | [0-9_A-Za-z\x80-\xff]+ | . ) (?:
(?!< \n) [^\S\n])? /xs' and the default highlighter function would be:
function default_highlighter($element){
return '<del class="diffchange">' . htmlspecialchars ( $element ) . '</del>';
}
For bug 8954 the highlighter function would be:
function default_highlighter($element){
return '{\color{red}' . $element . '}';
}
Think a bit about extensions such as WikiTeX that would use particular regexes
and highlighters for each tag implemented. This woul provide us with visual
diffs including stuff like circuit diagrams, chemestry formulas, fluxograms,
Chess & Go boards, etc.
The reason why I propose this kind of solution is because the default regex
currently used in DifferenceEngine.php is not suitable for every kind of
content. It is satisfactory for common text. But I have noticed that it is not
necessarily suitable for syntax dependent stuff (such as LaTeX, for example)
since the highlighted code must also match the syntax. The regex must split the
input into elements that could be safely applied to the highlighter function
producing a result that is also compliant to the syntax.
Version: 1.10.x
Severity: enhancement
OS: Linux
Platform: PC