Fix support for mediawiki.org

In one of the last config patches support for mediawiki.org was apparently
dropped. Add it back in.

Change-Id: I83704231ca7a44d9a09acb941817f4906f2a1e8d
Minor: Strip processed tokens from workstack in debug output.

Change-Id: I76f1d5836e62919cada11d2da3829e5f657380a3
Merge "Minor: Strip processed tokens from workstack in debug output."
Handle link prefix and trail in the DOMPostProc

* We now support link prefix
* We now handle link prefix and link trail in the DOM post-processor, because
  it's the simplest place to do it that has access to the env.conf.wiki values
  for the link prefix/trail regexes.

Change-Id: Ie7726d7a9d0f5e1a25398b059bd5aaa1324c9b3d
(bug 44807) Don't crash on interwiki pages

e.g. /en/Wikt:Lede, which was the bug's example. It now returns a 404 error
with an indication of where you can get the actual page (but not in any
computer-readable format).

Change-Id: I88d27fe9af124c1bf06b90a54a4c9ee695564f79
BUG 45026: Fixed crasher (eltIndex wasn't being set on tok array)

* eltIndex wasn't being set on the token array being pushed onto
  the workstack in one case (code rewrite from commit 555ec42).

* The fix is trivial, but to prevent future bugs like this,
  I introduced a pushChunk function to use with the workStack
  which implicitly sets eltIndex onto the pushed array.

Change-Id: I06824004e80fe7619059361395f2f99ac30c410d
Merge "(bug 44807) Don't crash on interwiki pages"
Merge "Handle link prefix and trail in the DOMPostProc"
Emit proper HTML document from web service and make image src relative

* Emit a proper HTML document including html, head and body elements. The head
  element contains a base href pointing to the wiki's article URL so that our
  relative links resolve when viewed directly from the web service.

* Make image src attributes relative. This should eliminate all absolute links
  pointing to the wiki itself.

* Store the wiki's article base URI in conf.wiki.baseURI.

No change in parser tests.

Change-Id: I8c191cfc874f8ed7d8d22dace8812005237269c8
Bug 44970: Parse HTML fragments inside a body, and use Util.parseHTML everywhere

Fragments starting with comments, link and meta tags were parsed incorrectly.
Comments ended up outside the implicit HTML element. Link and meta tags ended
up in the header.

This patch replaces direct uses of the HTML5 parser with Util.parseHTML and
wraps fragments into a body tag to avoid the issue above. It also returns the
document node from parseHTML, and makes sure that document.body is defined.

Also, use HTML.serialize wrapped into Util.serializeNode for full-page API
serialization output. This adaptively uses single quotes for (most) JSON
attributes, which cuts down on &quot; bloat.

Vs. current master (676fee70a4), the uncompressed size of the Barack Obama
article drops from 1722113 to 1475269 bytes. Compressed size drops slightly
from 263 to 257kb.

No change in parserTests.

Change-Id: I9b402c190e2782fba98a557181bc51245bcbd674
Use pretty serialization for parse.js HTML output too

Use HTML5's adaptive quoting for HTML output from parse.js too. This now also
includes the body element, which gives us its dsr info and makes sure that the
content is fully parsed as the body even if re-parsed with a browser. Without
the body wrapper, we'd get the same issues as the ones described in
ebaef8dcb9.

Change-Id: I0fbd01171920efd1188b7be2a8e0ff638e7c24d9
Properly strip title placeholder in base href value

Change-Id: I10f143b116e6077ad0cf38d1a9bf3ed58a58b53d
Dont clone tokens in AttributeExpander, if attrs are unchanged.

* AsyncTTM.transformTokens checks if a token was unchanged by a
  transformer to decide if it needs to be reprocessed or passed
  on to the next transformer.  It uses the "===" check
  on the before/after token.

  However, the AttributeExpander used to clone tokens before expanding
  attributes which means that the equality check will always fail
  in AsyncTTM.transformTokens leading it to do unnecessary work.

* This patch gets AttributeExpander to check if the token's attrs.
  are actually modified by the AttributeTransformer.  If yes, the
  token is cloned and updated.  If not, it is left unchanged.

* No change in parserTest results.

Change-Id: I8b26480c4490f932faf53aa6d1b87996b4c3826a
Check for non-null DSR in handleLinkNeighbors before updating it.

* en:Advaita Vedanta was crashing with undefined dsr -- fixed
  with this patch.

* Minor tweak in DOMTraverser.callHandlers

* No change in parser tests.

Change-Id: Ie562be34b8bed63a65eadece2c24954130b1221a
Merge "Dont clone tokens in AttributeExpander, if attrs are unchanged."
Merge "Check for non-null DSR in handleLinkNeighbors before updating it."