Merge "Change the rfcurl from protocol relative to HTTPS"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 13 Nov 2017 07:30:58 +0000 (07:30 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 13 Nov 2017 07:30:58 +0000 (07:30 +0000)
1  2 
languages/i18n/en.json
tests/parser/parserTests.txt

diff --combined languages/i18n/en.json
        "tog-shownumberswatching": "Show the number of watching users",
        "tog-oldsig": "Your existing signature:",
        "tog-fancysig": "Treat signature as wikitext (without an automatic link)",
 -      "tog-uselivepreview": "Use live preview",
 +      "tog-uselivepreview": "Show previews without reloading the page",
        "tog-forceeditsummary": "Prompt me when entering a blank edit summary",
        "tog-watchlisthideown": "Hide my edits from the watchlist",
        "tog-watchlisthidebots": "Hide bot edits from the watchlist",
        "tog-watchlisthideminor": "Hide minor edits from the watchlist",
        "tog-watchlisthideliu": "Hide edits by logged in users from the watchlist",
        "tog-watchlistreloadautomatically": "Reload the watchlist automatically whenever a filter is changed (JavaScript required)",
 +      "tog-watchlistunwatchlinks": "Add direct unwatch/watch links to watchlist entries (JavaScript required for toggle functionality)",
        "tog-watchlisthideanons": "Hide edits by anonymous users from the watchlist",
        "tog-watchlisthidepatrolled": "Hide patrolled edits from the watchlist",
        "tog-watchlisthidecategorization": "Hide categorization of pages",
@@@ -51,6 -50,7 +51,6 @@@
        "underline-never": "Never",
        "underline-default": "Skin or browser default",
        "editfont-style": "Edit area font style:",
 -      "editfont-default": "Browser default",
        "editfont-monospace": "Monospaced font",
        "editfont-sansserif": "Sans-serif font",
        "editfont-serif": "Serif font",
        "anonpreviewwarning": "<em>You are not logged in. Saving will record your IP address in this page's edit history.</em>",
        "missingsummary": "<strong>Reminder:</strong> You have not provided an edit summary.\nIf you click \"$1\" again, your edit will be saved without one.",
        "selfredirect": "<strong>Warning:</strong> You are redirecting this page to itself.\nYou may have specified the wrong target for the redirect, or you may be editing the wrong page.\nIf you click \"$1\" again, the redirect will be created anyway.",
 -      "missingcommenttext": "Please enter a comment below.",
 +      "missingcommenttext": "Please enter a comment.",
        "missingcommentheader": "<strong>Reminder:</strong> You have not provided a subject for this comment.\nIf you click \"$1\" again, your edit will be saved without one.",
        "summary-preview": "Preview of edit summary:",
        "subject-preview": "Preview of subject:",
        "explainconflict": "Someone else has changed this page since you started editing it.\nThe upper text area contains the page text as it currently exists.\nYour changes are shown in the lower text area.\nYou will have to merge your changes into the existing text.\n<strong>Only</strong> the text in the upper text area will be saved when you press \"$1\".",
        "yourtext": "Your text",
        "storedversion": "Stored revision",
 -      "nonunicodebrowser": "<strong>Warning: Your browser is not Unicode compliant.</strong>\nA workaround is in place to allow you to safely edit pages: Non-ASCII characters will appear in the edit box as hexadecimal codes.",
        "editingold": "<strong>Warning: You are editing an out-of-date revision of this page.</strong>\nIf you save it, any changes made since this revision will be lost.",
 +      "unicode-support-fail": "It appears that your browser does not support Unicode. It is required to edit pages, so your edit was not saved.",
        "yourdiff": "Differences",
        "copyrightwarning": "Please note that all contributions to {{SITENAME}} are considered to be released under the $2 (see $1 for details).\nIf you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.<br />\nYou are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.\n<strong>Do not submit copyrighted work without permission!</strong>",
        "copyrightwarning2": "Please note that all contributions to {{SITENAME}} may be edited, altered, or removed by other contributors.\nIf you do not want your writing to be edited mercilessly, then do not submit it here.<br />\nYou are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see $1 for details).\n<strong>Do not submit copyrighted work without permission!</strong>",
        "permissionserrorstext-withaction": "You do not have permission to $2, for the following {{PLURAL:$1|reason|reasons}}:",
        "contentmodelediterror": "You cannot edit this revision because its content model is <code>$1</code>, which differs from the current content model of the page <code>$2</code>.",
        "recreate-moveddeleted-warn": "<strong>Warning: You are recreating a page that was previously deleted.</strong>\n\nYou should consider whether it is appropriate to continue editing this page.\nThe deletion and move log for this page are provided here for convenience:",
 -      "moveddeleted-notice": "This page has been deleted.\nThe deletion and move log for the page are provided below for reference.",
 -      "moveddeleted-notice-recent": "Sorry, this page was recently deleted (within the last 24 hours).\nThe deletion and move log for the page are provided below for reference.",
 +      "moveddeleted-notice": "This page has been deleted.\nThe deletion, protection, and move log for the page are provided below for reference.",
 +      "moveddeleted-notice-recent": "Sorry, this page was recently deleted (within the last 24 hours).\nThe deletion, protection, and move log for the page are provided below for reference.",
        "log-fulllog": "View full log",
        "edit-hook-aborted": "Edit aborted by hook.\nIt gave no explanation.",
        "edit-gone-missing": "Could not update the page.\nIt appears to have been deleted.",
        "parser-template-loop-warning": "Template loop detected: [[$1]]",
        "template-loop-category": "Pages with template loops",
        "template-loop-category-desc": "The page contains a template loop, ie. a template which calls itself recursively.",
 +      "template-loop-warning": "<strong>Warning:</strong> This page calls [[:$1]] which causes a template loop (an infinite recursive call).",
        "parser-template-recursion-depth-warning": "Template recursion depth limit exceeded ($1)",
        "language-converter-depth-warning": "Language converter depth limit exceeded ($1)",
        "node-count-exceeded-category": "Pages where node count is exceeded",
        "searchall": "all",
        "showingresults": "Showing below up to {{PLURAL:$1|<strong>1</strong> result|<strong>$1</strong> results}} starting with #<strong>$2</strong>.",
        "showingresultsinrange": "Showing below up to {{PLURAL:$1|<strong>1</strong> result|<strong>$1</strong> results}} in range #<strong>$2</strong> to #<strong>$3</strong>.",
 -      "search-showingresults": "{{PLURAL:$4|Result <strong>$1</strong> of <strong>$3</strong>|Results <strong>$1 - $2</strong> of <strong>$3</strong>}}",
 +      "search-showingresults": "{{PLURAL:$4|Result <strong>$1</strong> of <strong>$3</strong>|Results <strong>$1  $2</strong> of <strong>$3</strong>}}",
        "search-nonefound": "There were no results matching the query.",
        "search-nonefound-thiswiki": "There were no results matching the query in this site.",
        "powersearch-legend": "Advanced search",
        "prefs-editwatchlist-clear": "Clear your watchlist",
        "prefs-watchlist-days": "Days to show in watchlist:",
        "prefs-watchlist-days-max": "Maximum $1 {{PLURAL:$1|day|days}}",
 -      "prefs-watchlist-edits": "Maximum number of changes to show in expanded watchlist:",
 +      "prefs-watchlist-edits": "Maximum number of changes to show in watchlist:",
        "prefs-watchlist-edits-max": "Maximum number: 1000",
        "prefs-watchlist-token": "Watchlist token:",
        "prefs-misc": "Misc",
        "timezoneregion-europe": "Europe",
        "timezoneregion-indian": "Indian Ocean",
        "timezoneregion-pacific": "Pacific Ocean",
 -      "allowemail": "Enable email from other users",
 +      "allowemail": "Allow other users to email me",
 +      "email-blacklist-label": "Prohibit these users from emailing me:",
        "prefs-searchoptions": "Search",
        "prefs-namespaces": "Namespaces",
        "default": "default",
        "prefs-editor": "Editor",
        "prefs-preview": "Preview",
        "prefs-advancedrc": "Advanced options",
 +      "prefs-opt-out": "Opt out of improvements",
        "prefs-advancedrendering": "Advanced options",
        "prefs-advancedsearchoptions": "Advanced options",
        "prefs-advancedwatchlist": "Advanced options",
        "recentchanges-summary": "Track the most recent changes to the wiki on this page.",
        "recentchangestext": "-",
        "recentchanges-noresult": "No changes during the given period match these criteria.",
 +      "recentchanges-timeout": "This search has timed out. You may wish to try different search parameters.",
 +      "recentchanges-network": "Due to a technical error, no results could be loaded. Please try refreshing the page.",
        "recentchanges-feed-description": "Track the most recent changes to the wiki in this feed.",
        "recentchanges-label-newpage": "This edit created a new page",
        "recentchanges-label-minor": "This is a minor edit",
        "recentchanges-legend-unpatrolled": "{{int:recentchanges-label-unpatrolled}}",
        "recentchanges-legend-plusminus": "(<em>±123</em>)",
        "recentchanges-submit": "Show",
 +      "rcfilters-tag-remove": "Remove '$1'",
 +      "rcfilters-legend-heading": "<strong>List of abbreviations:</strong>",
 +      "rcfilters-other-review-tools": "Other review tools",
 +      "rcfilters-group-results-by-page": "Group results by page",
 +      "rcfilters-grouping-title": "Grouping",
        "rcfilters-activefilters": "Active filters",
        "rcfilters-advancedfilters": "Advanced filters",
 +      "rcfilters-limit-title": "Changes to show",
 +      "rcfilters-limit-shownum": "Show last {{PLURAL:$1|change|$1 changes}}",
 +      "rcfilters-days-title": "Recent days",
 +      "rcfilters-hours-title": "Recent hours",
 +      "rcfilters-days-show-days": "$1 {{PLURAL:$1|day|days}}",
 +      "rcfilters-days-show-hours": "$1 {{PLURAL:$1|hour|hours}}",
 +      "rcfilters-highlighted-filters-list": "Highlighted: $1",
        "rcfilters-quickfilters": "Saved filters",
 -      "rcfilters-quickfilters-placeholder-title": "No links saved yet",
 +      "rcfilters-quickfilters-placeholder-title": "No filters saved yet",
        "rcfilters-quickfilters-placeholder-description": "To save your filter settings and reuse them later, click the bookmark icon in the Active Filter area, below.",
        "rcfilters-savedqueries-defaultlabel": "Saved filters",
        "rcfilters-savedqueries-rename": "Rename",
        "rcfilters-savedqueries-new-name-label": "Name",
        "rcfilters-savedqueries-new-name-placeholder": "Describe the purpose of the filter",
        "rcfilters-savedqueries-apply-label": "Create filter",
 +      "rcfilters-savedqueries-apply-and-setdefault-label": "Create default filter",
        "rcfilters-savedqueries-cancel-label": "Cancel",
        "rcfilters-savedqueries-add-new-title": "Save current filter settings",
 +      "rcfilters-savedqueries-already-saved": "These filters are already saved",
        "rcfilters-restore-default-filters": "Restore default filters",
        "rcfilters-clear-all-filters": "Clear all filters",
 -      "rcfilters-search-placeholder": "Filter recent changes (browse or start typing)",
 +      "rcfilters-show-new-changes": "View newest changes",
 +      "rcfilters-search-placeholder": "Filter changes (use menu or search for filter name)",
        "rcfilters-invalid-filter": "Invalid filter",
        "rcfilters-empty-filter": "No active filters. All contributions are shown.",
        "rcfilters-filterlist-title": "Filters",
 -      "rcfilters-filterlist-whatsthis": "What's this?",
 -      "rcfilters-filterlist-feedbacklink": "Provide feedback on the new (beta) filters",
 +      "rcfilters-filterlist-whatsthis": "How do these work?",
 +      "rcfilters-filterlist-feedbacklink": "Tell us what you think about these (new) filtering tools",
        "rcfilters-highlightbutton-title": "Highlight results",
        "rcfilters-highlightmenu-title": "Select a color",
        "rcfilters-highlightmenu-help": "Select a color to highlight this property",
        "rcfilters-filterlist-noresults": "No filters found",
        "rcfilters-noresults-conflict": "No results found because the search criteria are in conflict",
        "rcfilters-state-message-subset": "This filter has no effect because its results are included with those of the following, broader {{PLURAL:$2|filter|filters}} (try highlighting to distinguish it): $1",
 -      "rcfilters-state-message-fullcoverage": "Selecting all filters in a group is the same as selecting none, so this filter has no effect. Group includes: $1",
 -      "rcfilters-filtergroup-registration": "User registration",
 -      "rcfilters-filter-registered-label": "Registered",
 -      "rcfilters-filter-registered-description": "Logged-in editors.",
 -      "rcfilters-filter-unregistered-label": "Unregistered",
 -      "rcfilters-filter-unregistered-description": "Editors who aren’t logged in.",
 -      "rcfilters-filter-unregistered-conflicts-user-experience-level": "This filter conflicts with the following Experience {{PLURAL:$2|filter|filters}}, which {{PLURAL:$2|finds|find}} only registered users: $1",
 +      "rcfilters-state-message-fullcoverage": "Selecting all filters in this group is the same as selecting none, so this filter has no effect. Group includes: $1",
        "rcfilters-filtergroup-authorship": "Contribution authorship",
        "rcfilters-filter-editsbyself-label": "Changes by you",
        "rcfilters-filter-editsbyself-description": "Your own contributions.",
        "rcfilters-filter-editsbyother-label": "Changes by others",
        "rcfilters-filter-editsbyother-description": "All changes except your own.",
 -      "rcfilters-filtergroup-userExpLevel": "Experience level (for registered users only)",
 -      "rcfilters-filtergroup-user-experience-level-conflicts-unregistered": "Experience filters find only registered users, so this filter conflicts with the “Unregistered” filter.",
 -      "rcfilters-filtergroup-user-experience-level-conflicts-unregistered-global": "The \"Unregistered\" filter conflicts with one or more Experience filters, which find registered users only. The conflicting filters are marked in the Active Filters area, above.",
 +      "rcfilters-filtergroup-userExpLevel": "User registration and experience",
 +      "rcfilters-filter-user-experience-level-registered-label": "Registered",
 +      "rcfilters-filter-user-experience-level-registered-description": "Logged-in editors.",
 +      "rcfilters-filter-user-experience-level-unregistered-label": "Unregistered",
 +      "rcfilters-filter-user-experience-level-unregistered-description": "Editors who aren't logged-in.",
        "rcfilters-filter-user-experience-level-newcomer-label": "Newcomers",
 -      "rcfilters-filter-user-experience-level-newcomer-description": "Fewer than 10 edits and 4 days of activity.",
 +      "rcfilters-filter-user-experience-level-newcomer-description": "Registered editors who have fewer than 10 edits or 4 days of activity.",
        "rcfilters-filter-user-experience-level-learner-label": "Learners",
 -      "rcfilters-filter-user-experience-level-learner-description": "More experience than \"Newcomers\" but less than \"Experienced users\".",
 +      "rcfilters-filter-user-experience-level-learner-description": "Registered editors whose experience falls between \"Newcomers\" and \"Experienced users.\"",
        "rcfilters-filter-user-experience-level-experienced-label": "Experienced users",
 -      "rcfilters-filter-user-experience-level-experienced-description": "More than 30 days of activity and 500 edits.",
 +      "rcfilters-filter-user-experience-level-experienced-description": "Registered editors with more than 500 edits and 30 days of activity.",
        "rcfilters-filtergroup-automated": "Automated contributions",
        "rcfilters-filter-bots-label": "Bot",
        "rcfilters-filter-bots-description": "Edits made by automated tools.",
        "rcfilters-filter-watchlist-watchednew-description": "Changes to Watchlisted pages you haven't visited since the changes occurred.",
        "rcfilters-filter-watchlist-notwatched-label": "Not on Watchlist",
        "rcfilters-filter-watchlist-notwatched-description": "Everything except changes to your Watchlisted pages.",
 +      "rcfilters-filtergroup-watchlistactivity": "Watchlist activity",
 +      "rcfilters-filter-watchlistactivity-unseen-label": "Unseen changes",
 +      "rcfilters-filter-watchlistactivity-unseen-description": "Changes to pages you haven't visited since the changes occurred.",
 +      "rcfilters-filter-watchlistactivity-seen-label": "Seen changes",
 +      "rcfilters-filter-watchlistactivity-seen-description": "Changes to pages you have visited since the changes occurred.",
        "rcfilters-filtergroup-changetype": "Type of change",
        "rcfilters-filter-pageedits-label": "Page edits",
        "rcfilters-filter-pageedits-description": "Edits to wiki content, discussions, category descriptions…",
        "rcfilters-hideminor-conflicts-typeofchange-global": "The \"Minor edits\" filter conflicts with one or more Type of change filters, because certain types of change cannot be designated as \"minor\". The conflicting filters are marked in the Active filters area, above.",
        "rcfilters-hideminor-conflicts-typeofchange": "Certain types of change cannot be designated as \"minor\", so this filter conflicts with the following Type of Change filters: $1",
        "rcfilters-typeofchange-conflicts-hideminor": "This Type of change filter conflicts with the \"Minor edits\" filter. Certain types of change cannot be designated as \"minor\".",
 -      "rcfilters-filtergroup-lastRevision": "Last revision",
 -      "rcfilters-filter-lastrevision-label": "Last revision",
 -      "rcfilters-filter-lastrevision-description": "The most recent change to a page.",
 -      "rcfilters-filter-previousrevision-label": "Earlier revisions",
 -      "rcfilters-filter-previousrevision-description": "All changes that are not the most recent change to a page.",
 +      "rcfilters-filtergroup-lastRevision": "Latest revisions",
 +      "rcfilters-filter-lastrevision-label": "Latest revision",
 +      "rcfilters-filter-lastrevision-description": "Only the most recent change to a page.",
 +      "rcfilters-filter-previousrevision-label": "Not the latest revision",
 +      "rcfilters-filter-previousrevision-description": "All changes that are not the \"latest revision\".",
        "rcfilters-filter-excluded": "Excluded",
        "rcfilters-tag-prefix-namespace": ":$1",
        "rcfilters-tag-prefix-namespace-inverted": "<strong>:not</strong> $1",
        "rcfilters-tag-prefix-tags": "#$1",
 +      "rcfilters-exclude-button-off": "Exclude selected",
 +      "rcfilters-exclude-button-on": "Excluding selected",
        "rcfilters-view-tags": "Tagged edits",
        "rcfilters-view-namespaces-tooltip": "Filter results by namespace",
        "rcfilters-view-tags-tooltip": "Filter results using edit tags",
        "rcfilters-view-return-to-default-tooltip": "Return to main filter menu",
 +      "rcfilters-view-tags-help-icon-tooltip": "Learn more about Tagged edits",
 +      "rcfilters-liveupdates-button": "Live updates",
 +      "rcfilters-liveupdates-button-title-on": "Turn off live updates",
 +      "rcfilters-liveupdates-button-title-off": "Display new changes as they happen",
 +      "rcfilters-watchlist-markseen-button": "Mark all changes as seen",
 +      "rcfilters-watchlist-edit-watchlist-button": "Edit your list of watched pages",
 +      "rcfilters-watchlist-showupdated": "Changes to pages you haven't visited since the changes occurred are in <strong>bold</strong>, with solid markers.",
 +      "rcfilters-preference-label": "Hide the improved version of Recent Changes",
 +      "rcfilters-preference-help": "Rolls back the 2017 interface redesign and all tools added then and since.",
        "rcnotefrom": "Below {{PLURAL:$5|is the change|are the changes}} since <strong>$3, $4</strong> (up to <strong>$1</strong> shown).",
        "rclistfromreset": "Reset date selection",
        "rclistfrom": "Show new changes starting from $2, $3",
        "uploadbtn": "Upload file",
        "reuploaddesc": "Cancel upload and return to the upload form",
        "upload-tryagain": "Submit modified file description",
 +      "upload-tryagain-nostash": "Submit re-uploaded file and modified description",
        "uploadnologin": "Not logged in",
        "uploadnologintext": "Please $1 to upload files.",
        "upload_directory_missing": "The upload directory ($1) is missing and could not be created by the webserver.",
        "file-deleted-duplicate-notitle": "A file identical to this file has previously been deleted, and the title has been suppressed.\nYou should ask someone with the ability to view suppressed file data to review the situation before proceeding to re-upload it.",
        "uploadwarning": "Upload warning",
        "uploadwarning-text": "Please modify the file description below and try again.",
 +      "uploadwarning-text-nostash": "Please re-upload the file, modify the description below and try again.",
        "savefile": "Save file",
        "uploadedimage": "uploaded \"[[$1]]\"",
        "overwroteimage": "uploaded a new version of \"[[$1]]\"",
        "uploaded-script-svg": "Found scriptable element \"$1\" in the uploaded SVG file.",
        "uploaded-hostile-svg": "Found unsafe CSS in the style element of uploaded SVG file.",
        "uploaded-event-handler-on-svg": "Setting event-handler attributes <code>$1=\"$2\"</code> is not allowed in SVG files.",
 -      "uploaded-href-attribute-svg": "href attributes in SVG files are only allowed to link to http:// or https:// targets, found <code>&lt;$1 $2=\"$3\"&gt;</code>.",
 +      "uploaded-href-attribute-svg": "<a> elements can only link (href) to data: (embedded file), http:// or https://, or fragment (#, same-document) targets.  For other elements, such as <image>, only data: and fragment are allowed.  Try embedding images when exporting your SVG.  Found <code>&lt;$1 $2=\"$3\"&gt;</code>.",
        "uploaded-href-unsafe-target-svg": "Found href to unsafe data: URI target <code>&lt;$1 $2=\"$3\"&gt;</code> in the uploaded SVG file.",
        "uploaded-animate-svg": "Found \"animate\" tag that might be changing href, using the \"from\" attribute <code>&lt;$1 $2=\"$3\"&gt;</code> in the uploaded SVG file.",
        "uploaded-setting-event-handler-svg": "Setting event-handler attributes is blocked, found <code>&lt;$1 $2=\"$3\"&gt;</code> in the uploaded SVG file.",
        "uploadstash-refresh": "Refresh the list of files",
        "uploadstash-thumbnail": "view thumbnail",
        "uploadstash-exception": "Could not store upload in the stash ($1): \"$2\".",
 +      "uploadstash-bad-path": "Path doesn't exist.",
 +      "uploadstash-bad-path-invalid": "Path is not valid.",
 +      "uploadstash-bad-path-unknown-type": "Unknown type \"$1\".",
 +      "uploadstash-bad-path-unrecognized-thumb-name": "Unrecognized thumb name.",
 +      "uploadstash-bad-path-no-handler": "No handler found for mime $1 of file $2.",
 +      "uploadstash-bad-path-bad-format": "Key \"$1\" is not in a proper format.",
 +      "uploadstash-file-not-found": "Key \"$1\" not found in stash.",
 +      "uploadstash-file-not-found-no-thumb": "Could not obtain thumbnail.",
 +      "uploadstash-file-not-found-no-local-path": "No local path for scaled item.",
 +      "uploadstash-file-not-found-no-object": "Couldn't create local file object for thumbnail.",
 +      "uploadstash-file-not-found-no-remote-thumb": "Fetching thumbnail failed: $1\nURL = $2",
 +      "uploadstash-file-not-found-missing-content-type": "Missing content-type header.",
 +      "uploadstash-file-not-found-not-exists": "Cannot find path, or not a plain file.",
 +      "uploadstash-file-too-large": "Cannot serve a file larger than $1 bytes.",
 +      "uploadstash-not-logged-in": "No user is logged in, files must belong to users.",
 +      "uploadstash-wrong-owner": "This file ($1) doesn't belong to the current user.",
 +      "uploadstash-no-such-key": "No such key ($1), cannot remove.",
 +      "uploadstash-no-extension": "Extension is null.",
 +      "uploadstash-zero-length": "File is zero length.",
        "invalid-chunk-offset": "Invalid chunk offset",
        "img-auth-accessdenied": "Access denied",
        "img-auth-nopathinfo": "Missing PATH_INFO.\nYour server is not set up to pass this information.\nIt may be CGI-based and cannot support img_auth.\nSee https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Image_Authorization.",
        "listfiles_size": "Size",
        "listfiles_description": "Description",
        "listfiles_count": "Versions",
 -      "listfiles-show-all": "Include old versions of images",
 +      "listfiles-show-all": "Include old versions of files",
        "listfiles-latestversion": "Current version",
        "listfiles-latestversion-yes": "Yes",
        "listfiles-latestversion-no": "No",
        "pageswithprop-legend": "Pages with a page property",
        "pageswithprop-text": "This page lists pages that use a particular page property.",
        "pageswithprop-prop": "Property name:",
 +      "pageswithprop-reverse": "Sort in reverse order",
 +      "pageswithprop-sortbyvalue": "Sort by property value",
        "pageswithprop-submit": "Go",
        "pageswithprop-prophidden-long": "long text property value hidden ($1)",
        "pageswithprop-prophidden-binary": "binary property value hidden ($1)",
        "magiclink-tracking-pmid-desc": "This page uses PMID magic links. See [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Magic_links mediawiki.org] on how to migrate.",
        "magiclink-tracking-isbn": "Pages using ISBN magic links",
        "magiclink-tracking-isbn-desc": "This page uses ISBN magic links. See [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Magic_links mediawiki.org] on how to migrate.",
-       "rfcurl": "//tools.ietf.org/html/rfc$1",
+       "rfcurl": "https://tools.ietf.org/html/rfc$1",
        "pubmedurl": "//www.ncbi.nlm.nih.gov/pubmed/$1?dopt=Abstract",
        "specialloguserlabel": "Performer:",
        "speciallogtitlelabel": "Target (title or {{ns:user}}:username for user):",
        "unwatchthispage": "Stop watching",
        "notanarticle": "Not a content page",
        "notvisiblerev": "The last revision by a different user has been deleted",
 -      "watchlist-details": "{{PLURAL:$1|$1 page|$1 pages}} on your watchlist, not separately counting talk pages.",
 +      "watchlist-details": "{{PLURAL:$1|$1 page is|$1 pages are}} on your Watchlist (plus talk pages).",
        "wlheader-enotif": "Email notification is enabled.",
        "wlheader-showupdated": "Pages that have been changed since you last visited them are shown in <strong>bold</strong>.",
        "wlnote": "Below {{PLURAL:$1|is the last change|are the last <strong>$1</strong> changes}} in the last {{PLURAL:$2|hour|<strong>$2</strong> hours}}, as of $3, $4.",
        "watching": "Watching...",
        "unwatching": "Unwatching...",
        "watcherrortext": "An error occurred while changing your watchlist settings for \"$1\".",
 +      "watchlist-unwatch": "×",
 +      "watchlist-unwatch-undo": "+",
        "enotif_reset": "Mark all pages visited",
        "enotif_impersonal_salutation": "{{SITENAME}} user",
        "enotif_subject_deleted": "{{SITENAME}} page $1 has been {{GENDER:$2|deleted}} by $2",
        "enotif_lastdiff": "To view this change, see $1",
        "enotif_anon_editor": "anonymous user $1",
        "enotif_body": "Dear $WATCHINGUSERNAME,\n\n$PAGEINTRO $NEWPAGE\n\nEditor's summary: $PAGESUMMARY $PAGEMINOREDIT\n\nContact the editor:\nmail: $PAGEEDITOR_EMAIL\nwiki: $PAGEEDITOR_WIKI\n\nThere will be no other notifications in case of further activity unless you visit this page while logged in. You could also reset the notification flags for all your watched pages on your watchlist.\n\nYour friendly {{SITENAME}} notification system\n\n--\nTo change your email notification settings, visit\n{{canonicalurl:{{#special:Preferences}}}}\n\nTo change your watchlist settings, visit\n{{canonicalurl:{{#special:EditWatchlist}}}}\n\nTo delete the page from your watchlist, visit\n$UNWATCHURL\n\nFeedback and further assistance:\n$HELPPAGE",
 +      "enotif_minoredit": "This is a minor edit",
        "created": "created",
        "changed": "changed",
        "deletepage": "Delete page",
        "delete-warning-toobig": "This page has a large edit history, over $1 {{PLURAL:$1|revision|revisions}}.\nDeleting it may disrupt database operations of {{SITENAME}};\nproceed with caution.",
        "deleteprotected": "You cannot delete this page because it has been protected.",
        "deleting-backlinks-warning": "<strong>Warning:</strong> [[Special:WhatLinksHere/{{FULLPAGENAME}}|Other pages]] link to or transclude the page you are about to delete.",
 +      "deleting-subpages-warning": "<strong>Warning:</strong> The page you are about to delete has [[Special:PrefixIndex/{{FULLPAGENAME}}/|{{PLURAL:$1|a subpage|$1 subpages|51=over 50 subpages}}]].",
        "rollback": "Roll back edits",
        "rollbacklink": "rollback",
        "rollbacklinkcount": "rollback $1 {{PLURAL:$1|edit|edits}}",
        "undelete-search-title": "Search deleted pages",
        "undelete-search-box": "Search deleted pages",
        "undelete-search-prefix": "Show pages starting with:",
 +      "undelete-search-full": "Show page titles containing:",
        "undelete-search-submit": "Search",
        "undelete-no-results": "No matching pages found in the deletion archive.",
        "undelete-filename-mismatch": "Cannot undelete file revision with timestamp $1: Filename mismatch.",
        "sp-contributions-explain": "",
        "sp-contributions-footer": "-",
        "sp-contributions-footer-anon": "-",
 +      "sp-contributions-footer-anon-range": "-",
        "sp-contributions-footer-newbies": "-",
 +      "sp-contributions-outofrange": "Unable to show any results. The requested IP range is larger than the CIDR limit of /$1.",
        "whatlinkshere": "What links here",
        "whatlinkshere-title": "Pages that link to \"$1\"",
        "whatlinkshere-summary": "",
        "unblock": "Unblock user",
        "unblock-summary": "",
        "blockip": "Block {{GENDER:$1|user}}",
 -      "blockip-legend": "Block user",
        "blockiptext": "Use the form below to block write access from a specific IP address or username.\nThis should be done only to prevent vandalism, and in accordance with [[{{MediaWiki:Policy-url}}|policy]].\nFill in a specific reason below (for example, citing particular pages that were vandalized).\nYou can block IP address ranges using the [https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing CIDR] syntax; the largest allowed range is /$1 for IPv4 and /$2 for IPv6.",
        "ipaddressorusername": "IP address or username:",
        "ipbexpiry": "Expiration:",
        "ipb_blocked_as_range": "Error: The IP address $1 is not blocked directly and cannot be unblocked.\nIt is, however, blocked as part of the range $2, which can be unblocked.",
        "ip_range_invalid": "Invalid IP address range.",
        "ip_range_toolarge": "Range blocks larger than /$1 are not allowed.",
 +      "ip_range_exceeded": "The IP range exceeds its maximum range. Allowed range: /$1.",
 +      "ip_range_toolow": "IP ranges are effectively not allowed.",
        "proxyblocker": "Proxy blocker",
        "proxyblockreason": "Your IP address has been blocked because it is an open proxy.\nPlease contact your Internet service provider or technical support of your organization and inform them of this serious security problem.",
        "sorbs": "DNSBL",
        "delete_and_move_text": "The destination page \"[[:$1]]\" already exists.\nDo you want to delete it to make way for the move?",
        "delete_and_move_confirm": "Yes, delete the page",
        "delete_and_move_reason": "Deleted to make way for move from \"[[$1]]\"",
 -      "selfmove": "Source and destination titles are the same;\ncannot move a page over itself.",
 +      "selfmove": " The title is the same;\ncannot move a page over itself.",
        "immobile-source-namespace": "Cannot move pages in namespace \"$1\".",
        "immobile-target-namespace": "Cannot move pages into namespace \"$1\".",
        "immobile-target-namespace-iw": "Interwiki link is not a valid target for page move.",
        "import-nonewrevisions": "No revisions imported (all were either already present, or skipped due to errors).",
        "xml-error-string": "$1 at line $2, col $3 (byte $4): $5",
        "import-upload": "Upload XML data",
 -      "import-token-mismatch": "Loss of session data.\n\nYou might have been logged out. <strong>Please verify that you're still logged in and try again</strong>.\nIf it still does not work, try [[Special:UserLogout|logging out]] and logging back in, and check that your browser allows cookies from this site.",
 +      "import-token-mismatch": "Loss of session data.\n\nYou might have been logged out. '''Please verify that you're still logged in and try again'''.\nIf it still does not work, try [[Special:UserLogout|logging out]] and logging back in, and check that your browser allows cookies from this site.",
        "import-invalid-interwiki": "Cannot import from the specified wiki.",
        "import-error-edit": "Page \"$1\" was not imported because you are not allowed to edit it.",
        "import-error-create": "Page \"$1\" was not imported because you are not allowed to create it.",
        "specialpages": "Special pages",
        "specialpages-summary": "",
        "specialpages-note-top": "Legend",
 -      "specialpages-note": "* Normal special pages.\n* <span class=\"mw-specialpagerestricted\">Restricted special pages.</span>",
 +      "specialpages-note-restricted": "* Normal special pages.\n* <span class=\"mw-specialpagerestricted\">Restricted special pages.</span>",
 +      "specialpages-note-cached": "-",
        "specialpages-group-maintenance": "Maintenance reports",
        "specialpages-group-other": "Other special pages",
        "specialpages-group-login": "Login / create account",
        "compare-invalid-title": "The title you specified is invalid.",
        "compare-title-not-exists": "The title you specified does not exist.",
        "compare-revision-not-exists": "The revision you specified does not exist.",
 +      "diff-form": "Differences",
 +      "diff-form-oldid": "Old revision ID (optional)",
 +      "diff-form-revid": "Revision ID of difference",
 +      "diff-form-submit": "Show differences",
 +      "diff-form-summary": "",
 +      "permanentlink": "Permanent link",
 +      "permanentlink-revid": "Revision ID",
 +      "permanentlink-submit": "Go to revision",
 +      "permanentlink-summary": "",
        "dberr-problems": "Sorry! This site is experiencing technical difficulties.",
        "dberr-again": "Try waiting a few minutes and reloading.",
        "dberr-info": "(Cannot access the database: $1)",
        "mediastatistics-header-text": "Textual",
        "mediastatistics-header-executable": "Executables",
        "mediastatistics-header-archive": "Compressed formats",
 +      "mediastatistics-header-3d": "3D",
        "mediastatistics-header-total": "All files",
        "json-warn-trailing-comma": "$1 trailing {{PLURAL:$1|comma was|commas were}} removed from JSON",
        "json-error-unknown": "There was a problem with the JSON. Error: $1",
        "undelete-cantedit": "You cannot undelete this page as you are not allowed to edit this page.",
        "undelete-cantcreate": "You cannot undelete this page as there is no existing page with this name and you are not allowed to create this page.",
        "pagedata-title": "Page data",
 -      "pagedata-text": "This page provides a data interface to pages. Please provide the page title in the URL, using subpage syntax.\n* Content negotiation applies based on you client's Accept header. This means that the page data will be provided in the format preferred by your client.",
 +      "pagedata-text": "This page provides a data interface to pages. Please provide the page title in the URL, using subpage syntax.\n* Content negotiation applies based on your client's Accept header. This means that the page data will be provided in the format preferred by your client.",
        "pagedata-not-acceptable": "No matching format found. Supported MIME types: $1",
        "pagedata-bad-title": "Invalid title: $1."
  }
@@@ -109,13 -109,6 +109,13 @@@ Template:ech
  {{{1}}}
  !! endarticle
  
 +// For Serbian; localize Template namespace
 +!! article
 +Шаблон:Echo
 +!! text
 +{{{1}}}
 +!! endarticle
 +
  !! article
  Template:echo_with_span
  !! text
@@@ -285,12 -278,6 +285,12 @@@ Template:CircularRe
  <ref>{{CircularRef}}</ref>
  !! endarticle
  
 +!! article
 +Template:With: Colon
 +!! text
 +Template with colon
 +!! endarticle
 +
  ###
  ### Basic tests
  ###
@@@ -307,7 -294,7 +307,7 @@@ CircularRe
  <references />
  !! html/parsoid
  <p><span about="#mwt1" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion  mw:Extension/ref" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"CircularRef","href":"./Template:CircularRef"},"params":{},"i":0}}]}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></p>
 -<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">Error: Expansion loop detected at <a data-parsoid='{"a":{"href":null},"sa":{"href":"Template:CircularRef"}}'>Template:CircularRef</a></span></li></ol>
 +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">Error: Expansion loop detected at <a data-parsoid='{"a":{"href":null},"sa":{"href":"Template:CircularRef"}}'>Template:CircularRef</a></span></li></ol>
  !! end
  
  !! test
@@@ -1868,19 -1855,6 +1868,19 @@@ parsoid=wt2html,wt2w
  </ul>
  !! end
  
 +## Make sure ">" gets escaped in comments to avoid XSS
 +!! test
 +IE conditional comments
 +!! wikitext
 +<!--[if lt IE 9]>
 +      <script>alert('hi');</script>
 +<![endif]-->
 +!! html/parsoid
 +<!--[if lt IE 9]&#x3E;
 +      <script&#x3E;alert('hi');</script&#x3E;
 +<![endif]-->
 +!! end
 +
  ###
  ### paragraph wrapping tests
  ###
@@@ -1912,33 -1886,6 +1912,33 @@@ a <div>foo</div
  <p>b</p>
  !! end
  
 +!! test
 +No p-wrappable content
 +!! wikitext
 +<span><div>x</div></span>
 +<span><s><div>x</div></s></span>
 +<small><em></em></small><span><s><div>x</div></s></span>
 +!! html+tidy
 +<div><span>x</span></div>
 +<div><span><s>x</s></span></div>
 +<div><span><s>x</s></span></div>
 +!! html/parsoid
 +<span><div>x</div></span>
 +<span><s><div>x</div></s></span>
 +<small><em></em></small><span><s><div>x</div></s></span>
 +!! end
 +
 +# T177612: Parsoid-only test
 +!! test
 +Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
 +!! wikitext
 +{{echo|<span><div>x</div></span>}}
 +x
 +!! html/parsoid
 +<span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;span>&lt;div>x&lt;/div>&lt;/span>"}},"i":0}}]}'><div>x</div></span>
 +<p>x</p>
 +!! end
 +
  !! test
  Block tag on one line (<blockquote>)
  !! wikitext
@@@ -2476,7 -2423,7 +2476,7 @@@ Block tag pr
  foo
  </pre>
  !! html/parsoid
 -<p data-parsoid='{"stx":"html","autoInsertedEnd":true}'></p><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre><p data-parsoid='{"autoInsertedStart":true,"stx":"html"}'></p>
 +<p class='mw-empty-elt' data-parsoid='{"stx":"html","autoInsertedEnd":true}'></p><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre><p class='mw-empty-elt' data-parsoid='{"autoInsertedStart":true,"stx":"html"}'></p>
  !! end
  
  !!test
@@@ -2871,7 -2818,7 +2871,7 @@@ Templates: Handle comments in the targe
  <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
 +!! end
  
  !! test
  Templates: Handle comments in parameter names (T69657)
  <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo","key":{"wt":"1&lt;!-- should be ignored -->"}}},"i":0}}]}'>foo</p>
  
  <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo","key":{"wt":"&lt;!-- should be ignored -->1"}}},"i":0}}]}'>foo</p>
 -!!end
 +!! end
  
  !! test
  Templates: Other wikitext in parameter names (T69657)
  </p>
  !! html/parsoid
  <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"&#39;&#39;1&#39;&#39;":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
 -!!end
 +!! end
 +
 +!! test
 +Templates: With colons
 +!! wikitext
 +{{With: Colon}}
 +!! html/php
 +<p>Template with colon
 +</p>
 +!! html/parsoid
 +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"With: Colon","href":"./Template:With:_Colon"},"params":{},"i":0}}]}'>Template with colon</p>
 +!! end
  
  #--------------------------------------------------------------------
  # Transclusion parameter escaping tests
  #--------------------------------------------------------------------
 +
  !! test
  Templates: Parsoid parameter escaping test 1
  !! wikitext
@@@ -4359,21 -4294,6 +4359,21 @@@ Definition Lists: Mixed Lists: Test 1
  
  !! end
  
 +# This is a regression test for T175099
 +# html/php+tidy is insufficient since Tidy covers up the bug.
 +# But once Tidy is replaced with RemexHTML, html/php+tidy is good enough
 +!! test
 +Definition Lists: Mixed Lists: Test 11
 +!! wikitext
 +; a
 +:* b
 +!! html/*
 +<dl><dt> a</dt>
 +<dd>
 +<ul><li> b</li></ul></dd></dl>
 +
 +!! end
 +
  # The Parsoid team disagrees with the PHP parser's seemingly-random
  # rules regarding dd/dt on the next two tests.  Parsoid is more
  # consistent, and recognizes the shared nesting and keeps the
  # (And tidy again converts <dt> to <dd> before 'bar'.)
  
  !! test
 -Definition Lists: Mixed Lists: Test 11
 +Definition Lists: Mixed Lists: Test 12
  !! wikitext
  *#*#;*;;foo :bar
  *#*#;boo :baz
@@@ -4833,11 -4753,8 +4833,11 @@@ foo//example.com/Fo
  </p>
  !! end
  
 +## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
  !! test
  External links: with no contents
 +!! options
 +parsoid=wt2html,wt2wt
  !! wikitext
  [http://en.wikipedia.org/wiki/Foo]
  
@@@ -4941,7 -4858,7 +4941,7 @@@ External links: Free with trailing quot
  news:'a'b''c''d e
  !! html/php
  <p><b>News:</b> Stuff here
 -</p><p><a rel="nofollow" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e
 +</p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
  </p>
  !! html/parsoid
  <p><b>News:</b> Stuff here</p>
@@@ -5587,8 -5504,8 +5587,8 @@@ External link containing a single quote
  
  [//foo.org/bar'baz bang]
  !! html/php
 -<p><a rel="nofollow" class="external autonumber" href="//foo.org/bar'baz">[1]</a>
 -</p><p><a rel="nofollow" class="external text" href="//foo.org/bar'baz">bang</a>
 +<p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
 +</p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
  </p>
  !! html/parsoid
  <p><a rel="mw:ExtLink" href="//foo.org/bar'baz"></a></p>
@@@ -5706,7 -5623,7 +5706,7 @@@ Examples from RFC 2732, section 2
  
  !! html/php
  <p><a rel="nofollow" class="external free" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a>
- </p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
+ </p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
  </p>
  <ul><li> <a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
  <li> <a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
  <li> <a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
  <li> <a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
  <li> <a rel="nofollow" class="external free" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
- <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
+ <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
  </p>
  <ul><li> <a rel="nofollow" class="external free" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li>
  <li> <a rel="nofollow" class="external free" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li>
  !! html/parsoid
  <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a></p>
  
- <p>Examples from <a href="//tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
+ <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
  <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
  <li> <a rel="mw:ExtLink" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
  <li> <a rel="mw:ExtLink" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
  <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
  <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
  
- <p>Examples from <a href="//tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
+ <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
  <ul><li> <a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li>
  <li> <a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li>
  <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
@@@ -5769,7 -5686,7 +5769,7 @@@ Examples from RFC 2732, section 2
  
  !! html/php
  <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
- </p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
+ </p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
  </p>
  <ul><li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
  <li> <a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
  <li> <a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
  <li> <a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
  <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
- <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
+ <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
  </p>
  <ul><li> <a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
  <li> <a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
  !! html/parsoid
  <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
  
- <p>Examples from <a href="//tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
+ <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
  <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]">unicast</a></li>
  <li> <a rel="mw:ExtLink" href="http://[FF01::101]">multicast</a></li>
  <li> <a rel="mw:ExtLink" href="http://[::1]/">loopback</a></li>
  <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]">ipv4compat</a></li>
  <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
  
- <p>Examples from <a href="//tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
+ <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
  <ul><li> <a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
  <li> <a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
  <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
@@@ -5965,11 -5882,11 +5965,11 @@@ parsoid=html2w
  !! wikitext
  [[Foo|Bar]]
  [[Foo|Bar]]
 -[[wikipedia:Foo|Bar]]
 -[[wikipedia:Foo|Bar]]
 +[[:en:Foo|Bar]]
 +[[:en:Foo|Bar]]
  
 -[[wikipedia:European_Robin|European Robin]]
 -[[wikipedia:European_Robin|European Robin]]
 +[[:en:European_Robin|European Robin]]
 +[[:en:European_Robin|European Robin]]
  !! end
  
  !! test
@@@ -6717,7 -6634,7 +6717,7 @@@ Don't break on | in extension attribut
  !! html/parsoid
  <p><span about="#mwt2" class="mw-ref" id="cite_ref-hi.7Cho_1-0" rel="dc:references" typeof="mw:Transclusion  mw:Extension/ref" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;ref name=\"hi|ho\">ha&lt;/ref>"}},"i":0}}]}'><a href="./Main_Page#cite_note-hi.7Cho-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></p>
  
 -<ol class="mw-references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-hi.7Cho-1" id="cite_note-hi.7Cho-1"><a href="./Main_Page#cite_ref-hi.7Cho_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-hi.7Cho-1" class="mw-reference-text">ha</span></li></ol>
 +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-hi.7Cho-1" id="cite_note-hi.7Cho-1"><a href="./Main_Page#cite_ref-hi.7Cho_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-hi.7Cho-1" class="mw-reference-text">ha</span></li></ol>
  !! end
  
  ## We don't support roundtripping of these attributes in Parsoid.
@@@ -6892,7 -6809,7 +6892,7 @@@ T107652: <ref>s in templates that also 
  <table>
  <tbody><tr><td style="background:#f9f9f9;" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["|",{"template":{"target":{"wt":"table_attribs_7","href":"./Template:Table_attribs_7"},"params":{},"i":0}}]}'>Foo<span class="mw-ref" id="cite_ref-1" rel="dc:references" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></td></tr>
  </tbody></table>
 -<ol class="mw-references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
 +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
  !! end
  
  !! test
@@@ -7352,8 -7269,8 +7352,8 @@@ parsoid=wt2htm
  !! html
  <table>
  <tbody>
 -<tr></tr>
 -<tr></tr>
 +<tr class='mw-empty-elt'></tr>
 +<tr class='mw-empty-elt'></tr>
  </tbody></table>
  !! end
  
@@@ -7802,16 -7719,13 +7802,16 @@@ Piped link with extlink-like tex
  !! wikitext
  [[Main Page|[bar]]]
  [[Main Page|This is a [bar]]]
 +[[Main Page|[bar]]
  !! html/php
  <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
  <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
 +<a href="/wiki/Main_Page" title="Main Page">[bar</a>
  </p>
  !! html/parsoid
  <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
 -<a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a></p>
 +<a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
 +<a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
  !! end
  
  !! test
@@@ -8003,7 -7917,7 +8003,7 @@@ Link containing double-single-quotes '
  !! wikitext
  [[Lista d''e paise d''o munno]]
  !! html/php
 -<p><a href="/index.php?title=Lista_d%27%27e_paise_d%27%27o_munno&amp;action=edit&amp;redlink=1" class="new" title="Lista d''e paise d''o munno (page does not exist)">Lista d''e paise d''o munno</a>
 +<p><a href="/index.php?title=Lista_d%27%27e_paise_d%27%27o_munno&amp;action=edit&amp;redlink=1" class="new" title="Lista d&#39;&#39;e paise d&#39;&#39;o munno (page does not exist)">Lista d''e paise d''o munno</a>
  </p>
  !! html/parsoid
  <p><a rel="mw:WikiLink" href="./Lista_d''e_paise_d''o_munno" title="Lista d''e paise d''o munno">Lista d''e paise d''o munno</a></p>
@@@ -8068,9 -7982,9 +8068,9 @@@ Link with double quotes in title part (
  [[''Pentecoste''|''Pentecoste'']]
  !! html/php
  <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Denys_Savchenko_%27%27Pentecoste%27%27.jpg" class="new" title="File:Denys Savchenko &#39;&#39;Pentecoste&#39;&#39;.jpg">File:Denys Savchenko <i>Pentecoste</i>.jpg</a>
 -</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)">''Pentecoste''</a>
 -</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)">Pentecoste</a>
 -</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)"><i>Pentecoste</i></a>
 +</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="&#39;&#39;Pentecoste&#39;&#39; (page does not exist)">''Pentecoste''</a>
 +</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="&#39;&#39;Pentecoste&#39;&#39; (page does not exist)">Pentecoste</a>
 +</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="&#39;&#39;Pentecoste&#39;&#39; (page does not exist)"><i>Pentecoste</i></a>
  </p>
  !! html/parsoid
  <p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Denys_Savchenko_''Pentecoste''.jpg"><img resource="./File:Denys_Savchenko_''Pentecoste''.jpg" src="./Special:FilePath/Denys_Savchenko_''Pentecoste''.jpg" height="220" width="220"/></a></span></p>
@@@ -8151,6 -8065,7 +8151,6 @@@ Plain link to page with question mark i
  </p>
  !! end
  
 -
  # I'm fairly sure the expected result here is wrong.
  # We want these to be URL links, not pseudo-pages with URLs for titles....
  # However the current output is also pretty screwy.
@@@ -8173,34 -8088,6 +8173,34 @@@ Piped link to URL: [[http://www.example
  <p>Piped link to URL: [<a rel="mw:ExtLink" href="http://www.example.com%7Can" data-parsoid='{"a":{"href":"http://www.example.com%7Can"},"sa":{"href":"http://www.example.com|an"}}'>example URL</a>]</p>
  !! end
  
 +!! test
 +Plain link in template argument
 +!! options
 +parsoid=wt2html
 +!! wikitext
 +{{echo|[http://www.example.com |123]}}
 +
 +{{echo|[[http://www.example.com |123]]}}
 +
 +{{echo|[[http://www.example.com |123]}}
 +
 +{{echo|[http://www.example.com |123]]}}
 +!! html/php
 +<p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a> 
 +</p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
 +</p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
 +</p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a> 
 +</p>
 +!! html/parsoid
 +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[http://www.example.com "},"2":{"wt":"123]"}},"i":0}}]}'>[<a rel="mw:ExtLink" href="http://www.example.com">http://www.example.com</a> </p>
 +
 +<p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[http://www.example.com |123]]"}},"i":0}}]}'>[<a rel="mw:ExtLink" href="http://www.example.com">|123</a>]</p>
 +
 +<p>{{echo|[<a rel="mw:ExtLink" href="http://www.example.com" data-parsoid='{"targetOff":114,"contentOffsets":[114,118],"dsr":[90,119,24,1]}'>|123</a>}}</p>
 +
 +<p about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[http://www.example.com "},"2":{"wt":"123]]"}},"i":0}}]}'>[<a rel="mw:ExtLink" href="http://www.example.com">http://www.example.com</a> </p>
 +!! end
 +
  !! test
  T2002: [[page|http://url/]] should link to page, not http://url/
  !! wikitext
@@@ -8285,33 -8172,6 +8285,33 @@@ Non-breaking spaces in titl
  </p>
  !!end
  
 +# Add new article for the test below so that it doesn't red-link
 +!! article
 +Foo bar baz
 +!! text
 +boo
 +!! endarticle
 +
 +!! test
 +Multiple spaces in titles should normalize to a single underscore
 +!! options
 +parsoid=wt2html,wt2wt
 +!! wikitext
 +[[Foo bar baz|x]]
 +[[Foo  bar baz|x]]
 +[[Foo  bar   baz|x]]
 +!! html/php
 +<p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
 +<a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
 +<a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
 +</p>
 +!! html/parsoid
 +<p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
 +<a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
 +<a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
 +</p>
 +!! end
 +
  !! test
  Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
  !! options
@@@ -8363,7 -8223,7 +8363,7 @@@ language=ka
  !! wikitext
  [[Something]]'nice
  !! html
 -<p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (bet ele jaratılmag'an)">Something'nice</a>
 +<p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (bet ele jaratılmag&#39;an)">Something'nice</a>
  </p>
  !! end
  
@@@ -8547,31 -8407,6 +8547,31 @@@ parsoid=html2wt,html2htm
  Aðrir mótmælenda<nowiki/>[[söfnuður]]
  !! end
  
 +!! test
 +Parsoid link bracket escaping
 +!! options
 +parsoid=html2wt,html2html
 +!! html/parsoid
 +<p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
 +<p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
 +<p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
 +<p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
 +<p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
 +<p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
 +!! wikitext
 +[[Test]]
 +
 +[<nowiki/>[[Test]]]
 +
 +[[[[Test]]]]
 +
 +[[[<nowiki/>[[Test]]]]]
 +
 +[[[[[[Test]]]]]]
 +
 +[[[[[<nowiki/>[[Test]]]]]]]
 +!! end
 +
  !! test
  Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
  !! wikitext
@@@ -8639,11 -8474,8 +8639,11 @@@ parsoid=wt2html,wt2wt,html2htm
  <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
  !! end
  
 +## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
  !! test
  Interwiki link encoding conversion (T3636)
 +!! options
 +parsoid=wt2html,wt2wt
  !! wikitext
  *[[Wikipedia:ro:Olteni&#0355;a]]
  *[[Wikipedia:ro:Olteni&#355;a]]
  <li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
  <li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
  </ul>
 +!! html/parsoid
 +<ul>
 +<li><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/ro:Olteniţa" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
 +<li><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/ro:Olteniţa" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
 +</ul>
  !! end
  
  !! test
@@@ -8914,25 -8741,6 +8914,25 @@@ Blah blah bla
  <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
  !! end
  
 +!! test
 +Multiple colons escaping interlanguage links
 +!! options
 +parsoid=wt2html
 +!! wikitext
 +[[:es:Spanish]]
 +[[::es:Spanish]]
 +[[:::es:Spanish]]
 +!! html/php
 +<p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
 +[[::es:Spanish]]
 +[[:::es:Spanish]]
 +</p>
 +!! html/parsoid
 +<p><a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
 +[[::es:Spanish]]
 +[[:::es:Spanish]]</p>
 +!! end
 +
  ## parsoid html2wt will normalize the space to _
  !! test
  Space and question mark encoding in interlanguage links (T95473)
@@@ -9334,6 -9142,8 +9334,6 @@@ some tex
  <ol data-parsoid='{}'><li data-parsoid='{}'>redirect <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'>Main Page</a></li></ol>
  !! end
  
 -# FIXME: Should hoist the redirect to the top of the page and ensure there
 -# is only one.
  !! test
  New redirect
  !! options
@@@ -9341,53 -9151,7 +9341,53 @@@ parsoid=html2w
  !! html/parsoid
  <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
  !! wikitext
 +#REDIRECT [[Foo]]
  Foo
 +!! end
 +
 +!! test
 +Redirect followed by block on the same line
 +!! options
 +parsoid=wt2html
 +!! wikitext
 +#REDIRECT [[Main Page]]<!-- haha -->== hi ==
 +!! html/parsoid
 +<link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi"> hi </h2>
 +!! end
 +
 +!! test
 +Redirect followed by a newline
 +!! wikitext
 +#REDIRECT [[Main Page]]
 +A newline
 +!! html/parsoid
 +<link rel="mw:PageProp/redirect" href="./Main_Page"/>
 +<p>A newline</p>
 +!! end
 +
 +!! test
 +Redirect followed by multiple newlines
 +!! wikitext
 +#REDIRECT [[Main Page]]
 +
 +
 +A newline
 +!! html/parsoid
 +<link rel="mw:PageProp/redirect" href="./Main_Page"/>
 +
 +<p><br/>
 +A newline</p>
 +!! end
 +
 +!! test
 +Drop duplicate redirects
 +!! options
 +parsoid=html2wt
 +!! html/parsoid
 +<link rel="mw:PageProp/redirect" href="./Foo"/>
 +<link rel="mw:PageProp/redirect" href="./Bar"/>
 +<link rel="mw:PageProp/redirect" href="./Baz"/>
 +!! wikitext
  #REDIRECT [[Foo]]
  !! end
  
@@@ -9474,7 -9238,7 +9474,7 @@@ Handling html with a div self-closing t
  !! html/parsoid
  <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
  <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
 -<div title="" data-parsoid='{"stx":"html","selfClose":true,"brokenHTMLTag":true}'></div>
 +<div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
  <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
  <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
  <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
@@@ -9769,7 -9533,7 +9769,7 @@@ parsoi
  !! wikitext
  *<references />
  !! html/parsoid
 -<ul><li data-parsoid='{}'><ol class="mw-references" typeof="mw:Extension/references" about="#mwt2" data-parsoid='{}' data-mw='{"name":"references","attrs":{}}'></ol></li></ul>
 +<ul><li data-parsoid='{}'><ol class="mw-references references" typeof="mw:Extension/references" about="#mwt2" data-parsoid='{}' data-mw='{"name":"references","attrs":{}}'></ol></li></ul>
  !! end
  
  !! test
@@@ -9939,17 -9703,6 +9939,17 @@@ parsoid=wt2html,wt2w
  <ul>
  <li>not a li-hack</li>
  </ul>
 +!! html/parsoid
 +<ul><li> foo</li>
 +<li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"* "}'>li-hack</li>
 +<li about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,,"pi":[[{"k":"1"}]]}' data-mw='{"parts":["* ",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;li>templated li-hack"}},"i":0}}]}'>templated li-hack</li>
 +<li data-parsoid='{"autoInsertedEnd":true}'> <!--foo--> </li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'> unsupported li-hack with preceding comments</li></ul>
 +
 +<ul data-parsoid='{"stx":"html"}'>
 +<li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
 +</li>
 +</ul>
 +
  !!end
  
  !! test
@@@ -9985,9 -9738,9 +9985,9 @@@ Parsoid: Test of whitespace serializati
  parsoid
  !! wikitext
  * {{bullet}}
 -!! html
 +!! html/parsoid
  <ul>
 -<li> </li><li about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"bullet","href":"./Template:Bullet"},"params":{},"i":0}}]}'> Bar</li>
 +<li class="mw-empty-elt"> </li><li about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"bullet","href":"./Template:Bullet"},"params":{},"i":0}}]}'> Bar</li>
  </ul>
  !! end
  
@@@ -10668,13 -10421,11 +10668,13 @@@ parsoid={ "modes": ["wt2html","wt2wt"]
  Magic Word: {{REVISIONID}}
  !! options
  parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
 +showflags
  !! wikitext
  {{REVISIONID}}
  !! html/*
  <p>1337
  </p>
 +flags=vary-revision-id
  !! end
  
  !! test
@@@ -10998,10 -10749,10 +10998,10 @@@ Magic links: RFC (T2479
  !! wikitext
  RFC 822
  !! html/php
- <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
+ <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
  </p>
  !! html/parsoid
- <p><a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a></p>
+ <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a></p>
  !! end
  
  !! test
@@@ -11009,10 -10760,10 +11009,10 @@@ Magic links: RFC (T67278
  !! wikitext
  This is RFC 822 but thisRFC 822 is not RFC 822linked.
  !! html/php
- <p>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a> but thisRFC 822 is not RFC 822linked.
+ <p>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a> but thisRFC 822 is not RFC 822linked.
  </p>
  !! html/parsoid
- <p>This is <a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
+ <p>This is <a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
  !! end
  
  !! test
@@@ -11022,12 -10773,12 +11022,12 @@@ RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 82
  RFC
  822
  !! html/php
- <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
+ <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
  RFC
  822
  </p>
  !! html/parsoid
- <p><a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 822</a>
+ <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 822</a>
  RFC
  822</p>
  !! end
@@@ -11123,14 -10874,14 +11123,14 @@@ Magic links: use appropriate serializat
  !! wikitext
  X[[Special:BookSources/0978739256|foo]]
  
- X[//tools.ietf.org/html/rfc1234 foo]
+ X[https://tools.ietf.org/html/rfc1234 foo]
  !! html/php
  <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
- </p><p>X<a rel="nofollow" class="external text" href="//tools.ietf.org/html/rfc1234">foo</a>
+ </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
  </p>
  !! html/parsoid
  <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
- <p>X<a rel="mw:ExtLink" href="//tools.ietf.org/html/rfc1234">foo</a></p>
+ <p>X<a rel="mw:ExtLink" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
  !! end
  
  !! test
@@@ -11387,15 -11138,6 +11387,15 @@@ Templates with templated nam
  <ul about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"{{echo|inner list}} ","href":"./Template:Inner_list"},"params":{},"i":0}}]}'><li> item 1</li></ul>
  !! end
  
 +## Regression test; the output here isn't really that interesting.
 +!! test
 +Templates with templated name and top level template args
 +!! wikitext
 +{{1{{2{{{3}}}|4=5}}}}
 +!! html/parsoid
 +<p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1{{2{{{3}}}|4=5}}"},"params":{},"i":0}}]}'>{{1{{2{{{3}}}|4=5}}}}</p>
 +!! end
 +
  # Parsoid markup is deliberate "broken". This is an edge case.
  # See long comment in TemplateHandler.js:convertAttribsToString.
  !! test
@@@ -12135,8 -11877,6 +12135,8 @@@ parsoi
  ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
  !! test
  Preprocessor precedence 1: link is rightmost opening
 +!! options
 +parsoid=wt2html
  !! wikitext
  {{[[Foo|bar}}]]
  
@@@ -12145,17 -11885,13 +12145,17 @@@ But close-brace is not a valid characte
  
  However, we can still tell this was handled as a link in the preprocessor:
  {{echo|[[Foo}}|bar]]|bat}}
 -!! html
 +!! html/php
  <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
  </p><p>But close-brace is not a valid character in a link title:
  {{[[Foo}}|bar]]
  </p><p>However, we can still tell this was handled as a link in the preprocessor:
  [[Foo}}|bar]]
  </p>
 +!! html/parsoid
 +<p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
 +<p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
 +<p>However, we can still tell this was handled as a link in the preprocessor: <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Foo}}|bar]]"},"2":{"wt":"bat"}},"i":0}}]}'>[[Foo}}|bar]]</span></p>
  !! end
  
  !! test
@@@ -12164,33 -11900,26 +12164,33 @@@ Preprocessor precedence 2: template is 
  language=zh
  !! wikitext
  -{{echo|foo}-}}-
 -!! html
 +!! html/php
  <p>-foo}--
  </p>
 +!! html/parsoid
 +<p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
  !! end
  
  !! test
  Preprocessor precedence 3: language converter is rightmost opening
  !! options
  language=zh
 +parsoid=wt2html
  !! wikitext
  {{echo|hi}}
  
  {{-{R|echo|hi}}}-
  
  [[-{R|raw]]}-
 -!! html
 +!! html/php
  <p>hi
  </p><p>{{echo|hi}}
  </p><p>[[raw]]
  </p>
 +!! html/parsoid
 +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
 +<p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
 +<p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
  !! end
  
  !! test
@@@ -12199,9 -11928,7 +12199,9 @@@ Preprocessor precedence 4: left-most an
  language=zh
  !! wikitext
  <!--{raw}-->
 -!! html
 +!! html/php
 +!! html/parsoid
 +<!--{raw}-->
  !! end
  
  !! article
@@@ -12214,28 -11941,21 +12214,28 @@@ Template:Precedence
  Preprocessor precedence 5: tplarg takes precedence over template
  !! wikitext
  {{Precedence5|Bullet}}
 -!! html
 +!! html/php
  <ul><li> Bar</li></ul>
  
 +!! html/parsoid
 +<ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li> Bar</li></ul>
  !! end
  
  !! test
  Preprocessor precedence 6: broken link is rightmost opening
 +!! options
 +parsoid=wt2html
  !! wikitext
  {{echo|[[Foo}}
  
  {{echo|[[Foo|bar|bat=baz}}
 -!! html
 +!! html/php
  <p>{{echo|[[Foo}}
  </p><p>{{echo|[[Foo|bar|bat=baz}}
  </p>
 +!! html/parsoid
 +<p>{{echo|[[Foo}}</p>
 +<p>{{echo|[[Foo|bar|bat=baz}}</p>
  !! end
  
  # This next test exposes a difference between PHP and Parsoid:
  
  !! test
  Preprocessor precedence 7: broken template is rightmost opening
 +!! options
 +parsoid=wt2html
  !! wikitext
  [[Foo|{{echo|Bar]]
  
  
  Careful: linktrails can move the end of the wikilink:
  [[Foo|{{echo|y']]a}}l]]l
 -!! html
 +!! html/php
  <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
  </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
  </p><p>Careful: linktrails can move the end of the wikilink:
  <a href="/wiki/Foo" title="Foo">y'al</a>]]l
  </p>
 +!! html/parsoid
 +<p>[[Foo|{{echo|Bar]]</p>
 +<p><a rel="mw:WikiLink" href="./Foo" title="Foo"><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar]]-x"}},"i":0}}]}'>Bar]]-x</span>-y</a>-z</p>
 +<p>Careful: linktrails can move the end of the wikilink:
 +<a rel="mw:WikiLink" href="./Foo" title="Foo"><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"y&#39;]]a"}},"i":0}}]}'>y']]a</span>ll</a></p>
  !! end
  
  !! test
@@@ -12306,7 -12019,7 +12306,7 @@@ Template:Preprocessor_precedence_
  Preprocessor precedence 9: groups of braces
  !! wikitext
  {{Preprocessor precedence 9|Four|Bullet|1|2}}
 -!! html
 +!! html/php
  <dl><dt>4</dt>
  <dd> {Four}</dd>
  <dt>5</dt>
  <dt>7</dt>
  <dd> {Bullet}</dd></dl>
  
 +!! html/parsoid
 +<dl about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Preprocessor precedence 9","href":"./Template:Preprocessor_precedence_9"},"params":{"1":{"wt":"Four"},"2":{"wt":"Bullet"},"3":{"wt":"1"},"4":{"wt":"2"}},"i":0}}]}'>
 +<dt>4</dt>
 +<dd>{Four}</dd>
 +<dt>5</dt>
 +<dd></dd>
 +</dl><ul about="#mwt1">
 +<li>Bar</li>
 +</ul><span about="#mwt1"> </span><dl about="#mwt1">
 +<dt>6</dt>
 +<dd>Four</dd>
 +<dt>7</dt>
 +<dd>{Bullet}</dd>
 +</dl>
  !! end
  
  !! article
@@@ -12351,7 -12050,7 +12351,7 @@@ Preprocessor precedence 10: groups of b
  language=zh
  !! wikitext
  {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
 -!! html
 +!! html/php
  <dl><dt>1</dt>
  <dd> raw</dd>
  <dt>2</dt>
  <dt>7</dt>
  <dd> raw2</dd></dl>
  
 +!! html/parsoid
 +<dl about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Preprocessor precedence 10","href":"./Template:Preprocessor_precedence_10"},"params":{"1":{"wt":"Three"},"2":{"wt":"raw2"},"3":{"wt":"Bullet"},"4":{"wt":"1"},"5":{"wt":"2"}},"i":0}}]}'>
 +<dt>1</dt>
 +<dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
 +<dt>2</dt>
 +<dd>-</dd>
 +</dl><ul about="#mwt1">
 +<li>Bar-</li>
 +</ul><span about="#mwt1"> </span><dl about="#mwt1">
 +<dt>3</dt>
 +<dd>-Three-</dd>
 +<dt>4</dt>
 +<dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
 +<dt>5</dt>
 +<dd>-</dd>
 +</dl><ul about="#mwt1">
 +<li>Bar-</li>
 +</ul><span about="#mwt1"> </span><dl about="#mwt1">
 +<dt>6</dt>
 +<dd>-Three-</dd>
 +<dt>7</dt>
 +<dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
 +</dl>
  !! end
  
  !! test
@@@ -12402,23 -12078,15 +12402,23 @@@ Preprocessor precedence 11: found durin
  {{echo|-{{echo|-{{echo|x}}}}}}
  
  {{echo|-{{echo|x}}}}
 -!! html
 +!! html/php
  <p><span>-<span>-x</span></span>
  </p><p>--x
  </p><p>-x
  </p>
 +!! html/parsoid
 +<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#tag:span","function":"tag"},"params":{"1":{"wt":"-{{#tag:span|-{{echo|x}}}}"}},"i":0}}]}'>-<span>-x</span></span></p>
 +
 +<p about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"-{{echo|-{{echo|x}}}}"}},"i":0}}]}'>--x</p>
 +
 +<p about="#mwt7" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"-{{echo|x}}"}},"i":0}}]}'>-x</p>
  !! end
  
  !! test
  Preprocessor precedence 12: broken language converter closed by brace.
 +!! options
 +parsoid=wt2html
  !! wikitext
  This form breaks the template, which is unfortunate:
  * {{echo|foo-{bar}bat}}
@@@ -12433,7 -12101,7 +12433,7 @@@ tag, nothing bad happens
  <tag>foo-{bar}bat</tag>
  {{echo|<tag>foo-{bar}bat</tag>}}
  
 -!! html+tidy
 +!! html/php+tidy
  <p>This form breaks the template, which is unfortunate:</p>
  <ul>
  <li>{{echo|foo-{bar}bat}}</li>
@@@ -12461,67 -12129,38 +12461,67 @@@ array 
  array (
  )
  </pre>
 +!! html/parsoid
 +<p>This form breaks the template, which is unfortunate:</p>
 +<ul>
 +<li>{{echo|foo-{bar}bat}}</li>
 +</ul>
 +<p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
 +<ul>
 +<li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
 +<li><span typeof="mw:Transclusion mw:Nowiki" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;nowiki>foo-{bar}bat&lt;/nowiki>"}},"i":0}}]}'>foo-{bar}bat</span></li>
 +<li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
 +<li><pre typeof="mw:Transclusion mw:Extension/pre" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre>foo-{bar}bat&lt;/pre>"}},"i":0}}]}'>foo-{bar}bat</pre></li>
 +</ul>
 +<pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'></pre> <pre typeof="mw:Extension/tag mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;tag>foo-{bar}bat&lt;/tag>"}},"i":0}}]}'></pre>
  !! end
  
  !! test
 -Preprocessor precedence, 13: broken language converter in external link
 +Preprocessor precedence 13: broken language converter in external link
 +!! options
 +parsoid=wt2html
  !! wikitext
  * [http://example.com/-{foo Example in URL]
  * [http://example.com Example in -{link} description]
  * {{echo|[http://example.com/-{foo Breaks template, however]}}
 -!! html+tidy
 +!! html/php+tidy
  <ul>
  <li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
  <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
  <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
  </ul>
 +!! html/parsoid
 +<ul>
 +<li><a rel="mw:ExtLink" href="http://example.com/-{foo">Example in URL</a></li>
 +<li><a rel="mw:ExtLink" href="http://example.com">Example in -{link} description</a></li>
 +<li>{{echo|<a rel="mw:ExtLink" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
 +</ul>
  !! end
  
  !! test
 -Preprocessor precedence, 14: broken language converter in comment
 +Preprocessor precedence 14: broken language converter in comment
  !! wikitext
  * <!--{{foo}}--> ...should be ok
  * <!---{{foo}}--> ...extra dashes
  * {{echo|foo<!-- -{bar} -->bat}} ...should be ok
 -!! html+tidy
 +!! html/php+tidy
  <ul>
  <li>...should be ok</li>
  <li>...extra dashes</li>
  <li>foobat ...should be ok</li>
  </ul>
 +!! html/parsoid
 +<ul>
 +<li><!--{{foo}}--> ...should be ok</li>
 +<li><!--&#x2D;{{foo}}--> ...extra dashes</li>
 +<li><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;!-- -{bar} -->bat"}},"i":0}}]}'>foo</span><span about="#mwt1"><!-- &#x2D;{bar} --></span><span about="#mwt1">bat</span> ...should be ok</li>
 +</ul>
  !! end
  
  !! test
 -Preprocessor precedence, 15: broken brace markup in headings
 +Preprocessor precedence 15: broken brace markup in headings
 +!! options
 +parsoid=wt2html
  !! wikitext
  __NOTOC__ __NOEDITSECTION__
  ===1 foo[bar 1===
  5
  ===6 foo-{bar 6===
  6
 -!! html+tidy
 +!! html/php+tidy
  <h3><span class="mw-headline" id="1_foo.5Bbar_1">1 foo[bar 1</span></h3>
  <p>1</p>
  <h3><span class="mw-headline" id="2_foo.5B.5Bbar_2">2 foo[[bar 2</span></h3>
  <p>5</p>
  <h3><span class="mw-headline" id="6_foo-.7Bbar_6">6 foo-{bar 6</span></h3>
  <p>6</p>
 +!! html/parsoid
 +<meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/
 +>
 +<h3>1 foo[bar 1</h3>
 +<p>1</p>
 +<h3>2 foo[[bar 2</h3>
 +<p>2</p>
 +<h3>3 foo{bar 3</h3>
 +<p>3</p>
 +<h3>4 foo{{bar 4</h3>
 +<p>4</p>
 +<h3>5 foo{{{bar 5</h3>
 +<p>5</p>
 +<h3>6 foo-{bar 6</h3>
 +<p>6</p>
 +!! end
 +
 +!! test
 +Preprocessor precedence 16: matching closing braces to opening braces
 +!! options
 +language=zh
 +parsoid=wt2html
 +!! wikitext
 +-{{{echo|foo}}bar}-
 +!! html/php
 +<p>foobar
 +</p>
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[2,14,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo\"}},\"i\":0}}]}&#39;>foo&lt;/span>bar"}}'></span></p>
  !! end
  
  ###
@@@ -13304,7 -12914,7 +13304,7 @@@ Templates: Wiki Tables: 7. Fosterable <
  <tbody>
  </tbody></table>
  
 -<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
 +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
  !!end
  
  !! test
@@@ -13516,16 -13126,8 +13516,16 @@@ Templates: Parameters substituted at th
  <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
  !! end
  
 -!!test
 -Parser Functions: 1. Simple example
 +!! test
 +Templates: Param with empty arg in the final position
 +!! wikitext
 +{{{hi|}}}
 +!! html/parsoid
 +<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
 +!! end
 +
 +!!test
 +Parser Functions: 1. Simple example
  !! wikitext
  {{uc:foo}}
  !! html
@@@ -14017,34 -13619,17 +14017,34 @@@ pre-save transform: Signature expansio
  pst
  !! wikitext
  * ~~~
 +* ~~~~
 +* ~~~~~
  * <noinclude>~~~</noinclude>
  * <includeonly>~~~</includeonly>
  * <onlyinclude>~~~</onlyinclude>
  !! html/php
  * [[Special:Contributions/127.0.0.1|127.0.0.1]]
 +* [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
 +* 00:02, 1 January 1970 (UTC)
  * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
  * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
  * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
  !! end
  
  
 +!! test
 +ParserOutput flags from signature expansion (T84843)
 +!! options
 +pst
 +showflags
 +!! wikitext
 +~~~~
 +!! html/php
 +[[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
 +flags=user-signature
 +!! end
 +
 +
  !! test
  pre-save transform: Signature expansion in nowiki tags (T2093)
  !! options
@@@ -14267,16 -13852,6 +14267,16 @@@ parsoid=wt2html,wt2wt,html2htm
  <p><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" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
  !! end
  
 +!! test
 +Serialize simple image with figure-inline wrapper
 +!! options
 +parsoid=html2wt
 +!! html/parsoid
 +<p><figure-inline 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" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p>
 +!! wikitext
 +[[File:Foobar.jpg]]
 +!! end
 +
  !! test
  Simple image (using File: namespace, now canonical)
  !! wikitext
@@@ -14343,20 -13918,6 +14343,20 @@@ Image with caption, T55312 #
  <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption page=stuff</figcaption></figure>
  !! end
  
 +!! test
 +Image caption with pipe entity
 +!! wikitext
 +[[File:Foobar.jpg|thumb|one &#x7C; two]]
 +[[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
 +!! 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"></a></div>one &#x7c; two</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"></a></div>one <i>two</i> &#x7c; three</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/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>one <span typeof="mw:Entity">|</span> two</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/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>one <i>two</i> <span typeof="mw:Entity">|</span> three</figcaption></figure>
 +!! end
 +
  !! test
  Allow empty links in image captions (T62753)
  !! options
@@@ -14834,28 -14395,6 +14834,28 @@@ Alt image option should handle most kin
  <figure class="mw-default-size" typeof="mw:Image/Thumb mw:ExpandedAttrs" about="#mwt2" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"This is the image caption"},{"ck":"alt","ak":"alt=This is a [[link]] and a {{echo|&#39;&#39;bold template&#39;&#39;}}."}]}' data-mw='{"attribs":[["thumbnail",{"html":"thumb"}],["alt",{"html":"alt=This is a &lt;a rel=\"mw:WikiLink\" href=\"./Link\" title=\"Link\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./Link\"},\"sa\":{\"href\":\"link\"},\"dsr\":[65,73,2,2]}&#39;>link&lt;/a> and a &lt;i about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"dsr\":[80,106,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;#39;&amp;#39;bold template&amp;#39;&amp;#39;\"}},\"i\":0}}]}&#39;>bold template&lt;/i>."}]]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img alt="This is a link and a bold template." resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"alt":"This is a link and a bold template.","resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"alt":"alt=This is a [[link]] and a {{echo|&#39;&#39;bold template&#39;&#39;}}.","resource":"Image:Foobar.jpg"}}'/></a><figcaption>This is the image caption</figcaption></figure>
  !! end
  
 +!! test
 +Image with nested tables in caption
 +!! wikitext
 +[[File:Foobar.jpg|thumb|Foo<br />
 +{|
 +|
 +{|
 +|z
 +|}
 +|}
 +]]
 +!! html/parsoid
 +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Foo&lt;br/>\n{|\n|\n{|\n|z\n|}\n|}\n"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" 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,50,null,null]}'>Foo<br data-parsoid='{"stx":"html","selfClose":true}'/>
 +<table>
 +<tbody><tr><td>
 +<table>
 +<tbody><tr><td>z</td></tr>
 +</tbody></table></td></tr>
 +</tbody></table>
 +</figcaption></figure>
 +!! end
 +
  ###################
  # Conflicting image format options.
  # First option specified should 'win'.
@@@ -14932,7 -14471,7 +14932,7 @@@ parsoid=wt2html,wt2wt,html2htm
  #    enlarged.
  
  !! test
 -Image: "unspecified format" and border enlarge
 +Image: unspecified format and border enlarge
  !! options
  parsoid=wt2html,wt2wt,html2html
  !! wikitext
  </p><p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="2000" height="227" class="thumbborder" /></a>
  </p>
  !! html/parsoid
 -<p><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/1941px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="227" width="2000"/></a></span></p>
 -<p><span class="mw-image-border" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/1941px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="227" width="2000"/></a></span></p>
 +<p><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="227" width="2000"/></a></span></p>
 +<p><span class="mw-image-border" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="227" width="2000"/></a></span></p>
  !! end
  
  !! test
@@@ -14991,8 -14530,8 +14991,8 @@@ parsoid=wt2html,wt2wt,html2htm
  <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"></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/thumb/3/3a/Foobar.jpg/1941px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" 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/thumb/f/ff/Foobar.svg/240px-Foobar.svg" data-file-width="240" data-file-height="180" data-file-type="drawing" height="1500" width="2000"/></a></figure>
 +<figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" 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/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" data-file-width="240" data-file-height="180" data-file-type="drawing" height="1500" width="2000"/></a></figure>
  !! end
  
  !! test
@@@ -15021,8 -14560,8 +15021,8 @@@ parsoid=wt2html,wt2wt,html2htm
  </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/thumb/3/3a/Foobar.jpg/1941px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" 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/thumb/f/ff/Foobar.svg/240px-Foobar.svg" data-file-width="240" data-file-height="180" data-file-type="drawing" height="1500" width="2000"/></a></span></p>
 +<p><span typeof="mw:Image/Frameless"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" 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/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" data-file-width="240" data-file-height="180" data-file-type="drawing" height="1500" width="2000"/></a></span></p>
  !! end
  
  !! test
@@@ -15119,7 -14658,7 +15119,7 @@@ SVG thumbnails with no language se
  <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"></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/thumb/f/ff/Foobar.svg/220px-Foobar.svg" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>caption</figcaption></figure>
 +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/thumb/f/ff/Foobar.svg/220px-Foobar.svg.png" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>caption</figcaption></figure>
  !! end
  
  !! test
@@@ -15132,7 -14671,7 +15132,7 @@@ parsoid=wt2html,wt2wt,html2htm
  <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"></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/thumb/f/ff/Foobar.svg/220px-Foobar.svg" lang="de" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>caption</figcaption></figure>
 +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/thumb/f/ff/Foobar.svg/220px-Foobar.svg.png" lang="de" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>caption</figcaption></figure>
  !! end
  
  !! test
@@@ -15164,10 -14703,10 +15164,10 @@@ T3887: A RFC with a thumbnai
  !! wikitext
  [[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"></a></div>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc12354">RFC 12354</a></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"></a></div>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="https://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/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>This is <a href="//tools.ietf.org/html/rfc12354" rel="mw:ExtLink">RFC 12354</a></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/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>This is <a href="https://tools.ietf.org/html/rfc12354" rel="mw:ExtLink">RFC 12354</a></figcaption></figure>
  !! end
  
  !! test
@@@ -15699,7 -15238,7 +15699,7 @@@ T93580: 1. Templated <ref> inside bloc
  !! html/parsoid
  <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Caption with templated ref: {{echo|&lt;ref>foo&lt;/ref>}}"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>Caption with templated ref: <span about="#mwt5" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion  mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;ref>foo&lt;/ref>"}},"i":0}}]}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></figcaption></figure>
  
 -<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
 +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
  !! end
  
  !! test
@@@ -15709,9 -15248,9 +15709,9 @@@ T93580: 2. <ref> inside inline image
  
  <references />
  !! html/parsoid
 -<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: &lt;ref>foo&lt;/ref>"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,78,5,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"body\":{\"id\":\"mw-reference-text-cite_note-1\"},\"attrs\":{}}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>&lt;meta typeof=\"mw:Extension/ref/Marker\" about=\"#mwt2\" data-parsoid=&#39;{\"group\":\"\",\"name\":\"\",\"content\":\"foo\",\"hasRefInRef\":false,\"dsr\":[64,78,5,6]}&#39;/>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
 +<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: &lt;ref>foo&lt;/ref>"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,78,5,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"body\":{\"id\":\"mw-reference-text-cite_note-1\"},\"attrs\":{}}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
  
 -<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
 +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
  !! end
  
  !! test
@@@ -15721,9 -15260,9 +15721,9 @@@ T93580: 3. Templated <ref> inside inlin
  
  <references />
  !! html/parsoid
 -<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: {{echo|&lt;ref>{{echo|foo}}&lt;/ref>}}"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Transclusion  mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;lt;ref>{{echo|foo}}&amp;lt;/ref>\"}},\"i\":0}}]}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>&lt;meta typeof=\"mw:Transclusion mw:Extension/ref/Marker\" about=\"#mwt2\" data-parsoid=&#39;{\"group\":\"\",\"name\":\"\",\"content\":\"foo\",\"hasRefInRef\":false,\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;lt;ref>{{echo|foo}}&amp;lt;/ref>\"}},\"i\":0}}]}&#39;/>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
 +<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: {{echo|&lt;ref>{{echo|foo}}&lt;/ref>}}"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Transclusion  mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;lt;ref>{{echo|foo}}&amp;lt;/ref>\"}},\"i\":0}}]}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
  
 -<ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
 +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
  !! end
  
  ###
@@@ -15911,7 -15450,7 +15911,7 @@@ Link to categor
  !! wikitext
  [[:Category:MediaWiki User's Guide]]
  !! html
 -<p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
 +<p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
  </p>
  !! end
  
@@@ -16236,68 -15775,6 +16236,68 @@@ parsoid=wt2htm
  <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
  !! end
  
 +!! test
 +9. Categories and newlines: should behave properly with linkprefix (T87753)
 +!! options
 +language=ar
 +!! wikitext
 +foo bar
 +foo bar
 +[[تصنيف:Foo]]
 +[[تصنيف:Bar]]
 +!! html/php
 +<p>foo bar
 +foo bar
 +</p>
 +!! html/parsoid
 +<p>foo bar
 +foo bar</p>
 +<link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
 +<link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
 +!! end
 +
 +!! test
 +10. No regressions on internal links following category (T174639)
 +!! options
 +parsoid=wt2html,html2html
 +!! wikitext
 +[[Category:Foo]]<div>a
 +
 +[[Foo]]</div>
 +!! html/php
 +<div>a
 +<a href="/wiki/Foo" title="Foo">Foo</a></div>
 +
 +!! html/parsoid
 +<link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
 +
 +<a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
 +!! end
 +
 +# Note that Parsoid differs slightly from PHP due to T175421
 +!! test
 +11. Special case where only newlines separate links (T175416)
 +!! options
 +parsoid=wt2html,html2html
 +!! wikitext
 +[[Category:Foo]]
 +
 +[[Foo]][[es:Alimento]]
 +
 +[[Foo]]
 +!! html/php
 +<p><br />
 +<a href="/wiki/Foo" title="Foo">Foo</a>
 +</p><p><a href="/wiki/Foo" title="Foo">Foo</a>
 +</p>
 +!! html/parsoid
 +<link rel="mw:PageProp/Category" href="./Category:Foo"/>
 +
 +<p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
 +
 +<p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
 +!! end
 +
  !! test
  Category links with multiple namespaces
  !! wikitext
@@@ -16345,20 -15822,6 +16345,20 @@@ x[[Category:Foo]]
  <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
  !! end
  
 +!! test
 +Link prefix/suffixes aren't applied to language links
 +!! options
 +parsoid=wt2html
 +language=is
 +!! wikitext
 +x[[es:Foo]]y
 +!! html/php
 +<p>xy
 +</p>
 +!! html/parsoid
 +<p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
 +!! end
 +
  !! test
  Parsoid: Serialize link to file page with colon escape
  !! options
@@@ -16888,7 -16351,7 +16888,7 @@@ section 
  <h2><span class="mw-headline" id="text_.26_text">text &amp; text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: text &amp; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
  <p>section 3
  </p>
 -<h2><span class="mw-headline" id="text_.27_text">text ' text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: text ' text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span class="mw-headline" id="text_.27_text">text ' text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: text &#039; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
  <p>section 4
  </p>
  <h2><span class="mw-headline" id="text_.22_text">text " text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: text &quot; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
@@@ -17316,24 -16779,6 +17316,24 @@@ HTML tag with leading space is parsed a
  </p>
  !! end
  
 +## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
 +## the HTML5 parsing spec.
 +!! test
 +Element with broken attribute syntax
 +!! options
 +parsoid=wt2html
 +!! wikitext
 +<div style=" style="123">hi</div>
 +<div =>ho</div>
 +!! html/php
 +<div style="123">hi</div>
 +<div>ho</div>
 +
 +!! html/parsoid
 +<div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
 +<div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
 +!! end
 +
  ###
  ### Nesting tests (see T43545, T52604, T53081)
  ###
@@@ -17422,17 -16867,11 +17422,17 @@@ Nesting of <bdo
  Media link
  !! wikitext
  [[Media:Foobar.jpg]]
 +[[Media:Video.ogv]]
 +[[:Media:Video.ogv]]
  !! html/php
  <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
 +<a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
 +<a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
  </p>
  !! html/parsoid
 -<p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a></p>
 +<p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
 +<a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv">Media:Video.ogv</a>
 +<a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv" data-parsoid='{"a":{"namespace":"Media"},"sa":{"namespace":":Media"}}'>Media:Video.ogv</a></p>
  !! end
  
  !! test
@@@ -17499,6 -16938,8 +17499,6 @@@ Image link to nonexistent file (T3850 
  <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
  !! end
  
 -
 -
  !! test
  Character reference normalization in link text (T3938)
  !! wikitext
@@@ -18334,7 -17775,7 +18334,7 @@@ Parser hook: static parser hook inside 
  </p>
  !! html/parsoid
  <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
 -<p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt2"></p>
 +<p typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about='#mwt2'></p>
  !! end
  
  # Nested template calls; this case was broken by Parser.php rev 1.506,
@@@ -18366,16 -17807,18 +18366,16 @@@ Nested template call
  ### Sanitizer
  ###
  
 -# HTML+Tidy effectively strips out the empty tags completely
 -# But since Parsoid doesn't it wraps the <s></s> tags in p-tags
 -# which Tidy would have done for the PHP parser had there been content inside it.
 +# HTML+Tidy strips out empty tags completely. Parsoid doesn't.
 +# FIXME: Wikitext for this first test doesn't match its title.
  !! test
  Sanitizer: Closing of open tags
  !! wikitext
  <s></s><table></table>
 -!! html
 -<s></s><table></table>
 +!! html/php+tidy
  
  !! html/parsoid
 -<p><s></s></p><table></table>
 +<s></s><table></table>
  !! end
  
  !! test
@@@ -18492,17 -17935,12 +18492,17 @@@ but if we add a conversion instance: -{
  then we get cut off here: }-
  
  all additional text is vanished
 -!! html
 +!! html/php
  <p>this bit is safe: }-
  </p><p>but if we add a conversion instance: xxx
  </p><p>then we get cut off here: }-
  </p><p>all additional text is vanished
  </p>
 +!! html/parsoid
 +<p>this bit is safe: }-</p>
 +<p>but if we add a conversion instance: <span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"twoway":[{"l":"zh-cn","t":"xxx"},{"l":"zh-tw","t":"yyy"}]}'></span></p>
 +<p>then we get cut off here: }-</p>
 +<p>all additional text is vanished</p>
  !! end
  
  !! test
@@@ -20085,7 -19523,7 +20085,7 @@@ parsoid=wt2htm
  '''''
  !! html/php
  !! html/parsoid
 -<p><b><i></i></b></p>
 +<b><i></i></b>
  !! end
  
  # same html as previous, but wikitext adjusted to match parsoid html2wt
@@@ -20209,7 -19647,7 +20209,7 @@@ File:File:Foobar.jp
  
  !! html/parsoid
  <ul class="gallery mw-gallery-traditional" type="123" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"type":"123","summary":"345"},"body":{"extsrc":"\nFile:File:Foobar.jpg\n"}}'>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:File:Foobar.jpg</span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:File:Foobar.jpg"><img resource="./File:File:Foobar.jpg" src="./Special:FilePath/File:Foobar.jpg" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
  </ul>
  !! end
  
@@@ -20272,12 -19710,12 +20272,12 @@@ image4    |300px| centr
  
  !! html/parsoid
  <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">image1.png </span></div><div class="gallerytext"></div></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">image2.gif</span></div><div class="gallerytext"></div></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">image3</span></div><div class="gallerytext"></div></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">image4    </span></div><div class="gallerytext"></div></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;"> image5.svg</span></div><div class="gallerytext"> <a rel="mw:ExtLink" href="http://///////">http://///////</a></div></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">* image6</span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Image1.png"><img resource="./File:Image1.png" src="./Special:FilePath/Image1.png" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Image2.gif"><img resource="./File:Image2.gif" src="./Special:FilePath/Image2.gif" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Image3"><img resource="./File:Image3" src="./Special:FilePath/Image3" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Image4"><img resource="./File:Image4" src="./Special:FilePath/Image4" height="300" width="300"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Image5.svg"><img resource="./File:Image5.svg" src="./Special:FilePath/Image5.svg" height="120" width="120"/></a></span></div><div class="gallerytext"> <a rel="mw:ExtLink" href="http://///////">http://///////</a></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:*_image6"><img resource="./File:*_image6" src="./Special:FilePath/*_image6" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
  </ul>
  !! end
  
@@@ -20335,11 -19773,11 +20335,11 @@@ image:foobar.jpg|Blabla|alt=This is a f
  !! html/parsoid
  <ul class="gallery mw-gallery-traditional" style="max-width: 226px; _width: 226px;" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"widths":"70px","heights":"40px","perrow":"2"},"body":{}}'>
  <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
 -<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</span></div><div class="gallerytext">caption</div></li>
 -<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</span></div><div class="gallerytext"></div></li>
 -<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext">some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li>
 -<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext"></div></li>
 -<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img alt="This is a foo-bar." resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext">blabla.</div></li>
 +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="40" width="70"/></a></span></div><div class="gallerytext">caption</div></li>
 +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="40" width="70"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext">some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li>
 +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="This is a foo-bar." resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext">blabla.</div></li>
  </ul>
  !! end
  
@@@ -20394,13 -19832,13 +20394,13 @@@ image:foobar.jpg|Blabla|alt=This is a f
  </ul>
  
  !! html/parsoid
 -<ul class="gallery mw-gallery-traditional" style="max-width: 226px; _width: 226px;" typeof="mw:Extension/gallery" about="#mwt3" data-parsoid='{}' data-mw='{"name":"gallery","attrs":{"widths":"70px","heights":"40px","perrow":"2","caption":"Foo [[Main Page]]"},"body":{"extsrc":"\nFile:Nonexistent.jpg|caption\nFile:Nonexistent.jpg\nimage:foobar.jpg|some &#39;&#39;&#39;caption&#39;&#39;&#39; [[Main Page]]\nimage:foobar.jpg\nimage:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.\n"}}'>
 +<ul class="gallery mw-gallery-traditional" style="max-width: 226px; _width: 226px;" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"widths":"70px","heights":"40px","perrow":"2","caption":"Foo [[Main Page]]"},"body":{"extsrc":"\nFile:Nonexistent.jpg|caption\nFile:Nonexistent.jpg\nimage:foobar.jpg|some &#39;&#39;&#39;caption&#39;&#39;&#39; [[Main Page]]\nimage:foobar.jpg\nimage:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.\n"}}'>
  <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
 -<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</span></div><div class="gallerytext">caption</div></li>
 -<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</span></div><div class="gallerytext"></div></li>
 -<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext">some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li>
 -<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext"></div></li>
 -<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img alt="This is a foo-bar." resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext">blabla.</div></li>
 +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="40" width="70"/></a></span></div><div class="gallerytext">caption</div></li>
 +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="40" width="70"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext">some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li>
 +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="This is a foo-bar." resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext">blabla.</div></li>
  </ul>
  !! end
  
@@@ -20440,9 -19878,9 +20440,9 @@@ image:foobar.jpg|link=Main Page#section
  
  !! html/parsoid
  <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./Main_Page#section"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./Main_Page#section"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext">caption</div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./Main_Page#section"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./Main_Page#section"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext">caption</div></li>
  </ul>
  !! end
  
@@@ -20472,7 -19910,7 +20472,7 @@@ File:Foobar.jpg|{{echo|ho}
  !! html/parsoid
  <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
  <li class="gallerycaption"><span about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</span></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><span about="#mwt5" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"ho"}},"i":0}}]}'>ho</span></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><span about="#mwt5" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"ho"}},"i":0}}]}'>ho</span></div></li>
  </ul>
  !! end
  
@@@ -20507,8 -19945,8 +20507,8 @@@ File:Foobar.jpg|alt=galleryalt|{{Test|u
  
  !! html/parsoid
  <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><span typeof="mw:Image" data-mw='{"caption":"desc"}'><a href="./File:Foobar.jpg"><img alt="inneralt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="2" width="20"/></a></span></div></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><span about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"unamedParam"},"alt":{"wt":"param"}},"i":0}}]}'>This is a test template</span></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><span typeof="mw:Image" data-mw='{"caption":"desc"}'><a href="./File:Foobar.jpg"><img alt="inneralt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="2" width="20"/></a></span></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><span about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"unamedParam"},"alt":{"wt":"param"}},"i":0}}]}'>This is a test template</span></div></li>
  </ul>
  !! end
  
@@@ -20561,14 -19999,14 +20561,14 @@@ some <b>caption</b> <a href="/wiki/Main
  
  !! html/parsoid
  <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</span></div><div class="gallerytext"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a>caption</div></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</span></div><div class="gallerytext"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a></div></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><a href="./File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">File:Foobar.jpg</a>some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><a href="./File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">File:Foobar.jpg</a></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="120" width="120"/></a></span></div><div class="gallerytext"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a>caption</div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="120" width="120"/></a></span></div><div class="gallerytext"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><a href="./File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">File:Foobar.jpg</a>some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><a href="./File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">File:Foobar.jpg</a></div></li>
  </ul>
  !! end
  
 -## Should Parsoid be preserving these variations?
 +## Should Parsoid be preserving these variations?  See T151367
  !! test
  Gallery (with namespace-less filenames)
  !! options
@@@ -20609,10 -20047,10 +20609,10 @@@ foobar.jp
  
  !! html/parsoid
  <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</span></div><div class="gallerytext"></div></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">Nonexistent.jpg</span></div><div class="gallerytext"></div></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
  </ul>
  !! end
  
@@@ -20637,7 -20075,7 +20637,7 @@@ File:Foobar.jpg|alt=galleryalt|link=Int
  
  !! html/parsoid
  <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-parsoid='{"dsr":[0,70,2,2]}' data-mw='{"name":"gallery","attrs":{},"body":{}}'>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./InterWikiLink"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./InterWikiLink"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
  </ul>
  !! end
  
@@@ -20662,7 -20100,7 +20662,7 @@@ File:Foobar.jpg|alt=galleryalt|link=htt
  
  !! html/parsoid
  <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="http://www.example.org"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="http://www.example.org"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
  </ul>
  !! end
  
@@@ -20709,11 -20147,10 +20709,11 @@@ File:Foobar.jpg|alt=galleryalt|link=" o
  
  !! html/parsoid
  <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./%22_onclick=%22alert('malicious_javascript_code!');"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./%22_onclick=%22alert('malicious_javascript_code!');"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
  </ul>
  !! end
  
 +# Note that parsoid uses the invalid link as a caption, PHP does not.
  !! test
  Gallery with invalid title as link (T45964)
  !! options
@@@ -20736,7 -20173,7 +20736,7 @@@ File:Foobar.jpg|link=
  
  !! html/parsoid
  <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext">link=&lt;</div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext">link=&lt;</div></li>
  </ul>
  !! end
  
@@@ -20750,7 -20187,7 +20750,7 @@@ parsoid=
  !! html/parsoid
  <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
  <li class="gallerycaption">123</li>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Test.png</span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span>File:Test.png</span></div><div class="gallerytext"></div></li>
  </ul>
  !! wikitext
  <gallery caption="123">
@@@ -20779,7 -20216,7 +20779,7 @@@ File:Foobar.jp
  
  !! html/parsoid
  <ul class="gallery mw-gallery-traditional center" style="text-align: center;" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"class":"center","style":"text-align: center;"},"body":{}}'>
 -<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
 +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
  </ul>
  !! end
  
@@@ -20978,7 -20415,7 +20978,7 @@@ Double RF
  !! wikitext
  RFC RFC 1234
  !! html
- <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a>
+ <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
  </p>
  !! end
  
@@@ -20996,10 -20433,10 +20996,10 @@@ RFC code coverag
  !! wikitext
  RFC   983&#x20;987
  !! html
- <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
+ <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
  </p>
  !! html+tidy
- <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
+ <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
  !! end
  
  !! test
@@@ -21118,7 -20555,7 +21118,7 @@@ HTML with raw HTML ($wgRawHtml==true
  wgRawHtml=1
  !! wikitext
  <html><script>alert(1);</script></html>
 -!! html
 +!! html/php
  <p><script>alert(1);</script>
  </p>
  !! end
@@@ -21527,22 -20964,16 +21527,22 @@@ Parsing of overlapping (improperly nest
  ###
  ### Language variants related tests
  ###
 +
 +# Parsoid does not mark self-links.
 +# Parsoid does not convert links; PHP will do any necessary redirects.
 +
  !! test
  Self-link in language variants
  !! options
  title=[[Dunav]] language=sr
  !! wikitext
  Both [[Dunav]] and [[Дунав]] are names for this river.
 -!! html
 +!! html/php
  <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
  </p>
 -!!end
 +!! html/parsoid
 +<p>Both <a rel="mw:WikiLink" href="./Dunav" title="Dunav">Dunav</a> and <a rel="mw:WikiLink" href="./Дунав" title="Дунав">Дунав</a> are names for this river.</p>
 +!! end
  
  !! article
  Дуна
@@@ -21556,11 -20987,9 +21556,11 @@@ Link to another existing title shouldn'
  title=[[Duna]] language=sr
  !! wikitext
  [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
 -!! html
 +!! html/php
  <p><a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Дуна</a> is not a self-link while <a class="mw-selflink selflink">Duna</a> and <a class="mw-selflink selflink">Dуна</a> are still self-links.
  </p>
 +!! html/parsoid
 +<p><a rel="mw:WikiLink" href="./Дуна" title="Дуна">Дуна</a> is not a self-link while <a rel="mw:WikiLink" href="./Duna" title="Duna">Duna</a> and <a rel="mw:WikiLink" href="./Dуна" title="Dуна">Dуна</a> are still self-links.</p>
  !! end
  
  !! test
@@@ -21569,11 -20998,9 +21569,11 @@@ Link to a section of a variant of this 
  title=[[Duna]] language=sr
  !! wikitext
  [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
 -!! html
 +!! html/php
  <p><a class="mw-selflink selflink">Dуна</a> is a self-link while <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dunа#Foo</a> and <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dуна#Foo</a> are not self-links.
  </p>
 +!! html/parsoid
 +<p><a rel="mw:WikiLink" href="./Dуна" title="Dуна">Dуна</a> is a self-link while <a rel="mw:WikiLink" href="./Dunа#Foo" title="Dunа">Dunа#Foo</a> and <a rel="mw:WikiLink" href="./Dуна#Foo" title="Dуна">Dуна#Foo</a> are not self-links.</p>
  !! end
  
  !! test
@@@ -21582,12 -21009,10 +21582,12 @@@ Link to pages in language variant
  language=sr
  !! wikitext
  Main Page can be written as [[Маин Паге]]
 -!! html
 +!! html/php
  <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
  </p>
 -!!end
 +!! html/parsoid
 +<p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
 +!! end
  
  
  !! test
@@@ -21596,12 -21021,10 +21596,12 @@@ Multiple links to pages in language var
  language=sr
  !! wikitext
  [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
 -!! html
 +!! html/php
  <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a> can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a> same as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>.
  </p>
 -!!end
 +!! html/parsoid
 +<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a> can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a> same as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a>.</p>
 +!! end
  
  
  !! test
@@@ -21610,7 -21033,7 +21610,7 @@@ Simple template in language variant
  language=sr
  !! wikitext
  {{тест}}
 -!! html
 +!! html/php
  <p>This is a test template
  </p>
  !! end
@@@ -21622,7 -21045,7 +21622,7 @@@ Template with explicit namespace in lan
  language=sr
  !! wikitext
  {{Template:тест}}
 -!! html
 +!! html/php
  <p>This is a test template
  </p>
  !! end
@@@ -21634,7 -21057,7 +21634,7 @@@ Basic test for template parameter in la
  language=sr
  !! wikitext
  {{парамтест|param=foo}}
 -!! html
 +!! html/php
  <p>This is a test template with parameter foo
  </p>
  !! end
@@@ -21688,11 -21111,9 +21688,11 @@@ Stripping -{}- tags (language variants
  language=sr
  !! wikitext
  Latin proverb: -{Ne nuntium necare}-
 -!! html
 +!! html/php
  <p>Latin proverb: Ne nuntium necare
  </p>
 +!! html/parsoid
 +<p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
  !! end
  
  
@@@ -21702,11 -21123,9 +21702,11 @@@ Prevent conversion with -{}- tags (lang
  language=sr variant=sr-ec
  !! wikitext
  Latinski: -{Ne nuntium necare}-
 -!! html
 +!! html/php
  <p>Латински: Ne nuntium necare
  </p>
 +!! html/parsoid
 +<p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
  !! end
  
  
@@@ -21716,11 -21135,9 +21716,11 @@@ Prevent conversion of text with -{}- ta
  language=sr variant=sr-ec
  !! wikitext
  Latinski: -{Ne nuntium necare}-
 -!! html
 +!! html/php
  <p>Латински: Ne nuntium necare
  </p>
 +!! html/parsoid
 +<p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
  !! end
  
  
@@@ -21730,11 -21147,9 +21730,11 @@@ Prevent conversion of links with -{}- t
  language=sr variant=sr-ec
  !! wikitext
  -{[[Main Page]]}-
 -!! html
 +!! html/php
  <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
  </p>
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&lt;a rel=\"mw:WikiLink\" href=\"./Main_Page\" title=\"Main Page\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./Main_Page\"},\"sa\":{\"href\":\"Main Page\"},\"dsr\":[2,15,2,2]}&#39;>Main Page&lt;/a>"}}'></span></p>
  !! end
  
  
  language=sr variant=sr-ec
  !! wikitext
  == -{Naslov}- ==
 -!! html
 +
 +Note that even an unprotected headline ID is not affected by language
 +conversion:
 +
 +== Latinski ==
 +!! html/php
  <h2><span class="mw-headline" id="-.7BNaslov.7D-">Naslov</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Уреди одељак „Naslov“">уреди</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
 +цонверсион:
 +</p>
 +<h2><span class="mw-headline" id="Latinski">Латински</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Уреди одељак „Латински“">уреди</a><span class="mw-editsection-bracket">]</span></span></h2>
  
 -!! end
 +!! html/parsoid
 +<h2 id="-.7BNaslov.7D-"><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
  
 +<p>Note that even an unprotected headline ID is not affected by language
 +conversion:</p>
 +
 +<h2 id="Latinski">Latinski</h2>
 +!! end
  
  !! test
  Explicit definition of language variant alternatives
  language=zh variant=zh-tw
  !! wikitext
  -{zh:China;zh-tw:Taiwan}-, not China
 -!! html
 +!! html/php
  <p>Taiwan, not China
  </p>
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'></span>, not China</p>
  !! end
  
 +!! test
 +Filter syntax for language variants
 +!! options
 +language=zh variant=zh-tw
 +!! wikitext
 +foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
 +!! html/php
 +<p>fooblog, WEBJOURNAL, WEBLOGquux
 +</p>
 +!! html/parsoid
 +<p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
 +!! end
  
 +# Note that Parsoid post-processing for language variants needs to
 +# update the `title` attribute here, based on the mw:ExpandedAttrs property
  !! test
  Conversion around HTML tags
  !! options
  language=sr variant=sr-ec
  !! wikitext
 --{H|span=>sr-ec:script;title=>sr-ec:src;}-
 -<span title="La-{sr-el:L;sr-ec:C;}-tin">ski</span>
 -!! html
 +-{H|span=>sr-ec:script;title=>sr-ec:src}-
 +<span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
 +!! html/php
  <p>
  <span title="ЛаCтин">ски</span>
  </p>
 +!! html/parsoid
 +<p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[8]}' data-mw-variant='{"add":true,"oneway":[{"f":"span","l":"sr-ec","t":"script"},{"f":"title","l":"sr-ec","t":"src"}]}'/>
 +<span title="Latin" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"title"},{"html":"La&lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"twoway\":[{\"l\":\"sr-el\",\"t\":\"L\"},{\"l\":\"sr-ec\",\"t\":\"C\"}]}&#39; data-parsoid=&#39;{\"fl\":[],\"tSp\":[6],\"dsr\":[57,76,null,2]}&#39;>&lt;/span>tin"}]]}'>ski</span></p>
  !! end
  
 -
  !! test
 -Explicit session-wise language variant mapping (A flag and - flag)
 +Explicit session-wise two-way language variant mapping (A flag and - flag)
  !! options
  language=zh variant=zh-tw
  !! wikitext
 +This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
 +
  Taiwan is not China.
 -But -{A|zh:China;zh-tw:Taiwan}- is China,
 -(This-{-|zh:China;zh-tw:Taiwan}- should be stripped!)
 +
 +But -{A|zh:China; zh-tw:Taiwan}- is China,
 +
 +(This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
 +
  and -{China}- is China.
 -!! html
 -<p>Taiwan is not China.
 -But Taiwan is Taiwan,
 -(This should be stripped!)
 -and China is China.
 +!! html/php
 +<p>This is Taiwan, but we'll forget that now.
 +</p><p>Taiwan is not China.
 +</p><p>But Taiwan is Taiwan,
 +</p><p>(This should be stripped!)
 +</p><p>and China is China.
  </p>
 +!! html/parsoid
 +<p>This is <span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'></span>, but we'll forget that now.</p>
 +<p>Taiwan is not China.</p>
 +<p>But <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'></span> is China,</p>
 +<p>(This<meta typeof="mw:LanguageVariant" data-mw-variant='{"remove":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/> should be stripped!)</p>
 +<p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
  !! end
  
  !! test
 -Explicit session-wise language variant mapping (H flag for hide)
 +Explicit session-wise one-way language variant mapping (A flag and - flag)
  !! options
  language=zh variant=zh-tw
  !! wikitext
 -(This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
 -Taiwan is China.
 -!! html
 -<p>(This should be stripped!)
 -Taiwan is Taiwan.
 +This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
 +
 +COUNTRY is China or Taiwan.
 +
 +But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
 +
 +(This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
 +
 +and -{COUNTRY}- is COUNTRY.
 +!! html/php
 +<p>This is Taiwan, but we'll forget that now.
 +</p><p>COUNTRY is China or Taiwan.
 +</p><p>But Taiwan is Taiwan,
 +</p><p>(This should be stripped!)
 +</p><p>and COUNTRY is COUNTRY.
  </p>
 +!! html/parsoid
 +<p>This is <span typeof="mw:LanguageVariant" data-mw-variant='{"oneway":[{"f":"COUNTRY","l":"zh","t":"China"},{"f":"COUNTRY","l":"zh-tw","t":"Taiwan"}]}'></span>, but we'll forget that now.</p>
 +<p>COUNTRY is China or Taiwan.</p>
 +<p>But <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"COUNTRY","l":"zh","t":"China"},{"f":"COUNTRY","l":"zh-tw","t":"Taiwan"}]}'></span> is COUNTRY,</p>
 +<p>(This<meta typeof="mw:LanguageVariant" data-mw-variant='{"oneway":[{"f":"COUNTRY","l":"zh","t":"China"},{"f":"COUNTRY","l":"zh-tw","t":"Taiwan"}],"remove":true}'/> should be stripped!)</p>
 +<p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
  !! end
  
  !! test
 -Adding explicit conversion rule for title (T flag)
 +Explicit session-wise two-way language variant mapping (H flag for hide)
  !! options
 -language=zh variant=zh-tw showtitle
 +language=zh variant=zh-tw
  !! wikitext
 -Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
 -!! html
 -Taiwan
 -<p>Should be stripped!
 +(This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
 +
 +Taiwan is China.
 +!! html/php
 +<p>(This should be stripped!)
 +</p><p>Taiwan is Taiwan.
  </p>
 +!! html/parsoid
 +<p>(This<meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/> should be stripped!)</p>
 +<p>Taiwan is China.</p>
  !! end
  
  !! test
 -Testing that changing the language variant here in the tests actually works
 +Explicit session-wise one-way language variant mapping (H flag for hide)
  !! options
 -language=zh variant=zh showtitle
 +language=zh variant=zh-tw
  !! wikitext
 -Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
 -!! html
 -China
 -<p>Should be stripped!
 +(This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
 +
 +COUNTRY is Taiwan or China.
 +!! html/php
 +<p>(This should be stripped!)
 +</p><p>Taiwan is Taiwan or China.
  </p>
 +!! html/parsoid
 +<p>(This<meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[8]}' data-mw-variant='{"add":true,"oneway":[{"f":"COUNTRY","l":"zh","t":"China"},{"f":"COUNTRY","l":"zh-tw","t":"Taiwan"}]}'/> should be stripped!)</p>
 +<p>COUNTRY is Taiwan or China.</p>
  !! end
  
 +## Note that parsoid test runner does not support 'showtitle' option.
  !! test
 -Recursive conversion of alt and title attrs shouldn't clear converter state
 +Adding explicit conversion rule for title (T flag)
  !! options
 -language=zh variant=zh-cn showtitle
 +language=zh variant=zh-tw showtitle
  !! wikitext
 --{H|zh-cn:Exclamation;zh-tw:exclamation;}-
 -Should be stripped-{T|zh-cn:China;zh-tw:Taiwan}-<span title="exclamation">!</span>
 -!! html
 -China
 -<p>
 -Should be stripped<span title="Exclamation">!</span>
 +Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
 +
 +Taiwan is China.
 +!! html/php
 +Taiwan
 +<p>Should be stripped!
 +</p><p>Taiwan is China.
  </p>
 +!! html/parsoid
 +<p>Should be stripped<meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
 +<p>Taiwan is China.</p>
  !! end
  
  !! test
 -T26072: more test on conversion rule for title
 +Code coverage: T combined with H flag
  !! options
  language=zh variant=zh-tw showtitle
  !! wikitext
 -This should be stripped-{T|zh:China;zh-tw:Taiwan}-!
 -This won't take interferes with the title rule-{H|zh:Beijing;zh-tw:Taipei}-.
 -!! html
 +Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
 +
 +Taiwan is China.
 +!! html/php
  Taiwan
 -<p>This should be stripped!
 -This won't take interferes with the title rule.
 +<p>Should be stripped!
 +</p><p>Taiwan is Taiwan.
  </p>
 +!! html/parsoid
 +<p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
 +<p>Taiwan is China.</p>
  !! end
  
  !! test
 -Partly disable title conversion if variant == main language code
 +Code coverage: T with no variants
  !! options
 -language=zh variant=zh title=[[ZH]] showtitle
 +language=zh variant=zh-tw showtitle
  !! wikitext
 --{T|zh-cn:CN;zh-tw:TW}-
 -!! html
 -ZH
 +-{H|zh:China; zh-tw:Taiwan}-
 +Taiwan is China.-{T|Taiwan is China}-
 +!! html/php
 +Taiwan is China
  <p>
 +Taiwan is Taiwan.
  </p>
 +!! html/parsoid
 +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
 +Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
  !! end
  
  !! test
 -Partly disable title conversion if variant == main language code, more
 +Code coverage: rules with no variants
  !! options
 -language=zh variant=zh title=[[ZH]] showtitle
 +language=zh variant=zh-tw
  !! wikitext
 --{T|TW}-
 -!! html
 +-{H|zh:China; zh-tw:Taiwan}-
 +Taiwan is China.
 +-{H|China}-
 +Taiwan is China.
 +!! html/php
 +<p>
 +Taiwan is Taiwan.
 +
 +Taiwan is China.
 +</p>
 +!! html/parsoid
 +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
 +Taiwan is China.
 +<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
 +Taiwan is China.</p>
 +!! end
 +
 +
 +!! test
 +Code coverage: D flag for conversion rule
 +!! options
 +language=zh variant=zh-tw
 +!! wikitext
 +-{D|zh-cn:XA; zh-tw:YA}-
 +-{A;D|zh-cn:XB; zh-tw:YB}-
 +-{D;H|zh-cn:XC; zh-tw:YC}-
 +
 +-{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
 +
 +-{D|0=>zh-tw:1}-
 +-{A;D|2=>zh-tw:3}-
 +-{D;H|4=>zh-tw:5}-
 +
 +XA XB XC YA YB YC FOO BAR BAT 012345
 +!! html/php
 +<p>大陆:XA;台灣:YA;
 +
 +大陆:XC;台灣:YC;
 +</p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
 +</p><p>0⇒台灣:1;
 +
 +4⇒台灣:5;
 +</p><p>XA YB YC YA YB YC BAR BAR BAT 013355
 +</p>
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
 +<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
 +<span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"FOO","l":"zh-tw","t":"BAR"},{"f":"FOO","l":"zh-cn","t":"BAT"}]}'></span></p>
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
 +<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
 +<span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
 +<p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
 +!! end
 +
 +!! test
 +Code coverage: N flag for conversion rule
 +!! options
 +language=zh variant=zh-cn
 +!! wikitext
 +-{N|zh-cn}-
 +
 +-{N|zh-tw}-
 +
 +-{N|sr-ec}-
 +!! html/php
 +<p>大陆
 +</p><p>台灣
 +</p><p>српски (ћирилица)‎
 +</p>
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
 +!! end
 +
 +# html2wt suppresses the bogus 'D' flag, so this is wt2html only
 +!! test
 +Code coverage: N flag for conversion rule (wt2html only)
 +!! options
 +language=zh variant=zh-cn
 +parsoid=wt2html,html2html
 +!! wikitext
 +-{D;N|en}-
 +!! html/php
 +<p>English
 +</p>
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
 +!! end
 +
 +!! test
 +Testing that changing the language variant here in the tests actually works
 +!! options
 +language=zh variant=zh showtitle
 +!! wikitext
 +Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
 +!! html/php
 +China
 +<p>Should be stripped!
 +</p>
 +!! html/parsoid
 +<p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
 +!! end
 +
 +!! test
 +Recursive conversion of alt and title attrs shouldn't clear converter state
 +!! options
 +language=zh variant=zh-cn
 +showtitle
 +!! wikitext
 +-{H|zh-cn:Exclamation; zh-tw:exclamation}-
 +Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
 +!! html/php
 +China
 +<p>
 +Should be stripped<span title="Exclamation">!</span>
 +</p>
 +!! html/parsoid
 +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
 +Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh-cn","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/><span title="exclamation">!</span></p>
 +!! end
 +
 +!! test
 +T26072: more test on conversion rule for title
 +!! options
 +language=zh variant=zh-tw showtitle
 +!! wikitext
 +This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
 +
 +This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
 +!! html/php
 +Taiwan
 +<p>This should be stripped!
 +</p><p>This won't take interferes with the title rule.
 +</p>
 +!! html/parsoid
 +<p>This should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
 +<p>This won't take interferes with the title rule<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"Beijing"},{"l":"zh-tw","t":"Taipei"}]}'/>.</p>
 +!! end
 +
 +!! test
 +Partly disable title conversion if variant == main language code
 +!! options
 +language=zh variant=zh title=[[ZH]] showtitle
 +!! wikitext
 +-{T|zh-cn:CN;zh-tw:TW}-
 +!! html/php
  ZH
  <p>
  </p>
 +!! html/parsoid
 +<p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"title":true,"twoway":[{"l":"zh-cn","t":"CN"},{"l":"zh-tw","t":"TW"}]}'/></p>
 +!! end
 +
 +!! test
 +Partly disable title conversion if variant == main language code, more
 +!! options
 +language=zh variant=zh title=[[ZH]] showtitle
 +!! wikitext
 +-{T|TW}-
 +!! html/php
 +ZH
 +<p>
 +</p>
 +!! html/parsoid
 +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
  !! end
  
  !! test
@@@ -22135,26 -21303,9 +22135,26 @@@ Raw output of variant escape tags (R fl
  language=zh variant=zh-tw
  !! wikitext
  Raw: -{R|zh:China;zh-tw:Taiwan}-
 -!! html
 +!! html/php
  <p>Raw: zh:China;zh-tw:Taiwan
  </p>
 +!! html/parsoid
 +<p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
 +!! end
 +
 +# html2wt suppresses the bogus 'D' flags, so this is wt2html only
 +!! test
 +Raw output of variant escape tags (R flag) (wt2html only)
 +!! options
 +language=zh variant=zh-tw
 +parsoid=wt2html,html2html
 +!! wikitext
 +-{Variant}- -{D|syntax}- -{D;R|options}-
 +!! html/php
 +<p>Variant syntax options
 +</p>
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Variant"}}'></span> <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"syntax"}}'></span> <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"options"}}'></span></p>
  !! end
  
  !! test
@@@ -22163,24 -21314,9 +22163,24 @@@ Nested markup inside raw output of vari
  language=zh variant=zh-tw
  !! wikitext
  Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
 -!! html
 +!! html/php
  <p>Nested raw: nested Taiwan nested
  </p>
 +!! html/parsoid
 +<p>Nested raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"nested &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"twoway\":[{\"l\":\"zh\",\"t\":\"China\"},{\"l\":\"zh-tw\",\"t\":\"Taiwan\"}]}&#39; data-parsoid=&#39;{\"fl\":[],\"tSp\":[6],\"dsr\":[23,48,null,2]}&#39;>&lt;/span> nested"}}'></span></p>
 +!! end
 +
 +!! test
 +Nested markup and spaces inside raw output of variant escape tags (R flag)
 +!! options
 +language=zh variant=zh-tw
 +!! wikitext
 +X-{ outer -{ inner }- outer }-X
 +!! html/php
 +<p>X outer  inner  outer X
 +</p>
 +!! html/parsoid
 +<p>X<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":" outer &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"disabled\":{\"t\":\" inner \"}}&#39; data-parsoid=&#39;{\"fl\":[],\"dsr\":[10,21,null,2]}&#39;>&lt;/span> outer "}}'></span>X</p>
  !! end
  
  !! test
@@@ -22189,11 -21325,9 +22189,11 @@@ Templates inside raw output of variant 
  language=zh variant=zh-tw
  !! wikitext
  Nested raw: -{R|nested {{echo|hi}} templates}-
 -!! html
 +!! html/php
  <p>Nested raw: nested hi templates
  </p>
 +!! html/parsoid
 +<p>Nested raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"nested &lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[23,34,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"hi\"}},\"i\":0}}]}&#39;>hi&lt;/span> templates"}}'></span></p>
  !! end
  
  !! test
@@@ -22202,11 -21336,9 +22202,11 @@@ Strings evaluating false shouldn't be i
  language=zh variant=zh-cn
  !! input
  -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
 -!! result
 +!! html/php
  <p>0
  </p>
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[12]}' data-mw-variant='{"twoway":[{"l":"zh-cn","t":"0"},{"l":"zh-sg","t":"1"},{"l":"zh-tw","t":"2"},{"l":"zh-hk","t":"3"}]}'></span></p>
  !! end
  
  !! test
@@@ -22215,37 -21347,31 +22215,37 @@@ Conversion rules from [numeric-only str
  language=zh variant=zh-cn
  !! input
  -{H|0=>zh-cn:B}--{H|0=>zh-cn:C;0=>zh-cn:D}--{H|0=>zh-hans:A}-012345-{A|zh-tw:0;zh-cn:E;}-012345
 -!! result
 +!! html/php
  <p>D12345EE12345
  </p>
 +!! html/parsoid
 +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-cn","t":"B"}]}'/><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-cn","t":"C"},{"f":"0","l":"zh-cn","t":"D"}]}'/><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-hans","t":"A"}]}'/>012345<span typeof="mw:LanguageVariant" data-parsoid='{"fl":["A"],"tSp":[7]}' data-mw-variant='{"add":true,"twoway":[{"l":"zh-tw","t":"0"},{"l":"zh-cn","t":"E"}]}'></span>012345</p>
  !! end
  
  !! test
 -Bidirectional converter rule entries with an empty value should be ignored (T53551)
 +Two-way converter rule entries with an empty value should be ignored (T53551)
  !! options
  language=zh variant=zh-cn
  !! input
  -{H|zh-cn:foo;zh-tw:;}-foobar
 -!! result
 +!! html/php
  <p>foobar
  </p>
 +!! html/parsoid
 +<p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[7]}' data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"foo"},{"l":"zh-tw","t":""}]}'/>foobar</p>
  !! end
  
  !! test
 -Unidirectional converter rule entries with an empty "from" string should be ignored (T53551)
 +One-way converter rule entries with an empty "from" string should be ignored (T53551)
  !! options
  language=zh variant=zh-cn
  !! input
  -{H|=>zh-cn:foo;}-foobar
 -!! result
 +!! html/php
  <p>foobar
  </p>
 +!! html/parsoid
 +<p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
  !! end
  
  !! test
@@@ -22254,11 -21380,9 +22254,11 @@@ Empty converter rule entries shouldn't 
  language=zh variant=zh-cn
  !! input
  -{H|}-foobar
 -!! result
 +!! html/php
  <p>foobar
  </p>
 +!! html/parsoid
 +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
  !! end
  
  !! test
@@@ -22267,11 -21391,9 +22267,11 @@@ Nested using of manual convert synta
  language=zh variant=zh-hk
  !! wikitext
  Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
 -!! html
 +!! html/php
  <p>Nested: Hello Hong Kong!
  </p>
 +!! html/parsoid
 +<p>Nested: <span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[7]}' data-mw-variant='{"twoway":[{"l":"zh-hans","t":"Hi &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"twoway\":[{\"l\":\"zh-cn\",\"t\":\"China\"},{\"l\":\"zh-sg\",\"t\":\"Singapore\"}]}&#39; data-parsoid=&#39;{\"fl\":[],\"tSp\":[7],\"dsr\":[21,53,null,2]}&#39;>&lt;/span>"},{"l":"zh-hant","t":"Hello &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"twoway\":[{\"l\":\"zh-tw\",\"t\":\"Taiwan\"},{\"l\":\"zh-hk\",\"t\":\"H&amp;lt;span typeof=\\\"mw:LanguageVariant\\\" data-mw-variant=&amp;#39;{\\\"disabled\\\":{\\\"t\\\":\\\"ong\\\"}}&amp;#39; data-parsoid=&amp;#39;{\\\"fl\\\":[],\\\"dsr\\\":[90,97,null,2]}&amp;#39;>&amp;lt;/span> K&amp;lt;span typeof=\\\"mw:LanguageVariant\\\" data-mw-variant=&amp;#39;{\\\"disabled\\\":{\\\"t\\\":\\\"\\\"}}&amp;#39; data-parsoid=&amp;#39;{\\\"fl\\\":[],\\\"dsr\\\":[99,103,null,2]}&amp;#39;>&amp;lt;/span>ong\"}]}&#39; data-parsoid=&#39;{\"fl\":[],\"tSp\":[7],\"dsr\":[68,109,null,2]}&#39;>&lt;/span>"}]}'></span>!</p>
  !! end
  
  !! test
@@@ -22280,146 -21402,25 +22280,146 @@@ HTML markups with conversion syntax in 
  language=zh variant=zh-cn
  !! wikitext
  -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
 -!! html
 +!! html/php
  <p><span title="X">A</span>
  </p>
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"&lt;span title=\"\" about=\"#mwt1\" typeof=\"mw:ExpandedAttrs\" data-parsoid=&#39;{\"stx\":\"html\",\"a\":{\"title\":\"\"},\"sa\":{\"title\":\"-{X}-\"},\"dsr\":[21,49,20,7]}&#39; data-mw=&#39;{\"attribs\":[[{\"txt\":\"title\"},{\"html\":\"&amp;lt;span typeof=\\\"mw:LanguageVariant\\\" data-mw-variant=&amp;#39;{\\\"disabled\\\":{\\\"t\\\":\\\"X\\\"}}&amp;#39; data-parsoid=&amp;#39;{\\\"fl\\\":[],\\\"dsr\\\":[34,39,null,2]}&amp;#39;>&amp;lt;/span>\"}]]}&#39;>A&lt;/span>"}}'></span></p>
  !! end
  
  !! test
 -HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet)
 +HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
  !! options
 -language=zh variant=zh-cn disabled
 +language=zh variant=zh-cn
  !! wikitext
  -{<span title="-{X}-">A</span>}-
 -!! html
 +!! html/php+disabled
  <p><span title="X">A</span>
  </p>
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&lt;span title=\"\" about=\"#mwt1\" typeof=\"mw:ExpandedAttrs\" data-parsoid=&#39;{\"stx\":\"html\",\"a\":{\"title\":\"\"},\"sa\":{\"title\":\"-{X}-\"},\"dsr\":[2,30,20,7]}&#39; data-mw=&#39;{\"attribs\":[[{\"txt\":\"title\"},{\"html\":\"&amp;lt;span typeof=\\\"mw:LanguageVariant\\\" data-mw-variant=&amp;#39;{\\\"disabled\\\":{\\\"t\\\":\\\"X\\\"}}&amp;#39; data-parsoid=&amp;#39;{\\\"fl\\\":[],\\\"dsr\\\":[15,20,null,2]}&amp;#39;>&amp;lt;/span>\"}]]}&#39;>A&lt;/span>"}}'></span></p>
 +!! end
 +
 +# Parsoid and PHP disagree on how to parse this example: Parsoid
 +# insists that the content of a language converter element be a valid
 +# DOM fragment or attribute string
 +!! test
 +Language converter markup with block content
 +!! options
 +language=zh variant=zh-cn
 +!! wikitext
 +<span>a-{b<div>c}-d
 +
 +<span>a-{zh;zh-hans;zh-hant|b<div>c}-d
 +
 +<span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
 +!! html/php+tidy
 +<p><span>ab</span></p>
 +<div><span>cd <span>ab</span></span>
 +<div><span>cd <span>ad</span></span></div>
 +</div>
 +!! html/parsoid
 +<p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</span></p><div typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[10,16,5,0]}&#39;>c&lt;/div>"}}'></div><p>d</p>
 +
 +<p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</span></p><div typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[50,56,5,0]}&#39;>c&lt;/div>"}}'></div><p>d</p>
 +
 +<p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-cn","t":"x&lt;span data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[82,89,6,0]}&#39;>y&lt;/span>"},{"f":"0","l":"zh-tw","t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[100,106,5,0]}&#39;>c&lt;/div>"}]}'/>d</span></p>
 +!! end
 +
 +!! test
 +LanguageConverter selser (1)
 +!! options
 +language=zh variant=zh-cn
 +parsoid={
 +  "modes": ["wt2wt", "selser"],
 +  "changes": [
 +    ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
 +  ]
 +}
 +!! wikitext
 +-{raw}-
 +!! wikitext/edited
 +-{edited}-
 +!! end
 +
 +!! test
 +LanguageConverter selser (2)
 +!! options
 +language=zh variant=zh-cn
 +parsoid={
 +  "modes": ["wt2wt", "selser"],
 +  "changes": [
 +    ["span[class='x']", "contents", "text", "-{foo}-"],
 +    ["a", "contents", "text", "-{"],
 +    ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
 +  ]
 +}
 +!! wikitext
 +<span class="x">TEXT1</span>
 +[http://example.com TEXT2]
 +[[Foo|TEXT3]]
 +{{echo|TEXT4}}
 +!! wikitext/edited
 +<span class="x"><nowiki>-{foo}-</nowiki></span>
 +[http://example.com -{]
 +[[Foo|<nowiki>-{</nowiki>]]
 +{{1x|<nowiki>-{</nowiki>}}
 +!! end
 +
 +# Tests LanguageVariantText in ConstrainedText
 +!! test
 +LanguageConverter selser (3)
 +!! options
 +language=zh variant=zh-cn
 +parsoid={
 +  "modes": ["wt2wt", "selser"],
 +  "changes": [
 +    ["td > span", "attr", "typeof", "mw:LanguageVariant"],
 +    ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
 +  ]
 +}
 +!! wikitext
 +{|
 +|-
 +|<span>Foo</span>
 +|}
 +!! wikitext/edited
 +{|
 +|-
 +|<nowiki/>-{edited}-
 +|}
 +!! end
 +
 +# Tests LanguageVariantText._fromSelSer
 +!! test
 +LanguageConverter selser (4)
 +!! options
 +language=zh variant=zh-cn
 +parsoid={
 +  "modes": ["wt2wt", "selser"],
 +  "changes": [
 +    ["td > span.x", "remove"]
 +  ]
 +}
 +!! wikitext
 +{|
 +|-
 +|<span class="x">Foo</span>-{Bar}-
 +||<span class="x">Foo</span>-{Bar}-
 +|}
 +!! wikitext/edited
 +{|
 +|-
 +|<nowiki/>-{Bar}-
 +||-{Bar}-
 +|}
  !! end
  
  # Since Parsoid is starting to emit canonical wikitext for links,
  # [http://example.com http://example.com] will not RT back to that
  # form anymore.
 +# Parsoid does not language-convert links (it is done in a
 +# post-processing step)
  !! test
  Proper conversion of text in external links
  !! options
@@@ -22448,8 -21449,8 +22448,8 @@@ gopher://www.google.co
  <a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
  <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
  <a rel="mw:ExtLink" href="https://www.google.com">irc://www.google.com</a>
 -<a rel="mw:ExtLink" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
 -<a rel="mw:ExtLink" href="//www.google.com">www.гоогле.цом</a></p>
 +<a rel="mw:ExtLink" href="ftp://www.google.com">www.google.com/ftp://dir</a>
 +<a rel="mw:ExtLink" href="//www.google.com">www.google.com</a></p>
  !! end
  
  !! test
@@@ -22458,11 -21459,9 +22458,11 @@@ Do not convert roman numbers to languag
  language=sr variant=sr-ec
  !! wikitext
  Fridrih IV je car.
 -!! html
 +!! html/php
  <p>Фридрих IV је цар.
  </p>
 +!! html/parsoid
 +<p>Fridrih IV je car.</p>
  !! end
  
  !! test
@@@ -22482,11 -21481,9 +22482,11 @@@ Don't convert raw rule "-{R|=&gt;}-" t
  language=sr
  !! wikitext
  -{R|=&gt;}-
 -!! html
 +!! html/php
  <p>=&gt;
  </p>
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"=&lt;span typeof=\"mw:Entity\" data-parsoid=&#39;{\"src\":\"&amp;amp;gt;\",\"srcContent\":\">\",\"dsr\":[5,9,null,null]}&#39;>>&lt;/span>"}}'></span></p>
  !!end
  
  !! test
@@@ -22495,11 -21492,9 +22495,11 @@@ Don't break link parsing if language co
  language=sr variant=sr-ec
  !! wikitext
  [[Main Page|-{R|main page}-]]
 -!! html
 +!! html/php
  <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
  </p>
 +!! html/parsoid
 +<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"main page"}}' data-parsoid='{"fl":["R"]}'></span></a></p>
  !! end
  
  !! test
@@@ -22511,8 -21506,6 +22511,8 @@@ language=sr variant=sr-e
  !! html/php
  <p>foo
  </p>
 +!! html/parsoid
 +<p><span typeof="mw:Transclusion mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo"}}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Шаблон:Echo"},"params":{"1":{"wt":"-{R|foo}-"}},"i":0}}]}'></span></p>
  !! end
  
  !! test
@@@ -22520,12 -21513,12 +22520,12 @@@ T146305: Don't break image parsing if l
  !! options
  language=sr
  !! wikitext
 -[[File:Foobar.jpg|thumb|-{R|caption:}-]]
 +[[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
  !! html/php
  <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/%D0%94%D0%B0%D1%82%D0%BE%D1%82%D0%B5%D0%BA%D0%B0: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/%D0%94%D0%B0%D1%82%D0%BE%D1%82%D0%B5%D0%BA%D0%B0:Foobar.jpg" class="internal" title="Повећај"></a></div>caption:</div></div></div>
  
  !! html/parsoid
 -<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./Датотека:Foobar.jpg"><img resource="./Датотека:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><span typeof="mw:LanguageVariant" data-mw='{"disabled":true,"show":true,"text":"caption:"}'></span></figcaption></figure>
 +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"}]}'><a href="./Датотека:Foobar.jpg"><img resource="./Датотека:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"caption:"}}' data-parsoid='{"fl":["R"]}'></span></figcaption></figure>
  !! end
  
  !! test
@@@ -22533,15 -21526,14 +22533,15 @@@ T146305: Don't break image parsing if n
  !! options
  language=zh variant=zh-cn
  !! wikitext
 -[[File:Foobar.jpg|thumb|-{zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
 +[[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
  !! 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="放大"></a></div>blog (hk: WEBJOURNAL, tw: WEBLOG)</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/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><span typeof="mw:LanguageVariant" data-mw='{"bidir":[{"l":"zh-cn","t":"blog (hk: &lt;span typeof=\"mw:LanguageVariant\" data-parsoid=&#39;{\"fl\":[\"zh-hans\"],\"dsr\":[42,64,null,2]}&#39; data-mw=&#39;{\"filter\":[\"zh-hans\"],\"text\":\"WEBJOURNAL\"}&#39;>&lt;/span>, tw: &lt;span typeof=\"mw:LanguageVariant\" data-parsoid=&#39;{\"fl\":[\"zh-hans\"],\"dsr\":[70,88,null,2]}&#39; data-mw=&#39;{\"filter\":[\"zh-hans\"],\"text\":\"WEBLOG\"}&#39;>&lt;/span>)"}],"show":true}'></span></figcaption></figure>
 +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"zh-cn","t":"blog (hk: &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"filter\":{\"l\":[\"zh-hans\"],\"t\":\"WEBJOURNAL\"}}&#39; data-parsoid=&#39;{\"fl\":[\"zh-hans\"],\"dsr\":[43,65,null,2]}&#39;>&lt;/span>, tw: &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"filter\":{\"l\":[\"zh-hans\"],\"t\":\"WEBLOG\"}}&#39; data-parsoid=&#39;{\"fl\":[\"zh-hans\"],\"dsr\":[71,89,null,2]}&#39;>&lt;/span>)"}]}'></span></figcaption></figure>
  !! end
  
 +# XXX html2wt disabled because rich markup in alt is not preserved.
  !! test
  Don't break gallery if language converter markup is inside.
  !! options
@@@ -22551,7 -21543,7 +22551,7 @@@ language=z
  File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
  File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
  </gallery>
 -!! html
 +!! html/php
  <ul class="gallery mw-gallery-traditional">
                <li class="gallerybox" style="width: 155px"><div style="width: 155px">
                        <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="bat" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
                </div></li>
  </ul>
  
 +!! html/parsoid
 +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-\nFile:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt\n"}}'>
 +<li class="gallerybox">
 +<div class="thumb"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div>
 +<div class="gallerytext"><span typeof="mw:Image" data-mw='{"caption":"&lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"disabled\":{\"t\":\"bar\"}}&#39; data-parsoid=&#39;{\"fl\":[\"R\"],\"dsr\":[68,77,null,2]}&#39;>&lt;/span>"}'><a href="./File:Foobar.jpg"><img alt="" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="2" width="20"/></a></span></div>
 +</li>
 +<li class="gallerybox">
 +<div class="thumb"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div>
 +<div class="gallerytext"><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"unamedParam"},"alt":{"wt":"-{R|param}-"}},"i":0}}]}'>This is a test template</span></div>
 +</li>
 +</ul>
  !! end
  
  !! test
@@@ -22594,8 -21575,9 +22594,8 @@@ language=zh variant=zh-c
  <dt>foo:bar</dt></dl>
  
  !! html/parsoid
 -<dl>
 -<dt><span typeof="mw:LanguageVariant" data-mw='{"bidir":[{"l":"zh-cn","t":"AAA"},{"l":"zh-tw","t":"BBB"}],"show":true}'></span></dt>
 -<dt><span typeof="mw:LanguageVariant" data-mw='{"disabled":true,"show":true,"text":"foo:bar"}'></span></dt>
 +<dl><dt data-parsoid='{"dsr":[0,24,1,0]}'><span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"twoway":[{"l":"zh-cn","t":"AAA"},{"l":"zh-tw","t":"BBB"}]}'></span></dt>
 +<dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
  </dl>
  !! end
  
@@@ -22608,15 -21590,16 +22608,15 @@@ language=zh variant=zh-c
  !! wikitext
  ;<b>foo:bar
  ;-{zh-cn:AAA
 -!! html/php
 -<dl><dt><b>foo:bar</dt>
 -<dt>-{zh-cn:AAA</b></dt></dl>
 -
 -!! html/parsoid
 +!! html/php+tidy
  <dl>
  <dt><b>foo:bar</b></dt>
 -<b>
 -<dt>-{zh-cn</dt>
 -<dd>AAA</dd>
 +<dt><b>-{zh-cn:AAA</b></dt>
 +</dl>
 +!! html/parsoid
 +<dl><dt data-parsoid='{"dsr":[0,11,1,0]}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
 +<dt data-parsoid='{"dsr":[12,20,1,0]}'>-{zh-cn</dt>
 +<dd data-parsoid='{"stx":"row","dsr":[20,24,1,0]}'>AAA</dd>
  </b></dl>
  !! end
  
@@@ -22625,23 -21608,22 +22625,23 @@@ T153135: Nested language converter mark
  !! options
  language=zh variant=zh-cn
  !! wikitext
 -;-{zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
 +;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
  !! html/php
  <dl><dt>AAA foo:bar bat:baz</dt>
  <dd>def</dd></dl>
  
  !! html/parsoid
 -<dl>
 -<dt><span typeof="mw:LanguageVariant" data-mw='{"bidir":[{"l":"zh-cn","t":"AAA &lt;span typeof=\"mw:LanguageVariant\" data-parsoid=&#39;{\"fl\":[\"zh-hans\"],\"dsr\":[13,32,null,2]}&#39; data-mw=&#39;{\"filter\":[\"zh-hans\"],\"text\":\"bar\"}&#39;>&lt;/span> &lt;span typeof=\"mw:LanguageVariant\" data-parsoid=&#39;{\"fl\":[\"R\"],\"dsr\":[33,46,null,2]}&#39; data-mw=&#39;{\"disabled\":true,\"show\":true,\"text\":\"bat:baz\"}&#39;>&lt;/span>"}],"show":true}'></span></dt>
 -<dd>def</dd>
 +<dl><dt data-parsoid='{"dsr":[0,49,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"zh-cn","t":"AAA &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"filter\":{\"l\":[\"zh-hans\"],\"t\":\"foo:bar\"}}&#39; data-parsoid=&#39;{\"fl\":[\"zh-hans\"],\"dsr\":[14,33,null,2]}&#39;>&lt;/span> &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"disabled\":{\"t\":\"bat:baz\"}}&#39; data-parsoid=&#39;{\"fl\":[\"R\"],\"dsr\":[34,47,null,2]}&#39;>&lt;/span>"}]}'></span></dt>
 +<dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
  </dl>
  !! end
  
 +# html2wt mode disabled due to <nowiki> insertion.
  !! test
  T153140: Don't break table handling if language converter markup is in the cell.
  !! options
  language=sr variant=sr-ec
 +parsoid=wt2html,wt2wt,html2html
  !! wikitext
  {|
  |-
  
  !! html/parsoid
  <table>
 -
 +<tbody>
  <tr>
 -<td> B
 -</td></tr></table>
 +<td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
 +</tr>
 +</tbody>
 +</table>
 +!! end
  
 +!! test
 +Language converter tricky html2wt cases (1)
 +!! options
 +language=sr
 +parsoid=html2wt,wt2wt
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
 +!! wikitext
 +-{<nowiki>}-</nowiki>}-
 +!! html/php
 +<p>&#125;-
 +</p>
 +!! end
 +
 +!! test
 +Language converter tricky html2wt cases (2)
 +!! options
 +language=sr
 +parsoid=html2wt,wt2wt
 +!! html/parsoid
 +<p>-{foo}-</p>
 +!! wikitext
 +<nowiki>-{foo}-</nowiki>
 +!! html/php
 +<p>-&#123;foo&#125;-
 +</p>
 +!! end
 +
 +!! test
 +Language converter tricky html2wt cases (3)
 +!! options
 +language=sr
 +parsoid=html2wt,wt2wt
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
 +!! wikitext
 +-{R||}-
 +
 +-{R|R|raw}-
 +
 +-{<nowiki>-{foo}-</nowiki>}-
 +!! html/php
 +<p>|
 +</p><p>R|raw
 +</p><p>-&#123;foo&#125;-
 +</p>
 +!! end
 +
 +!! test
 +Language converter tricky html2wt cases (4)
 +!! options
 +language=sr
 +parsoid=html2wt,wt2wt
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[2,14,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"hey\"}},\"i\":0}}]}&#39;>hey&lt;/span>"}}'></span></p>
 +!! wikitext
 +-{R|{{echo|hey}}}-
 +!! html/php
 +<p>hey
 +</p>
 +!! end
 +
 +# Note that the <nowiki> escaping added by parsoid for source text,
 +# destination text, and language names only works on the PHP side
 +# for *destination text*.  (HTML entity escaping wouldn't work
 +# any better.)  This is probably a bug, at least for source texts.
 +# (For language names PHP uses a precise regexp based on the languages
 +# it currently knows have variants, which is fragile since this set
 +# can grow/shrink over time.)
 +!! test
 +Language converter tricky html2wt cases (5)
 +!! options
 +language=zh variant=zh-cn
 +!! html/parsoid
 +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"a:b=>c","l":"zh-cn","t":"x;foo=>zh-cn:boo"},{"f":"bar","l":"zh-cn","t":"bat;xyz=>zh-cn:abc"}]}'/>foobar</p>
 +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-tw","t":"xyz"},{"l":"zh-cn","t":"0;zh-tw:bar"}]}'></span></p>
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
 +<p>a:b=>c xyz</p>
 +!! wikitext
 +-{H|<nowiki>a:b=>c</nowiki>=>zh-cn:<nowiki>x;foo=>zh-cn:boo</nowiki>;bar=>zh-cn:<nowiki>bat;xyz=>zh-cn:abc</nowiki>}-foobar
 +
 +-{H|A=><nowiki>bo:g;us</nowiki>:B}-
 +
 +-{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
 +
 +-{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
 +
 +a:b=>c xyz
 +!! html/php+disabled
 +<p>foobat;xyz=&gt;zh-cn:abc
 +</p><p>A
 +</p><p>0;zh-tw:bar
 +</p><p>abc
 +</p><p>a:b=&gt;c 0;zh-tw:bar
 +</p>
 +!! end
 +
 +!! test
 +T179579: Nowiki and lc interaction
 +!! options
 +parsoid=wt2html
 +language=sr
 +!! wikitext
 +-{</nowiki>123}-
 +
 +-{123<nowiki>|</nowiki>456}-
 +!! html/parsoid
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
 +
 +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"123&lt;span typeof=\"mw:Nowiki\" data-parsoid=&#39;{\"dsr\":[23,41,8,9]}&#39;>|&lt;/span>456"}}' data-parsoid='{"fl":[],"src":"-{123&lt;nowiki>|&lt;/nowiki>456}-"}'></span></p>
  !! end
  
  !! test
@@@ -24555,7 -23421,9 +24555,7 @@@ parsoid=wt2html,wt2w
  !! wikitext
  '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
  !! html/parsoid
 -<p><b><small></small></b></p>
 -<figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure>
 -<p></p>
 +<b><small><figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure></small></b>
  !! end
  
  #### ----------------------------------------------------------------
@@@ -24630,12 -23498,12 +24630,12 @@@ Empty LI and TR nodes should not be str
  !! html/parsoid
  <ul>
  <li> a</li>
 -<li></li>
 +<li class='mw-empty-elt'></li>
  <li> b</li>
  </ul>
  <table>
  <tbody>
 -<tr></tr>
 +<tr class='mw-empty-elt'></tr>
  <tr>
  <td>foo</td>
  </tr>
@@@ -24649,9 -23517,9 +24649,9 @@@ Empty TR nodes should not be stripped i
  {{EmptyTRWithHTMLAttrTest}}
  !! html/parsoid
  <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
 -<tr align="center"></tr>
 +<tr align='center'></tr>
  <tr><td>foo</td></tr>
 -<tr align="center"></tr>
 +<tr align='center'></tr>
  <tr><td>bar</td></tr>
  </table>
  !! end
@@@ -25754,9 -24622,9 +25754,9 @@@ Links 8. Add <nowiki/>s between text-no
  !! options
  parsoid=html2wt
  !! html/parsoid
- <p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
- <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
- X<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
+ <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
+ <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
+ X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
  !! wikitext
  RFC 123<nowiki/>4
  RFC 123<nowiki/>y
@@@ -25768,18 -24636,18 +25768,18 @@@ Links 9. Don't add spurious <nowiki/>s 
  !! options
  parsoid=html2wt
  !! html/parsoid
- <p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
- <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
- -<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
+ <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
+ <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
+ -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
  </p>
  !! wikitext
  RFC 123?foo
  RFC 123&foo
  -RFC 123-
  !! html/php
- <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>?foo
- <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
- -<a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>-
+ <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
+ <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
+ -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
  </p>
  !! end
  
@@@ -25937,7 -24805,7 +25937,7 @@@ parsoid=html2w
  '<i>foo</i> <span class="mw-ref" id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span>
  '<i>foo</i> <div title="name">test</div>
  '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
 -<ol class="mw-references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
 +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
  <li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="./Main_Page#cite_ref-1">↑</a></span> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">test</span></li>
  </ol>
  !! wikitext
  parsoid=html2wt
  !! html/parsoid
  <p>foo <span about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span></p>
 -<ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
 +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
  <li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text"><i>a</i>
   b</span></li>
  </ol>
@@@ -26495,7 -25363,7 +26495,7 @@@ RT-ed inter-element separators should b
  
  !! html/parsoid
  <table>
 -<tbody><tr data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
 +<tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
  </tbody></table>
  !!end
  
@@@ -26642,7 -25510,7 +26642,7 @@@ parsoi
  !! html
  <table>
  <tbody>
 -<tr></tr>
 +<tr class='mw-empty-elt'></tr>
  <tr about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<tr><td>foo</td></tr>"}},"i":0}}]}'>
  <td>foo</td></tr>
  </tbody></table>
@@@ -26664,7 -25532,7 +26664,7 @@@ parsoi
  !! html
  <table>
  <tbody>
 -<tr></tr>
 +<tr class='mw-empty-elt'></tr>
   <!--c-->
  <tr>
  <!--c--> </tr><!--d-->
@@@ -27082,17 -25950,12 +27082,17 @@@ parsoid=html2w
  <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
  <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
  <a href='fr%3AFoo'>Foo</a></p>
 +<p><a href='FR%3AFoo'>Foo</a>
 +<a href='./FR:Foo'>Foo</a></p>
  !! wikitext
  [[:fr:Foo|Foo]]
  [[:fr:Foo|Foo]]
  [[:fr:Foo|Foo]]
  
  [[:fr:Foo|Foo]]
 +[[:fr:Foo|Foo]]
 +[[:fr:Foo|Foo]]
 +
  [[:fr:Foo|Foo]]
  [[:fr:Foo|Foo]]
  !! end
@@@ -27362,7 -26225,7 +27362,7 @@@ Image: Block level image should have \
  <p>123</p>
  <figure class="mw-halign-right" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/150px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="17" width="150"/></a></figure>
  <p>456</p>
 -!!end
 +!! end
  
  !! test
  Image: New block level image should have \n before and after (existing content)
  <p>123</p>
  <figure class="mw-halign-right" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"right","ak":"right"},{"ck":"thumbnail","ak":"thumb"},{"ck":"width","ak":"150x150px"}]}'><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/150px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="17" width="150" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"17","width":"150"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure>
  <p>456</p>
 -!!end
 +!! end
  
  !! test
  Image: upright option (parsoid)
  <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/170px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="19" width="170"/></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/thumb/3/3a/Foobar.jpg/110px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="12" width="110"/></a><figcaption>caption</figcaption></figure>
  <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/500px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="57" width="500"/></a><figcaption>caption</figcaption></figure>
 -!!end
 +!! end
  
  !! test
  Image: upright option is ignored on inline and frame images (parsoid)
  [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
  !! html/parsoid
  <p><span typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/500px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="57" width="500"/></a></span></p>
 -!!end
 +!! end
 +
 +!! test
 +Image: in template parameter with empty parameter
 +!! wikitext
 +{{echo|[[File:Foobar.jpg|link=]]}}
 +!! html/parsoid
 +<p><span class="mw-default-size" typeof="mw:Transclusion mw:Image" about="#mwt1" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[File:Foobar.jpg|link=]]"}},"i":0}}]}'><span><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></span></span></p>
 +!! end
  
  !! test
  Image: from basic HTML (1)
@@@ -28040,9 -26895,9 +28040,9 @@@ Edited RFC links not serializable as RF
  !! options
  parsoid=html2wt
  !! html/parsoid
- <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
+ <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
  !! wikitext
- [//tools.ietf.org/html/rfc123 New RFC]
+ [https://tools.ietf.org/html/rfc123 New RFC]
  !! end
  
  !! test
@@@ -28186,7 -27041,7 +28186,7 @@@ Magic links inside image captions (auto
  <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"></a></div>
- <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a></div>
+ <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a></div>
  </div>
  </div>
  <div class="thumb tright">
  </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/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></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/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="//tools.ietf.org/html/rfc1234" rel="mw:ExtLink">RFC 1234</a></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/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink">RFC 1234</a></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/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a></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/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="./Special:BookSources/123456789X" rel="mw:WikiLink">ISBN 123456789x</a></figcaption></figure>
  !! end
@@@ -29461,197 -28316,19 +29461,197 @@@ unclosed internal link XSS (T137264
  <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
  !! end
  
 +# Use $wgRawHtml to inject a <style> tag, since you normally can't in wikitext
 +# (Parsoid doesn't support $wgRawHtml==true)
  !! test
  Validating that <style> isn't eaten by tidy (T167349)
  !! options
 -# Use $wgRawHtml to inject a <style> tag, since you normally can't in wikitext
  wgRawHtml=1
  !! wikitext
  <div class="foo">
  <html><style>.foo::before { content: "<foo>"; }</style></html>
  <html><style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style></html>
  </div>
 -!! html+tidy
 +!! html/php+tidy
  <div class="foo">
  <style>.foo::before { content: "<foo>"; }</style>
  <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
  </div>
  !! end
 +
 +!! test
 +Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
 +!! wikitext
 +== A&B&amp;C&amp;amp;D&amp;amp;amp;E ==
 +[[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
 +!! html/php
 +<h2><span class="mw-headline" id="A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
 +</p>
 +!! end
 +
 +!! test
 +Decoding of HTML entities in indicator names for IDs (T104196)
 +!! options
 +showindicators
 +!! wikitext
 +<indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
 +!! html/php
 +1&2&3&amp;4&amp;amp;5=Indicator
 +
 +!! end
 +
 +!! test
 +HTML5 ids: fallback to legacy
 +!! config
 +wgFragmentMode=[ 'html5', 'legacy' ]
 +!! wikitext
 +== Foo bar ==
 +
 +== foo Bar ==
 +
 +== Тест ==
 +
 +== Тест ==
 +
 +== тест ==
 +
 +== Hey < # " > % : ' ==
 +[[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
 +
 +{{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
 +
 +<!-- These two links should produce identical HTML -->
 +[[#啤酒]] [[#%E5%95%A4%E9%85%92]]
 +
 +!! html/php
 +<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 +<ul>
 +<li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
 +<li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
 +<li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
 +<li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
 +<li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
 +<li class="toclevel-1 tocsection-6"><a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
 +</ul>
 +</div>
 +
 +<h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span class="mw-headline" id="foo_Bar_2">foo Bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span id=".D0.A2.D0.B5.D1.81.D1.82"></span><span class="mw-headline" id="Тест">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span id=".D0.A2.D0.B5.D1.81.D1.82_2"></span><span class="mw-headline" id="Тест_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span id=".D1.82.D0.B5.D1.81.D1.82"></span><span class="mw-headline" id="тест">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span id="Hey_.3C_.23_.22_.3E_.25_:_.27"></span><span class="mw-headline" id="Hey_&lt;_#_&quot;_&gt;_%_:_'">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : &#039;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
 +</p><p>💩 <span id="💩"></span>
 +</p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
 +</p>
 +!! end
 +
 +!! test
 +HTML5 ids: legacy with a fallback to modern
 +!! config
 +wgFragmentMode=[ 'legacy', 'html5' ]
 +!! wikitext
 +== Foo bar ==
 +
 +== foo Bar ==
 +
 +== Тест ==
 +
 +== Тест ==
 +
 +== тест ==
 +
 +== Hey < # " > % : ' ==
 +[[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
 +
 +{{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
 +
 +<!-- These two links should produce identical HTML -->
 +[[#啤酒]] [[#%E5%95%A4%E9%85%92]]
 +
 +!! html/php
 +<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 +<ul>
 +<li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
 +<li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
 +<li class="toclevel-1 tocsection-3"><a href="#.D0.A2.D0.B5.D1.81.D1.82"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
 +<li class="toclevel-1 tocsection-4"><a href="#.D0.A2.D0.B5.D1.81.D1.82_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
 +<li class="toclevel-1 tocsection-5"><a href="#.D1.82.D0.B5.D1.81.D1.82"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
 +<li class="toclevel-1 tocsection-6"><a href="#Hey_.3C_.23_.22_.3E_.25_:_.27"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
 +</ul>
 +</div>
 +
 +<h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span class="mw-headline" id="foo_Bar_2">foo Bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span id="Тест"></span><span class="mw-headline" id=".D0.A2.D0.B5.D1.81.D1.82">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span id="Тест_2"></span><span class="mw-headline" id=".D0.A2.D0.B5.D1.81.D1.82_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span id="тест"></span><span class="mw-headline" id=".D1.82.D0.B5.D1.81.D1.82">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span id="Hey_&lt;_#_&quot;_&gt;_%_:_'"></span><span class="mw-headline" id="Hey_.3C_.23_.22_.3E_.25_:_.27">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : &#039;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#.D0.A2.D0.B5.D1.81.D1.82">#Тест</a> <a href="#.D1.82.D0.B5.D1.81.D1.82">#тест</a> <a href="#Hey_.3C_.23_.22_.3E_.25_:_.27">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
 +</p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
 +</p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
 +</p>
 +!! end
 +
 +!! test
 +HTML5 ids: no legacy
 +!! config
 +wgFragmentMode=[ 'html5' ]
 +!! wikitext
 +== Foo bar ==
 +
 +== foo Bar ==
 +
 +== Тест ==
 +
 +== Тест ==
 +
 +== тест ==
 +
 +== Hey < # " > % : ' ==
 +[[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
 +
 +{{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
 +
 +<!-- These two links should produce identical HTML -->
 +[[#啤酒]] [[#%E5%95%A4%E9%85%92]]
 +
 +!! html/php
 +<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
 +<ul>
 +<li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
 +<li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
 +<li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
 +<li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
 +<li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
 +<li class="toclevel-1 tocsection-6"><a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
 +</ul>
 +</div>
 +
 +<h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span class="mw-headline" id="foo_Bar_2">foo Bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span class="mw-headline" id="Тест">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span class="mw-headline" id="Тест_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span class="mw-headline" id="тест">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<h2><span class="mw-headline" id="Hey_&lt;_#_&quot;_&gt;_%_:_'">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : &#039;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
 +</p><p>💩 <span id="💩"></span>
 +</p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
 +</p>
 +!! end
 +
 +!! test
 +T90902: Normalize weird characters in section IDs
 +!! config
 +wgFragmentMode=[ 'html5', 'legacy' ]
 +!! wikitext
 +== Foo&nbsp;bar ==
 +[[#Foo&nbsp;bar]]
 +
 +!! html/php
 +<h2><span class="mw-headline" id="Foo_bar">Foo&#160;bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 +<p><a href="#Foo_bar">#Foo&#160;bar</a>
 +</p>
 +!! end