Updated mediawiki/extensions Project: mediawiki/extensions/VisualEditor…


Updated mediawiki/extensions Project: mediawiki/extensions/VisualEditor 8174c9dafcaafa8eac5636c8119f5c5e44c03c11 null First attempt implementing rewriting rules on the DOM

  • This is implemented as a post-processing pass.
  • Might require additional checks to verify rewriteability.
  • Implemented as a pair-wise tag DOM minimization strategy, i.e. it takes tag pairs (B, I) for ex, and attempts to normalize the tree just for those tag pairs. Normalizing across multiple tags is implemented as pairwise rewriting across all pairs: Ex:(b,i), (b,u),(i,u) for (b,i,u)
  • Copied over attributes as part of rewriting, but some of the attributes lose their meaning on rewriting since tags are reordered (ex: sourcePosn, sourceTagPosn). How do we handle this?

Output examples and possible issues to fix:


gets rewritten to:


But, the equivalent wikitext form:


does not get rewritten because of parsing differences.
This wikitext gets parsed into:


The extra ''' token in the middle thwarts DOM rewriting.

However, a slightly different version:


gets properly normalized to:


An alternative, but fun strategy to play with is to use the following
two normalization primitives: S(wap) and M(erge).

  • S rewrites T1(T2(x)) into T2(T1(x)) (ex: <b><i>foo</i></b> ==> <i><b>foo</b></i>)
  • M rewrites (T(x),T(y)) into (T(x,y)). (ex: <b>foo</b><b>bar</b> ==> <b>foobar</b>)

The current rewriting strategy could possibly be re-implemented as S-M
rewriting. The problem to solve there would be to find an efficient
rewriting strategy that is guaranteed to lead to a normal form. I may
not play with it now, but just documenting it for later (to play with
in my spare time).

This commit is just as a record of fun/experimental code where I get to
learn details of JS, wikitext, parsing, and DOM manipulation. Next
version of this code will attempt to introduce minimal DOM restructuring
across multiple tags at once which can be more efficient.

gwicke: Removed now passing test from whitelist, and updated another whitelist
entry which is now improved.

Change-Id: Ie97bcb164eb62c34ba61aa76ba2f4c232aa713d8


ssastryAuthored on
Gerrit Code ReviewCommitted on May 29 2012, 6:21 AM
rMEXTf3002e781dcf: Updated mediawiki/extensions Project: mediawiki/extensions/CentralNotice…