Fix image parsing, which had been broken by the i18n fixes.

There was a bit of confusion in the image parsing code between
'canonical' mediawiki attribute names (which have img_ prefixes) the
unprefixed names used internally by the parser and renderer, and
localized forms used in the wikitext markup.

Added explicit comments documenting which is which, since they are
often the same when looking at English wikipedia.  We also made the
data stored in the optNames JSON attribute consistent (the key is the
"short form" of the canonical mediawiki attribute name).

Removed some "whitespace preservation" code, originally added in
88fc91a292428e873ea3fdd06f24a1ce59e7eeab.  The particular syntax
with whitespace surrounding the equals sign is not actually
supported by the PHP parser, and we stopped parsing it as well
with the i18n fixes in 6e4ef20e926f150250a4398b9e2bff9dfc176585.
So the code wasn't doing anything any more, and the thing it
was supposed to be doing it shouldn't have been doing in the first
place.  (We actually still pass the rt test case in 88fc91a, because
we preserve unparsed attributes literally.)

Tested with:

echo '[[Archivo:Nombre|miniatura|izquierda|enlace=foo|caption]]' |
 node tests/parse.js  --prefix=es --wt2wt

which is a handy way to keep clear the localized and nonlocalized
versions of these properties when stepping through the code.

Change-Id: Idac285b1537c2bc663178b032f5bdfe6d13e7cdd
Don't sanitize away attributes on <figure> and <figcaption>.

This makes the 'class' and RDFa properties on image thumbnails (re)appear.

Change-Id: I5947a045b3cae4090328fff84515f68341bc769b
Parse 'class=' attribute on [[File:]].

Change-Id: I96b5f1248cbad840106d07f6d3a1b4982fe400f1
oHash doesn't need to be in data-parsoid attribute for thumbnails.

This just bloats the HTML output.  The wikitext serializer uses the
'optionList' and 'optNames' properties; it doesn't need oHash.

Change-Id: Ic4305a6df19b24fdc9fdbf1ef6e8ba7bff2c0827
Support 'border' attribute for images; fix up width/height.

We now only emit width/height attributes if they are non-empty.

The border attribute is in addition to thumb/framed/frameless, according to
http://www.mediawiki.org/wiki/Help:Images#Format

However, none of border/framed/frameless should do anything if 'thumb' is
specified (by design).  Note that fact in renderThumb.

Change-Id: Ibf6e313e232403dc1f726d56886f4efe4c98a6f3
Support 'thumb=$1' option for images.

Change-Id: Ice79d2d8eb150d17a544b9427f373f91a763c875
Support 'valign' and 'halign' attributes on non-thumb images.

Change-Id: Ia2bfbc6cf473d749bab3f7871fa7584dc1631f68
Update cache file if parserTests parser or .txt is updated.

Also allows using runtests.sh from directories other than js/tests.

Change-Id: I5b9208dc14ed6f68c7667530d30af254339c6435
Merge "Update cache file if parserTests parser or .txt is updated."
Serialize figure-captions in non-sol state to prevent RT errors.

* Figure captions are not in a Start-Of-Line (SOL) in wikitext,
  so they have to serialized in non-sol state as well.  Without
  this, captions that have wikitext-like-chars in the sol-position
  will get nowiki-escaped. For example,

  [[File:foo.jpg|thumb| bar]] will get serialized to:
  [[File:foo.jpg|thumb|<nowiki> bar</nowiki>]]

* This is a bug that crept in with a switch from token-based
  serialization handlers to DOM-based handlers in 8939c692. But, the
  bug was hidden because of two reasons. We didn't have parser tests
  to cover this scenario. But, wikitext above wasn't getting parsed
  to figure-tags because of bugs from 6e4ef20e that tackled i18n.
  This i18n bug was fixed in 54695ae3 which exposed the figure
  serialization bug in RT-testing.

* This patch fixes the original bug.

* No change in parser test results.  TODO: Add new ones.

* Unrelated fixes:
  - Removed stale 'emitNewlineOnNextToken' property from serializer
    state which has since been refactored to make this unnecessary.

Change-Id: Iaa111628dd3d30118d85837a138fe10ff3d2e325
Remove Jasmine tests and associated setup files.

* No longer used.  These tests have long since been folded
  into core parser tests.

Change-Id: I676df1e9fdcb76fb9c72ed6bdd344a06a4c29f94
Update cache file if parserTests parser or .txt is updated (take 2).

This is a better solution than the fix already merged in
e348d00e3314d5b0ee6b7ce3d813f84baea6d594 -- it uses the existing
fileDependencies[] and CACHE mechanism of ParserTests.getTests().

Also fixes a bug where the cache file was written to the cwd, not the
__dirname directory (ie js/tests), and adds the cache file and the
parser tests to .gitignore.

Change-Id: I051349612e9a23a9aaf8a534161c80dfcae8db96
Merge "Support 'border' attribute for images; fix up width/height."
Merge "Update cache file if parserTests parser or .txt is updated (take 2)."
Fix buggy token passing in parserFunctions expandKV and rejoinKV.

* expandKV and rejoinKV were not always passing tokens back in
  { tokens: token-array } form to the callbacks.  This was caught
  by verifyTokensIntegrity check in Async TTM on the following
  wikitext snippet from en:England_national_football_team

{{Football kit |
| pattern_la= |pattern_b= |pattern_ra= |pattern_sh= |pattern_so=
| leftarm=fff|body=fff|rightarm=fff|shorts=fff|socks=000000|title= Home
}}

* Surprisingly parsing the page via localhost:8000/en/... didn't
  report the error to the console.  Neither did a rt-run through
  roundtrip-test.js.  Need to check where the error went in case
  the error message got lost rather than a different code path
  getting exercised because of async. related reasons.

* Unrelated:
  - s.res.tokens.rank wasn't being updated in maybeAsyncReturn.
  - It appears some cb's in parserFunctions return {}.
    Tweaked verifyToksIntegrity to accept {} and return
    { tokens:[] } instead.
  - verifyToksIntegrity result wasn't being used in certain cases.

* No change in parser test results.

Change-Id: I15e4f922f259382e3241b2da7a8a22ec9b498841
Merge "Serialize figure-captions in non-sol state to prevent RT errors."
Merge "Remove Jasmine tests and associated setup files."
Merge "Fix buggy token passing in parserFunctions expandKV and rejoinKV."
Fix the config setup in parse.js

There's an instance of using parsoidConfig before we define it. Now fixed.

Change-Id: I4ff9bdd85506a96642960fd9f29e392fd692469d
Parse "options" sections in parserTests.txt test cases (take 2).

Improvement to already-merged 0110b0b46b3d150032fdcebf8a12fe2c776522d8.
This grammar matches more closely the grammar found in the PHP test parser
at tests/parser/parserTest.inc:parseOptions() and handles value lists
and the newly-added "parsoid" simple option.  (The latter by replacing
the hard-coded list of simple options with a more flexible parser.)

Change-Id: Ic449411afd8f5906dd140b0020b52b49fe1b44c7