Last modified: 2013-03-14 16:33:03 UTC
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.
How would this work with extensions such as wikidiff and wikidiff2?
If I got it right, wikidiff is an external diff engine, right? So, here we have 2 options: # when using an external diff engine you won't have visual diffs, or # implement something similar on the alternative external diff engine. different diff engines => different features, right?
Different diff engines = same algorithm rewritten in C++ for speed, at least for wikidiff2 (diffs were very slow at one point, now they're a few ms). It would probably be kind of difficult to hook PHP functions into that, and for that matter I assume linking C++ functions into it would require a recompile, so making this accessible to extensions at least would be tricky for the wikidiffs (although they could still work with core features). The extensions are at these URLs respectively: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/wikidiff/ http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/wikidiff2/