Merge "Handle conflicting image format options in predictable way."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 15 Apr 2014 16:50:38 +0000 (16:50 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 15 Apr 2014 16:50:38 +0000 (16:50 +0000)
1  2 
includes/parser/Parser.php
tests/parser/parserTests.txt

@@@ -591,7 -591,7 +591,7 @@@ class Parser 
         * If $frame is not provided, then template variables (e.g., {{{1}}}) within $text are not expanded
         *
         * @param string $text text extension wants to have parsed
 -       * @param $frame PPFrame: The frame to use for expanding any template variables
 +       * @param PPFrame $frame The frame to use for expanding any template variables
         *
         * @return string
         */
         * hook.
         *
         * @param string $text text to be expanded
 -       * @param $frame PPFrame: The frame to use for expanding any template variables
 -       * @return String
 +       * @param PPFrame $frame The frame to use for expanding any template variables
 +       * @return string
         * @since 1.19
         */
        public function recursivePreprocess( $text, $frame = false ) {
         * @param $text String
         * @param $title Title
         * @param $options ParserOptions
 +       * @param $params Array
         * @return String
         */
 -      public function getPreloadText( $text, Title $title, ParserOptions $options ) {
 +      public function getPreloadText( $text, Title $title, ParserOptions $options, $params = array() ) {
 +              $msg = new RawMessage( $text );
 +              $text = $msg->params( $params )->plain();
 +
                # Parser (re)initialisation
                $this->startParse( $title, $options, self::OT_PLAIN, true );
  
         * Set the current user.
         * Should only be used when doing pre-save transform.
         *
 -       * @param $user Mixed: User object or null (to reset)
 +       * @param User|null $user User object or null (to reset)
         */
        function setUser( $user ) {
                $this->mUser = $user;
        /**
         * Set the output type
         *
 -       * @param $ot Integer: new value
 +       * @param int $ot new value
         */
        function setOutputType( $ot ) {
                $this->mOutputType = $ot;
         *     '<element param="x">tag content</element>' ) )
         * @endcode
         *
 -       * @param array $elements list of element names. Comments are always extracted.
 +       * @param array $elements List of element names. Comments are always extracted.
         * @param string $text Source text string.
         * @param array $matches Out parameter, Array: extracted tags
 -       * @param $uniq_prefix string
 -       * @return String: stripped text
 +       * @param string $uniq_prefix
 +       * @return string Stripped text
         */
        public static function extractTagsAndParams( $elements, $text, &$matches, $uniq_prefix = '' ) {
                static $n = 1;
         * @param $url String
         * @return String
         *
 -       * @todo  This can merge genuinely required bits in the path or query string,
 -       *        breaking legit URLs. A proper fix would treat the various parts of
 -       *        the URL differently; as a workaround, just use the output for
 -       *        statistical records, not for actual linking/output.
 +       * @todo This can merge genuinely required bits in the path or query string,
 +       *       breaking legit URLs. A proper fix would treat the various parts of
 +       *       the URL differently; as a workaround, just use the output for
 +       *       statistical records, not for actual linking/output.
         */
        static function replaceUnusualEscapes( $url ) {
                return preg_replace_callback( '/%[0-9A-Fa-f]{2}/',
        /**
         * Process [[ ]] wikilinks
         *
 -       * @param $s string
 +       * @param string $s
         *
 -       * @return String: processed text
 +       * @return string Processed text
         *
         * @private
         */
         * breaking URLs in the following text without breaking trails on the
         * wiki links, it's been made into a horrible function.
         *
 -       * @param $nt Title
 -       * @param $text String
 -       * @param array $query or String
 -       * @param $trail String
 -       * @param $prefix String
 -       * @return String: HTML-wikitext mix oh yuck
 +       * @param Title $nt
 +       * @param string $text
 +       * @param array|string $query
 +       * @param string $trail
 +       * @param string $prefix
 +       * @return string HTML-wikitext mix oh yuck
         */
        function makeKnownLinkHolder( $nt, $text = '', $query = array(), $trail = '', $prefix = '' ) {
                list( $inside, $trail ) = Linker::splitTrail( $trail );
         * Not needed quite as much as it used to be since free links are a bit
         * more sensible these days. But bracketed links are still an issue.
         *
 -       * @param string $text more-or-less HTML
 -       * @return String: less-or-more HTML with NOPARSE bits
 +       * @param string $text More-or-less HTML
 +       * @return string Less-or-more HTML with NOPARSE bits
         */
        function armorLinks( $text ) {
                return preg_replace( '/\b((?i)' . $this->mUrlProtocols . ')/',
        /**
         * Handle link to subpage if necessary
         *
 -       * @param string $target the source of the link
 -       * @param &$text String: the link text, modified as necessary
 -       * @return string the full name of the link
 +       * @param string $target The source of the link
 +       * @param string &$text The link text, modified as necessary
 +       * @return string The full name of the link
         * @private
         */
        function maybeDoSubpageLink( $target, &$text ) {
        /**
         * Make lists from lines starting with ':', '*', '#', etc. (DBL)
         *
 -       * @param $text String
 -       * @param $linestart Boolean: whether or not this is at the start of a line.
 +       * @param string $text
 +       * @param bool $linestart Whether or not this is at the start of a line.
         * @private
 -       * @return string the lists rendered as HTML
 +       * @return string The lists rendered as HTML
         */
        function doBlockLevels( $text, $linestart ) {
                wfProfileIn( __METHOD__ );
         * This is the ghost of replace_variables().
         *
         * @param string $text The text to parse
 -       * @param $flags Integer: bitwise combination of:
 -       *          self::PTD_FOR_INCLUSION    Handle "<noinclude>" and "<includeonly>" as if the text is being
 -       *                                     included. Default is to assume a direct page view.
 +       * @param int $flags Bitwise combination of:
 +       *   - self::PTD_FOR_INCLUSION: Handle "<noinclude>" and "<includeonly>" as if the text is being
 +       *     included. Default is to assume a direct page view.
         *
         * The generated DOM tree must depend only on the input text and the flags.
         * The DOM tree must be the same in OT_HTML and OT_WIKI mode, to avoid a regression of bug 4899.
         * Return the text of a template, after recursively
         * replacing any variables or templates within the template.
         *
 -       * @param array $piece the parts of the template
 +       * @param array $piece The parts of the template
         *  $piece['title']: the title, i.e. the part before the |
         *  $piece['parts']: the parameter array
         *  $piece['lineStart']: whether the brace was at the start of a line
 -       * @param $frame PPFrame The current frame, contains template arguments
 +       * @param PPFrame $frame The current frame, contains template arguments
         * @throws MWException
 -       * @return String: the text of the template
 +       * @return string The text of the template
         * @private
         */
        function braceSubstitution( $piece, $frame ) {
                                        }
                                } elseif ( MWNamespace::isNonincludable( $title->getNamespace() ) ) {
                                        $found = false; # access denied
 -                                      wfDebug( __METHOD__ . ": template inclusion denied for " . $title->getPrefixedDBkey() );
 +                                      wfDebug( __METHOD__ . ": template inclusion denied for " .
 +                                              $title->getPrefixedDBkey() . "\n" );
                                } else {
                                        list( $text, $title ) = $this->getTemplateDom( $title );
                                        if ( $text !== false ) {
         * Static function to get a template
         * Can be overridden via ParserOptions::setTemplateCallback().
         *
 -       * @param $title  Title
 -       * @param $parser Parser
 +       * @param Title $title
 +       * @param Parser $parser
         *
         * @return array
         */
        /**
         * Increment an include size counter
         *
 -       * @param string $type the type of expansion
 -       * @param $size Integer: the size of the text
 -       * @return Boolean: false if this inclusion would take it over the maximum, true otherwise
 +       * @param string $type The type of expansion
 +       * @param int $size The size of the text
 +       * @return bool false if this inclusion would take it over the maximum, true otherwise
         */
        function incrementIncludeSize( $type, $size ) {
                if ( $this->mIncludeSizes[$type] + $size > $this->mOptions->getMaxIncludeSize() ) {
        /**
         * Increment the expensive function count
         *
 -       * @return Boolean: false if the limit has been exceeded
 +       * @return bool false if the limit has been exceeded
         */
        function incrementExpensiveFunctionCount() {
                $this->mExpensiveFunctionCount++;
         * Add a tracking category, getting the title from a system message,
         * or print a debug message if the title is invalid.
         *
 -       * @param string $msg message key
 -       * @return Boolean: whether the addition was successful
 +       * Please add any message that you use with this function to
 +       * $wgTrackingCategories. That way they will be listed on
 +       * Special:TrackingCategories.
 +       *
 +       * @param string $msg Message key
 +       * @return bool Whether the addition was successful
         */
        public function addTrackingCategory( $msg ) {
                if ( $this->mTitle->getNamespace() === NS_SPECIAL ) {
         * Transform wiki markup when saving a page by doing "\r\n" -> "\n"
         * conversion, substitting signatures, {{subst:}} templates, etc.
         *
 -       * @param string $text the text to transform
 -       * @param $title Title: the Title object for the current article
 -       * @param $user User: the User object describing the current user
 -       * @param $options ParserOptions: parsing options
 -       * @param $clearState Boolean: whether to clear the parser state first
 -       * @return String: the altered wiki markup
 +       * @param string $text The text to transform
 +       * @param Title $title The Title object for the current article
 +       * @param User $user The User object describing the current user
 +       * @param ParserOptions $options Parsing options
 +       * @param bool $clearState Whether to clear the parser state first
 +       * @return string The altered wiki markup
         */
        public function preSaveTransform( $text, Title $title, User $user, ParserOptions $options, $clearState = true ) {
                $this->startParse( $title, $options, self::OT_WIKI, $clearState );
         * 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures @see cleanSigInSig
         * 2) Substitute all transclusions
         *
 -       * @param $text String
 +       * @param string $text
         * @param bool $parsing Whether we're cleaning (preferences save) or parsing
 -       * @return String: signature text
 +       * @return string Signature text
         */
        public function cleanSig( $text, $parsing = false ) {
                if ( !$parsing ) {
        /**
         * Strip ~~~, ~~~~ and ~~~~~ out of signatures
         *
 -       * @param $text String
 -       * @return String: signature text with /~{3,5}/ removed
 +       * @param string $text
 +       * @return string Signature text with /~{3,5}/ removed
         */
        public static function cleanSigInSig( $text ) {
                $text = preg_replace( '/~{3,5}/', '', $text );
        /**
         * Wrapper for preprocess()
         *
 -       * @param string $text the text to preprocess
 -       * @param $options ParserOptions: options
 -       * @param $title Title object or null to use $wgTitle
 -       * @return String
 +       * @param string $text The text to preprocess
 +       * @param ParserOptions $options Options
 +       * @param Title|null $title Title object or null to use $wgTitle
 +       * @return string
         */
        public function transformMsg( $text, $options, $title = null ) {
                static $executing = false;
         * this interface, as it is not documented and injudicious use could smash
         * private variables.**
         *
 -       * @param $tag Mixed: the tag to use, e.g. 'hook' for "<hook>"
 -       * @param $callback Mixed: the callback function (and object) to use for the tag
 +       * @param string $tag The tag to use, e.g. 'hook' for "<hook>"
 +       * @param mixed $callback The callback function (and object) to use for the tag
         * @throws MWException
 -       * @return Mixed|null The old value of the mTagHooks array associated with the hook
 +       * @return mixed|null The old value of the mTagHooks array associated with the hook
         */
        public function setHook( $tag, $callback ) {
                $tag = strtolower( $tag );
         * @since 1.10
         * @todo better document or deprecate this
         *
 -       * @param $tag Mixed: the tag to use, e.g. 'hook' for "<hook>"
 -       * @param $callback Mixed: the callback function (and object) to use for the tag
 +       * @param string $tag The tag to use, e.g. 'hook' for "<hook>"
 +       * @param mixed $callback The callback function (and object) to use for the tag
         * @throws MWException
 -       * @return Mixed|null The old value of the mTagHooks array associated with the hook
 +       * @return mixed|null The old value of the mTagHooks array associated with the hook
         */
        function setTransparentTagHook( $tag, $callback ) {
                $tag = strtolower( $tag );
         *   isHTML                    The returned text is HTML, armour it against wikitext transformation
         *
         * @param string $id The magic word ID
 -       * @param $callback Mixed: the callback function (and object) to use
 -       * @param $flags Integer: a combination of the following flags:
 +       * @param mixed $callback The callback function (and object) to use
 +       * @param int $flags A combination of the following flags:
         *     SFH_NO_HASH   No leading hash, i.e. {{plural:...}} instead of {{#if:...}}
         *
         *     SFH_OBJECT_ARGS   Pass the template arguments as PPNode objects instead of text. This
                                                                $handlerOptions[$paramName] = $match;
                                                        } else {
                                                                // Guess not. Append it to the caption.
 -                                                              wfDebug( "$parameterMatch failed parameter validation" );
 +                                                              wfDebug( "$parameterMatch failed parameter validation\n" );
                                                                $label .= '|' . $parameterMatch;
                                                        }
                                                }
                $caption = '';
                $params = array( 'frame' => array(), 'handler' => array(),
                        'horizAlign' => array(), 'vertAlign' => array() );
+               $seenformat = false;
                foreach ( $parts as $part ) {
                        $part = trim( $part );
                        list( $magicName, $value ) = $mwArray->matchVariableStartToEnd( $part );
                                                                }
                                                        }
                                                        break;
+                                               case 'frameless':
+                                               case 'framed':
+                                               case 'thumbnail':
+                                                       // use first appearing option, discard others.
+                                                       $validated = ! $seenformat;
+                                                       $seenformat = true;
+                                                       break;
                                                default:
                                                        # Most other things appear to be empty or numeric...
                                                        $validated = ( $value === false || is_numeric( trim( $value ) ) );
         * string. If $text is the empty string and section 0 is replaced, $newText is
         * returned.
         *
 -       * @param string $mode one of "get" or "replace"
 -       * @param string $newText replacement text for section data.
 -       * @return String: for "get", the extracted section text.
 -       *                 for "replace", the whole page with the section replaced.
 +       * @param string $mode One of "get" or "replace"
 +       * @param string $newText Replacement text for section data.
 +       * @return string For "get", the extracted section text.
 +       *   for "replace", the whole page with the section replaced.
         */
        private function extractSections( $text, $section, $mode, $newText = '' ) {
                global $wgTitle; # not generally used but removes an ugly failure mode
         * specified by $section has been replaced with $text. If the target
         * section does not exist, $oldtext is returned unchanged.
         *
 -       * @param string $oldtext former text of the article
 -       * @param int $section section identifier
 -       * @param string $text replacing text
 -       * @return String: modified text
 +       * @param string $oldtext Former text of the article
 +       * @param int $section Section identifier
 +       * @param string $text Replacing text
 +       * @return string Modified text
         */
        public function replaceSection( $oldtext, $section, $text ) {
                return $this->extractSections( $oldtext, $section, "replace", $text );
        /**
         * Get the ID of the revision we are parsing
         *
 -       * @return Mixed: integer or null
 +       * @return int|null
         */
        function getRevisionId() {
                return $this->mRevisionId;
        /**
         * Get the name of the user that edited the last revision
         *
 -       * @return String: user name
 +       * @return string User name
         */
        function getRevisionUser() {
                if ( is_null( $this->mRevisionUser ) ) {
  # language=XXX  set content language to XXX for this test
  # variant=XXX   set the variant of language for this test (eg zh-tw)
  # disabled      do not run test
 -# parsoid       parsoid-only test (not run by PHP parser)
 -# php           php-only test (not run by the parsoid parser)
 +# parsoid       parsoid-specific options (not run by PHP parser unless
 +#                 the test includes an html/php section)
 +# php           php-only test (not run by the parsoid parser unless
 +#                 the test includes an html/parsoid section)
  # showtitle     make the first line the title
  # comment       run through Linker::formatComment() instead of main parser
  # local         format section links in edit comment text as local links
  # notoc         disable table of contents
 +# thumbsize=NNN set the default thumb size to NNNpx for this test
  #
  # You can also set the following parser properties via test options:
  #  wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
@@@ -522,55 -519,27 +522,55 @@@ Italics and bold: 2-quote opening seque
  
  !! test
  Italics and bold: 2-quote opening sequence: (2,3)
 +!! options
 +parsoid=wt2html
  !! wikitext
  ''foo'''
 -!! html
 +!! html/*
  <p><i>foo'</i>
  </p>
  !!end
  
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: 2-quote opening sequence: (2,3) w/ nowiki
 +!! wikitext
 +''<nowiki>foo'</nowiki>''
 +!! html
 +<p><i>foo'</i>
 +</p>
 +!! end
 +
 +
  !! test
  Italics and bold: 2-quote opening sequence: (2,4)
 +!! options
 +parsoid=wt2html
  !! wikitext
  ''foo''''
 -!! html
 +!! html/*
  <p><i>foo''</i>
  </p>
  !!end
  
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
 +!! wikitext
 +''<nowiki>foo''</nowiki>''
 +!! html
 +<p><i>foo''</i>
 +</p>
 +!! end
 +
 +
  # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
  !! test
  Italics and bold: 2-quote opening sequence: (2,5)
 +!! options
 +parsoid=wt2html
  !! wikitext
  ''foo'''''
  !! html/php
  </p>
  !!end
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
 +!! wikitext
 +''foo'''''<nowiki/>'''
 +!! html/php
 +<p><i>foo</i>
 +</p>
 +!! html/parsoid
 +<p><i>foo</i><b></b>
 +</p>
 +!! end
 +
  
  ###
  ### 3-quote opening sequence tests
@@@ -621,32 -577,17 +621,32 @@@ Italics and bold: 3-quote opening seque
  
  !! test
  Italics and bold: 3-quote opening sequence: (3,4)
 +!! options
 +parsoid=wt2html
  !! wikitext
  '''foo''''
 -!! html
 +!! html/*
  <p><b>foo'</b>
  </p>
  !!end
  
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: 3-quote opening sequence: (3,4) w/ nowiki
 +!! wikitext
 +'''<nowiki>foo'</nowiki>'''
 +!! html
 +<p><b>foo'</b>
 +</p>
 +!! end
 +
 +
  # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
  !! test
  Italics and bold: 3-quote opening sequence: (3,5)
 +!! options
 +parsoid=wt2html
  !! wikitext
  '''foo'''''
  !! html/php
  </p>
  !!end
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
 +!! wikitext
 +'''foo'''''<nowiki/>''
 +!! html/php
 +<p><b>foo</b>
 +</p>
 +!! html/parsoid
 +<p><b>foo</b><i></i>
 +</p>
 +!! end
 +
  
  ###
  ### 4-quote opening sequence tests
  
  !! test
  Italics and bold: 4-quote opening sequence: (4,2)
 +!! options
 +parsoid=wt2html
  !! wikitext
  ''''foo''
 -!! html
 +!! html/*
  <p>''<i>foo</i>
  </p>
  !!end
  
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
 +!! wikitext
 +<nowiki>''</nowiki>''foo''
 +!! html
 +<p>''<i>foo</i>
 +</p>
 +!! end
 +
 +
  !! test
  Italics and bold: 4-quote opening sequence: (4,3)
  !! wikitext
  
  !! test
  Italics and bold: 4-quote opening sequence: (4,4)
 +!! options
 +parsoid=wt2html
  !! wikitext
  ''''foo''''
 -!! html
 +!! html/*
  <p>'<b>foo'</b>
  </p>
  !!end
  
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
 +!! wikitext
 +''''<nowiki>foo'</nowiki>'''
 +!! html
 +<p>'<b>foo'</b>
 +</p>
 +!! end
 +
 +
  # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
  !! test
  Italics and bold: 4-quote opening sequence: (4,5)
 +!! options
 +parsoid=wt2html
  !! wikitext
  ''''foo'''''
  !! html/php
  </p>
  !!end
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
 +!! wikitext
 +''''foo'''''<nowiki/>''
 +!! html/php
 +<p>'<b>foo</b>
 +</p>
 +!! html/parsoid
 +<p>'<b>foo</b><i></i>
 +</p>
 +!! end
 +
  
  ###
  ### 5-quote opening sequence tests
  !! test
  Italics and bold: 5-quote opening sequence: (5,2)
  !! options
 +parsoid=wt2html
  !! wikitext
  '''''foo''
 -!! html
 +!! html/*
  <p><b><i>foo</i></b>
  </p>
  !!end
  
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +# skipping wt2html and html2html because it wants to put <i> before <b>
 +!! test
 +Italics and bold: 5-quote opening sequence: (5,2+3)
 +!! options
 +parsoid=wt2wt,html2wt
 +!! wikitext
 +'''''foo'''''
 +!! html/*
 +<p><b><i>foo</i></b>
 +</p>
 +!! end
 +
  !! test
  Italics and bold: 5-quote opening sequence: (5,3)
 +!! options
 +parsoid=wt2html
  !! wikitext
  '''''foo'''
 -!! html
 +!! html/*
  <p><i><b>foo</b></i>
  </p>
  !!end
  
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: 5-quote opening sequence: (5,3+2)
 +!! wikitext
 +'''''foo'''''
 +!! html
 +<p><i><b>foo</b></i>
 +</p>
 +!! end
 +
 +
  !! test
  Italics and bold: 5-quote opening sequence: (5,4)
 +!! options
 +parsoid=wt2html
  !! wikitext
  '''''foo''''
 -!! html
 +!! html/*
  <p><i><b>foo'</b></i>
  </p>
  !!end
  
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: 5-quote opening sequence: (5,4+2) w/ nowiki
 +!! wikitext
 +'''''<nowiki>foo'</nowiki>'''''
 +!! html
 +<p><i><b>foo'</b></i>
 +</p>
 +!! end
 +
 +
  !! test
  Italics and bold: 5-quote opening sequence: (5,5)
  !! wikitext
  ###
  !! test
  Italics and bold: multiple quote sequences: (2,4,2)
 +!! options
 +parsoid=wt2html
  !! wikitext
  ''foo''''bar''
 -!! html
 +!! html/*
  <p><i>foo'<b>bar</b></i>
  </p>
  !!end
  
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
 +!! wikitext
 +''<nowiki>foo'</nowiki>'''bar'''''
 +!! html
 +<p><i>foo'<b>bar</b></i>
 +</p>
 +!! end
 +
 +
  !! test
  Italics and bold: multiple quote sequences: (2,4,3)
 +!! options
 +parsoid=wt2html
  !! wikitext
  ''foo''''bar'''
 -!! html
 +!! html/*
  <p><i>foo'<b>bar</b></i>
  </p>
  !!end
  
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
 +!! wikitext
 +''<nowiki>foo'</nowiki>'''bar'''''
 +!! html
 +<p><i>foo'<b>bar</b></i>
 +</p>
 +!! end
 +
 +
  !! test
  Italics and bold: multiple quote sequences: (2,4,4)
 +!! options
 +parsoid=wt2html
  !! wikitext
  ''foo''''bar''''
 -!! html
 +!! html/*
  <p><i>foo'<b>bar'</b></i>
  </p>
  !!end
  
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
 +!! wikitext
 +''<nowiki>foo'</nowiki>'''<nowiki>bar'</nowiki>'''''
 +!! html
 +<p><i>foo'<b>bar'</b></i>
 +</p>
 +!! end
 +
 +
  # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
  !! test
  Italics and bold: multiple quote sequences: (3,4,2)
 +!! options
 +parsoid=wt2html
  !! wikitext
  '''foo''''bar''
  !! html/php
  </p>
  !!end
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
 +!! options
 +parsoid
 +!! wikitext
 +'''<nowiki>foo'</nowiki>'''bar''<nowiki/>''
 +!! html/php
 +<p><b>foo'</b>bar
 +</p>
 +!! html/parsoid
 +<p><b><span typeof="mw:Nowiki">foo'</span></b>bar<i></i>
 +</p>
 +!! end
 +
  
  # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
  !! test
  Italics and bold: multiple quote sequences: (3,4,3)
 +!! options
 +parsoid=wt2html
  !! wikitext
  '''foo''''bar'''
  !! html/php
  </p>
  !!end
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +!! test
 +Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
 +!! wikitext
 +'''<nowiki>foo'</nowiki>'''bar'''<nowiki/>'''
 +!! html/php
 +<p><b>foo'</b>bar
 +</p>
 +!! html/parsoid
 +<p><b><span typeof="mw:Nowiki">foo'</span></b>bar<b></b>
 +</p>
 +!! end
 +
  ###
  ### other quote tests
  ###
@@@ -1000,30 -776,14 +1000,30 @@@ Italics and bold: other quote tests: (2
  
  !! test
  Italics and bold: other quote tests: (3,2,3,2)
 +!! options
 +parsoid=wt2html
  !! wikitext
  '''this is about ''foo'''s family''
 -!! html
 +!! html/*
  <p><b>this is about <i>foo</i></b><i>s family</i>
  </p>
  !!end
  
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +# add 'parsoid' option to use 'parsoid' normalization of the placeholder
 +!! test
 +Italics and bold: other quote tests: (3,2,3+2+2,2)
 +!! options
 +parsoid
 +!! wikitext
 +'''this is about ''foo'''''<nowiki/>''s family''
 +!! html/*
 +<p><b>this is about <i>foo</i></b><i>s family</i>
 +</p>
 +!! end
 +
 +
  !! test
  Italics and bold: other quote tests: (3,2,3,3)
  !! options
  </p>
  !! end
  
 +!! test
 +Multiple comments should still parse as SOL-transparent
 +!! options
 +parsoid=wt2html,wt2wt
 +!! wikitext
 +<!--c1-->*a
 +<!--c2--><!--c3--><!--c4-->*b
 +!! html
 +<ul>
 +<li>a
 +</li>
 +<li>b
 +</li>
 +</ul>
 +!! end
 +
  ###
  ### paragraph wrapping tests
  ###
  </p>
  !! end
  
 +!! test
 +Templates: Handle comments in the target
 +!! wikitext
 +{{echo
 +<!-- should be ignored -->
 +|foo}}
 +
 +{{echo<!-- should be ignored -->
 +|foo}}
 +
 +{{echo<!-- should be ignored -->|foo}}
 +
 +{{<!-- should be ignored -->echo|foo}}
 +!!html/parsoid
 +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n&lt;!-- should be ignored -->\n","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
 +
 +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo&lt;!-- should be ignored -->\n","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
 +
 +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo&lt;!-- should be ignored -->","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
 +
 +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
 +!!end
 +
  #--------------------------------------------------------------------
  # Transclusion parameter escaping tests
  #--------------------------------------------------------------------
@@@ -5788,17 -5509,6 +5788,17 @@@ language=ka
  </p>
  !! end
  
 +!! test
 +Link with multiple ":" in a subpage-supporting namespace (bug 63636)
 +!! wikitext
 +[[User:Foo/Test/63636:Bar|Test]]
 +!! html/php
 +<p><a href="/index.php?title=User:Foo/Test/63636:Bar&amp;action=edit&amp;redlink=1" class="new" title="User:Foo/Test/63636:Bar (page does not exist)">Test</a>
 +</p>
 +!! html/parsoid
 +<p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar">Test</a></p>
 +!! end
 +
  !! test
  1. Interaction of linktrail and template encapsulation
  !! options
@@@ -5969,30 -5679,16 +5969,30 @@@ Interwiki link with fragment (bug 2130
  # Ideally the wikipedia: prefix here should be proto-relative too
  !! test
  Different interwiki prefixes mapping to the same URL
 -!! options
 -parsoid
  !! wikitext
 +[[:en:Foo]]
 +
 +[[:en:Foo|Foo]]
 +
  [[wikipedia:Foo]]
  
 -[[:en:Foo]]
 -!! html
 -<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":"wikipedia:Foo"},"isIW":true}'>wikipedia:Foo</a></p>
 +[[:wikipedia:Foo|Foo]]
 +
 +[[wikipedia:en:Foo]]
  
 +[[:wikipedia:en:Foo]]
 +!! html/parsoid
  <p><a rel="mw:ExtLink" href="//en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"simple","a":{"href":"//en.wikipedia.org/wiki/Foo"},"sa":{"href":":en:Foo"},"isIW":true}'>en:Foo</a></p>
 +
 +<p><a rel="mw:ExtLink" href="//en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"piped","a":{"href":"//en.wikipedia.org/wiki/Foo"},"sa":{"href":":en:Foo"},"isIW":true}'>Foo</a></p>
 +
 +<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":"wikipedia:Foo"},"isIW":true}'>wikipedia:Foo</a></p>
 +
 +<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"piped","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":":wikipedia:Foo"},"isIW":true}'>Foo</a></p>
 +
 +<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/en:Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/en:Foo"},"sa":{"href":"wikipedia:en:Foo"},"isIW":true}'>wikipedia:en:Foo</a></p>
 +
 +<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/en:Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/en:Foo"},"sa":{"href":":wikipedia:en:Foo"},"isIW":true}'>wikipedia:en:Foo</a></p>
  !! end
  
  !! test
@@@ -9966,7 -9662,7 +9966,7 @@@ Special:Foobar_nonexisten
  ### Images
  ###
  ### For Parsoid-specific tests, see
 -#### http://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
 +#### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
  
  !! test
  Simple image
@@@ -10051,15 -9747,13 +10051,15 @@@ Image with caption, bug 53312 #
  
  !! test
  Allow empty links in image captions (Bug 60753)
 +!! options
 +thumbsize=220
  !! wikitext
  [[File:Foobar.jpg|thumb|Caption [[Link1]]
  [[]]
  [[Link2]]
  ]]
  !! html/php
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Caption <a href="/index.php?title=Link1&amp;action=edit&amp;redlink=1" class="new" title="Link1 (page does not exist)">Link1</a> [[]] <a href="/index.php?title=Link2&amp;action=edit&amp;redlink=1" class="new" title="Link2 (page does not exist)">Link2</a></div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Caption <a href="/index.php?title=Link1&amp;action=edit&amp;redlink=1" class="new" title="Link1 (page does not exist)">Link1</a> [[]] <a href="/index.php?title=Link2&amp;action=edit&amp;redlink=1" class="new" title="Link2 (page does not exist)">Link2</a></div></div></div>
  
  !! html/parsoid
  <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Caption [[Link1]]\n[[]]\n[[Link2]]\n"}],"dsr":[0,59,2,2]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"dsr":[2,null,null,null]}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption data-parsoid='{"dsr":[null,57,null,null]}'>Caption <a rel="mw:WikiLink" href="./Link1" data-parsoid='{"stx":"simple","a":{"href":"./Link1"},"sa":{"href":"Link1"},"dsr":[32,41,2,2]}'>Link1</a>
@@@ -10138,8 -9832,6 +10138,8 @@@ Image with multiple attributes from th
  
  !! test
  Image with link tails
 +!! options
 +thumbsize=220
  !! wikitext
  123[[File:Foobar.jpg]]456
  123[[File:Foobar.jpg|right]]456
  <p>123<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>456
  </p>
  123<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>456
 -123<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div></div></div></div>456
 +123<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div></div></div></div>456
  
  !! html/parsoid
  <p>123<span class="mw-default-size" typeof="mw:Image"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"></a></span>456</p>
@@@ -10180,14 -9872,12 +10180,14 @@@ Image with multiple widths -- use las
  
  !! test
  Image with multiple alignments -- use first (bug 48664)
 +!! options
 +thumbsize=220
  !! wikitext
  [[File:Foobar.jpg|thumb|left|right|center|caption]]
  
  [[File:Foobar.jpg|middle|text-top|caption]]
  !! html/php
 -<div class="thumb tleft"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
 +<div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" style="vertical-align: middle" /></a>
  </p>
  !! html/parsoid
@@@ -10343,12 -10033,11 +10343,12 @@@ Image with link parameter (URL target) 
  !! test
  Thumbnail image with link parameter
  !! options
 +thumbsize=220
  parsoid=wt2html,wt2wt,html2html
  !! wikitext
  [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
  !! html/php
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="http://example.com/"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="http://example.com/"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div>
  
  !! html/parsoid
  <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="http://example.com/"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>Title</figcaption></figure>
  
  !! test
  Manually-specified thumbnail image
 +!! options
 +thumbsize=220
  !! wikitext
 -[[Image:Foobar.jpg|thumb=Thumb.png|Title]]
 +[[File:Foobar.jpg|thumb=Thumb.png|Title]]
  !! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/File:Foobar.jpg"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div>
  
  !! html/parsoid
 -XXX NOT IMPLEMENTED XXX
 +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" height="135" width="135"/></a><figcaption>Title</figcaption></figure>
  !! end
  
  !! test
  Manually-specified thumbnail image with explicit link to wiki page
 +!! options
 +thumbsize=220
 +parsoid=wt2html,wt2wt,html2html
  !! wikitext
 -[[Image:Foobar.jpg|thumb=Thumb.png|link=Main Page|Title]]
 +[[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
  !! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/Main_Page" title="Main Page"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div>
  
  !! html/parsoid
 -XXX NOT IMPLEMENTED XXX
 +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" height="135" width="135"/></a><figcaption>Title</figcaption></figure>
  !! end
  
  !! test
  Manually-specified thumbnail image with explicit link to url
 +!! options
 +thumbsize=220
 +parsoid=wt2html,wt2wt,html2html
  !! wikitext
 -[[Image:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
 +[[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
  !! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="http://example.com"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div>
  
  !! html/parsoid
 -XXX NOT IMPLEMENTED XXX
 +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="http://example.com"><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" height="135" width="135"/></a><figcaption>Title</figcaption></figure>
  !! end
  
  !! test
  Manually-specified thumbnail image with explicit no link
 +!! options
 +thumbsize=220
 +parsoid=wt2html,wt2wt,html2html
  !! wikitext
 -[[Image:Foobar.jpg|thumb=Thumb.png|link=|Title]]
 +[[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
  !! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:137px;"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" />  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div>
  
  !! html/parsoid
 -XXX NOT IMPLEMENTED XXX
 +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><span><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" height="135" width="135"/></span><figcaption>Title</figcaption></figure>
  !! end
  
  !! test
  Manually-specified thumbnail image with explicit link and alt text
 +!! options
 +thumbsize=220
 +parsoid=wt2html,wt2wt,html2html
  !! wikitext
 -[[Image:Foobar.jpg|thumb=Thumb.png|link=Main Page|alt=alttext|Title]]
 +[[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
  !! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/Main_Page" title="Main Page"><img alt="alttext" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div>
  
  !! html/parsoid
 -XXX NOT IMPLEMENTED XXX
 +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="Main_Page"><img alt="alttext" resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" height="135" width="135"/></a><figcaption>Title</figcaption></figure>
  !! end
  
  !! test
@@@ -10466,14 -10141,60 +10466,60 @@@ parsoid=wt2html,wt2wt,html2htm
  <p><span class="mw-default-size" typeof="mw:Image"><a href="File:Foobar.jpg"><img alt="testing bold in alt" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
  !! end
  
+ ###################
+ # Conflicting image format options.
+ # First option specified should 'win'.
+ # All three cases in each test should be identical.
+ !! test
+ Image with 'frameless' first.
+ !! wikitext
+ [[File:Foobar.jpg|frameless|caption]]
+ [[File:Foobar.jpg|frameless|frame|caption]]
+ [[File:Foobar.jpg|frameless|thumb|caption]]
+ !! html/php
+ <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
+ </p><p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
+ </p><p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
+ </p>
+ !! end
+ !! test
+ Image with 'frame' first.
+ !! wikitext
+ [[File:Foobar.jpg|frame|caption]]
+ [[File:Foobar.jpg|frame|frameless|caption]]
+ [[File:Foobar.jpg|frame|thumb|caption]]
+ !! html/php
+ <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a>  <div class="thumbcaption">caption</div></div></div>
+ <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a>  <div class="thumbcaption">caption</div></div></div>
+ <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a>  <div class="thumbcaption">caption</div></div></div>
+ !! end
+ !! test
+ Image with 'thumb' first.
+ !! wikitext
+ [[File:Foobar.jpg|thumb|caption]]
+ [[File:Foobar.jpg|thumb|frameless|caption]]
+ [[File:Foobar.jpg|thumb|frame|caption]]
+ !! html/php
+ <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
+ <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
+ <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
+ !! end
  ###################
  # Image sizing.
  # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
  # and https://bugzilla.wikimedia.org/show_bug.cgi?id=62258
  # Foobar has actual size of 1941x220
 -# 1. Thumbs & frameless always reduce, can't be enlarged
 -# 2. Framed images ignore width; always render at default size.
 -#    If given a height, they respect height but continue to ignore width.
 +# 1. Thumbs & frameless always reduce, can't be enlarged unless it's
 +#    a scalable format.
 +# 2. Framed images always ignore size options; always render at default size.
  # 3. "Unspecified format" and border are the only types which can be
  #    enlarged.
  
@@@ -10525,20 -10246,16 +10571,20 @@@ parsoid=wt2html,wt2wt,html2htm
  !! end
  
  !! test
 -Image: thumbs can't be enlarged past original size
 +Image: bitmap thumbs can't be enlarged past original size, but vector can.
  !! options
  parsoid=wt2html,wt2wt,html2html
  !! wikitext
  [[File:Foobar.jpg|thumb|2000px]]
 +
 +[[File:Foobar.svg|thumb|2000px]]
  !! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div></div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:2002px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" width="2000" height="1500" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/3000px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/4000px-Foobar.svg.png 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div></div></div></div>
  
  !! html/parsoid
  <figure typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></figure>
 +<figure typeof="mw:Image/Thumb"><a href="File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" height="1500" width="2000"/></a></figure>
  !! end
  
  !! test
@@@ -10555,24 -10272,20 +10601,24 @@@ parsoid=wt2html,wt2wt,html2htm
  !! end
  
  !! test
 -Image: frameless can't be enlarged past original size
 +Image: bitmap frameless can't be enlarged past original size, but vector can
  !! options
  parsoid=wt2html,wt2wt,html2html
  !! wikitext
  [[File:Foobar.jpg|frameless|2000px]]
 +
 +[[File:Foobar.svg|frameless|2000px]]
  !! html/php
  <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
 +</p><p><a href="/wiki/File:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" width="2000" height="1500" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/3000px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/4000px-Foobar.svg.png 2x" /></a>
  </p>
  !! html/parsoid
  <p><span typeof="mw:Image/Frameless"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
 +<p><span typeof="mw:Image/Frameless"><a href="File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" height="1500" width="2000"/></a></span></p>
  !! end
  
  !! test
 -Image: framed images ignore size if only width is given
 +Image: framed images are always unscaled.
  !! options
  parsoid=wt2html,wt2wt,html2html
  !! wikitext
  
  [[File:Foobar.jpg|frame|50px]]
  
 +[[File:Foobar.jpg|frame|50x50px]]
 +
  [[File:Foobar.jpg|frame|2000px]]
  !! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a>  <div class="thumbcaption"></div></div></div>
  <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a>  <div class="thumbcaption"></div></div></div>
  <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a>  <div class="thumbcaption"></div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a>  <div class="thumbcaption"></div></div></div>
  
  !! html/parsoid
 -<figure class="mw-default-size" typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></figure><figure typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></figure><figure typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></figure>
 -!! end
 -
 -!! test
 -Image: framed images respect size if given a height, but ignore width.
 -!! wikitext
 -[[File:Foobar.jpg|frame|50x50px]]
 -!! html/php
 -<div class="thumb tright"><div class="thumbinner" style="width:444px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/442px-Foobar.jpg" width="442" height="50" class="thumbimage" /></a>  <div class="thumbcaption"></div></div></div>
 -
 -!! html/parsoid
 -<figure typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="50" width="442"/></a></figure>
 +<figure class="mw-default-size" typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></figure><figure typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></figure><figure typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></figure><figure typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></figure>
  !! end
  
  ###################
@@@ -10628,12 -10349,10 +10674,12 @@@ Frameless image caption with a free UR
  
  !! test
  Thumbnail image caption with a free URL
 +!! options
 +thumbsize=220
  !! wikitext
  [[File:Foobar.jpg|thumb|http://example.com]]
  !! html/php
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
  
  !! html/parsoid
  <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></figcaption></figure>
  !! test
  Thumbnail image caption with a free URL and explicit alt
  !! options
 +thumbsize=220
  parsoid=wt2html,wt2wt,html2html
  !! wikitext
  [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
  !! html/php
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Alteration" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Alteration" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
  
  !! html/parsoid
  <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img alt="Alteration" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></figcaption></figure>
@@@ -10658,191 -10376,153 +10704,191 @@@ SVG thumbnails with no language se
  !! options
  !! wikitext
  [[File:Foobar.svg|thumb|caption]]
 -!! html
 +!! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
  
 +!! html/parsoid
 +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" height="165" width="220"/></a><figcaption>caption</figcaption></figure>
  !! end
  
  !! test
  SVG thumbnails with language de
  !! options
 +parsoid=wt2html,wt2wt,html2html
  !! wikitext
  [[File:Foobar.svg|thumb|caption|lang=de]]
 -!! html
 +!! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=File:Foobar.svg&amp;lang=de" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/langde-180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/langde-270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/langde-360px-Foobar.svg.png 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
  
 +!! html/parsoid
 +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" lang="de" height="165" width="220"/></a><figcaption>caption</figcaption></figure>
  !! end
  
  !! test
  SVG thumbnails with invalid language code
  !! options
 +parsoid=wt2html,wt2wt,html2html
  !! wikitext
  [[File:Foobar.svg|thumb|caption|lang=invalid.language.code]]
 -!! html
 +!! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>lang=invalid.language.code</div></div></div>
  
 +!! html/parsoid
 +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" height="165" width="220"/></a><figcaption>lang=invalid.language.code</figcaption></figure>
  !! end
  
  !! test
  BUG 1887: A ISBN with a thumbnail
  !! wikitext
 -[[Image:foobar.jpg|thumb|ISBN 1235467890]]
 -!! html
 +[[File:Foobar.jpg|thumb|ISBN 1235467890]]
 +!! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a href="/wiki/Special:BookSources/1235467890" class="internal mw-magiclink-isbn">ISBN 1235467890</a></div></div></div>
  
 +!! html/parsoid
 +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption><a href="Special:BookSources/1235467890" rel="mw:ExtLink">ISBN 1235467890</a></figcaption></figure>
  !! end
  
  !! test
  BUG 1887: A RFC with a thumbnail
  !! wikitext
 -[[Image:foobar.jpg|thumb|This is RFC 12354]]
 -!! html
 +[[File:Foobar.jpg|thumb|This is RFC 12354]]
 +!! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
  
 +!! html/parsoid
 +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>This is <a href="//tools.ietf.org/html/rfc12354" rel="mw:ExtLink">RFC 12354</a></figcaption></figure>
  !! end
  
  !! test
  BUG 1887: A mailto link with a thumbnail
  !! wikitext
 -[[Image:foobar.jpg|thumb|Please mailto:nobody@example.com]]
 -!! html
 +[[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
 +!! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Please <a rel="nofollow" class="external free" href="mailto:nobody@example.com">mailto:nobody@example.com</a></div></div></div>
  
 +!! html/parsoid
 +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>Please <a rel="mw:ExtLink" href="mailto:nobody@example.com">mailto:nobody@example.com</a></figcaption></figure>
  !! end
  
  # Pending resolution to bug 368
  !! test
  BUG 648: Frameless image caption with a link
  !! wikitext
 -[[Image:foobar.jpg|text with a [[link]] in it]]
 -!! html
 +[[File:Foobar.jpg|text with a [[link]] in it]]
 +!! html/php
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
 +!! html/parsoid
 +<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"text with a [[link]] in it"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
  !! end
  
  !! test
  BUG 648: Frameless image caption with a link (suffix)
  !! wikitext
 -[[Image:foobar.jpg|text with a [[link]]foo in it]]
 -!! html
 +[[File:Foobar.jpg|text with a [[link]]foo in it]]
 +!! html/php
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a linkfoo in it"><img alt="text with a linkfoo in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
 +!! html/parsoid
 +<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"text with a [[link]]foo in it"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
  !! end
  
  !! test
  BUG 648: Frameless image caption with an interwiki link
  !! wikitext
 -[[Image:foobar.jpg|text with a [[MeatBall:Link]] in it]]
 -!! html
 +[[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
 +!! html/php
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a MeatBall:Link in it"><img alt="text with a MeatBall:Link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
 +!! html/parsoid
 +<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"text with a [[MeatBall:Link]] in it"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
  !! end
  
  !! test
  BUG 648: Frameless image caption with a piped interwiki link
  !! wikitext
 -[[Image:foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
 -!! html
 +[[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
 +!! html/php
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
 +!! html/parsoid
 +<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"text with a [[MeatBall:Link|link]] in it"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
  !! end
  
  !! test
  Escape HTML special chars in image alt text
  !! wikitext
 -[[Image:foobar.jpg|& < > "]]
 -!! html
 +[[File:Foobar.jpg|& < > "]]
 +!! html/php
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img alt="&amp; &lt; &gt; &quot;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
 +!! html/parsoid
 +<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"&amp; &lt; > \""}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
  !! end
  
  !! test
  BUG 499: Alt text should have &#1234;, not &amp;1234;
  !! wikitext
 -[[Image:foobar.jpg|&#9792;]]
 -!! html
 +[[File:Foobar.jpg|&#9792;]]
 +!! html/php
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="♀"><img alt="♀" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
 +!! html/parsoid
 +<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"&amp;#9792;"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
  !! end
  
  !! test
  Broken image caption with link
 +!! options
 +parsoid=wt2html,wt2wt,html2html
  !! wikitext
  [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
 -!! html
 +!! html/php
  <p>[[Image:Foobar.jpg|thumb|This is a broken caption. But <a href="/wiki/Main_Page" title="Main Page">this</a> is just an ordinary link.
  </p>
 +!! html/parsoid
 +<p>[[Image:Foobar.jpg|thumb|This is a broken caption. But <a rel="mw:WikiLink" href="Main_Page">this</a> is just an ordinary link.</p>
  !! end
  
  !! test
  Image caption containing another image
  !! wikitext
 -[[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]]
 -!! html
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This is a caption with another <a href="/index.php?title=Special:Upload&amp;wpDestFile=Icon.png" class="new" title="File:Icon.png">image</a> inside it!</div></div></div>
 +[[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
 +!! html/php
 +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This is a caption with another <a href="/wiki/File:Thumb.png" class="image" title="image"><img alt="image" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" /></a> inside it!</div></div></div>
  
 +!! html/parsoid
 +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>This is a caption with another <span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"image"}'><a href="File:Thumb.png"><img resource="./File:Thumb.png" src="//example.com/images/e/ea/Thumb.png" height="135" width="135"/></a></span> inside it!</figcaption></figure>
  !! end
  
  !! test
 -Image caption containing a newline
 +Image: caption containing a newline
  !! wikitext
 -[[Image:Foobar.jpg|This
 +[[File:Foobar.jpg|This
  *is some text]]
 -!! html
 +!! html/php
  <p><a href="/wiki/File:Foobar.jpg" class="image" title="This *is some text"><img alt="This *is some text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
  </p>
 +!! html/parsoid
 +<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"This\n*is some text"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
  !!end
  
  !!test
 -Parsoid: Image caption containing leading space
 +Image: caption containing leading space
  (The leading space should not trigger nowiki escaping in wt2wt mode)
  !! wikitext
 -[[Image:Foobar.jpg|thumb| bar]]
 -!! html
 +[[File:Foobar.jpg|thumb| bar]]
 +!! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>bar</div></div></div>
  
 +!! html/parsoid
 +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption> bar</figcaption></figure>
  !!end
  
  !! test
 -Images: caption containing a table
 +Image: caption containing a table
 +!! options
 +parsoid=wt2html,wt2wt,html2html
  !! wikitext
  [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
  {|
@@@ -10905,13 -10585,12 +10951,13 @@@ language=e
  !! test
  Localized image handling (2).
  !! options
 +thumbsize=220
  parsoid=wt2html,wt2wt,html2html
  language=es
  !! wikitext
  [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
  !! html/php
 -<div class="thumb tleft"><div class="thumbinner" style="width:182px;"><a href="/wiki/Foo" title="Foo"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/Archivo:Foobar.jpg" class="internal" title="Aumentar"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
 +<div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/Foo" title="Foo"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/Archivo:Foobar.jpg" class="internal" title="Aumentar"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
  
  !! html/parsoid
  <figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb"><a href="./Foo"><img resource="./Archivo:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
  !! test
  "border", "frameless" and "class" attributes on an image.
  !! options
 +thumbsize=220
  parsoid=wt2html,wt2wt,html2html
  !! wikitext
  [[File:Foobar.jpg|frameless|border|class=extra|caption]]
  !! html/php
 -<p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="extra thumbborder" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
 +<p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="extra thumbborder" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>
  </p>
  !! html/parsoid
  <p><span class="mw-default-size mw-image-border extra" typeof="mw:Image/Frameless" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a></span></p>
  !! test
  Invalid image attributes (bug 62500)
  !! options
 +thumbsize=220
  parsoid=wt2html,wt2wt,html2html
  !! wikitext
  [[File:Foobar.jpg|thumb|float|left|caption]]
  
  [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
  !! html/php
 -<div class="thumb tleft"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
 -<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
 -<div class="thumb tleft"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
 +<div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
 +<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
 +<div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
  
  !! html/parsoid
  <figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>caption</figcaption></figure><figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>caption</figcaption></figure><figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
@@@ -10979,7 -10656,7 +11025,7 @@@ wgEnableUploads=
  !! end
  
  # Parsoid-specific testing for images
 -# http://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
 +# https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
  # Currently imperfect due to a flaw in the Parsoid testrunner
  # Work in progress
  # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
@@@ -11101,36 -10778,48 +11147,36 @@@ valign, and caption (existing content
  
  !! test
  Parsoid-specific image handling - framed image with specific size and caption
 +(size is ignored)
 +!! options
 +parsoid=wt2html,wt2wt,html2html
  !! wikitext
 -[[Image:Foobar.jpg|frame|500x50px|caption]]
 +[[File:Foobar.jpg|frame|500x50px|caption]]
  !! html/parsoid
  <figure typeof="mw:Image/Frame">
  <a href="File:Foobar.jpg">
 -<img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/442px-Foobar.jpg" height="50" width="442" />
 +<img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941" />
  </a>
  <figcaption>caption</figcaption>
  </figure>
  !! end
  
 -!! test
 -Parsoid-specific image handling - framed image with specific size and caption
 -(existing content)
 -!! wikitext
 -[[File:Foobar.jpg|442x50px|frame|caption]]
 -!! html/parsoid
 -<figure typeof="mw:Image/Frame" data-parsoid='{"optList":[{"ck":"width","ak":"442x50px"},{"ck":"framed","ak":"frame"},{"ck":"caption","ak":"caption"}],"size":"442x50"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/442px-Foobar.jpg" height="50" width="442" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"50","width":"442"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>caption</figcaption></figure>
 -!! end
 -
  !! test
  Parsoid-specific image handling - framed image with specific size, halign, valign, and caption
 +(size is ignored)
 +!! options
 +parsoid=wt2html,wt2wt,html2html
  !! wikitext
 -[[Image:Foobar.jpg|left|baseline|frame|500x50px|caption]]
 +[[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
  !! html/parsoid
  <figure class="mw-halign-left mw-valign-baseline" typeof="mw:Image/Frame">
  <a href="File:Foobar.jpg">
 -<img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/442px-Foobar.jpg" height="50" width="442" />
 +<img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941" />
  </a>
  <figcaption>caption</figcaption>
  </figure>
  !! end
  
 -!! test
 -Parsoid-specific image handling - framed image with specific size, halign,
 -valign, and caption (existing content)
 -!! wikitext
 -[[File:Foobar.jpg|442x50px|frame|left|baseline|caption]]
 -!! html/parsoid
 -<figure class="mw-halign-left mw-valign-baseline" typeof="mw:Image/Frame" data-parsoid='{"optList":[{"ck":"width","ak":"442x50px"},{"ck":"framed","ak":"frame"},{"ck":"left","ak":"left"},{"ck":"baseline","ak":"baseline"},{"ck":"caption","ak":"caption"}],"size":"442x50"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/442px-Foobar.jpg" height="50" width="442" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"50","width":"442"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>caption</figcaption></figure>
 -!! end
 -
  !! test
  Parsoid-specific image handling - frameless image with specific size, border, and caption
  !! wikitext
  !! end
  
  !! test
 -Parsoid-specific image handling - empty caption
 +Parsoid-specific image handling - empty caption (1)
 +!! options
 +parsoid=wt2html,wt2wt
  !! wikitext
  [[File:Foobar.jpg|thumb|]]
  !! html/parsoid
  <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption></figcaption></figure>
  !! end
  
 +# empty captions don't get serialized unless we're in the "round trip" case
 +!! test
 +Parsoid-specific image handling - empty caption (2)
 +!! options
 +parsoid=html2wt
 +!! html/parsoid
 +<figure class="mw-default-size" typeof="mw:Image/Thumb">
 +  <a href="File:Foobar.jpg">
 +    <img resource="./File:Foobar.jpg"
 +         src="//example.com/images/3/3a/Foobar.jpg"
 +         height="25" width="220"/>
 +  </a>
 +  <figcaption></figcaption>
 +</figure>
 +!! wikitext
 +[[File:Foobar.jpg|thumb]]
 +!! end
 +
  !! test
  Parsoid-specific image handling - whitespace caption
  !! wikitext
@@@ -11267,78 -10936,22 +11313,78 @@@ subpage title=[[Subpage test/1/2/3/4]
  <p><a rel="mw:WikiLink" href="Subpage_test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
  !! end
  
 -# TODO: make this PHP-parser compatible!
  !! test
  Parsoid: dot-slash prefixed wikilinks
 -!! options
 -parsoid=wt2wt,wt2html,html2html
  !! wikitext
  [[./foo]]
  
  [[././bar]]
  
  [[././baz/]]
 -!! html
 -<p><a rel="mw:WikiLink" href="./Foo">foo</a></p>
 -<p><a rel="mw:WikiLink" href="./Bar">bar</a></p>
 -<p><a rel="mw:WikiLink" href="./Baz/">baz/</a></p>
 -!! end
 +!! html/php
 +<p>[[./foo]]
 +</p><p>[[././bar]]
 +</p><p>[[././baz/]]
 +</p>
 +!! html/parsoid
 +<p>[[./foo]]
 +</p><p>[[././bar]]
 +</p><p>[[././baz/]]
 +</p>
 +!! end
 +
 +!! test
 +Render invalid page names as plain text (bug 51090)
 +!! wikitext
 +[[./../foo|bar]]
 +[[foo�|bar]]
 +[[foo/.|bar]]
 +[[foo/..|bar]]
 +[[foo~~~bar]]
 +[[foo>bar]]
 +[[foo[bar]]
 +[[.]]
 +[[..]]
 +[[foo././bar]]
 +
 +[[{{echo|./../foo}}|bar]]
 +[[{{echo|foo/.}}|bar]]
 +[[{{echo|foo/..}}|bar]]
 +[[{{echo|foo~~~~bar}}]]
 +[[{{echo|foo>bar}}]]
 +[[{{echo|foo././bar}}]]
 +[[{{echo|foo{bar}}]]
 +[[{{echo|foo}bar}}]]
 +[[{{echo|foo[bar}}]]
 +[[{{echo|foo]bar}}]]
 +[[{{echo|foo<bar}}]]
 +!!html/php
 +<p>[[./../foo|bar]]
 +[[foo�|bar]]
 +[[foo/.|bar]]
 +[[foo/..|bar]]
 +[[foo~~~bar]]
 +[[foo&gt;bar]]
 +[[foo[bar]]
 +[[.]]
 +[[..]]
 +[[foo././bar]]
 +</p><p>[[./../foo|bar]]
 +[[foo/.|bar]]
 +[[foo/..|bar]]
 +[[foo~~~~bar]]
 +[[foo&gt;bar]]
 +[[foo././bar]]
 +[[foo{bar]]
 +[[foo}bar]]
 +[[foo[bar]]
 +[[foo]bar]]
 +[[foo&lt;bar]]
 +</p>
 +!!html/parsoid
 +<p>[[./../foo|bar]][[foo�|bar]][[foo/.|bar]][[foo/..|bar]][[foo~~~bar]][[foo>bar]][[foo[bar]][[.]][[..]][[foo././bar]]</p>
 +<p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]][[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]][[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]][[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]][[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]][[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]][[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]][[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]][[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]][[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]][[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;bar"}},"i":0}}]}'>foo&lt;bar</span>]]</p>
 +!!end
  
  !! test
  Disabled subpages
@@@ -12080,23 -11693,6 +12126,23 @@@ __NOEDITSECTION_
  
  !! end
  
 +!! test
 +Single-line or multiline-comments can follow headings
 +!! options
 +parsoid=wt2html,wt2wt
 +!! wikitext
 +==foo==<!---->
 +==bar==<!--c1-->
 +==baz==<!--
 +c2
 +c3-->
 +!! html
 +<h2><span class="mw-headline" id="foo">foo</span></h2>
 +<h2><span class="mw-headline" id="bar">bar</span></h2>
 +<h2><span class="mw-headline" id="baz">baz</span></h2>
 +
 +!! end
 +
  !! test
  BUG 1219 URL next to image (broken)
  !! wikitext
@@@ -13728,11 -13324,9 +13774,11 @@@ http://example.com<pre>junk</pre
  Fuzz testing: image with bogus manual thumbnail
  !! wikitext
  [[Image:foobar.jpg|thumbnail= ]]
 -!! html
 +!! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail:   <div class="thumbcaption"></div></div></div>
  
 +!! html/parsoid
 +<meta typeof="mw:Placeholder" data-parsoid='{"src":"[[Image:foobar.jpg|thumbnail= ]]","optList":[{"ck":"manualthumb","ak":"thumbnail= "}],"dsr":[0,32,null,null]}'/>
  !!end
  
  !! test
@@@ -14755,8 -14349,6 +14801,8 @@@ Handling of &#x0A; in URL
  # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
  !! test
  5 quotes, code coverage +1 line
 +!! options
 +parsoid=wt2html
  !! wikitext
  '''''
  !! html/php
  <p><b><i></i></b></p>
  !! end
  
 +# same html as previous, but wikitext adjusted to match parsoid html2wt
 +# note that wt2html and html2html will put the <i> before the <b>
 +!! test
 +5 quotes, code coverage +1 line w/ nowiki (1)
 +!! options
 +parsoid=wt2wt,html2wt
 +!! wikitext
 +'''''<nowiki/>'''''
 +!! html/php
 +<p><i></i>
 +</p>
 +!! html/parsoid
 +<p><b><i></i></b></p>
 +!! end
 +
 +# same as previous, just swapping the <i> and <b>
 +!! test
 +5 quotes, code coverage +1 line w/ nowiki (2)
 +!! wikitext
 +'''''<nowiki/>'''''
 +!! html/php
 +<p><i></i>
 +</p>
 +!! html/parsoid
 +<p><i><b></b></i></p>
 +!! end
 +
  !! test
  Special:Search page linking.
  !! wikitext
@@@ -15161,14 -14726,6 +15207,14 @@@ ISBN 3-462-04561-
  </p>
  !! end
  
 +!! test
 +ISBN with empty prefix (parsoid test)
 +!! wikitext
 +ISBN 1234567890
 +!! html/parsoid
 +<p><a href="Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567890</a></p>
 +!! end
 +
  !! test
  Bug 22905: <abbr> followed by ISBN followed by </a>
  !! wikitext
@@@ -19550,23 -19107,6 +19596,23 @@@ parsoi
  
  !!end
  
 +!! test
 +New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
 +!! options
 +parsoid=html2wt
 +!! wikitext
 +<includeonly>foo</includeonly>
 +new para
 +
 +[[./Category:Foo]]
 +
 += new heading =
 +!! html
 +<meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>foo&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><p>new para</p>
 +
 +<link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid=''/><h1>new heading</h1>
 +!! end
 +
  ## PHP emits broken html for this, and since this is primarily
  ## a Parsoid serializer test, marking this Parsoid only
  !!test
@@@ -19593,7 -19133,7 +19639,7 @@@ parsoi
  </body>
  !!end
  
 -## Currently the p-wrapper is fragile in how adds / removes transformations.
 +## Currently the p-wrapper is fragile in how it adds / removes transformations.
  ## Having nested or stray pre tags results in the attempt to add duplicates,
  ## causing an assertion fail. This test tries to prevent that situation.
  !!test
@@@ -19807,17 -19347,6 +19853,17 @@@ parsoid=wt2wt,wt2htm
  <td>b</td></tr></tbody></table>
  !!end
  
 +!!test
 +9. Encapsulate foster-parented transclusion content
 +!!options
 +parsoid=wt2wt,wt2html
 +!! wikitext
 +<table>{{echo|hi</table>hello}}
 +!! html
 +<span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":["&lt;table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;/table>hello"}},"i":0}}]}' data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"pi":[[{"k":"1","spc":["","","",""]}]]}'>hi</span>
 +<table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2" data-parsoid="{}">hello</span>
 +!!end
 +
  !!test
  Table in fosterable position
  !!options
@@@ -19858,128 -19387,62 +19904,128 @@@ parsoid=html2w
  !! test
  Image: Modifying size of an image (1)
  !! options
 -parsoid=html2wt
 +parsoid={
 +  "modes": ["wt2wt"],
 +  "changes": [
 +    ["img[height]", "attr", "height", "22"],
 +    ["img[width]", "attr", "width", "200"]
 +  ]
 +}
  !! wikitext
 +[[Image:Foobar.jpg|230x230px]]
 +!! wikitext/edited
  [[Image:Foobar.jpg|200x200px]]
 -!! html
 -<p><span typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"230x230px"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/230px-Foobar.jpg" height="22" width="200" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"26","width":"230"},"sa":{"resource":"Image:Foobar.jpg"}}'/></a></span></p>
  !!end
  
  !! test
  Image: Modifying size of an image (2)
  !! options
 -parsoid=html2wt
 +parsoid={
 +  "modes": ["wt2wt"],
 +  "changes": [
 +    ["img[height]", "attr", "height", "100"],
 +    ["img[width]", "attr", "width", "500"]
 +  ]
 +}
  !! wikitext
 +[[Image:Foobar.jpg|230x230px]]
 +!! wikitext/edited
  [[Image:Foobar.jpg|500x500px]]
 -!! html
 -<p><span typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"230x230px"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/230px-Foobar.jpg" height="100" width="500" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"26","width":"230"},"sa":{"resource":"Image:Foobar.jpg"}}'/></a></span></p>
  !!end
  
 -# note that the data-parsoid value conflicts with the figure's class
 +# Change in size is ignored so long as class='mw-default-size'
 +!! test
 +Image: Modifying size of an image (3)
 +!! options
 +parsoid={
 +  "modes": ["wt2wt"],
 +  "changes": [
 +    ["figure[class]", "removeClass", "mw-default-size"],
 +    ["figure img", "attr", "height", "19"],
 +    ["figure img", "attr", "width", "170"]
 +  ]
 +}
 +!! wikitext
 +[[Image:Foobar.jpg|thumb]]
 +!! wikitext/edited
 +[[Image:Foobar.jpg|thumb|170x170px]]
 +!!end
 +
  !! test
  Image: Modifying alignment of an image (bug 48665)
  !! options
 -parsoid=html2wt
 +parsoid={
 +  "modes": ["wt2wt"],
 +  "changes": [
 +    ["figure[class]", "removeClass", "mw-halign-right"],
 +    ["figure[class]", "addClass", "mw-halign-left"]
 +  ]
 +}
  !! wikitext
 +[[Image:Foobar.jpg|thumb|caption|right]]
 +!! wikitext/edited
  [[Image:Foobar.jpg|thumb|caption|left]]
 -!! html
 -<figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"caption"},{"ck":"right","ak":"right"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" height="20" width="180" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"20","width":"180"},"sa":{"resource":"Image:Foobar.jpg"}}'/></a><figcaption>caption</figcaption></figure>
 +!! end
 +
 +!! test
 +Image: Modifying mw-default-size of an frameless image (bug 62805)
 +!! options
 +parsoid={
 +  "modes": ["wt2wt"],
 +  "changes": [
 +    ["figure.mw-default-size", "removeClass", "mw-default-size"]
 +  ]
 +}
 +!! wikitext
 +[[Image:Foobar.jpg|frameless|right]]
 +!! wikitext/edited
 +[[Image:Foobar.jpg|frameless|right|220x220px]]
  !! end
  
  !! test
  Image: Modifying valign of an image (bug 49221)
  !! options
 -parsoid=html2wt
 +parsoid={
 +  "modes": ["wt2wt"],
 +  "changes": [
 +    ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
 +    ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
 +  ]
 +}
  !! wikitext
 +[[File:Foobar.jpg|20px|middle]]
 +!! wikitext/edited
  [[File:Foobar.jpg|20px|text-top]]
 -!! html
 -<p><span class="mw-valign-text-top" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"20px"},{"ck":"text_top","ak":"text-top"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" height="2" width="20" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"2","width":"20"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
  !! end
  
  !! test
  Image: Modifying alt attribute of an image (bug 56400)
  !! options
 -parsoid=html2wt
 +parsoid={
 +  "modes": ["wt2wt"],
 +  "changes": [
 +    ["img[alt]", "attr", "alt", "some alternate edited text"]
 +  ]
 +}
  !! wikitext
 +[[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
 +!! wikitext/edited
  [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
 -!! html
 -<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"some caption"},{"ck":"alt","ak":"alt=some alternate text"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img alt="some alternate edited text" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" height="20" width="180" data-parsoid='{"a":{"alt":"some alternate edited text","resource":"./File:Foobar.jpg","height":"20","width":"180"},"sa":{"alt":"alt=some alternate edited text","resource":"File:Foobar.jpg"}}'/></a><figcaption>some caption</figcaption></figure>
  !!end
  
  !! test
  Image: Modifying caption of an image
  !! options
 -parsoid=html2wt
 +parsoid={
 +  "modes": ["wt2wt"],
 +  "changes": [
 +    ["figcaption", "text", "new caption"]
 +  ]
 +}
  !! wikitext
 +[[Image:Foobar.jpg|thumb|original caption]]
 +!! wikitext/edited
  [[Image:Foobar.jpg|thumb|new caption]]
 -!! html
 -<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"original caption"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" height="20" width="180" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"20","width":"180"},"sa":{"resource":"Image:Foobar.jpg"}}'/></a><figcaption>new caption</figcaption></figure>
  !!end
  
  !! test
@@@ -20031,7 -19494,7 +20077,7 @@@ parsoi
  !!end
  
  !! test
 -Images: upright option (parsoid)
 +Image: upright option (parsoid)
  !! options
  parsoid
  !! wikitext
  !!end
  
  !! test
 -Images: upright option is ignored on inline and frame images (parsoid)
 +Image: upright option is ignored on inline and frame images (parsoid)
  !! options
  parsoid
  !! wikitext
  <p><span typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="57" width="500"/></a></span></p>
  !!end
  
 +!! test
 +Image: from basic HTML (1)
 +!! options
 +parsoid=html2wt
 +!! html/parsoid
 +<span typeof="mw:Image">
 +  <img src="File:Foobar.jpg" width=100 height=100 alt="Alt">
 +</span>
 +!! wikitext
 +[[File:Foobar.jpg|link=|alt=Alt|100x100px]]
 +!! end
 +
 +!! test
 +Image: from basic HTML (2)
 +!! options
 +parsoid=html2wt
 +!! html/parsoid
 +<img src="File:Foobar.jpg" width=100 height=100 alt="Alt">
 +!! wikitext
 +[[File:Foobar.jpg|link=|alt=Alt|100x100px]]
 +!! end
 +
 +!! test
 +Image: from basic HTML (3)
 +!! options
 +parsoid=html2wt
 +!! html/parsoid
 +<a href="Main"><img src="File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
 +!! wikitext
 +[[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
 +!! end
 +
 +!! test
 +Image: from basic HTML (4)
 +!! options
 +parsoid=html2wt
 +!! html/parsoid
 +<img src="File:Foobar.jpg">
 +!! wikitext
 +[[File:Foobar.jpg|link=]]
 +!! end
 +
  !! test
  Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
  !! options