summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-04-01 06:11:44 +0200
committerPierre Schmitz <pierre@archlinux.de>2015-04-01 06:11:44 +0200
commit14f74d141ab5580688bfd46d2f74c026e43ed967 (patch)
tree081b7cbfc4d246ecc42831978d080331267cf57c /tests
parent4a953b6bfda28604979feb9cfbb58974d13b84bb (diff)
Update to MediaWiki 1.24.2
Diffstat (limited to 'tests')
-rw-r--r--tests/.htaccess1
-rw-r--r--tests/TestsAutoLoader.php115
-rw-r--r--tests/browser/Gemfile.lock82
-rw-r--r--tests/browser/README.mediawiki64
-rw-r--r--tests/browser/environment_variables5
-rw-r--r--tests/browser/features/create_account.feature12
-rw-r--r--tests/browser/features/create_and_follow_wiki_link.feature9
-rw-r--r--tests/browser/features/edit_page.feature11
-rw-r--r--tests/browser/features/file.feature23
-rw-r--r--tests/browser/features/login.feature42
-rw-r--r--tests/browser/features/main_page_links.feature19
-rw-r--r--tests/browser/features/preferences.feature60
-rw-r--r--tests/browser/features/step_definitions/create_account_steps.rb18
-rw-r--r--tests/browser/features/step_definitions/create_and_follow_wiki_link_steps.rb28
-rw-r--r--tests/browser/features/step_definitions/edit_page_steps.rb24
-rw-r--r--tests/browser/features/step_definitions/file_steps.rb18
-rw-r--r--tests/browser/features/step_definitions/login_steps.rb65
-rw-r--r--tests/browser/features/step_definitions/main_page_links_steps.rb47
-rw-r--r--tests/browser/features/step_definitions/preferences_appearance_steps.rb85
-rw-r--r--tests/browser/features/step_definitions/preferences_editing_steps.rb54
-rw-r--r--tests/browser/features/step_definitions/preferences_user_profile_steps.rb43
-rw-r--r--tests/browser/features/step_definitions/view_history_steps.rb8
-rw-r--r--tests/browser/features/support/env.rb2
-rw-r--r--tests/browser/features/support/hooks.rb2
-rw-r--r--tests/browser/features/support/modules/url_module.rb10
-rw-r--r--tests/browser/features/support/pages/create_account_page.rb19
-rw-r--r--tests/browser/features/support/pages/edit_page.rb8
-rw-r--r--tests/browser/features/support/pages/file_does_not_exist_page.rb19
-rw-r--r--tests/browser/features/support/pages/login_error_page.rb5
-rw-r--r--tests/browser/features/support/pages/main_page.rb19
-rw-r--r--tests/browser/features/support/pages/preferences_appearance_page.rb41
-rw-r--r--tests/browser/features/support/pages/preferences_editing_page.rb28
-rw-r--r--tests/browser/features/support/pages/preferences_page.rb22
-rw-r--r--tests/browser/features/support/pages/preferences_user_profile_page.rb28
-rw-r--r--tests/browser/features/support/pages/view_history_page.rb7
-rw-r--r--tests/browser/features/support/pages/ztargetpage.rb7
-rw-r--r--tests/browser/features/view_history.feature11
-rw-r--r--tests/parser/ParserTestResult.php45
-rw-r--r--tests/parser/README8
-rw-r--r--tests/parser/extraParserTests.txtbin0 -> 1261 bytes
-rw-r--r--tests/parser/parserTest.inc1655
-rw-r--r--tests/parser/parserTests.txt21904
-rw-r--r--tests/parser/parserTestsParserHook.php66
-rw-r--r--tests/parser/preprocess/All_system_messages.expected5625
-rw-r--r--tests/parser/preprocess/All_system_messages.txt5624
-rw-r--r--tests/parser/preprocess/Factorial.expected17
-rw-r--r--tests/parser/preprocess/Factorial.txt16
-rw-r--r--tests/parser/preprocess/Fundraising.expected18
-rw-r--r--tests/parser/preprocess/Fundraising.txt17
-rw-r--r--tests/parser/preprocess/NestedTemplates.expected90
-rw-r--r--tests/parser/preprocess/NestedTemplates.txt89
-rw-r--r--tests/parser/preprocess/QuoteQuran.expected140
-rw-r--r--tests/parser/preprocess/QuoteQuran.txt139
-rw-r--r--tests/parserTests.php95
-rw-r--r--tests/phpunit/LessFileCompilationTest.php60
-rw-r--r--tests/phpunit/Makefile91
-rw-r--r--tests/phpunit/MediaWikiLangTestCase.php32
-rw-r--r--tests/phpunit/MediaWikiPHPUnitTestListener.php129
-rw-r--r--tests/phpunit/MediaWikiTestCase.php1141
-rw-r--r--tests/phpunit/README53
-rw-r--r--tests/phpunit/ResourceLoaderTestCase.php95
-rw-r--r--tests/phpunit/TODO20
-rw-r--r--tests/phpunit/bootstrap.php36
-rw-r--r--tests/phpunit/data/autoloader/TestAutoloadedCamlClass.php4
-rw-r--r--tests/phpunit/data/autoloader/TestAutoloadedClass.php4
-rw-r--r--tests/phpunit/data/autoloader/TestAutoloadedLocalClass.php4
-rw-r--r--tests/phpunit/data/autoloader/TestAutoloadedSerializedClass.php4
-rw-r--r--tests/phpunit/data/css/expected.css11
-rw-r--r--tests/phpunit/data/css/simple-ltr.gifbin0 -> 35 bytes
-rw-r--r--tests/phpunit/data/css/simple-rtl.gifbin0 -> 35 bytes
-rw-r--r--tests/phpunit/data/css/test.css11
-rw-r--r--tests/phpunit/data/cssmin/green.gifbin0 -> 35 bytes
-rw-r--r--tests/phpunit/data/cssmin/large.pngbin0 -> 36462 bytes
-rw-r--r--tests/phpunit/data/cssmin/red.gifbin0 -> 35 bytes
-rw-r--r--tests/phpunit/data/db/mysql/functions.sql12
-rw-r--r--tests/phpunit/data/db/postgres/functions.sql12
-rw-r--r--tests/phpunit/data/db/sqlite/tables-1.13.sql342
-rw-r--r--tests/phpunit/data/db/sqlite/tables-1.15.sql454
-rw-r--r--tests/phpunit/data/db/sqlite/tables-1.16.sql478
-rw-r--r--tests/phpunit/data/db/sqlite/tables-1.17.sql511
-rw-r--r--tests/phpunit/data/db/sqlite/tables-1.18.sql530
-rw-r--r--tests/phpunit/data/filerepo/video.pngbin0 -> 116 bytes
-rw-r--r--tests/phpunit/data/filerepo/wiki.pngbin0 -> 22589 bytes
-rw-r--r--tests/phpunit/data/gitinfo/info-testValidJsonData.json1
-rw-r--r--tests/phpunit/data/less/common/test.common.mixins.less5
-rw-r--r--tests/phpunit/data/less/module/dependency.less3
-rw-r--r--tests/phpunit/data/less/module/styles.css6
-rw-r--r--tests/phpunit/data/less/module/styles.less6
-rw-r--r--tests/phpunit/data/localisationcache/en.json5
-rw-r--r--tests/phpunit/data/localisationcache/ru.json4
-rw-r--r--tests/phpunit/data/localisationcache/uk.json3
-rw-r--r--tests/phpunit/data/media/1bit-png.pngbin0 -> 167 bytes
-rw-r--r--tests/phpunit/data/media/Animated_PNG_example_bouncing_beach_ball.pngbin0 -> 72209 bytes
-rw-r--r--tests/phpunit/data/media/Bishzilla_blink.gifbin0 -> 39057 bytes
-rw-r--r--tests/phpunit/data/media/Gtk-media-play-ltr.svg35
-rw-r--r--tests/phpunit/data/media/LoremIpsum.djvubin0 -> 3249 bytes
-rw-r--r--tests/phpunit/data/media/Png-native-test.pngbin0 -> 4665 bytes
-rw-r--r--tests/phpunit/data/media/QA_icon.svg77
-rw-r--r--tests/phpunit/data/media/README61
-rw-r--r--tests/phpunit/data/media/Soccer_ball_animated.svg55
-rw-r--r--tests/phpunit/data/media/Speech_bubbles.svg14
-rw-r--r--tests/phpunit/data/media/Toll_Texas_1.svg150
-rw-r--r--tests/phpunit/data/media/Tux.svg902
-rw-r--r--tests/phpunit/data/media/US_states_by_total_state_tax_revenue.svg248
-rw-r--r--tests/phpunit/data/media/Wikimedia-logo.svg14
-rw-r--r--tests/phpunit/data/media/Xmp-exif-multilingual_test.jpgbin0 -> 12544 bytes
-rw-r--r--tests/phpunit/data/media/animated-xmp.gifbin0 -> 3864 bytes
-rw-r--r--tests/phpunit/data/media/animated.gifbin0 -> 497 bytes
-rw-r--r--tests/phpunit/data/media/broken_exif_date.jpgbin0 -> 3233 bytes
-rw-r--r--tests/phpunit/data/media/exif-gps.jpgbin0 -> 665 bytes
-rw-r--r--tests/phpunit/data/media/exif-user-comment.jpgbin0 -> 484 bytes
-rw-r--r--tests/phpunit/data/media/greyscale-na-png.pngbin0 -> 365 bytes
-rw-r--r--tests/phpunit/data/media/greyscale-png.pngbin0 -> 415 bytes
-rw-r--r--tests/phpunit/data/media/iptc-invalid-psir.jpgbin0 -> 9574 bytes
-rw-r--r--tests/phpunit/data/media/iptc-timetest-invalid.jpgbin0 -> 9573 bytes
-rw-r--r--tests/phpunit/data/media/iptc-timetest.jpgbin0 -> 9573 bytes
-rw-r--r--tests/phpunit/data/media/jpeg-comment-binary.jpgbin0 -> 448 bytes
-rw-r--r--tests/phpunit/data/media/jpeg-comment-iso8859-1.jpgbin0 -> 447 bytes
-rw-r--r--tests/phpunit/data/media/jpeg-comment-multiple.jpgbin0 -> 431 bytes
-rw-r--r--tests/phpunit/data/media/jpeg-comment-utf.jpgbin0 -> 445 bytes
-rw-r--r--tests/phpunit/data/media/jpeg-iptc-bad-hash.jpgbin0 -> 499 bytes
-rw-r--r--tests/phpunit/data/media/jpeg-iptc-good-hash.jpgbin0 -> 499 bytes
-rw-r--r--tests/phpunit/data/media/jpeg-padding-even.jpgbin0 -> 450 bytes
-rw-r--r--tests/phpunit/data/media/jpeg-padding-odd.jpgbin0 -> 451 bytes
-rw-r--r--tests/phpunit/data/media/jpeg-xmp-alt.jpgbin0 -> 3255 bytes
-rw-r--r--tests/phpunit/data/media/jpeg-xmp-psir.jpgbin0 -> 3308 bytes
-rw-r--r--tests/phpunit/data/media/jpeg-xmp-psir.xmp35
-rw-r--r--tests/phpunit/data/media/landscape-plain.jpgbin0 -> 38771 bytes
-rw-r--r--tests/phpunit/data/media/nonanimated.gifbin0 -> 200 bytes
-rw-r--r--tests/phpunit/data/media/portrait-rotated.jpgbin0 -> 38577 bytes
-rw-r--r--tests/phpunit/data/media/rgb-na-png.pngbin0 -> 593 bytes
-rw-r--r--tests/phpunit/data/media/rgb-png.pngbin0 -> 663 bytes
-rw-r--r--tests/phpunit/data/media/say-test.oggbin0 -> 5132 bytes
-rw-r--r--tests/phpunit/data/media/test.jpgbin0 -> 437 bytes
-rw-r--r--tests/phpunit/data/media/test.tiffbin0 -> 566 bytes
-rw-r--r--tests/phpunit/data/media/xmp.pngbin0 -> 582 bytes
-rw-r--r--tests/phpunit/data/parser/LoremIpsum.djvubin0 -> 3249 bytes
-rw-r--r--tests/phpunit/data/parser/headbg.jpgbin0 -> 7881 bytes
-rw-r--r--tests/phpunit/data/parser/wiki.pngbin0 -> 22589 bytes
-rw-r--r--tests/phpunit/data/upload/headbg.jpgbin0 -> 7881 bytes
-rw-r--r--tests/phpunit/data/xmp/1.result.php8
-rw-r--r--tests/phpunit/data/xmp/1.xmp11
-rw-r--r--tests/phpunit/data/xmp/2.result.php8
-rw-r--r--tests/phpunit/data/xmp/2.xmp12
-rw-r--r--tests/phpunit/data/xmp/3-invalid.result.php7
-rw-r--r--tests/phpunit/data/xmp/3-invalid.xmp31
-rw-r--r--tests/phpunit/data/xmp/3.result.php8
-rw-r--r--tests/phpunit/data/xmp/3.xmp29
-rw-r--r--tests/phpunit/data/xmp/4.result.php7
-rw-r--r--tests/phpunit/data/xmp/4.xmp22
-rw-r--r--tests/phpunit/data/xmp/5.result.php7
-rw-r--r--tests/phpunit/data/xmp/5.xmp16
-rw-r--r--tests/phpunit/data/xmp/6.result.php8
-rw-r--r--tests/phpunit/data/xmp/6.xmp18
-rw-r--r--tests/phpunit/data/xmp/7.result.php52
-rw-r--r--tests/phpunit/data/xmp/7.xmp67
-rw-r--r--tests/phpunit/data/xmp/README3
-rw-r--r--tests/phpunit/data/xmp/bag-for-seq.result.php10
-rw-r--r--tests/phpunit/data/xmp/bag-for-seq.xmp1
-rw-r--r--tests/phpunit/data/xmp/doctype-included.result.php3
-rw-r--r--tests/phpunit/data/xmp/doctype-included.xmp12
-rw-r--r--tests/phpunit/data/xmp/doctype-not-included.xmp11
-rw-r--r--tests/phpunit/data/xmp/flash.result.php8
-rw-r--r--tests/phpunit/data/xmp/flash.xmp11
-rw-r--r--tests/phpunit/data/xmp/gps.result.php11
-rw-r--r--tests/phpunit/data/xmp/gps.xmp17
-rw-r--r--tests/phpunit/data/xmp/invalid-child-not-struct.result.php7
-rw-r--r--tests/phpunit/data/xmp/invalid-child-not-struct.xmp12
-rw-r--r--tests/phpunit/data/xmp/no-namespace.result.php7
-rw-r--r--tests/phpunit/data/xmp/no-namespace.xmp11
-rw-r--r--tests/phpunit/data/xmp/no-recognized-props.result.php2
-rw-r--r--tests/phpunit/data/xmp/no-recognized-props.xmp8
-rw-r--r--tests/phpunit/data/xmp/utf16BE.result.php12
-rw-r--r--tests/phpunit/data/xmp/utf16BE.xmpbin0 -> 930 bytes
-rw-r--r--tests/phpunit/data/xmp/utf16LE.result.php12
-rw-r--r--tests/phpunit/data/xmp/utf16LE.xmpbin0 -> 930 bytes
-rw-r--r--tests/phpunit/data/xmp/utf32BE.result.php12
-rw-r--r--tests/phpunit/data/xmp/utf32BE.xmpbin0 -> 1856 bytes
-rw-r--r--tests/phpunit/data/xmp/utf32LE.result.php12
-rw-r--r--tests/phpunit/data/xmp/utf32LE.xmpbin0 -> 1856 bytes
-rw-r--r--tests/phpunit/data/xmp/xmpExt.result.php8
-rw-r--r--tests/phpunit/data/xmp/xmpExt.xmp13
-rw-r--r--tests/phpunit/data/xmp/xmpExt2.xmp8
-rw-r--r--tests/phpunit/data/zip/cd-gap.zipbin0 -> 182 bytes
-rw-r--r--tests/phpunit/data/zip/cd-truncated.zipbin0 -> 171 bytes
-rw-r--r--tests/phpunit/data/zip/class-trailing-null.zipbin0 -> 173 bytes
-rw-r--r--tests/phpunit/data/zip/class-trailing-slash.zipbin0 -> 173 bytes
-rw-r--r--tests/phpunit/data/zip/class.zipbin0 -> 173 bytes
-rw-r--r--tests/phpunit/data/zip/empty.zipbin0 -> 22 bytes
-rw-r--r--tests/phpunit/data/zip/looks-like-zip64.zipbin0 -> 173 bytes
-rw-r--r--tests/phpunit/data/zip/nosig.zipbin0 -> 173 bytes
-rw-r--r--tests/phpunit/data/zip/split.zipbin0 -> 196 bytes
-rw-r--r--tests/phpunit/data/zip/trail.zipbin0 -> 181 bytes
-rw-r--r--tests/phpunit/data/zip/wrong-cd-start-disk.zipbin0 -> 173 bytes
-rw-r--r--tests/phpunit/data/zip/wrong-central-entry-sig.zipbin0 -> 173 bytes
-rw-r--r--tests/phpunit/docs/ExportDemoTest.php31
-rw-r--r--tests/phpunit/includes/ArrayUtilsTest.php311
-rw-r--r--tests/phpunit/includes/ArticleTablesTest.php53
-rw-r--r--tests/phpunit/includes/ArticleTest.php95
-rw-r--r--tests/phpunit/includes/BlockTest.php368
-rw-r--r--tests/phpunit/includes/CollationTest.php117
-rw-r--r--tests/phpunit/includes/DiffHistoryBlobTest.php40
-rw-r--r--tests/phpunit/includes/EditPageTest.php499
-rw-r--r--tests/phpunit/includes/ExternalStoreTest.php87
-rw-r--r--tests/phpunit/includes/ExtraParserTest.php218
-rw-r--r--tests/phpunit/includes/FallbackTest.php72
-rw-r--r--tests/phpunit/includes/FauxRequestTest.php18
-rw-r--r--tests/phpunit/includes/FauxResponseTest.php118
-rw-r--r--tests/phpunit/includes/FormOptionsInitializationTest.php89
-rw-r--r--tests/phpunit/includes/FormOptionsTest.php103
-rw-r--r--tests/phpunit/includes/GitInfoTest.php42
-rw-r--r--tests/phpunit/includes/GlobalFunctions/GlobalTest.php745
-rw-r--r--tests/phpunit/includes/GlobalFunctions/GlobalWithDBTest.php32
-rw-r--r--tests/phpunit/includes/GlobalFunctions/README2
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfAssembleUrlTest.php112
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfBCP47Test.php121
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfBaseConvertTest.php195
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfBaseNameTest.php40
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php117
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfGetCallerTest.php46
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfParseUrlTest.php157
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php93
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfShellExecTest.php20
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfShorthandToIntegerTest.php31
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfTimestampTest.php196
-rw-r--r--tests/phpunit/includes/GlobalFunctions/wfUrlencodeTest.php124
-rw-r--r--tests/phpunit/includes/HooksTest.php202
-rw-r--r--tests/phpunit/includes/HtmlFormatterTest.php127
-rw-r--r--tests/phpunit/includes/HtmlTest.php773
-rw-r--r--tests/phpunit/includes/HttpTest.php216
-rw-r--r--tests/phpunit/includes/ImagePage404Test.php53
-rw-r--r--tests/phpunit/includes/ImagePageTest.php90
-rw-r--r--tests/phpunit/includes/ImportTest.php101
-rw-r--r--tests/phpunit/includes/LanguageConverterTest.php187
-rw-r--r--tests/phpunit/includes/LicensesTest.php25
-rw-r--r--tests/phpunit/includes/LinkFilterTest.php274
-rw-r--r--tests/phpunit/includes/LinkerTest.php192
-rw-r--r--tests/phpunit/includes/LinksUpdateTest.php266
-rw-r--r--tests/phpunit/includes/LocalFileTest.php184
-rw-r--r--tests/phpunit/includes/MWFunctionTest.php33
-rw-r--r--tests/phpunit/includes/MWNamespaceTest.php612
-rw-r--r--tests/phpunit/includes/MWTimestampTest.php342
-rw-r--r--tests/phpunit/includes/MediaWikiVersionFetcherTest.php21
-rw-r--r--tests/phpunit/includes/MessageTest.php368
-rw-r--r--tests/phpunit/includes/MimeMagicTest.php49
-rw-r--r--tests/phpunit/includes/OutputPageTest.php273
-rw-r--r--tests/phpunit/includes/PasswordTest.php33
-rw-r--r--tests/phpunit/includes/PathRouterTest.php264
-rw-r--r--tests/phpunit/includes/PreferencesTest.php91
-rw-r--r--tests/phpunit/includes/RequestContextTest.php96
-rw-r--r--tests/phpunit/includes/RevisionStorageTest.php574
-rw-r--r--tests/phpunit/includes/RevisionStorageTestContentHandlerUseDB.php89
-rw-r--r--tests/phpunit/includes/RevisionTest.php506
-rw-r--r--tests/phpunit/includes/SampleTest.php108
-rw-r--r--tests/phpunit/includes/SanitizerTest.php349
-rw-r--r--tests/phpunit/includes/SanitizerValidateEmailTest.php103
-rw-r--r--tests/phpunit/includes/SiteConfigurationTest.php363
-rw-r--r--tests/phpunit/includes/SpecialPageTest.php105
-rw-r--r--tests/phpunit/includes/StatusTest.php573
-rw-r--r--tests/phpunit/includes/TemplateCategoriesTest.php96
-rw-r--r--tests/phpunit/includes/TestUser.php62
-rw-r--r--tests/phpunit/includes/TimeAdjustTest.php39
-rw-r--r--tests/phpunit/includes/TitleArrayFromResultTest.php119
-rw-r--r--tests/phpunit/includes/TitleMethodsTest.php300
-rw-r--r--tests/phpunit/includes/TitlePermissionTest.php770
-rw-r--r--tests/phpunit/includes/TitleTest.php650
-rw-r--r--tests/phpunit/includes/UserArrayFromResultTest.php114
-rw-r--r--tests/phpunit/includes/UserTest.php369
-rw-r--r--tests/phpunit/includes/WebRequestTest.php358
-rw-r--r--tests/phpunit/includes/WikiPageTest.php1301
-rw-r--r--tests/phpunit/includes/WikiPageTestContentHandlerUseDB.php61
-rw-r--r--tests/phpunit/includes/XmlJsTest.php24
-rw-r--r--tests/phpunit/includes/XmlSelectTest.php185
-rw-r--r--tests/phpunit/includes/XmlTest.php411
-rw-r--r--tests/phpunit/includes/XmlTypeCheckTest.php49
-rw-r--r--tests/phpunit/includes/actions/ActionTest.php199
-rw-r--r--tests/phpunit/includes/api/ApiBaseTest.php46
-rw-r--r--tests/phpunit/includes/api/ApiBlockTest.php83
-rw-r--r--tests/phpunit/includes/api/ApiCreateAccountTest.php161
-rw-r--r--tests/phpunit/includes/api/ApiEditPageTest.php496
-rw-r--r--tests/phpunit/includes/api/ApiLoginTest.php181
-rw-r--r--tests/phpunit/includes/api/ApiMainTest.php72
-rw-r--r--tests/phpunit/includes/api/ApiModuleManagerTest.php318
-rw-r--r--tests/phpunit/includes/api/ApiOptionsTest.php459
-rw-r--r--tests/phpunit/includes/api/ApiParseTest.php35
-rw-r--r--tests/phpunit/includes/api/ApiPurgeTest.php45
-rw-r--r--tests/phpunit/includes/api/ApiQueryAllPagesTest.php34
-rw-r--r--tests/phpunit/includes/api/ApiRevisionDeleteTest.php114
-rw-r--r--tests/phpunit/includes/api/ApiTestCase.php196
-rw-r--r--tests/phpunit/includes/api/ApiTestCaseUpload.php171
-rw-r--r--tests/phpunit/includes/api/ApiTestContext.php21
-rw-r--r--tests/phpunit/includes/api/ApiTokensTest.php40
-rw-r--r--tests/phpunit/includes/api/ApiUnblockTest.php31
-rw-r--r--tests/phpunit/includes/api/ApiUploadTest.php572
-rw-r--r--tests/phpunit/includes/api/ApiWatchTest.php157
-rw-r--r--tests/phpunit/includes/api/MockApi.php20
-rw-r--r--tests/phpunit/includes/api/MockApiQueryBase.php11
-rw-r--r--tests/phpunit/includes/api/PrefixUniquenessTest.php30
-rw-r--r--tests/phpunit/includes/api/RandomImageGenerator.php496
-rw-r--r--tests/phpunit/includes/api/UserWrapper.php25
-rw-r--r--tests/phpunit/includes/api/format/ApiFormatJsonTest.php22
-rw-r--r--tests/phpunit/includes/api/format/ApiFormatNoneTest.php16
-rw-r--r--tests/phpunit/includes/api/format/ApiFormatPhpTest.php17
-rw-r--r--tests/phpunit/includes/api/format/ApiFormatTestBase.php32
-rw-r--r--tests/phpunit/includes/api/format/ApiFormatWddxTest.php20
-rw-r--r--tests/phpunit/includes/api/generateRandomImages.php46
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryBasicTest.php353
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryContinue2Test.php71
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryContinueTest.php316
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryContinueTestBase.php218
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryRevisionsTest.php40
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryTest.php130
-rw-r--r--tests/phpunit/includes/api/query/ApiQueryTestBase.php148
-rw-r--r--tests/phpunit/includes/api/words.txt1000
-rw-r--r--tests/phpunit/includes/cache/GenderCacheTest.php104
-rw-r--r--tests/phpunit/includes/cache/LocalisationCacheTest.php91
-rw-r--r--tests/phpunit/includes/cache/MessageCacheTest.php128
-rw-r--r--tests/phpunit/includes/cache/RedisBloomCacheTest.php71
-rw-r--r--tests/phpunit/includes/changes/EnhancedChangesListTest.php132
-rw-r--r--tests/phpunit/includes/changes/OldChangesListTest.php187
-rw-r--r--tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php331
-rw-r--r--tests/phpunit/includes/changes/RecentChangeTest.php286
-rw-r--r--tests/phpunit/includes/changes/TestRecentChangesHelper.php137
-rw-r--r--tests/phpunit/includes/composer/ComposerVersionNormalizerTest.php161
-rw-r--r--tests/phpunit/includes/config/ConfigFactoryTest.php70
-rw-r--r--tests/phpunit/includes/config/GlobalVarConfigTest.php120
-rw-r--r--tests/phpunit/includes/config/HashConfigTest.php63
-rw-r--r--tests/phpunit/includes/config/MultiConfigTest.php38
-rw-r--r--tests/phpunit/includes/content/ContentHandlerTest.php525
-rw-r--r--tests/phpunit/includes/content/CssContentTest.php87
-rw-r--r--tests/phpunit/includes/content/JavaScriptContentTest.php293
-rw-r--r--tests/phpunit/includes/content/JsonContentTest.php114
-rw-r--r--tests/phpunit/includes/content/TextContentTest.php490
-rw-r--r--tests/phpunit/includes/content/WikitextContentHandlerTest.php241
-rw-r--r--tests/phpunit/includes/content/WikitextContentTest.php433
-rw-r--r--tests/phpunit/includes/db/DatabaseMysqlBaseTest.php247
-rw-r--r--tests/phpunit/includes/db/DatabaseSQLTest.php725
-rw-r--r--tests/phpunit/includes/db/DatabaseSqliteTest.php455
-rw-r--r--tests/phpunit/includes/db/DatabaseTest.php237
-rw-r--r--tests/phpunit/includes/db/DatabaseTestHelper.php170
-rw-r--r--tests/phpunit/includes/db/LBFactoryTest.php61
-rw-r--r--tests/phpunit/includes/db/ORMRowTest.php226
-rw-r--r--tests/phpunit/includes/db/ORMTableTest.php150
-rw-r--r--tests/phpunit/includes/db/TestORMRowTest.php218
-rw-r--r--tests/phpunit/includes/debug/MWDebugTest.php141
-rw-r--r--tests/phpunit/includes/deferred/DeferredUpdatesTest.php38
-rw-r--r--tests/phpunit/includes/diff/ArrayDiffFormatterTest.php135
-rw-r--r--tests/phpunit/includes/diff/DiffOpTest.php73
-rw-r--r--tests/phpunit/includes/diff/DiffTest.php20
-rw-r--r--tests/phpunit/includes/diff/DifferenceEngineTest.php121
-rw-r--r--tests/phpunit/includes/diff/FakeDiffOp.php11
-rw-r--r--tests/phpunit/includes/exception/BadTitleErrorTest.php43
-rw-r--r--tests/phpunit/includes/exception/ErrorPageErrorTest.php67
-rw-r--r--tests/phpunit/includes/exception/MWExceptionHandlerTest.php74
-rw-r--r--tests/phpunit/includes/exception/MWExceptionTest.php241
-rw-r--r--tests/phpunit/includes/exception/ReadOnlyErrorTest.php16
-rw-r--r--tests/phpunit/includes/exception/ThrottledErrorTest.php44
-rw-r--r--tests/phpunit/includes/exception/UserNotLoggedInTest.php16
-rw-r--r--tests/phpunit/includes/filebackend/FileBackendTest.php2472
-rw-r--r--tests/phpunit/includes/filerepo/FileRepoTest.php55
-rw-r--r--tests/phpunit/includes/filerepo/RepoGroupTest.php59
-rw-r--r--tests/phpunit/includes/filerepo/StoreBatchTest.php146
-rw-r--r--tests/phpunit/includes/filerepo/file/FileTest.php386
-rw-r--r--tests/phpunit/includes/htmlform/HTMLAutoCompleteSelectFieldTest.php68
-rw-r--r--tests/phpunit/includes/htmlform/HTMLCheckMatrixTest.php105
-rw-r--r--tests/phpunit/includes/installer/InstallDocFormatterTest.php72
-rw-r--r--tests/phpunit/includes/installer/OracleInstallerTest.php52
-rw-r--r--tests/phpunit/includes/jobqueue/JobQueueTest.php344
-rw-r--r--tests/phpunit/includes/jobqueue/RefreshLinksPartitionTest.php112
-rw-r--r--tests/phpunit/includes/json/FormatJsonTest.php279
-rw-r--r--tests/phpunit/includes/libs/CSSMinTest.php401
-rw-r--r--tests/phpunit/includes/libs/GenericArrayObjectTest.php280
-rw-r--r--tests/phpunit/includes/libs/HashRingTest.php56
-rw-r--r--tests/phpunit/includes/libs/IEUrlExtensionTest.php173
-rw-r--r--tests/phpunit/includes/libs/IPSetTest.php252
-rw-r--r--tests/phpunit/includes/libs/JavaScriptMinifierTest.php204
-rw-r--r--tests/phpunit/includes/libs/MWMessagePackTest.php75
-rw-r--r--tests/phpunit/includes/libs/ProcessCacheLRUTest.php237
-rw-r--r--tests/phpunit/includes/libs/RunningStatTest.php79
-rw-r--r--tests/phpunit/includes/logging/LogFormatterTest.php242
-rw-r--r--tests/phpunit/includes/logging/LogTests.i18n.php15
-rw-r--r--tests/phpunit/includes/mail/MailAddressTest.php63
-rw-r--r--tests/phpunit/includes/mail/UserMailerTest.php14
-rw-r--r--tests/phpunit/includes/media/BitmapMetadataHandlerTest.php167
-rw-r--r--tests/phpunit/includes/media/BitmapScalingTest.php140
-rw-r--r--tests/phpunit/includes/media/DjVuTest.php69
-rw-r--r--tests/phpunit/includes/media/ExifBitmapTest.php146
-rw-r--r--tests/phpunit/includes/media/ExifRotationTest.php280
-rw-r--r--tests/phpunit/includes/media/ExifTest.php47
-rw-r--r--tests/phpunit/includes/media/FakeDimensionFile.php31
-rw-r--r--tests/phpunit/includes/media/FormatMetadataTest.php71
-rw-r--r--tests/phpunit/includes/media/GIFMetadataExtractorTest.php111
-rw-r--r--tests/phpunit/includes/media/GIFTest.php142
-rw-r--r--tests/phpunit/includes/media/IPTCTest.php85
-rw-r--r--tests/phpunit/includes/media/JpegMetadataExtractorTest.php111
-rw-r--r--tests/phpunit/includes/media/JpegTest.php54
-rw-r--r--tests/phpunit/includes/media/MediaHandlerTest.php56
-rw-r--r--tests/phpunit/includes/media/MediaWikiMediaTestCase.php86
-rw-r--r--tests/phpunit/includes/media/PNGMetadataExtractorTest.php155
-rw-r--r--tests/phpunit/includes/media/PNGTest.php131
-rw-r--r--tests/phpunit/includes/media/SVGMetadataExtractorTest.php160
-rw-r--r--tests/phpunit/includes/media/SVGTest.php41
-rw-r--r--tests/phpunit/includes/media/TiffTest.php45
-rw-r--r--tests/phpunit/includes/media/XCFTest.php78
-rw-r--r--tests/phpunit/includes/media/XMPTest.php223
-rw-r--r--tests/phpunit/includes/media/XMPValidateTest.php50
-rw-r--r--tests/phpunit/includes/normal/CleanUpTest.php409
-rw-r--r--tests/phpunit/includes/objectcache/BagOStuffTest.php147
-rw-r--r--tests/phpunit/includes/parser/MagicVariableTest.php229
-rw-r--r--tests/phpunit/includes/parser/MediaWikiParserTest.php134
-rw-r--r--tests/phpunit/includes/parser/NewParserTest.php1091
-rw-r--r--tests/phpunit/includes/parser/ParserMethodsTest.php187
-rw-r--r--tests/phpunit/includes/parser/ParserOutputTest.php87
-rw-r--r--tests/phpunit/includes/parser/ParserPreloadTest.php80
-rw-r--r--tests/phpunit/includes/parser/PreprocessorTest.php247
-rw-r--r--tests/phpunit/includes/parser/TagHooksTest.php108
-rw-r--r--tests/phpunit/includes/parser/TidyTest.php64
-rw-r--r--tests/phpunit/includes/password/BcryptPasswordTest.php40
-rw-r--r--tests/phpunit/includes/password/LayeredParameterizedPasswordTest.php51
-rw-r--r--tests/phpunit/includes/password/PasswordTestCase.php88
-rw-r--r--tests/phpunit/includes/password/Pbkdf2PasswordTest.php24
-rw-r--r--tests/phpunit/includes/poolcounter/PoolCounterTest.php72
-rw-r--r--tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php132
-rw-r--r--tests/phpunit/includes/resourceloader/ResourceLoaderStartupModuleTest.php388
-rw-r--r--tests/phpunit/includes/resourceloader/ResourceLoaderTest.php249
-rw-r--r--tests/phpunit/includes/resourceloader/ResourceLoaderWikiModuleTest.php67
-rw-r--r--tests/phpunit/includes/search/SearchEngineTest.php187
-rw-r--r--tests/phpunit/includes/search/SearchUpdateTest.php81
-rw-r--r--tests/phpunit/includes/site/MediaWikiSiteTest.php109
-rw-r--r--tests/phpunit/includes/site/SiteListTest.php240
-rw-r--r--tests/phpunit/includes/site/SiteSQLStoreTest.php134
-rw-r--r--tests/phpunit/includes/site/SiteTest.php296
-rw-r--r--tests/phpunit/includes/site/TestSites.php115
-rw-r--r--tests/phpunit/includes/skins/SkinFactoryTest.php70
-rw-r--r--tests/phpunit/includes/skins/SkinTemplateTest.php43
-rw-r--r--tests/phpunit/includes/specialpage/SpecialPageFactoryTest.php225
-rw-r--r--tests/phpunit/includes/specials/ImageListPagerTest.php22
-rw-r--r--tests/phpunit/includes/specials/QueryAllSpecialPagesTest.php74
-rw-r--r--tests/phpunit/includes/specials/SpecialMIMESearchTest.php48
-rw-r--r--tests/phpunit/includes/specials/SpecialMyLanguageTest.php65
-rw-r--r--tests/phpunit/includes/specials/SpecialPreferencesTest.php57
-rw-r--r--tests/phpunit/includes/specials/SpecialRecentchangesTest.php123
-rw-r--r--tests/phpunit/includes/specials/SpecialSearchTest.php144
-rw-r--r--tests/phpunit/includes/title/MediaWikiPageLinkRendererTest.php169
-rw-r--r--tests/phpunit/includes/title/MediaWikiTitleCodecTest.php384
-rw-r--r--tests/phpunit/includes/title/TitleValueTest.php100
-rw-r--r--tests/phpunit/includes/upload/UploadBaseTest.php427
-rw-r--r--tests/phpunit/includes/upload/UploadFromUrlTest.php328
-rw-r--r--tests/phpunit/includes/upload/UploadStashTest.php107
-rw-r--r--tests/phpunit/includes/utils/CdbTest.php90
-rw-r--r--tests/phpunit/includes/utils/IPTest.php580
-rw-r--r--tests/phpunit/includes/utils/MWCryptHKDFTest.php89
-rw-r--r--tests/phpunit/includes/utils/StringUtilsTest.php149
-rw-r--r--tests/phpunit/includes/utils/UIDGeneratorTest.php129
-rw-r--r--tests/phpunit/includes/utils/ZipDirectoryReaderTest.php84
-rw-r--r--tests/phpunit/install-phpunit.sh38
-rw-r--r--tests/phpunit/languages/LanguageAmTest.php35
-rw-r--r--tests/phpunit/languages/LanguageArTest.php87
-rw-r--r--tests/phpunit/languages/LanguageArqTest.php26
-rw-r--r--tests/phpunit/languages/LanguageBeTest.php42
-rw-r--r--tests/phpunit/languages/LanguageBe_taraskTest.php97
-rw-r--r--tests/phpunit/languages/LanguageBhoTest.php35
-rw-r--r--tests/phpunit/languages/LanguageBsTest.php42
-rw-r--r--tests/phpunit/languages/LanguageClassesTestCase.php74
-rw-r--r--tests/phpunit/languages/LanguageCsTest.php41
-rw-r--r--tests/phpunit/languages/LanguageCuTest.php42
-rw-r--r--tests/phpunit/languages/LanguageCyTest.php43
-rw-r--r--tests/phpunit/languages/LanguageDsbTest.php41
-rw-r--r--tests/phpunit/languages/LanguageFrTest.php35
-rw-r--r--tests/phpunit/languages/LanguageGaTest.php35
-rw-r--r--tests/phpunit/languages/LanguageGdTest.php53
-rw-r--r--tests/phpunit/languages/LanguageGvTest.php44
-rw-r--r--tests/phpunit/languages/LanguageHeTest.php132
-rw-r--r--tests/phpunit/languages/LanguageHiTest.php35
-rw-r--r--tests/phpunit/languages/LanguageHrTest.php42
-rw-r--r--tests/phpunit/languages/LanguageHsbTest.php41
-rw-r--r--tests/phpunit/languages/LanguageHuTest.php35
-rw-r--r--tests/phpunit/languages/LanguageHyTest.php35
-rw-r--r--tests/phpunit/languages/LanguageKshTest.php35
-rw-r--r--tests/phpunit/languages/LanguageLnTest.php35
-rw-r--r--tests/phpunit/languages/LanguageLtTest.php63
-rw-r--r--tests/phpunit/languages/LanguageLvTest.php44
-rw-r--r--tests/phpunit/languages/LanguageMgTest.php36
-rw-r--r--tests/phpunit/languages/LanguageMkTest.php40
-rw-r--r--tests/phpunit/languages/LanguageMlTest.php38
-rw-r--r--tests/phpunit/languages/LanguageMoTest.php45
-rw-r--r--tests/phpunit/languages/LanguageMtTest.php77
-rw-r--r--tests/phpunit/languages/LanguageNlTest.php24
-rw-r--r--tests/phpunit/languages/LanguageNsoTest.php34
-rw-r--r--tests/phpunit/languages/LanguagePlTest.php77
-rw-r--r--tests/phpunit/languages/LanguageRoTest.php45
-rw-r--r--tests/phpunit/languages/LanguageRuTest.php115
-rw-r--r--tests/phpunit/languages/LanguageSeTest.php53
-rw-r--r--tests/phpunit/languages/LanguageSgsTest.php71
-rw-r--r--tests/phpunit/languages/LanguageShTest.php42
-rw-r--r--tests/phpunit/languages/LanguageSkTest.php42
-rw-r--r--tests/phpunit/languages/LanguageSlTest.php44
-rw-r--r--tests/phpunit/languages/LanguageSmaTest.php53
-rw-r--r--tests/phpunit/languages/LanguageSrTest.php249
-rw-r--r--tests/phpunit/languages/LanguageTest.php1635
-rw-r--r--tests/phpunit/languages/LanguageTiTest.php34
-rw-r--r--tests/phpunit/languages/LanguageTlTest.php34
-rw-r--r--tests/phpunit/languages/LanguageTrTest.php61
-rw-r--r--tests/phpunit/languages/LanguageUkTest.php72
-rw-r--r--tests/phpunit/languages/LanguageUzTest.php124
-rw-r--r--tests/phpunit/languages/LanguageWaTest.php34
-rw-r--r--tests/phpunit/languages/SpecialPageAliasTest.php63
-rw-r--r--tests/phpunit/languages/utils/CLDRPluralRuleEvaluatorTest.php151
-rw-r--r--tests/phpunit/maintenance/DumpTestCase.php386
-rw-r--r--tests/phpunit/maintenance/MaintenanceTest.php830
-rw-r--r--tests/phpunit/maintenance/backupPrefetchTest.php277
-rw-r--r--tests/phpunit/maintenance/backupTextPassTest.php584
-rw-r--r--tests/phpunit/maintenance/backup_LogTest.php225
-rw-r--r--tests/phpunit/maintenance/backup_PageTest.php428
-rw-r--r--tests/phpunit/maintenance/fetchTextTest.php261
-rw-r--r--tests/phpunit/mocks/filebackend/MockFSFile.php69
-rw-r--r--tests/phpunit/mocks/filebackend/MockFileBackend.php39
-rw-r--r--tests/phpunit/mocks/media/MockBitmapHandler.php32
-rw-r--r--tests/phpunit/mocks/media/MockDjVuHandler.php49
-rw-r--r--tests/phpunit/mocks/media/MockImageHandler.php86
-rw-r--r--tests/phpunit/mocks/media/MockSvgHandler.php28
-rw-r--r--tests/phpunit/phpunit.php233
-rw-r--r--tests/phpunit/run-tests.bat1
-rw-r--r--tests/phpunit/skins/SideBarTest.php219
-rw-r--r--tests/phpunit/structure/AutoLoaderTest.php135
-rw-r--r--tests/phpunit/structure/ResourcesTest.php269
-rw-r--r--tests/phpunit/structure/StructureTest.php67
-rw-r--r--tests/phpunit/suite.xml64
-rw-r--r--tests/phpunit/suites/ExtensionsParserTestSuite.php8
-rw-r--r--tests/phpunit/suites/ExtensionsTestSuite.php47
-rw-r--r--tests/phpunit/suites/LessTestSuite.php34
-rw-r--r--tests/phpunit/suites/UploadFromUrlTestSuite.php207
-rw-r--r--tests/phpunit/tests/MediaWikiTestCaseTest.php77
-rw-r--r--tests/qunit/.htaccess1
-rw-r--r--tests/qunit/QUnitTestResources.php117
-rw-r--r--tests/qunit/data/callMwLoaderTestCallback.js1
-rw-r--r--tests/qunit/data/generateJqueryMsgData.php149
-rw-r--r--tests/qunit/data/load.mock.php74
-rw-r--r--tests/qunit/data/mediawiki.jqueryMsg.data.js491
-rw-r--r--tests/qunit/data/qunitOkCall.js2
-rw-r--r--tests/qunit/data/styleTest.css.php61
-rw-r--r--tests/qunit/data/testrunner.js547
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js108
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.autoEllipsis.test.js53
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.byteLength.test.js37
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js252
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.client.test.js638
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.color.test.js18
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.colorUtil.test.js63
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.getAttrs.test.js13
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.hidpi.test.js22
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.highlightText.test.js235
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.localize.test.js135
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js339
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js55
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.placeholder.test.js145
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.tabIndex.test.js35
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js1327
-rw-r--r--tests/qunit/suites/resources/jquery/jquery.textSelection.test.js273
-rw-r--r--tests/qunit/suites/resources/mediawiki.api/mediawiki.api.category.test.js30
-rw-r--r--tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js25
-rw-r--r--tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js312
-rw-r--r--tests/qunit/suites/resources/mediawiki.api/mediawiki.api.watch.test.js46
-rw-r--r--tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.test.js63
-rw-r--r--tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js650
-rw-r--r--tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js434
-rw-r--r--tests/qunit/suites/resources/mediawiki/mediawiki.cldr.test.js81
-rw-r--r--tests/qunit/suites/resources/mediawiki/mediawiki.cookie.test.js172
-rw-r--r--tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js798
-rw-r--r--tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js70
-rw-r--r--tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js475
-rw-r--r--tests/qunit/suites/resources/mediawiki/mediawiki.test.js985
-rw-r--r--tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js40
-rw-r--r--tests/qunit/suites/resources/mediawiki/mediawiki.user.test.js54
-rw-r--r--tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js343
-rw-r--r--tests/qunit/suites/resources/startup.test.js143
-rw-r--r--tests/testHelpers.inc832
577 files changed, 110986 insertions, 0 deletions
diff --git a/tests/.htaccess b/tests/.htaccess
new file mode 100644
index 00000000..3a428827
--- /dev/null
+++ b/tests/.htaccess
@@ -0,0 +1 @@
+Deny from all
diff --git a/tests/TestsAutoLoader.php b/tests/TestsAutoLoader.php
new file mode 100644
index 00000000..2e8fed44
--- /dev/null
+++ b/tests/TestsAutoLoader.php
@@ -0,0 +1,115 @@
+<?php
+/**
+ * AutoLoader for the testing suite.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Testing
+ */
+
+global $wgAutoloadClasses;
+$testDir = __DIR__;
+
+$wgAutoloadClasses += array(
+
+ # tests
+ 'DbTestPreviewer' => "$testDir/testHelpers.inc",
+ 'DbTestRecorder' => "$testDir/testHelpers.inc",
+ 'DelayedParserTest' => "$testDir/testHelpers.inc",
+ 'ParserTestResult' => "$testDir/parser/ParserTestResult.php",
+ 'TestFileIterator' => "$testDir/testHelpers.inc",
+ 'TestRecorder' => "$testDir/testHelpers.inc",
+ 'ITestRecorder' => "$testDir/testHelpers.inc",
+ 'DjVuSupport' => "$testDir/testHelpers.inc",
+ 'TidySupport' => "$testDir/testHelpers.inc",
+
+ # tests/phpunit
+ 'MediaWikiTestCase' => "$testDir/phpunit/MediaWikiTestCase.php",
+ 'MediaWikiPHPUnitTestListener' => "$testDir/phpunit/MediaWikiPHPUnitTestListener.php",
+ 'MediaWikiLangTestCase' => "$testDir/phpunit/MediaWikiLangTestCase.php",
+ 'ResourceLoaderTestCase' => "$testDir/phpunit/ResourceLoaderTestCase.php",
+ 'ResourceLoaderTestModule' => "$testDir/phpunit/ResourceLoaderTestCase.php",
+ 'ResourceLoaderFileModuleTestModule' => "$testDir/phpunit/ResourceLoaderTestCase.php",
+ 'ResourceLoaderWikiModuleTestModule' => "$testDir/phpunit/ResourceLoaderTestCase.php",
+ 'TestUser' => "$testDir/phpunit/includes/TestUser.php",
+ 'LessFileCompilationTest' => "$testDir/phpunit/LessFileCompilationTest.php",
+
+ # tests/phpunit/includes
+ 'BlockTest' => "$testDir/phpunit/includes/BlockTest.php",
+ 'RevisionStorageTest' => "$testDir/phpunit/includes/RevisionStorageTest.php",
+ 'WikiPageTest' => "$testDir/phpunit/includes/WikiPageTest.php",
+
+ # tests/phpunit/includes/api
+ 'ApiFormatTestBase' => "$testDir/phpunit/includes/api/format/ApiFormatTestBase.php",
+ 'ApiTestCase' => "$testDir/phpunit/includes/api/ApiTestCase.php",
+ 'ApiTestContext' => "$testDir/phpunit/includes/api/ApiTestContext.php",
+ 'MockApi' => "$testDir/phpunit/includes/api/MockApi.php",
+ 'MockApiQueryBase' => "$testDir/phpunit/includes/api/MockApiQueryBase.php",
+ 'UserWrapper' => "$testDir/phpunit/includes/api/UserWrapper.php",
+ 'RandomImageGenerator' => "$testDir/phpunit/includes/api/RandomImageGenerator.php",
+
+ # tests/phpunit/includes/changes
+ 'TestRecentChangesHelper' => "$testDir/phpunit/includes/changes/TestRecentChangesHelper.php",
+
+ # tests/phpunit/includes/content
+ 'DummyContentHandlerForTesting' => "$testDir/phpunit/includes/content/ContentHandlerTest.php",
+ 'DummyContentForTesting' => "$testDir/phpunit/includes/content/ContentHandlerTest.php",
+ 'ContentHandlerTest' => "$testDir/phpunit/includes/content/ContentHandlerTest.php",
+ 'JavaScriptContentTest' => "$testDir/phpunit/includes/content/JavaScriptContentTest.php",
+ 'TextContentTest' => "$testDir/phpunit/includes/content/TextContentTest.php",
+ 'WikitextContentTest' => "$testDir/phpunit/includes/content/WikitextContentTest.php",
+
+ # tests/phpunit/includes/db
+ 'ORMRowTest' => "$testDir/phpunit/includes/db/ORMRowTest.php",
+ 'ORMTableTest' => "$testDir/phpunit/includes/db/ORMTableTest.php",
+ 'PageORMTableForTesting' => "$testDir/phpunit/includes/db/ORMTableTest.php",
+ 'DatabaseTestHelper' => "$testDir/phpunit/includes/db/DatabaseTestHelper.php",
+
+ # tests/phpunit/includes/passwords
+ 'PasswordTestCase' => "$testDir/phpunit/includes/password/PasswordTestCase.php",
+
+ # tests/phpunit/languages
+ 'LanguageClassesTestCase' => "$testDir/phpunit/languages/LanguageClassesTestCase.php",
+
+ # tests/phpunit/includes/libs
+ 'GenericArrayObjectTest' => "$testDir/phpunit/includes/libs/GenericArrayObjectTest.php",
+
+ # tests/phpunit/maintenance
+ 'DumpTestCase' => "$testDir/phpunit/maintenance/DumpTestCase.php",
+
+ # tests/phpunit/media
+ 'FakeDimensionFile' => "$testDir/phpunit/includes/media/FakeDimensionFile.php",
+ 'MediaWikiMediaTestCase' => "$testDir/phpunit/includes/media/MediaWikiMediaTestCase.php",
+
+ # tests/phpunit/mocks
+ 'MockFSFile' => "$testDir/phpunit/mocks/filebackend/MockFSFile.php",
+ 'MockFileBackend' => "$testDir/phpunit/mocks/filebackend/MockFileBackend.php",
+ 'MockBitmapHandler' => "$testDir/phpunit/mocks/media/MockBitmapHandler.php",
+ 'MockImageHandler' => "$testDir/phpunit/mocks/media/MockImageHandler.php",
+ 'MockSvgHandler' => "$testDir/phpunit/mocks/media/MockSvgHandler.php",
+ 'MockDjVuHandler' => "$testDir/phpunit/mocks/media/MockDjVuHandler.php",
+
+ # tests/parser
+ 'NewParserTest' => "$testDir/phpunit/includes/parser/NewParserTest.php",
+ 'MediaWikiParserTest' => "$testDir/phpunit/includes/parser/MediaWikiParserTest.php",
+ 'ParserTest' => "$testDir/parser/parserTest.inc",
+ 'ParserTestParserHook' => "$testDir/parser/parserTestsParserHook.php",
+
+ # tests/phpunit/includes/site
+ 'SiteTest' => "$testDir/phpunit/includes/site/SiteTest.php",
+ 'TestSites' => "$testDir/phpunit/includes/site/TestSites.php",
+);
diff --git a/tests/browser/Gemfile.lock b/tests/browser/Gemfile.lock
new file mode 100644
index 00000000..1ea4eb55
--- /dev/null
+++ b/tests/browser/Gemfile.lock
@@ -0,0 +1,82 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ builder (3.2.2)
+ childprocess (0.5.3)
+ ffi (~> 1.0, >= 1.0.11)
+ cucumber (1.3.16)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.3)
+ gherkin (~> 2.12)
+ multi_json (>= 1.7.5, < 2.0)
+ multi_test (>= 0.1.1)
+ data_magic (0.19)
+ faker (>= 1.1.2)
+ yml_reader (>= 0.3)
+ diff-lcs (1.2.5)
+ domain_name (0.5.20)
+ unf (>= 0.0.5, < 1.0.0)
+ faker (1.4.3)
+ i18n (~> 0.5)
+ faraday (0.9.0)
+ multipart-post (>= 1.2, < 3)
+ faraday-cookie_jar (0.0.6)
+ faraday (>= 0.7.4)
+ http-cookie (~> 1.0.0)
+ ffi (1.9.3)
+ gherkin (2.12.2)
+ multi_json (~> 1.3)
+ headless (1.0.2)
+ http-cookie (1.0.2)
+ domain_name (~> 0.5)
+ i18n (0.6.11)
+ json (1.8.1)
+ mediawiki_api (0.2.1)
+ faraday (~> 0.9, >= 0.9.0)
+ faraday-cookie_jar (~> 0.0, >= 0.0.6)
+ mediawiki_selenium (0.3.2)
+ cucumber (~> 1.3, >= 1.3.10)
+ headless (~> 1.0, >= 1.0.1)
+ json (~> 1.8, >= 1.8.1)
+ mediawiki_api (~> 0.2, >= 0.2.1)
+ page-object (~> 1.0)
+ rest-client (~> 1.6, >= 1.6.7)
+ rspec-expectations (~> 2.14, >= 2.14.4)
+ syntax (~> 1.2, >= 1.2.0)
+ mime-types (2.3)
+ multi_json (1.10.1)
+ multi_test (0.1.1)
+ multipart-post (2.0.0)
+ netrc (0.7.7)
+ page-object (1.0.2)
+ page_navigation (>= 0.9)
+ selenium-webdriver (>= 2.42.0)
+ watir-webdriver (>= 0.6.9)
+ page_navigation (0.9)
+ data_magic (>= 0.14)
+ rest-client (1.7.2)
+ mime-types (>= 1.16, < 3.0)
+ netrc (~> 0.7)
+ rspec-expectations (2.99.2)
+ diff-lcs (>= 1.1.3, < 2.0)
+ rubyzip (1.1.6)
+ selenium-webdriver (2.42.0)
+ childprocess (>= 0.5.0)
+ multi_json (~> 1.0)
+ rubyzip (~> 1.0)
+ websocket (~> 1.0.4)
+ syntax (1.2.0)
+ unf (0.1.4)
+ unf_ext
+ unf_ext (0.0.6)
+ watir-webdriver (0.6.10)
+ selenium-webdriver (>= 2.18.0)
+ websocket (1.0.7)
+ yml_reader (0.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ mediawiki_api
+ mediawiki_selenium
diff --git a/tests/browser/README.mediawiki b/tests/browser/README.mediawiki
new file mode 100644
index 00000000..22657627
--- /dev/null
+++ b/tests/browser/README.mediawiki
@@ -0,0 +1,64 @@
+Purpose:
+
+The purpose of these tests is to validate that a newly installed (or updated, or hacked, or whatever) mediawiki instance presents to the user a set of expected features, regardless of what language the wiki is in, or where it is installed, or what extensions it might have.
+
+The tests are based on the basic definition of a wiki, a website where anyone
+
+* can read a page
+* can create a page
+* can edit a page
+* can link one page to another page
+
+Install:
+
+Ruby 1.9.3 or higher is required
+Firefox browser is required
+::
+ cd /tests/browser
+ gem update --system
+ gem install bundler
+ bundle install
+
+Run the tests:
+
+Edit the environment_variables file with appropriate values for your wiki
+$source environment_variables (example shown in bash shell)
+
+bundle exec cucumber features/
+
+Note that the acceptance tests will create three pages in your wiki entitled "Editing Test Page", "Link Source Test Page", and "Link Target Test Page". These pages may be deleted at any time. If you wish to re-run the tests at any time, these test pages will be re-created or reset to their original contents at the time that the tests run.
+
+For more information about running Selenium tests please see
+https://github.com/wikimedia/mediawiki-selenium
+
+Details:
+
+create_account.feature
+* Checks three different ways to arrive on page allowing the user to create an account
+
+create_and_follow_wiki_link.feature:
+* uses the mediawiki API to create a link target page
+* uses the mediawiki API to create a link source page
+* navigates a browser to the link source page
+* clicks the link in that page to the link target page
+* validates that the browser has in fact followed the link to the target page correctly
+
+edit_page.feature:
+* uses the mediawiki API to create an editable page on the wiki
+* navigates a browser to the page
+* clicks the Edit button to invoke the basic editor
+* edits the page with a particular string containing a static part and also a quasi-unique random part
+* saves the edited page
+* checks that the saved page contains the particular string with which the page was edited
+
+main_page.feature:
+* navigates a browser to the default landing page of the wiki
+* checks for the View History link on the landing page
+* checks for the full set of of sidebar links that should exist on every mediawiki wiki
+
+view_history.feature
+* similar to edit_page.feature but checks for an older version of the edited page
+
+Notes:
+
+Tested on beta labs hewiki, dewiki, enwiki, and on a local installation of mediawiki \ No newline at end of file
diff --git a/tests/browser/environment_variables b/tests/browser/environment_variables
new file mode 100644
index 00000000..25c45775
--- /dev/null
+++ b/tests/browser/environment_variables
@@ -0,0 +1,5 @@
+export MEDIAWIKI_URL=http://localhost/wiki/
+export MEDIAWIKI_API_URL=http://localhost/w/api.php
+export MEDIAWIKI_USER=Selenium_user
+export MEDIAWIKI_PASSWORD=Selenium_password
+export BROWSER=firefox
diff --git a/tests/browser/features/create_account.feature b/tests/browser/features/create_account.feature
new file mode 100644
index 00000000..0b4e83a5
--- /dev/null
+++ b/tests/browser/features/create_account.feature
@@ -0,0 +1,12 @@
+@chrome @clean @firefox @phantomjs
+Feature: Create account
+
+ Scenario Outline: Go to Create account page
+ Given I go to Create account page at <path>
+ Then form has Create account button
+
+ Examples:
+ | path |
+ | Special:CreateAccount |
+ | Special:UserLogin/signup |
+ | Special:UserLogin?type=signup |
diff --git a/tests/browser/features/create_and_follow_wiki_link.feature b/tests/browser/features/create_and_follow_wiki_link.feature
new file mode 100644
index 00000000..a0aa624e
--- /dev/null
+++ b/tests/browser/features/create_and_follow_wiki_link.feature
@@ -0,0 +1,9 @@
+@chrome @clean @firefox @login @phantomjs
+Feature: Create Page With Wiki Link
+
+ Scenario: Create Page With Wiki Link
+ Given I create page "Link Target Test Page" with content "Link Target Test Page"
+ And I go to the "Link Source Test Page" page with content "This is a [[Link Target Test Page|link to the test target page]] right here."
+ When I click the Link Target link
+ Then I should be on the Link Target Test Page
+ And the page content should contain "Link Target Test Page"
diff --git a/tests/browser/features/edit_page.feature b/tests/browser/features/edit_page.feature
new file mode 100644
index 00000000..b905795e
--- /dev/null
+++ b/tests/browser/features/edit_page.feature
@@ -0,0 +1,11 @@
+@chrome @clean @firefox @login @phantomjs
+Feature: Edit Page
+
+ Scenario: Create and edit page
+ Given I go to the "Editing Test Page" page with content "This is a page to test editing"
+ When I click Edit
+ And I edit the page with "Edited and a random string"
+ And I click Preview
+ And I click Show Changes
+ And I save the edit
+ Then the edited page content should contain "Edited and a random string"
diff --git a/tests/browser/features/file.feature b/tests/browser/features/file.feature
new file mode 100644
index 00000000..0bd36ed6
--- /dev/null
+++ b/tests/browser/features/file.feature
@@ -0,0 +1,23 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+@chrome @clean @firefox @internet_explorer_6 @internet_explorer_7 @internet_explorer_8 @internet_explorer_9 @internet_explorer_10 @phantomjs
+Feature: File
+
+ Scenario: Anonymous goes to file that does not exist
+ Given I am at file that does not exist
+ Then page should show that no such file exists
+
+ @login
+ Scenario: Logged-in user goes to file that does not exist
+ Given I am logged in
+ And I am at file that does not exist
+ Then page should show that no such file exists
diff --git a/tests/browser/features/login.feature b/tests/browser/features/login.feature
new file mode 100644
index 00000000..c34d23d3
--- /dev/null
+++ b/tests/browser/features/login.feature
@@ -0,0 +1,42 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+@chrome @clean @firefox @internet_explorer_6 @internet_explorer_7 @internet_explorer_8 @internet_explorer_9 @internet_explorer_10 @phantomjs
+Feature: Log in
+
+ Background:
+ Given I am at Log in page
+
+ Scenario: Go to Log in page
+ Then Username element should be there
+ And Password element should be there
+ And Log in element should be there
+
+ Scenario: Log in without entering credentials
+ When I log in without entering credentials
+ Then error box should be visible
+
+ Scenario: Log in without entering password
+ When I log in without entering password
+ Then error box should be visible
+
+ Scenario: Log in with incorrect username
+ When I log in with incorrect username
+ Then error box should be visible
+
+ Scenario: Log in with incorrect password
+ When I log in with incorrect password
+ Then error box should be visible
+
+ @login
+ Scenario: Log in with valid credentials
+ When I am logged in
+ Then error box should not be visible
diff --git a/tests/browser/features/main_page_links.feature b/tests/browser/features/main_page_links.feature
new file mode 100644
index 00000000..3613c828
--- /dev/null
+++ b/tests/browser/features/main_page_links.feature
@@ -0,0 +1,19 @@
+@chrome @clean @firefox @phantomjs
+Feature: Main Page View History Links
+
+ Background:
+ Given I open the main wiki URL
+
+ Scenario: Main Page View History links exist
+ Then I should see a link for View History
+
+ Scenario: Main Page Sidebar Links
+ Then I should see a link for Recent changes
+ And I should see a link for Random page
+ And I should see a link for Help
+ And I should see a link for What links here
+ And I should see a link for Related changes
+ And I should see a link for Special pages
+ And I should see a link for Printable version
+ And I should see a link for Permanent link
+ And I should see a link for Page information
diff --git a/tests/browser/features/preferences.feature b/tests/browser/features/preferences.feature
new file mode 100644
index 00000000..9e3abfde
--- /dev/null
+++ b/tests/browser/features/preferences.feature
@@ -0,0 +1,60 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+@chrome @clean @firefox @internet_explorer_6 @internet_explorer_7 @internet_explorer_8 @internet_explorer_9 @internet_explorer_10 @login @phantomjs
+Feature: Preferences
+
+ Scenario: Preferences Appearance
+ Given I am logged in
+ When I navigate to Preferences
+ And I click Appearance
+ Then I can select skins
+ And I can select image size
+ And I can select thumbnail size
+ And I can select Threshold for stub link
+ And I can select underline preferences
+ And I have advanced options checkboxes
+ And I can click Save
+ And I can restore default settings
+ And I can select date format
+ And I can see time offset section
+ And I can see local time
+ And I can select my time zone
+
+
+ Scenario: Preferences Editing
+ Given I am logged in
+ When I navigate to Preferences
+ And I click Editing
+ Then I can select edit area font style
+ And I can select section editing via edit links
+ And I can select section editing by right clicking
+ And I can select section editing by double clicking
+ And I can select to prompt me when entering a blank edit summary
+ And I can select to warn me when I leave an edit page with unsaved changes
+ And I can select show edit toolbar
+ And I can select show preview on first edit
+ And I can select show preview before edit box
+ And I can select live preview
+
+
+ Scenario: Preferences User profile
+ Given I am logged in
+ When I navigate to Preferences
+ And I click User profile
+ Then I can see my Basic informations
+ And I can change my language
+ And I can change my gender
+ And I can see my signature
+ And I can change my signature
+ And I can see my email
+ And I can click Save
+ And I can restore default settings
diff --git a/tests/browser/features/step_definitions/create_account_steps.rb b/tests/browser/features/step_definitions/create_account_steps.rb
new file mode 100644
index 00000000..7fa29843
--- /dev/null
+++ b/tests/browser/features/step_definitions/create_account_steps.rb
@@ -0,0 +1,18 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+Given(/^I go to Create account page at (.+)$/) do |path|
+ visit(CreateAccountPage, :using_params => {:page_title => path})
+end
+
+Then(/^form has Create account button$/) do
+ on(CreateAccountPage).create_account_element.should exist
+end
diff --git a/tests/browser/features/step_definitions/create_and_follow_wiki_link_steps.rb b/tests/browser/features/step_definitions/create_and_follow_wiki_link_steps.rb
new file mode 100644
index 00000000..ba41f7fb
--- /dev/null
+++ b/tests/browser/features/step_definitions/create_and_follow_wiki_link_steps.rb
@@ -0,0 +1,28 @@
+Given(/^I go to the "(.+)" page with content "(.+)"$/) do |page_title, page_content|
+ @wikitext = page_content
+ on(APIPage).create page_title, page_content
+ step "I am on the #{page_title} page"
+end
+
+Given(/^I am on the (.+) page$/) do |article|
+ article = article.gsub(/ /, '_')
+ visit(ZtargetPage, :using_params => {:article_name => article})
+end
+
+Given(/^I create page "(.*?)" with content "(.*?)"$/) do |page_title, page_content|
+ on(APIPage).create page_title, page_content
+end
+
+
+When(/^I click the Link Target link$/) do
+ on(ZtargetPage).link_target_page_link
+end
+
+Then(/^I should be on the Link Target Test Page$/) do
+ @browser.url.should match /Link_Target_Test_Page/
+end
+
+Then(/^the page content should contain "(.*?)"$/) do |content|
+ on(ZtargetPage).page_content.should match content
+end
+
diff --git a/tests/browser/features/step_definitions/edit_page_steps.rb b/tests/browser/features/step_definitions/edit_page_steps.rb
new file mode 100644
index 00000000..5ab02bec
--- /dev/null
+++ b/tests/browser/features/step_definitions/edit_page_steps.rb
@@ -0,0 +1,24 @@
+When(/^I click Edit$/) do
+ on(MainPage).edit_link
+end
+
+When(/^I click Preview$/) do
+ on(EditPage).preview_button
+end
+
+When(/^I click Show Changes$/) do
+ on(EditPage).show_changes_button
+end
+
+When(/^I edit the page with "(.*?)"$/) do |edit_content|
+ on(EditPage).edit_page_content_element.send_keys(edit_content + @random_string)
+end
+
+When(/^I save the edit$/) do
+ on(EditPage).save_button
+end
+
+Then(/^the edited page content should contain "(.*?)"$/) do |content|
+ on(MainPage).page_content.should match(content + @random_string)
+end
+
diff --git a/tests/browser/features/step_definitions/file_steps.rb b/tests/browser/features/step_definitions/file_steps.rb
new file mode 100644
index 00000000..a2ed1bfc
--- /dev/null
+++ b/tests/browser/features/step_definitions/file_steps.rb
@@ -0,0 +1,18 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+Given(/^I am at file that does not exist$/) do
+ visit(FileDoesNotExistPage, using_params: {page_name: @random_string})
+end
+
+Then(/^page should show that no such file exists$/) do
+ on(FileDoesNotExistPage).file_does_not_exist_message_element.should be_visible
+end
diff --git a/tests/browser/features/step_definitions/login_steps.rb b/tests/browser/features/step_definitions/login_steps.rb
new file mode 100644
index 00000000..b654b2d3
--- /dev/null
+++ b/tests/browser/features/step_definitions/login_steps.rb
@@ -0,0 +1,65 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+Given(/^I am at Log in page$/) do
+ visit LoginPage
+end
+
+When(/^I log in with incorrect password$/) do
+ on(LoginPage).login_with(ENV["MEDIAWIKI_USER"], "incorrect password", false)
+end
+
+When(/^I log in with incorrect username$/) do
+ on(LoginPage).login_with("incorrect username", ENV["MEDIAWIKI_PASSWORD"], false)
+end
+
+When(/^I log in without entering credentials$/) do
+ on(LoginPage).login_with("", "", false)
+end
+
+When(/^I log in without entering password$/) do
+ on(LoginPage).login_with(ENV["MEDIAWIKI_USER"], "", false)
+end
+
+Then(/^error box should be visible$/) do
+ on(LoginErrorPage).error_box_element.should be_visible
+end
+
+Then(/^error box should not be visible$/) do
+ on(LoginErrorPage).error_box_element.should_not be_visible
+end
+
+Then(/^feedback should be (.+)$/) do |feedback|
+ on(LoginPage) do |page|
+ page.feedback_element.when_present.click
+ page.feedback.should match Regexp.escape(feedback)
+ end
+end
+
+Then(/^Log in element should be there$/) do
+ on(LoginPage).login_element.should exist
+end
+
+Then(/^main page should open$/) do
+ @browser.url.should == on(MainPage).class.url
+end
+
+Then(/^Password element should be there$/) do
+ on(LoginPage).password_element.should exist
+end
+
+Then(/^there should be a link to (.+)$/) do |text|
+ on(LoginPage).username_displayed_element.when_present.text.should == text
+end
+
+Then(/^Username element should be there$/) do
+ on(LoginPage).username_element.should exist
+end
diff --git a/tests/browser/features/step_definitions/main_page_links_steps.rb b/tests/browser/features/step_definitions/main_page_links_steps.rb
new file mode 100644
index 00000000..c76fd2ba
--- /dev/null
+++ b/tests/browser/features/step_definitions/main_page_links_steps.rb
@@ -0,0 +1,47 @@
+Given(/^I open the main wiki URL$/) do
+ visit(MainPage)
+end
+
+Then(/^I should see a link for View History$/) do
+ on(MainPage).view_history_link_element.should be_visible
+end
+
+Then(/^I should see a link for Edit$/) do
+ on(MainPage).edit_link_element.should be_visible
+end
+
+Then(/^I should see a link for Recent changes$/) do
+ on(MainPage).recent_changes_link_element.should be_visible
+end
+
+Then(/^I should see a link for Random page$/) do
+ on(MainPage).random_page_link_element.should be_visible
+end
+
+Then(/^I should see a link for Help$/) do
+ on(MainPage).help_link_element.should be_visible
+end
+
+Then(/^I should see a link for What links here$/) do
+ on(MainPage).what_links_here_link_element.should be_visible
+end
+
+Then(/^I should see a link for Related changes$/) do
+ on(MainPage).related_changes_link_element.should be_visible
+end
+
+Then(/^I should see a link for Special pages$/) do
+ on(MainPage).special_pages_link_element.should be_visible
+end
+
+Then(/^I should see a link for Printable version$/) do
+ on(MainPage).printable_version_link_element.should be_visible
+end
+
+Then(/^I should see a link for Permanent link$/) do
+ on(MainPage).permanent_link_link_element.should be_visible
+end
+
+Then(/^I should see a link for Page information$/) do
+ on(MainPage).page_information_link_element.should be_visible
+end
diff --git a/tests/browser/features/step_definitions/preferences_appearance_steps.rb b/tests/browser/features/step_definitions/preferences_appearance_steps.rb
new file mode 100644
index 00000000..0046af69
--- /dev/null
+++ b/tests/browser/features/step_definitions/preferences_appearance_steps.rb
@@ -0,0 +1,85 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+When(/^I click Appearance$/) do
+ visit(PreferencesPage).appearance_link_element.when_present.click
+end
+
+When(/^I navigate to Preferences$/) do
+ visit(PreferencesPage)
+end
+
+Then(/^I can click Save$/) do
+ on(PreferencesPage).save_button_element.should exist
+end
+
+Then(/^I can restore default settings$/) do
+ on(PreferencesAppearancePage).restore_default_link_element.should exist
+end
+
+Then(/^I can see local time$/) do
+ on(PreferencesAppearancePage).local_time_span_element.should exist
+end
+
+Then(/^I can see time offset section$/) do
+ on(PreferencesAppearancePage).time_offset_table_element.should be_visible
+end
+
+Then(/^I can select date format$/) do
+ on(PreferencesAppearancePage) do |page|
+ page.no_preference_radio_element.should exist
+ page.mo_day_year_radio_element.should exist
+ page.day_mo_year_radio_element.should exist
+ page.year_mo_day_radio_element.should exist
+ page.iso_8601_radio_element.should exist
+ end
+end
+
+Then(/^I can select image size$/) do
+ on(PreferencesAppearancePage).size_select_element.should exist
+end
+
+Then(/^I can select my time zone$/) do
+ on(PreferencesAppearancePage) do |page|
+ page.time_offset_select_element.should exist
+ page.other_offset_element.should exist
+ end
+end
+
+Then(/^I can select skins$/) do
+ on(PreferencesAppearancePage) do |page|
+ page.cologne_blue_element.should exist
+ page.modern_element.should exist
+ page.monobook_element.should exist
+ page.vector_element.should exist
+ end
+end
+
+Then(/^I can select Threshold for stub link$/) do
+ on(PreferencesAppearancePage).threshold_select_element.should exist
+end
+
+Then(/^I can select thumbnail size$/) do
+ on(PreferencesAppearancePage).thumb_select_element.should exist
+end
+
+Then(/^I can select underline preferences$/) do
+ on(PreferencesAppearancePage).underline_select_element.should exist
+end
+
+Then(/^I have advanced options checkboxes$/) do
+ on(PreferencesAppearancePage) do |page|
+ page.hidden_categories_check_element.should exist
+ page.auto_number_check_element.should exist
+ end
+end
+
+
diff --git a/tests/browser/features/step_definitions/preferences_editing_steps.rb b/tests/browser/features/step_definitions/preferences_editing_steps.rb
new file mode 100644
index 00000000..ad29a745
--- /dev/null
+++ b/tests/browser/features/step_definitions/preferences_editing_steps.rb
@@ -0,0 +1,54 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+When(/^I click Editing$/) do
+ visit(PreferencesPage).editing_link_element.when_present.click
+end
+
+Then(/^I can select edit area font style$/) do
+ on(PreferencesEditingPage).edit_area_font_style_select_element.when_present.should exist
+end
+
+Then(/^I can select live preview$/) do
+ on(PreferencesEditingPage).live_preview_check_element.when_present.should exist
+end
+
+Then(/^I can select section editing by double clicking$/) do
+ on(PreferencesEditingPage).edit_section_double_click_check_element.when_present.should exist
+end
+
+Then(/^I can select section editing by right clicking$/) do
+ on(PreferencesEditingPage).edit_section_right_click_check_element.when_present.should exist
+end
+
+Then(/^I can select section editing via edit links$/) do
+ on(PreferencesEditingPage).edit_section_edit_link_element.when_present.should exist
+end
+
+Then(/^I can select show edit toolbar$/) do
+ on(PreferencesEditingPage).show_edit_toolbar_check_element.when_present.should exist
+end
+
+Then(/^I can select show preview before edit box$/) do
+ on(PreferencesEditingPage).preview_on_top_check_element.when_present.should exist
+end
+
+Then(/^I can select show preview on first edit$/) do
+ on(PreferencesEditingPage).preview_on_first_check_element.when_present.should exist
+end
+
+Then(/^I can select to prompt me when entering a blank edit summary$/) do
+ on(PreferencesEditingPage).forced_edit_summary_check_element.when_present.should exist
+end
+
+Then(/^I can select to warn me when I leave an edit page with unsaved changes$/) do
+ on(PreferencesEditingPage).unsaved_changes_check_element.when_present.should exist
+end
diff --git a/tests/browser/features/step_definitions/preferences_user_profile_steps.rb b/tests/browser/features/step_definitions/preferences_user_profile_steps.rb
new file mode 100644
index 00000000..529af66d
--- /dev/null
+++ b/tests/browser/features/step_definitions/preferences_user_profile_steps.rb
@@ -0,0 +1,43 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+When(/^I click User profile$/) do
+ visit(PreferencesPage).user_profile_link_element.when_present.click
+end
+
+Then(/^I can change my gender$/) do
+ on(PreferencesUserProfilePage) do |page|
+ page.gender_undefined_radio_element.should exist
+ page.gender_male_radio_element.should exist
+ page.gender_female_radio_element.should exist
+ end
+end
+
+Then(/^I can change my language$/) do
+ on(PreferencesUserProfilePage).lang_select_element.should exist
+end
+
+Then(/^I can change my signature$/) do
+ on(PreferencesUserProfilePage).signature_field_element.should exist
+end
+
+Then(/^I can see my Basic informations$/) do
+ on(PreferencesUserProfilePage).basic_info_table_element.should exist
+end
+
+Then(/^I can see my email$/) do
+ on(PreferencesUserProfilePage).email_table_element.should exist
+end
+
+Then(/^I can see my signature$/) do
+ on(PreferencesUserProfilePage).signature_table_element.should exist
+end
+
diff --git a/tests/browser/features/step_definitions/view_history_steps.rb b/tests/browser/features/step_definitions/view_history_steps.rb
new file mode 100644
index 00000000..1ecc0085
--- /dev/null
+++ b/tests/browser/features/step_definitions/view_history_steps.rb
@@ -0,0 +1,8 @@
+When(/^I click View History$/) do
+ on(ViewHistoryPage).view_history_link
+end
+
+Then(/^I should see a link to a previous version of the page$/) do
+ on(ViewHistoryPage).old_version_link_element.should be_visible
+end
+
diff --git a/tests/browser/features/support/env.rb b/tests/browser/features/support/env.rb
new file mode 100644
index 00000000..7c122366
--- /dev/null
+++ b/tests/browser/features/support/env.rb
@@ -0,0 +1,2 @@
+require "mediawiki_api"
+require "mediawiki_selenium"
diff --git a/tests/browser/features/support/hooks.rb b/tests/browser/features/support/hooks.rb
new file mode 100644
index 00000000..85309f39
--- /dev/null
+++ b/tests/browser/features/support/hooks.rb
@@ -0,0 +1,2 @@
+# Needed for cucumber --dry-run -f stepdefs
+require 'page-object'
diff --git a/tests/browser/features/support/modules/url_module.rb b/tests/browser/features/support/modules/url_module.rb
new file mode 100644
index 00000000..6c329e87
--- /dev/null
+++ b/tests/browser/features/support/modules/url_module.rb
@@ -0,0 +1,10 @@
+module URL
+ def self.url(name)
+ if ENV["MEDIAWIKI_URL"]
+ mediawiki_url = ENV["MEDIAWIKI_URL"]
+ else
+ mediawiki_url = "http://127.0.0.1:80/w/index.php"
+ end
+ "#{mediawiki_url}#{name}"
+ end
+end
diff --git a/tests/browser/features/support/pages/create_account_page.rb b/tests/browser/features/support/pages/create_account_page.rb
new file mode 100644
index 00000000..380bccbc
--- /dev/null
+++ b/tests/browser/features/support/pages/create_account_page.rb
@@ -0,0 +1,19 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+class CreateAccountPage
+ include PageObject
+
+ include URL
+ page_url URL.url("<%=params[:page_title]%>")
+
+ button(:create_account, id: "wpCreateaccount")
+end
diff --git a/tests/browser/features/support/pages/edit_page.rb b/tests/browser/features/support/pages/edit_page.rb
new file mode 100644
index 00000000..b619c342
--- /dev/null
+++ b/tests/browser/features/support/pages/edit_page.rb
@@ -0,0 +1,8 @@
+class EditPage
+ include PageObject
+
+ text_area(:edit_page_content, id: "wpTextbox1")
+ button(:preview_button, id: "wpPreview")
+ button(:show_changes_button, id: "wpDiff")
+ button(:save_button, id: "wpSave")
+end \ No newline at end of file
diff --git a/tests/browser/features/support/pages/file_does_not_exist_page.rb b/tests/browser/features/support/pages/file_does_not_exist_page.rb
new file mode 100644
index 00000000..c8491f3b
--- /dev/null
+++ b/tests/browser/features/support/pages/file_does_not_exist_page.rb
@@ -0,0 +1,19 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+class FileDoesNotExistPage
+ include PageObject
+
+ include URL
+ page_url URL.url("File:<%=params[:page_name]%>")
+
+ div(:file_does_not_exist_message, id: "mw-imagepage-nofile")
+end
diff --git a/tests/browser/features/support/pages/login_error_page.rb b/tests/browser/features/support/pages/login_error_page.rb
new file mode 100644
index 00000000..4fc9ca7f
--- /dev/null
+++ b/tests/browser/features/support/pages/login_error_page.rb
@@ -0,0 +1,5 @@
+class LoginErrorPage
+ include PageObject
+
+ div(:error_box, class: "errorbox")
+end \ No newline at end of file
diff --git a/tests/browser/features/support/pages/main_page.rb b/tests/browser/features/support/pages/main_page.rb
new file mode 100644
index 00000000..7d96c2b2
--- /dev/null
+++ b/tests/browser/features/support/pages/main_page.rb
@@ -0,0 +1,19 @@
+class MainPage
+ include PageObject
+
+ include URL
+ page_url URL.url("")
+
+ a(:edit_link, href: /action=edit/)
+ li(:help_link, id: "n-help")
+ div(:page_content, id: "content")
+ li(:page_information_link, id: "t-info")
+ li(:permanent_link_link, id: "t-permalink")
+ a(:printable_version_link, href: /printable=yes/)
+ li(:random_page_link, id: "n-randompage")
+ li(:recent_changes_link, id: "n-recentchanges")
+ li(:related_changes_link, id: "t-recentchangeslinked")
+ li(:special_pages_link, id: "t-specialpages")
+ a(:view_history_link, href: /action=history/)
+ li(:what_links_here_link, id: "t-whatlinkshere")
+end \ No newline at end of file
diff --git a/tests/browser/features/support/pages/preferences_appearance_page.rb b/tests/browser/features/support/pages/preferences_appearance_page.rb
new file mode 100644
index 00000000..c24e3862
--- /dev/null
+++ b/tests/browser/features/support/pages/preferences_appearance_page.rb
@@ -0,0 +1,41 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+class PreferencesAppearancePage
+ include PageObject
+
+ include URL
+ page_url URL.url("Special:Preferences#mw-prefsection-rendering")
+
+ checkbox(:auto_number_check, id: "mw-input-wpnumberheadings")
+ radio_button(:cologne_blue, id: "mw-input-wpskin-cologneblue")
+ radio_button(:day_mo_year_radio, id: "mw-input-wpdate-dmy")
+ checkbox(:dont_show_aft_check, id: "mw-input-wparticlefeedback-disable")
+ checkbox(:exclude_from_experiments_check, id: "mw-input-wpvector-noexperiments")
+ checkbox(:hidden_categories_check, id: "mw-input-wpshowhiddencats")
+ radio_button(:iso_8601_radio, id: "mw-input-wpdate-ISO_8601")
+ span(:local_time_span, id: "wpLocalTime")
+ radio_button(:mo_day_year_radio, id: "mw-input-wpdate-mdy")
+ radio_button(:modern, id: "mw-input-wpskin-modern")
+ radio_button(:monobook, id: "mw-input-wpskin-monobook")
+ radio_button(:no_preference_radio, id: "mw-input-wpdate-default")
+ text_field(:other_offset, id: "mw-input-wptimecorrection-other")
+ a(:restore_default_link, href: /reset/)
+ select_list(:size_select, id: "mw-input-wpimagesize")
+ select_list(:threshold_select, id: "mw-input-wpstubthreshold")
+ select_list(:time_offset_select, id: "mw-input-wptimecorrection")
+ table(:time_offset_table, id: "mw-htmlform-timeoffset")
+ select_list(:thumb_select, id: "mw-input-wpthumbsize")
+ select_list(:underline_select, id: "mw-input-wpunderline")
+ radio_button(:vector, id: "mw-input-wpskin-vector")
+ radio_button(:year_mo_day_radio, id: "mw-input-wpdate-ymd")
+end
+
diff --git a/tests/browser/features/support/pages/preferences_editing_page.rb b/tests/browser/features/support/pages/preferences_editing_page.rb
new file mode 100644
index 00000000..aed9c41d
--- /dev/null
+++ b/tests/browser/features/support/pages/preferences_editing_page.rb
@@ -0,0 +1,28 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+class PreferencesEditingPage
+ include PageObject
+
+ include URL
+ page_url URL.url("Special:Preferences#mw-prefsection-rendering")
+
+ select_list(:edit_area_font_style_select, id: "mw-input-wpeditfont")
+ checkbox(:edit_section_double_click_check, id: "mw-input-wpeditondblclick")
+ checkbox(:edit_section_edit_link, id: "mw-input-wpeditsectiononrightclick")
+ checkbox(:edit_section_right_click_check, id: "mw-input-wpeditsectiononrightclick")
+ checkbox(:forced_edit_summary_check, id: "mw-input-wpforceeditsummary")
+ checkbox(:live_preview_check, id: "mw-input-wpuselivepreview")
+ checkbox(:preview_on_first_check, id: "mw-input-wppreviewonfirst")
+ checkbox(:preview_on_top_check, id: "mw-input-wppreviewontop")
+ checkbox(:show_edit_toolbar_check, id: "mw-input-wpshowtoolbar")
+ checkbox(:unsaved_changes_check, id: "mw-input-wpuseeditwarning")
+end
diff --git a/tests/browser/features/support/pages/preferences_page.rb b/tests/browser/features/support/pages/preferences_page.rb
new file mode 100644
index 00000000..919ba27f
--- /dev/null
+++ b/tests/browser/features/support/pages/preferences_page.rb
@@ -0,0 +1,22 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+class PreferencesPage
+ include PageObject
+
+ include URL
+ page_url URL.url("Special:Preferences")
+
+ a(:appearance_link, id: "preftab-rendering")
+ a(:editing_link, id: "preftab-editing")
+ a(:user_profile_link, id: "preftab-personal")
+ button(:save_button, id: "prefcontrol")
+end
diff --git a/tests/browser/features/support/pages/preferences_user_profile_page.rb b/tests/browser/features/support/pages/preferences_user_profile_page.rb
new file mode 100644
index 00000000..28e10b97
--- /dev/null
+++ b/tests/browser/features/support/pages/preferences_user_profile_page.rb
@@ -0,0 +1,28 @@
+#
+# This file is subject to the license terms in the LICENSE file found in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/LICENSE. No part of
+# qa-browsertests, including this file, may be copied, modified, propagated, or
+# distributed except according to the terms contained in the LICENSE file.
+#
+# Copyright 2012-2014 by the Mediawiki developers. See the CREDITS file in the
+# qa-browsertests top-level directory and at
+# https://git.wikimedia.org/blob/qa%2Fbrowsertests/HEAD/CREDITS
+#
+class PreferencesUserProfilePage
+ include PageObject
+
+ include URL
+ page_url URL.url("Special:Preferences#mw-prefsection-personal")
+
+ table(:basic_info_table, id: "mw-htmlform-info")
+ link(:change_password_link, text: "Change password")
+ table(:email_table, id: "mw-htmlform-email")
+ radio_button(:gender_female_radio, id: "mw-input-wpgender-male")
+ radio_button(:gender_male_radio, id: "mw-input-wpgender-female")
+ radio_button(:gender_undefined_radio, id: "mw-input-wpgender-unknown")
+ select_list(:lang_select, id: "mw-input-wplanguage")
+ checkbox(:remember_password_check, id: "mw-input-wprememberpassword")
+ text_field(:signature_field, id: "mw-input-wpnickname")
+ table(:signature_table, id: "mw-htmlform-signature")
+end
diff --git a/tests/browser/features/support/pages/view_history_page.rb b/tests/browser/features/support/pages/view_history_page.rb
new file mode 100644
index 00000000..66895986
--- /dev/null
+++ b/tests/browser/features/support/pages/view_history_page.rb
@@ -0,0 +1,7 @@
+class ViewHistoryPage
+ include PageObject
+
+ a(:view_history_link, href: /action=history/)
+ a(:old_version_link, href: /oldid=/)
+
+end \ No newline at end of file
diff --git a/tests/browser/features/support/pages/ztargetpage.rb b/tests/browser/features/support/pages/ztargetpage.rb
new file mode 100644
index 00000000..c1f46eca
--- /dev/null
+++ b/tests/browser/features/support/pages/ztargetpage.rb
@@ -0,0 +1,7 @@
+class ZtargetPage < MainPage
+ include URL
+ page_url URL.url("<%=params[:article_name]%>")
+ include PageObject
+
+ a(:link_target_page_link, text: "link to the test target page")
+end \ No newline at end of file
diff --git a/tests/browser/features/view_history.feature b/tests/browser/features/view_history.feature
new file mode 100644
index 00000000..ba61ebda
--- /dev/null
+++ b/tests/browser/features/view_history.feature
@@ -0,0 +1,11 @@
+@chrome @clean @firefox @phantomjs
+Feature: View History
+
+ Scenario: Edit page and view history
+ Given I go to the "History Test Page" page with content "This is a page that will have history"
+ When I click Edit
+ And I edit the page with "Edited and a random string"
+ And I save the edit
+ And the edited page content should contain "Edited and a random string"
+ And I click View History
+ Then I should see a link to a previous version of the page
diff --git a/tests/parser/ParserTestResult.php b/tests/parser/ParserTestResult.php
new file mode 100644
index 00000000..7d9415a2
--- /dev/null
+++ b/tests/parser/ParserTestResult.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * @copyright Copyright © 2013, Antoine Musso
+ * @copyright Copyright © 2013, Wikimedia Foundation Inc.
+ * @license GNU GPL v2
+ *
+ * @file
+ */
+
+/**
+ * Represent the result of a parser test.
+ *
+ * @since 1.22
+ */
+class ParserTestResult {
+ /**
+ * Description of the parser test.
+ *
+ * This is usually the text used to describe a parser test in the .txt
+ * files. It is initialized on a construction and you most probably
+ * never want to change it.
+ */
+ public $description;
+ /** Text that was expected */
+ public $expected;
+ /** Actual text rendered */
+ public $actual;
+
+ /**
+ * @param string $description A short text describing the parser test
+ * usually the text in the parser test .txt file. The description
+ * is later available using the property $description.
+ */
+ public function __construct( $description ) {
+ $this->description = $description;
+ }
+
+ /**
+ * Whether the test passed
+ * @return bool
+ */
+ public function isSuccess() {
+ return $this->expected === $this->actual;
+ }
+}
diff --git a/tests/parser/README b/tests/parser/README
new file mode 100644
index 00000000..8b413376
--- /dev/null
+++ b/tests/parser/README
@@ -0,0 +1,8 @@
+Parser tests are run using our PHPUnit test suite in tests/phpunit:
+
+ $ cd tests/phpunit
+ ./phpunit.php --group Parser
+
+You can optionally filter by title using --regex. I.e. :
+
+ ./phpunit.php --group Parser --regex="Bug 6200"
diff --git a/tests/parser/extraParserTests.txt b/tests/parser/extraParserTests.txt
new file mode 100644
index 00000000..bef8f506
--- /dev/null
+++ b/tests/parser/extraParserTests.txt
Binary files differ
diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc
new file mode 100644
index 00000000..a9df6832
--- /dev/null
+++ b/tests/parser/parserTest.inc
@@ -0,0 +1,1655 @@
+<?php
+/**
+ * Helper code for the MediaWiki parser test suite. Some code is duplicated
+ * in PHPUnit's NewParserTests.php, so you'll probably want to update both
+ * at the same time.
+ *
+ * Copyright © 2004, 2010 Brion Vibber <brion@pobox.com>
+ * https://www.mediawiki.org/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @todo Make this more independent of the configuration (and if possible the database)
+ * @todo document
+ * @file
+ * @ingroup Testing
+ */
+
+/**
+ * @ingroup Testing
+ */
+class ParserTest {
+ /**
+ * @var bool $color whereas output should be colorized
+ */
+ private $color;
+
+ /**
+ * @var bool $showOutput Show test output
+ */
+ private $showOutput;
+
+ /**
+ * @var bool $useTemporaryTables Use temporary tables for the temporary database
+ */
+ private $useTemporaryTables = true;
+
+ /**
+ * @var bool $databaseSetupDone True if the database has been set up
+ */
+ private $databaseSetupDone = false;
+
+ /**
+ * Our connection to the database
+ * @var DatabaseBase
+ */
+ private $db;
+
+ /**
+ * Database clone helper
+ * @var CloneDatabase
+ */
+ private $dbClone;
+
+ /**
+ * @var DjVuSupport
+ */
+ private $djVuSupport;
+
+ /**
+ * @var TidySupport
+ */
+ private $tidySupport;
+
+ private $maxFuzzTestLength = 300;
+ private $fuzzSeed = 0;
+ private $memoryLimit = 50;
+ private $uploadDir = null;
+
+ public $regex = "";
+ private $savedGlobals = array();
+
+ /**
+ * Sets terminal colorization and diff/quick modes depending on OS and
+ * command-line options (--color and --quick).
+ * @param array $options
+ */
+ public function __construct( $options = array() ) {
+ # Only colorize output if stdout is a terminal.
+ $this->color = !wfIsWindows() && Maintenance::posix_isatty( 1 );
+
+ if ( isset( $options['color'] ) ) {
+ switch ( $options['color'] ) {
+ case 'no':
+ $this->color = false;
+ break;
+ case 'yes':
+ default:
+ $this->color = true;
+ break;
+ }
+ }
+
+ $this->term = $this->color
+ ? new AnsiTermColorer()
+ : new DummyTermColorer();
+
+ $this->showDiffs = !isset( $options['quick'] );
+ $this->showProgress = !isset( $options['quiet'] );
+ $this->showFailure = !(
+ isset( $options['quiet'] )
+ && ( isset( $options['record'] )
+ || isset( $options['compare'] ) ) ); // redundant output
+
+ $this->showOutput = isset( $options['show-output'] );
+
+ if ( isset( $options['filter'] ) ) {
+ $options['regex'] = $options['filter'];
+ }
+
+ if ( isset( $options['regex'] ) ) {
+ if ( isset( $options['record'] ) ) {
+ echo "Warning: --record cannot be used with --regex, disabling --record\n";
+ unset( $options['record'] );
+ }
+ $this->regex = $options['regex'];
+ } else {
+ # Matches anything
+ $this->regex = '';
+ }
+
+ $this->setupRecorder( $options );
+ $this->keepUploads = isset( $options['keep-uploads'] );
+
+ if ( isset( $options['seed'] ) ) {
+ $this->fuzzSeed = intval( $options['seed'] ) - 1;
+ }
+
+ $this->runDisabled = isset( $options['run-disabled'] );
+ $this->runParsoid = isset( $options['run-parsoid'] );
+
+ $this->djVuSupport = new DjVuSupport();
+ $this->tidySupport = new TidySupport();
+ if ( !$this->tidySupport->isEnabled() ) {
+ echo "Warning: tidy is not installed, skipping some tests\n";
+ }
+
+ $this->hooks = array();
+ $this->functionHooks = array();
+ $this->transparentHooks = array();
+ self::setUp();
+ }
+
+ static function setUp() {
+ global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc,
+ $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache,
+ $wgExtraNamespaces, $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo,
+ $wgExtraInterlanguageLinkPrefixes, $wgLocalInterwikis,
+ $parserMemc, $wgThumbnailScriptPath, $wgScriptPath,
+ $wgArticlePath, $wgScript, $wgStylePath, $wgExtensionAssetsPath,
+ $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgLockManagers;
+
+ $wgScript = '/index.php';
+ $wgScriptPath = '/';
+ $wgArticlePath = '/wiki/$1';
+ $wgStylePath = '/skins';
+ $wgExtensionAssetsPath = '/extensions';
+ $wgThumbnailScriptPath = false;
+ $wgLockManagers = array( array(
+ 'name' => 'fsLockManager',
+ 'class' => 'FSLockManager',
+ 'lockDirectory' => wfTempDir() . '/test-repo/lockdir',
+ ), array(
+ 'name' => 'nullLockManager',
+ 'class' => 'NullLockManager',
+ ) );
+ $wgLocalFileRepo = array(
+ 'class' => 'LocalRepo',
+ 'name' => 'local',
+ 'url' => 'http://example.com/images',
+ 'hashLevels' => 2,
+ 'transformVia404' => false,
+ 'backend' => new FSFileBackend( array(
+ 'name' => 'local-backend',
+ 'wikiId' => wfWikiId(),
+ 'containerPaths' => array(
+ 'local-public' => wfTempDir() . '/test-repo/public',
+ 'local-thumb' => wfTempDir() . '/test-repo/thumb',
+ 'local-temp' => wfTempDir() . '/test-repo/temp',
+ 'local-deleted' => wfTempDir() . '/test-repo/deleted',
+ )
+ ) )
+ );
+ $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
+ $wgNamespaceAliases['Image'] = NS_FILE;
+ $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
+ # add a namespace shadowing a interwiki link, to test
+ # proper precedence when resolving links. (bug 51680)
+ $wgExtraNamespaces[100] = 'MemoryAlpha';
+
+ // XXX: tests won't run without this (for CACHE_DB)
+ if ( $wgMainCacheType === CACHE_DB ) {
+ $wgMainCacheType = CACHE_NONE;
+ }
+ if ( $wgMessageCacheType === CACHE_DB ) {
+ $wgMessageCacheType = CACHE_NONE;
+ }
+ if ( $wgParserCacheType === CACHE_DB ) {
+ $wgParserCacheType = CACHE_NONE;
+ }
+
+ $wgEnableParserCache = false;
+ DeferredUpdates::clearPendingUpdates();
+ $wgMemc = wfGetMainCache(); // checks $wgMainCacheType
+ $messageMemc = wfGetMessageCacheStorage();
+ $parserMemc = wfGetParserCacheStorage();
+
+ $wgUser = new User;
+ $context = new RequestContext;
+ $wgLang = $context->getLanguage();
+ $wgOut = $context->getOutput();
+ $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
+ $wgRequest = $context->getRequest();
+
+ if ( $wgStyleDirectory === false ) {
+ $wgStyleDirectory = "$IP/skins";
+ }
+
+ self::setupInterwikis();
+ $wgLocalInterwikis = array( 'local', 'mi' );
+ // "extra language links"
+ // see https://gerrit.wikimedia.org/r/111390
+ array_push( $wgExtraInterlanguageLinkPrefixes, 'mul' );
+ }
+
+ /**
+ * Insert hardcoded interwiki in the lookup table.
+ *
+ * This function insert a set of well known interwikis that are used in
+ * the parser tests. They can be considered has fixtures are injected in
+ * the interwiki cache by using the 'InterwikiLoadPrefix' hook.
+ * Since we are not interested in looking up interwikis in the database,
+ * the hook completely replace the existing mechanism (hook returns false).
+ */
+ public static function setupInterwikis() {
+ # Hack: insert a few Wikipedia in-project interwiki prefixes,
+ # for testing inter-language links
+ Hooks::register( 'InterwikiLoadPrefix', function ( $prefix, &$iwData ) {
+ static $testInterwikis = array(
+ 'local' => array(
+ 'iw_url' => 'http://doesnt.matter.org/$1',
+ 'iw_api' => '',
+ 'iw_wikiid' => '',
+ 'iw_local' => 0 ),
+ 'wikipedia' => array(
+ 'iw_url' => 'http://en.wikipedia.org/wiki/$1',
+ 'iw_api' => '',
+ 'iw_wikiid' => '',
+ 'iw_local' => 0 ),
+ 'meatball' => array(
+ 'iw_url' => 'http://www.usemod.com/cgi-bin/mb.pl?$1',
+ 'iw_api' => '',
+ 'iw_wikiid' => '',
+ 'iw_local' => 0 ),
+ 'memoryalpha' => array(
+ 'iw_url' => 'http://www.memory-alpha.org/en/index.php/$1',
+ 'iw_api' => '',
+ 'iw_wikiid' => '',
+ 'iw_local' => 0 ),
+ 'zh' => array(
+ 'iw_url' => 'http://zh.wikipedia.org/wiki/$1',
+ 'iw_api' => '',
+ 'iw_wikiid' => '',
+ 'iw_local' => 1 ),
+ 'es' => array(
+ 'iw_url' => 'http://es.wikipedia.org/wiki/$1',
+ 'iw_api' => '',
+ 'iw_wikiid' => '',
+ 'iw_local' => 1 ),
+ 'fr' => array(
+ 'iw_url' => 'http://fr.wikipedia.org/wiki/$1',
+ 'iw_api' => '',
+ 'iw_wikiid' => '',
+ 'iw_local' => 1 ),
+ 'ru' => array(
+ 'iw_url' => 'http://ru.wikipedia.org/wiki/$1',
+ 'iw_api' => '',
+ 'iw_wikiid' => '',
+ 'iw_local' => 1 ),
+ 'mi' => array(
+ 'iw_url' => 'http://mi.wikipedia.org/wiki/$1',
+ 'iw_api' => '',
+ 'iw_wikiid' => '',
+ 'iw_local' => 1 ),
+ 'mul' => array(
+ 'iw_url' => 'http://wikisource.org/wiki/$1',
+ 'iw_api' => '',
+ 'iw_wikiid' => '',
+ 'iw_local' => 1 ),
+ );
+ if ( array_key_exists( $prefix, $testInterwikis ) ) {
+ $iwData = $testInterwikis[$prefix];
+ }
+
+ // We only want to rely on the above fixtures
+ return false;
+ } );// hooks::register
+ }
+
+ /**
+ * Remove the hardcoded interwiki lookup table.
+ */
+ public static function tearDownInterwikis() {
+ Hooks::clear( 'InterwikiLoadPrefix' );
+ }
+
+ public function setupRecorder( $options ) {
+ if ( isset( $options['record'] ) ) {
+ $this->recorder = new DbTestRecorder( $this );
+ $this->recorder->version = isset( $options['setversion'] ) ?
+ $options['setversion'] : SpecialVersion::getVersion();
+ } elseif ( isset( $options['compare'] ) ) {
+ $this->recorder = new DbTestPreviewer( $this );
+ } else {
+ $this->recorder = new TestRecorder( $this );
+ }
+ }
+
+ /**
+ * Remove last character if it is a newline
+ * @group utility
+ * @param string $s
+ * @return string
+ */
+ public static function chomp( $s ) {
+ if ( substr( $s, -1 ) === "\n" ) {
+ return substr( $s, 0, -1 );
+ } else {
+ return $s;
+ }
+ }
+
+ /**
+ * Run a fuzz test series
+ * Draw input from a set of test files
+ * @param array $filenames
+ */
+ function fuzzTest( $filenames ) {
+ $GLOBALS['wgContLang'] = Language::factory( 'en' );
+ $dict = $this->getFuzzInput( $filenames );
+ $dictSize = strlen( $dict );
+ $logMaxLength = log( $this->maxFuzzTestLength );
+ $this->setupDatabase();
+ ini_set( 'memory_limit', $this->memoryLimit * 1048576 );
+
+ $numTotal = 0;
+ $numSuccess = 0;
+ $user = new User;
+ $opts = ParserOptions::newFromUser( $user );
+ $title = Title::makeTitle( NS_MAIN, 'Parser_test' );
+
+ while ( true ) {
+ // Generate test input
+ mt_srand( ++$this->fuzzSeed );
+ $totalLength = mt_rand( 1, $this->maxFuzzTestLength );
+ $input = '';
+
+ while ( strlen( $input ) < $totalLength ) {
+ $logHairLength = mt_rand( 0, 1000000 ) / 1000000 * $logMaxLength;
+ $hairLength = min( intval( exp( $logHairLength ) ), $dictSize );
+ $offset = mt_rand( 0, $dictSize - $hairLength );
+ $input .= substr( $dict, $offset, $hairLength );
+ }
+
+ $this->setupGlobals();
+ $parser = $this->getParser();
+
+ // Run the test
+ try {
+ $parser->parse( $input, $title, $opts );
+ $fail = false;
+ } catch ( Exception $exception ) {
+ $fail = true;
+ }
+
+ if ( $fail ) {
+ echo "Test failed with seed {$this->fuzzSeed}\n";
+ echo "Input:\n";
+ printf( "string(%d) \"%s\"\n\n", strlen( $input ), $input );
+ echo "$exception\n";
+ } else {
+ $numSuccess++;
+ }
+
+ $numTotal++;
+ $this->teardownGlobals();
+ $parser->__destruct();
+
+ if ( $numTotal % 100 == 0 ) {
+ $usage = intval( memory_get_usage( true ) / $this->memoryLimit / 1048576 * 100 );
+ echo "{$this->fuzzSeed}: $numSuccess/$numTotal (mem: $usage%)\n";
+ if ( $usage > 90 ) {
+ echo "Out of memory:\n";
+ $memStats = $this->getMemoryBreakdown();
+
+ foreach ( $memStats as $name => $usage ) {
+ echo "$name: $usage\n";
+ }
+ $this->abort();
+ }
+ }
+ }
+ }
+
+ /**
+ * Get an input dictionary from a set of parser test files
+ * @param array $filenames
+ * @return string
+ */
+ function getFuzzInput( $filenames ) {
+ $dict = '';
+
+ foreach ( $filenames as $filename ) {
+ $contents = file_get_contents( $filename );
+ preg_match_all(
+ '/!!\s*(input|wikitext)\n(.*?)\n!!\s*(result|html|html\/\*|html\/php)/s',
+ $contents,
+ $matches
+ );
+
+ foreach ( $matches[1] as $match ) {
+ $dict .= $match . "\n";
+ }
+ }
+
+ return $dict;
+ }
+
+ /**
+ * Get a memory usage breakdown
+ * @return array
+ */
+ function getMemoryBreakdown() {
+ $memStats = array();
+
+ foreach ( $GLOBALS as $name => $value ) {
+ $memStats['$' . $name] = strlen( serialize( $value ) );
+ }
+
+ $classes = get_declared_classes();
+
+ foreach ( $classes as $class ) {
+ $rc = new ReflectionClass( $class );
+ $props = $rc->getStaticProperties();
+ $memStats[$class] = strlen( serialize( $props ) );
+ $methods = $rc->getMethods();
+
+ foreach ( $methods as $method ) {
+ $memStats[$class] += strlen( serialize( $method->getStaticVariables() ) );
+ }
+ }
+
+ $functions = get_defined_functions();
+
+ foreach ( $functions['user'] as $function ) {
+ $rf = new ReflectionFunction( $function );
+ $memStats["$function()"] = strlen( serialize( $rf->getStaticVariables() ) );
+ }
+
+ asort( $memStats );
+
+ return $memStats;
+ }
+
+ function abort() {
+ $this->abort();
+ }
+
+ /**
+ * Run a series of tests listed in the given text files.
+ * Each test consists of a brief description, wikitext input,
+ * and the expected HTML output.
+ *
+ * Prints status updates on stdout and counts up the total
+ * number and percentage of passed tests.
+ *
+ * @param array $filenames Array of strings
+ * @return bool True if passed all tests, false if any tests failed.
+ */
+ public function runTestsFromFiles( $filenames ) {
+ $ok = false;
+
+ // be sure, ParserTest::addArticle has correct language set,
+ // so that system messages gets into the right language cache
+ $GLOBALS['wgLanguageCode'] = 'en';
+ $GLOBALS['wgContLang'] = Language::factory( 'en' );
+
+ $this->recorder->start();
+ try {
+ $this->setupDatabase();
+ $ok = true;
+
+ foreach ( $filenames as $filename ) {
+ $tests = new TestFileIterator( $filename, $this );
+ $ok = $this->runTests( $tests ) && $ok;
+ }
+
+ $this->teardownDatabase();
+ $this->recorder->report();
+ } catch ( DBError $e ) {
+ echo $e->getMessage();
+ }
+ $this->recorder->end();
+
+ return $ok;
+ }
+
+ function runTests( $tests ) {
+ $ok = true;
+
+ foreach ( $tests as $t ) {
+ $result =
+ $this->runTest( $t['test'], $t['input'], $t['result'], $t['options'], $t['config'] );
+ $ok = $ok && $result;
+ $this->recorder->record( $t['test'], $result );
+ }
+
+ if ( $this->showProgress ) {
+ print "\n";
+ }
+
+ return $ok;
+ }
+
+ /**
+ * Get a Parser object
+ *
+ * @param string $preprocessor
+ * @return Parser
+ */
+ function getParser( $preprocessor = null ) {
+ global $wgParserConf;
+
+ $class = $wgParserConf['class'];
+ $parser = new $class( array( 'preprocessorClass' => $preprocessor ) + $wgParserConf );
+
+ foreach ( $this->hooks as $tag => $callback ) {
+ $parser->setHook( $tag, $callback );
+ }
+
+ foreach ( $this->functionHooks as $tag => $bits ) {
+ list( $callback, $flags ) = $bits;
+ $parser->setFunctionHook( $tag, $callback, $flags );
+ }
+
+ foreach ( $this->transparentHooks as $tag => $callback ) {
+ $parser->setTransparentTagHook( $tag, $callback );
+ }
+
+ wfRunHooks( 'ParserTestParser', array( &$parser ) );
+
+ return $parser;
+ }
+
+ /**
+ * Run a given wikitext input through a freshly-constructed wiki parser,
+ * and compare the output against the expected results.
+ * Prints status and explanatory messages to stdout.
+ *
+ * @param string $desc Test's description
+ * @param string $input Wikitext to try rendering
+ * @param string $result Result to output
+ * @param array $opts Test's options
+ * @param string $config Overrides for global variables, one per line
+ * @return bool
+ */
+ public function runTest( $desc, $input, $result, $opts, $config ) {
+ if ( $this->showProgress ) {
+ $this->showTesting( $desc );
+ }
+
+ $opts = $this->parseOptions( $opts );
+ $context = $this->setupGlobals( $opts, $config );
+
+ $user = $context->getUser();
+ $options = ParserOptions::newFromContext( $context );
+
+ if ( isset( $opts['djvu'] ) ) {
+ if ( !$this->djVuSupport->isEnabled() ) {
+ return $this->showSkipped();
+ }
+ }
+
+ if ( isset( $opts['title'] ) ) {
+ $titleText = $opts['title'];
+ } else {
+ $titleText = 'Parser test';
+ }
+
+ $local = isset( $opts['local'] );
+ $preprocessor = isset( $opts['preprocessor'] ) ? $opts['preprocessor'] : null;
+ $parser = $this->getParser( $preprocessor );
+ $title = Title::newFromText( $titleText );
+
+ if ( isset( $opts['pst'] ) ) {
+ $out = $parser->preSaveTransform( $input, $title, $user, $options );
+ } elseif ( isset( $opts['msg'] ) ) {
+ $out = $parser->transformMsg( $input, $options, $title );
+ } elseif ( isset( $opts['section'] ) ) {
+ $section = $opts['section'];
+ $out = $parser->getSection( $input, $section );
+ } elseif ( isset( $opts['replace'] ) ) {
+ $section = $opts['replace'][0];
+ $replace = $opts['replace'][1];
+ $out = $parser->replaceSection( $input, $section, $replace );
+ } elseif ( isset( $opts['comment'] ) ) {
+ $out = Linker::formatComment( $input, $title, $local );
+ } elseif ( isset( $opts['preload'] ) ) {
+ $out = $parser->getPreloadText( $input, $title, $options );
+ } else {
+ $output = $parser->parse( $input, $title, $options, true, true, 1337 );
+ $output->setTOCEnabled( !isset( $opts['notoc'] ) );
+ $out = $output->getText();
+ if ( isset( $opts['tidy'] ) ) {
+ if ( !$this->tidySupport->isEnabled() ) {
+ return $this->showSkipped();
+ }
+ $out = MWTidy::tidy( $out );
+ $out = preg_replace( '/\s+$/', '', $out );
+ }
+
+ if ( isset( $opts['showtitle'] ) ) {
+ if ( $output->getTitleText() ) {
+ $title = $output->getTitleText();
+ }
+
+ $out = "$title\n$out";
+ }
+
+ if ( isset( $opts['ill'] ) ) {
+ $out = implode( ' ', $output->getLanguageLinks() );
+ } elseif ( isset( $opts['cat'] ) ) {
+ $outputPage = $context->getOutput();
+ $outputPage->addCategoryLinks( $output->getCategories() );
+ $cats = $outputPage->getCategoryLinks();
+
+ if ( isset( $cats['normal'] ) ) {
+ $out = implode( ' ', $cats['normal'] );
+ } else {
+ $out = '';
+ }
+ }
+ }
+
+ $this->teardownGlobals();
+
+ $testResult = new ParserTestResult( $desc );
+ $testResult->expected = $result;
+ $testResult->actual = $out;
+
+ return $this->showTestResult( $testResult );
+ }
+
+ /**
+ * Refactored in 1.22 to use ParserTestResult
+ * @param ParserTestResult $testResult
+ * @return bool
+ */
+ function showTestResult( ParserTestResult $testResult ) {
+ if ( $testResult->isSuccess() ) {
+ $this->showSuccess( $testResult );
+ return true;
+ } else {
+ $this->showFailure( $testResult );
+ return false;
+ }
+ }
+
+ /**
+ * Use a regex to find out the value of an option
+ * @param string $key Name of option val to retrieve
+ * @param array $opts Options array to look in
+ * @param mixed $default Default value returned if not found
+ * @return mixed
+ */
+ private static function getOptionValue( $key, $opts, $default ) {
+ $key = strtolower( $key );
+
+ if ( isset( $opts[$key] ) ) {
+ return $opts[$key];
+ } else {
+ return $default;
+ }
+ }
+
+ private function parseOptions( $instring ) {
+ $opts = array();
+ // foo
+ // foo=bar
+ // foo="bar baz"
+ // foo=[[bar baz]]
+ // foo=bar,"baz quux"
+ // foo={...json...}
+ $defs = '(?(DEFINE)
+ (?<qstr> # Quoted string
+ "
+ (?:[^\\\\"] | \\\\.)*
+ "
+ )
+ (?<json>
+ \{ # Open bracket
+ (?:
+ [^"{}] | # Not a quoted string or object, or
+ (?&qstr) | # A quoted string, or
+ (?&json) # A json object (recursively)
+ )*
+ \} # Close bracket
+ )
+ (?<value>
+ (?:
+ (?&qstr) # Quoted val
+ |
+ \[\[
+ [^]]* # Link target
+ \]\]
+ |
+ [\w-]+ # Plain word
+ |
+ (?&json) # JSON object
+ )
+ )
+ )';
+ $regex = '/' . $defs . '\b
+ (?<k>[\w-]+) # Key
+ \b
+ (?:\s*
+ = # First sub-value
+ \s*
+ (?<v>
+ (?&value)
+ (?:\s*
+ , # Sub-vals 1..N
+ \s*
+ (?&value)
+ )*
+ )
+ )?
+ /x';
+ $valueregex = '/' . $defs . '(?&value)/x';
+
+ if ( preg_match_all( $regex, $instring, $matches, PREG_SET_ORDER ) ) {
+ foreach ( $matches as $bits ) {
+ $key = strtolower( $bits['k'] );
+ if ( !isset( $bits['v'] ) ) {
+ $opts[$key] = true;
+ } else {
+ preg_match_all( $valueregex, $bits['v'], $vmatches );
+ $opts[$key] = array_map( array( $this, 'cleanupOption' ), $vmatches[0] );
+ if ( count( $opts[$key] ) == 1 ) {
+ $opts[$key] = $opts[$key][0];
+ }
+ }
+ }
+ }
+ return $opts;
+ }
+
+ private function cleanupOption( $opt ) {
+ if ( substr( $opt, 0, 1 ) == '"' ) {
+ return stripcslashes( substr( $opt, 1, -1 ) );
+ }
+
+ if ( substr( $opt, 0, 2 ) == '[[' ) {
+ return substr( $opt, 2, -2 );
+ }
+
+ if ( substr( $opt, 0, 1 ) == '{' ) {
+ return FormatJson::decode( $opt, true );
+ }
+ return $opt;
+ }
+
+ /**
+ * Set up the global variables for a consistent environment for each test.
+ * Ideally this should replace the global configuration entirely.
+ * @param string $opts
+ * @param string $config
+ * @return RequestContext
+ */
+ private function setupGlobals( $opts = '', $config = '' ) {
+ global $IP;
+
+ # Find out values for some special options.
+ $lang =
+ self::getOptionValue( 'language', $opts, 'en' );
+ $variant =
+ self::getOptionValue( 'variant', $opts, false );
+ $maxtoclevel =
+ self::getOptionValue( 'wgMaxTocLevel', $opts, 999 );
+ $linkHolderBatchSize =
+ self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 );
+
+ $settings = array(
+ 'wgServer' => 'http://example.org',
+ 'wgServerName' => 'example.org',
+ 'wgScript' => '/index.php',
+ 'wgScriptPath' => '/',
+ 'wgArticlePath' => '/wiki/$1',
+ 'wgActionPaths' => array(),
+ 'wgLockManagers' => array( array(
+ 'name' => 'fsLockManager',
+ 'class' => 'FSLockManager',
+ 'lockDirectory' => $this->uploadDir . '/lockdir',
+ ), array(
+ 'name' => 'nullLockManager',
+ 'class' => 'NullLockManager',
+ ) ),
+ 'wgLocalFileRepo' => array(
+ 'class' => 'LocalRepo',
+ 'name' => 'local',
+ 'url' => 'http://example.com/images',
+ 'hashLevels' => 2,
+ 'transformVia404' => false,
+ 'backend' => new FSFileBackend( array(
+ 'name' => 'local-backend',
+ 'wikiId' => wfWikiId(),
+ 'containerPaths' => array(
+ 'local-public' => $this->uploadDir,
+ 'local-thumb' => $this->uploadDir . '/thumb',
+ 'local-temp' => $this->uploadDir . '/temp',
+ 'local-deleted' => $this->uploadDir . '/delete',
+ )
+ ) )
+ ),
+ 'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
+ 'wgUploadNavigationUrl' => false,
+ 'wgStylePath' => '/skins',
+ 'wgSitename' => 'MediaWiki',
+ 'wgLanguageCode' => $lang,
+ 'wgDBprefix' => $this->db->getType() != 'oracle' ? 'parsertest_' : 'pt_',
+ 'wgRawHtml' => self::getOptionValue( 'wgRawHtml', $opts, false ),
+ 'wgLang' => null,
+ 'wgContLang' => null,
+ 'wgNamespacesWithSubpages' => array( 0 => isset( $opts['subpage'] ) ),
+ 'wgMaxTocLevel' => $maxtoclevel,
+ 'wgCapitalLinks' => true,
+ 'wgNoFollowLinks' => true,
+ 'wgNoFollowDomainExceptions' => array(),
+ 'wgThumbnailScriptPath' => false,
+ 'wgUseImageResize' => true,
+ 'wgSVGConverter' => 'null',
+ 'wgSVGConverters' => array( 'null' => 'echo "1">$output' ),
+ 'wgLocaltimezone' => 'UTC',
+ 'wgAllowExternalImages' => self::getOptionValue( 'wgAllowExternalImages', $opts, true ),
+ 'wgThumbLimits' => array( self::getOptionValue( 'thumbsize', $opts, 180 ) ),
+ 'wgDefaultLanguageVariant' => $variant,
+ 'wgVariantArticlePath' => false,
+ 'wgGroupPermissions' => array( '*' => array(
+ 'createaccount' => true,
+ 'read' => true,
+ 'edit' => true,
+ 'createpage' => true,
+ 'createtalk' => true,
+ ) ),
+ 'wgNamespaceProtection' => array( NS_MEDIAWIKI => 'editinterface' ),
+ 'wgDefaultExternalStore' => array(),
+ 'wgForeignFileRepos' => array(),
+ 'wgLinkHolderBatchSize' => $linkHolderBatchSize,
+ 'wgExperimentalHtmlIds' => false,
+ 'wgExternalLinkTarget' => false,
+ 'wgHtml5' => true,
+ 'wgWellFormedXml' => true,
+ 'wgAllowMicrodataAttributes' => true,
+ 'wgAdaptiveMessageCache' => true,
+ 'wgDisableLangConversion' => false,
+ 'wgDisableTitleConversion' => false,
+ // Tidy options.
+ // We always set 'wgUseTidy' to false when parsing, but certain
+ // test-running modes still use tidy if available, so ensure
+ // that the tidy-related options are all set to their defaults.
+ 'wgUseTidy' => false,
+ 'wgAlwaysUseTidy' => false,
+ 'wgDebugTidy' => false,
+ 'wgTidyConf' => $IP . '/includes/tidy.conf',
+ 'wgTidyOpts' => '',
+ 'wgTidyInternal' => $this->tidySupport->isInternal(),
+ );
+
+ if ( $config ) {
+ $configLines = explode( "\n", $config );
+
+ foreach ( $configLines as $line ) {
+ list( $var, $value ) = explode( '=', $line, 2 );
+
+ $settings[$var] = eval( "return $value;" );
+ }
+ }
+
+ $this->savedGlobals = array();
+
+ /** @since 1.20 */
+ wfRunHooks( 'ParserTestGlobals', array( &$settings ) );
+
+ foreach ( $settings as $var => $val ) {
+ if ( array_key_exists( $var, $GLOBALS ) ) {
+ $this->savedGlobals[$var] = $GLOBALS[$var];
+ }
+
+ $GLOBALS[$var] = $val;
+ }
+
+ $GLOBALS['wgContLang'] = Language::factory( $lang );
+ $GLOBALS['wgMemc'] = new EmptyBagOStuff;
+
+ $context = new RequestContext();
+ $GLOBALS['wgLang'] = $context->getLanguage();
+ $GLOBALS['wgOut'] = $context->getOutput();
+ $GLOBALS['wgUser'] = $context->getUser();
+
+ // We (re)set $wgThumbLimits to a single-element array above.
+ $context->getUser()->setOption( 'thumbsize', 0 );
+
+ global $wgHooks;
+
+ $wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup';
+ $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
+
+ MagicWord::clearCache();
+
+ return $context;
+ }
+
+ /**
+ * List of temporary tables to create, without prefix.
+ * Some of these probably aren't necessary.
+ * @return array
+ */
+ private function listTables() {
+ $tables = array( 'user', 'user_properties', 'user_former_groups', 'page', 'page_restrictions',
+ 'protected_titles', 'revision', 'text', 'pagelinks', 'imagelinks',
+ 'categorylinks', 'templatelinks', 'externallinks', 'langlinks', 'iwlinks',
+ 'site_stats', 'hitcounter', 'ipblocks', 'image', 'oldimage',
+ 'recentchanges', 'watchlist', 'interwiki', 'logging',
+ 'querycache', 'objectcache', 'job', 'l10n_cache', 'redirect', 'querycachetwo',
+ 'archive', 'user_groups', 'page_props', 'category', 'msg_resource', 'msg_resource_links'
+ );
+
+ if ( in_array( $this->db->getType(), array( 'mysql', 'sqlite', 'oracle' ) ) ) {
+ array_push( $tables, 'searchindex' );
+ }
+
+ // Allow extensions to add to the list of tables to duplicate;
+ // may be necessary if they hook into page save or other code
+ // which will require them while running tests.
+ wfRunHooks( 'ParserTestTables', array( &$tables ) );
+
+ return $tables;
+ }
+
+ /**
+ * Set up a temporary set of wiki tables to work with for the tests.
+ * Currently this will only be done once per run, and any changes to
+ * the db will be visible to later tests in the run.
+ */
+ public function setupDatabase() {
+ global $wgDBprefix;
+
+ if ( $this->databaseSetupDone ) {
+ return;
+ }
+
+ $this->db = wfGetDB( DB_MASTER );
+ $dbType = $this->db->getType();
+
+ if ( $wgDBprefix === 'parsertest_' || ( $dbType == 'oracle' && $wgDBprefix === 'pt_' ) ) {
+ throw new MWException( 'setupDatabase should be called before setupGlobals' );
+ }
+
+ $this->databaseSetupDone = true;
+
+ # SqlBagOStuff broke when using temporary tables on r40209 (bug 15892).
+ # It seems to have been fixed since (r55079?), but regressed at some point before r85701.
+ # This works around it for now...
+ ObjectCache::$instances[CACHE_DB] = new HashBagOStuff;
+
+ # CREATE TEMPORARY TABLE breaks if there is more than one server
+ if ( wfGetLB()->getServerCount() != 1 ) {
+ $this->useTemporaryTables = false;
+ }
+
+ $temporary = $this->useTemporaryTables || $dbType == 'postgres';
+ $prefix = $dbType != 'oracle' ? 'parsertest_' : 'pt_';
+
+ $this->dbClone = new CloneDatabase( $this->db, $this->listTables(), $prefix );
+ $this->dbClone->useTemporaryTables( $temporary );
+ $this->dbClone->cloneTableStructure();
+
+ if ( $dbType == 'oracle' ) {
+ $this->db->query( 'BEGIN FILL_WIKI_INFO; END;' );
+ # Insert 0 user to prevent FK violations
+
+ # Anonymous user
+ $this->db->insert( 'user', array(
+ 'user_id' => 0,
+ 'user_name' => 'Anonymous' ) );
+ }
+
+ # Update certain things in site_stats
+ $this->db->insert( 'site_stats',
+ array( 'ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1 ) );
+
+ # Reinitialise the LocalisationCache to match the database state
+ Language::getLocalisationCache()->unloadAll();
+
+ # Clear the message cache
+ MessageCache::singleton()->clear();
+
+ // Remember to update newParserTests.php after changing the below
+ // (and it uses a slightly different syntax just for teh lulz)
+ $this->uploadDir = $this->setupUploadDir();
+ $user = User::createNew( 'WikiSysop' );
+ $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Foobar.jpg' ) );
+ # note that the size/width/height/bits/etc of the file
+ # are actually set by inspecting the file itself; the arguments
+ # to recordUpload2 have no effect. That said, we try to make things
+ # match up so it is less confusing to readers of the code & tests.
+ $image->recordUpload2( '', 'Upload of some lame file', 'Some lame file', array(
+ 'size' => 7881,
+ 'width' => 1941,
+ 'height' => 220,
+ 'bits' => 8,
+ 'media_type' => MEDIATYPE_BITMAP,
+ 'mime' => 'image/jpeg',
+ 'metadata' => serialize( array() ),
+ 'sha1' => wfBaseConvert( '1', 16, 36, 31 ),
+ 'fileExists' => true
+ ), $this->db->timestamp( '20010115123500' ), $user );
+
+ $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Thumb.png' ) );
+ # again, note that size/width/height below are ignored; see above.
+ $image->recordUpload2( '', 'Upload of some lame thumbnail', 'Some lame thumbnail', array(
+ 'size' => 22589,
+ 'width' => 135,
+ 'height' => 135,
+ 'bits' => 8,
+ 'media_type' => MEDIATYPE_BITMAP,
+ 'mime' => 'image/png',
+ 'metadata' => serialize( array() ),
+ 'sha1' => wfBaseConvert( '2', 16, 36, 31 ),
+ 'fileExists' => true
+ ), $this->db->timestamp( '20130225203040' ), $user );
+
+ $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Foobar.svg' ) );
+ $image->recordUpload2( '', 'Upload of some lame SVG', 'Some lame SVG', array(
+ 'size' => 12345,
+ 'width' => 240,
+ 'height' => 180,
+ 'bits' => 0,
+ 'media_type' => MEDIATYPE_DRAWING,
+ 'mime' => 'image/svg+xml',
+ 'metadata' => serialize( array() ),
+ 'sha1' => wfBaseConvert( '', 16, 36, 31 ),
+ 'fileExists' => true
+ ), $this->db->timestamp( '20010115123500' ), $user );
+
+ # This image will be blacklisted in [[MediaWiki:Bad image list]]
+ $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Bad.jpg' ) );
+ $image->recordUpload2( '', 'zomgnotcensored', 'Borderline image', array(
+ 'size' => 12345,
+ 'width' => 320,
+ 'height' => 240,
+ 'bits' => 24,
+ 'media_type' => MEDIATYPE_BITMAP,
+ 'mime' => 'image/jpeg',
+ 'metadata' => serialize( array() ),
+ 'sha1' => wfBaseConvert( '3', 16, 36, 31 ),
+ 'fileExists' => true
+ ), $this->db->timestamp( '20010115123500' ), $user );
+
+ # A DjVu file
+ $image = wfLocalFile( Title::makeTitle( NS_FILE, 'LoremIpsum.djvu' ) );
+ $image->recordUpload2( '', 'Upload a DjVu', 'A DjVu', array(
+ 'size' => 3249,
+ 'width' => 2480,
+ 'height' => 3508,
+ 'bits' => 0,
+ 'media_type' => MEDIATYPE_BITMAP,
+ 'mime' => 'image/vnd.djvu',
+ 'metadata' => '<?xml version="1.0" ?>
+<!DOCTYPE DjVuXML PUBLIC "-//W3C//DTD DjVuXML 1.1//EN" "pubtext/DjVuXML-s.dtd">
+<DjVuXML>
+<HEAD></HEAD>
+<BODY><OBJECT height="3508" width="2480">
+<PARAM name="DPI" value="300" />
+<PARAM name="GAMMA" value="2.2" />
+</OBJECT>
+<OBJECT height="3508" width="2480">
+<PARAM name="DPI" value="300" />
+<PARAM name="GAMMA" value="2.2" />
+</OBJECT>
+<OBJECT height="3508" width="2480">
+<PARAM name="DPI" value="300" />
+<PARAM name="GAMMA" value="2.2" />
+</OBJECT>
+<OBJECT height="3508" width="2480">
+<PARAM name="DPI" value="300" />
+<PARAM name="GAMMA" value="2.2" />
+</OBJECT>
+<OBJECT height="3508" width="2480">
+<PARAM name="DPI" value="300" />
+<PARAM name="GAMMA" value="2.2" />
+</OBJECT>
+</BODY>
+</DjVuXML>',
+ 'sha1' => wfBaseConvert( '', 16, 36, 31 ),
+ 'fileExists' => true
+ ), $this->db->timestamp( '20010115123600' ), $user );
+ }
+
+ public function teardownDatabase() {
+ if ( !$this->databaseSetupDone ) {
+ $this->teardownGlobals();
+ return;
+ }
+ $this->teardownUploadDir( $this->uploadDir );
+
+ $this->dbClone->destroy();
+ $this->databaseSetupDone = false;
+
+ if ( $this->useTemporaryTables ) {
+ if ( $this->db->getType() == 'sqlite' ) {
+ # Under SQLite the searchindex table is virtual and need
+ # to be explicitly destroyed. See bug 29912
+ # See also MediaWikiTestCase::destroyDB()
+ wfDebug( __METHOD__ . " explicitly destroying sqlite virtual table parsertest_searchindex\n" );
+ $this->db->query( "DROP TABLE `parsertest_searchindex`" );
+ }
+ # Don't need to do anything
+ $this->teardownGlobals();
+ return;
+ }
+
+ $tables = $this->listTables();
+
+ foreach ( $tables as $table ) {
+ if ( $this->db->getType() == 'oracle' ) {
+ $this->db->query( "DROP TABLE pt_$table DROP CONSTRAINTS" );
+ } else {
+ $this->db->query( "DROP TABLE `parsertest_$table`" );
+ }
+ }
+
+ if ( $this->db->getType() == 'oracle' ) {
+ $this->db->query( 'BEGIN FILL_WIKI_INFO; END;' );
+ }
+
+ $this->teardownGlobals();
+ }
+
+ /**
+ * Create a dummy uploads directory which will contain a couple
+ * of files in order to pass existence tests.
+ *
+ * @return string The directory
+ */
+ private function setupUploadDir() {
+ global $IP;
+
+ if ( $this->keepUploads ) {
+ $dir = wfTempDir() . '/mwParser-images';
+
+ if ( is_dir( $dir ) ) {
+ return $dir;
+ }
+ } else {
+ $dir = wfTempDir() . "/mwParser-" . mt_rand() . "-images";
+ }
+
+ // wfDebug( "Creating upload directory $dir\n" );
+ if ( file_exists( $dir ) ) {
+ wfDebug( "Already exists!\n" );
+ return $dir;
+ }
+
+ wfMkdirParents( $dir . '/3/3a', null, __METHOD__ );
+ copy( "$IP/tests/phpunit/data/parser/headbg.jpg", "$dir/3/3a/Foobar.jpg" );
+ wfMkdirParents( $dir . '/e/ea', null, __METHOD__ );
+ copy( "$IP/tests/phpunit/data/parser/wiki.png", "$dir/e/ea/Thumb.png" );
+ wfMkdirParents( $dir . '/0/09', null, __METHOD__ );
+ copy( "$IP/tests/phpunit/data/parser/headbg.jpg", "$dir/0/09/Bad.jpg" );
+ wfMkdirParents( $dir . '/f/ff', null, __METHOD__ );
+ file_put_contents( "$dir/f/ff/Foobar.svg",
+ '<?xml version="1.0" encoding="utf-8"?>' .
+ '<svg xmlns="http://www.w3.org/2000/svg"' .
+ ' version="1.1" width="240" height="180"/>' );
+ wfMkdirParents( $dir . '/5/5f', null, __METHOD__ );
+ copy( "$IP/tests/phpunit/data/parser/LoremIpsum.djvu", "$dir/5/5f/LoremIpsum.djvu" );
+
+ return $dir;
+ }
+
+ /**
+ * Restore default values and perform any necessary clean-up
+ * after each test runs.
+ */
+ private function teardownGlobals() {
+ RepoGroup::destroySingleton();
+ FileBackendGroup::destroySingleton();
+ LockManagerGroup::destroySingletons();
+ LinkCache::singleton()->clear();
+
+ foreach ( $this->savedGlobals as $var => $val ) {
+ $GLOBALS[$var] = $val;
+ }
+ }
+
+ /**
+ * Remove the dummy uploads directory
+ * @param string $dir
+ */
+ private function teardownUploadDir( $dir ) {
+ if ( $this->keepUploads ) {
+ return;
+ }
+
+ // delete the files first, then the dirs.
+ self::deleteFiles(
+ array(
+ "$dir/3/3a/Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/1000px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/1500px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/177px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/206px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/265px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/274px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/353px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/442px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/450px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/600px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg",
+
+ "$dir/e/ea/Thumb.png",
+
+ "$dir/0/09/Bad.jpg",
+
+ "$dir/5/5f/LoremIpsum.djvu",
+ "$dir/thumb/5/5f/LoremIpsum.djvu/page2-2480px-LoremIpsum.djvu.jpg",
+ "$dir/thumb/5/5f/LoremIpsum.djvu/page2-3720px-LoremIpsum.djvu.jpg",
+ "$dir/thumb/5/5f/LoremIpsum.djvu/page2-4960px-LoremIpsum.djvu.jpg",
+
+ "$dir/f/ff/Foobar.svg",
+ "$dir/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png",
+ "$dir/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png",
+ "$dir/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png",
+ "$dir/thumb/f/ff/Foobar.svg/3000px-Foobar.svg.png",
+ "$dir/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png",
+ "$dir/thumb/f/ff/Foobar.svg/4000px-Foobar.svg.png",
+ "$dir/thumb/f/ff/Foobar.svg/langde-180px-Foobar.svg.png",
+ "$dir/thumb/f/ff/Foobar.svg/langde-270px-Foobar.svg.png",
+ "$dir/thumb/f/ff/Foobar.svg/langde-360px-Foobar.svg.png",
+
+ "$dir/math/f/a/5/fa50b8b616463173474302ca3e63586b.png",
+ )
+ );
+
+ self::deleteDirs(
+ array(
+ "$dir/3/3a",
+ "$dir/3",
+ "$dir/thumb/3/3a/Foobar.jpg",
+ "$dir/thumb/3/3a",
+ "$dir/thumb/3",
+ "$dir/e/ea",
+ "$dir/e",
+ "$dir/f/ff/",
+ "$dir/f/",
+ "$dir/thumb/f/ff/Foobar.svg",
+ "$dir/thumb/f/ff/",
+ "$dir/thumb/f/",
+ "$dir/0/09/",
+ "$dir/0/",
+ "$dir/5/5f",
+ "$dir/5",
+ "$dir/thumb/5/5f/LoremIpsum.djvu",
+ "$dir/thumb/5/5f",
+ "$dir/thumb/5",
+ "$dir/thumb",
+ "$dir/math/f/a/5",
+ "$dir/math/f/a",
+ "$dir/math/f",
+ "$dir/math",
+ "$dir",
+ )
+ );
+ }
+
+ /**
+ * Delete the specified files, if they exist.
+ * @param array $files Full paths to files to delete.
+ */
+ private static function deleteFiles( $files ) {
+ foreach ( $files as $file ) {
+ if ( file_exists( $file ) ) {
+ unlink( $file );
+ }
+ }
+ }
+
+ /**
+ * Delete the specified directories, if they exist. Must be empty.
+ * @param array $dirs Full paths to directories to delete.
+ */
+ private static function deleteDirs( $dirs ) {
+ foreach ( $dirs as $dir ) {
+ if ( is_dir( $dir ) ) {
+ rmdir( $dir );
+ }
+ }
+ }
+
+ /**
+ * "Running test $desc..."
+ * @param string $desc
+ */
+ protected function showTesting( $desc ) {
+ print "Running test $desc... ";
+ }
+
+ /**
+ * Print a happy success message.
+ *
+ * Refactored in 1.22 to use ParserTestResult
+ *
+ * @param ParserTestResult $testResult
+ * @return bool
+ */
+ protected function showSuccess( ParserTestResult $testResult ) {
+ if ( $this->showProgress ) {
+ print $this->term->color( '1;32' ) . 'PASSED' . $this->term->reset() . "\n";
+ }
+
+ return true;
+ }
+
+ /**
+ * Print a failure message and provide some explanatory output
+ * about what went wrong if so configured.
+ *
+ * Refactored in 1.22 to use ParserTestResult
+ *
+ * @param ParserTestResult $testResult
+ * @return bool
+ */
+ protected function showFailure( ParserTestResult $testResult ) {
+ if ( $this->showFailure ) {
+ if ( !$this->showProgress ) {
+ # In quiet mode we didn't show the 'Testing' message before the
+ # test, in case it succeeded. Show it now:
+ $this->showTesting( $testResult->description );
+ }
+
+ print $this->term->color( '31' ) . 'FAILED!' . $this->term->reset() . "\n";
+
+ if ( $this->showOutput ) {
+ print "--- Expected ---\n{$testResult->expected}\n";
+ print "--- Actual ---\n{$testResult->actual}\n";
+ }
+
+ if ( $this->showDiffs ) {
+ print $this->quickDiff( $testResult->expected, $testResult->actual );
+ if ( !$this->wellFormed( $testResult->actual ) ) {
+ print "XML error: $this->mXmlError\n";
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Print a skipped message.
+ *
+ * @return bool
+ */
+ protected function showSkipped() {
+ if ( $this->showProgress ) {
+ print $this->term->color( '1;33' ) . 'SKIPPED' . $this->term->reset() . "\n";
+ }
+
+ return true;
+ }
+
+ /**
+ * Run given strings through a diff and return the (colorized) output.
+ * Requires writable /tmp directory and a 'diff' command in the PATH.
+ *
+ * @param string $input
+ * @param string $output
+ * @param string $inFileTail Tailing for the input file name
+ * @param string $outFileTail Tailing for the output file name
+ * @return string
+ */
+ protected function quickDiff( $input, $output,
+ $inFileTail = 'expected', $outFileTail = 'actual'
+ ) {
+ # Windows, or at least the fc utility, is retarded
+ $slash = wfIsWindows() ? '\\' : '/';
+ $prefix = wfTempDir() . "{$slash}mwParser-" . mt_rand();
+
+ $infile = "$prefix-$inFileTail";
+ $this->dumpToFile( $input, $infile );
+
+ $outfile = "$prefix-$outFileTail";
+ $this->dumpToFile( $output, $outfile );
+
+ $shellInfile = wfEscapeShellArg( $infile );
+ $shellOutfile = wfEscapeShellArg( $outfile );
+
+ global $wgDiff3;
+ // we assume that people with diff3 also have usual diff
+ $shellCommand = ( wfIsWindows() && !$wgDiff3 ) ? 'fc' : 'diff -au';
+
+ $diff = wfShellExec( "$shellCommand $shellInfile $shellOutfile" );
+
+ unlink( $infile );
+ unlink( $outfile );
+
+ return $this->colorDiff( $diff );
+ }
+
+ /**
+ * Write the given string to a file, adding a final newline.
+ *
+ * @param string $data
+ * @param string $filename
+ */
+ private function dumpToFile( $data, $filename ) {
+ $file = fopen( $filename, "wt" );
+ fwrite( $file, $data . "\n" );
+ fclose( $file );
+ }
+
+ /**
+ * Colorize unified diff output if set for ANSI color output.
+ * Subtractions are colored blue, additions red.
+ *
+ * @param string $text
+ * @return string
+ */
+ protected function colorDiff( $text ) {
+ return preg_replace(
+ array( '/^(-.*)$/m', '/^(\+.*)$/m' ),
+ array( $this->term->color( 34 ) . '$1' . $this->term->reset(),
+ $this->term->color( 31 ) . '$1' . $this->term->reset() ),
+ $text );
+ }
+
+ /**
+ * Show "Reading tests from ..."
+ *
+ * @param string $path
+ */
+ public function showRunFile( $path ) {
+ print $this->term->color( 1 ) .
+ "Reading tests from \"$path\"..." .
+ $this->term->reset() .
+ "\n";
+ }
+
+ /**
+ * Insert a temporary test article
+ * @param string $name The title, including any prefix
+ * @param string $text The article text
+ * @param int $line The input line number, for reporting errors
+ * @param bool $ignoreDuplicate Whether to silently ignore duplicate pages
+ */
+ public static function addArticle( $name, $text, $line = 'unknown', $ignoreDuplicate = '' ) {
+ global $wgCapitalLinks;
+
+ $oldCapitalLinks = $wgCapitalLinks;
+ $wgCapitalLinks = true; // We only need this from SetupGlobals() See r70917#c8637
+
+ $text = self::chomp( $text );
+ $name = self::chomp( $name );
+
+ $title = Title::newFromText( $name );
+
+ if ( is_null( $title ) ) {
+ throw new MWException( "invalid title '$name' at line $line\n" );
+ }
+
+ $page = WikiPage::factory( $title );
+ $page->loadPageData( 'fromdbmaster' );
+
+ if ( $page->exists() ) {
+ if ( $ignoreDuplicate == 'ignoreduplicate' ) {
+ return;
+ } else {
+ throw new MWException( "duplicate article '$name' at line $line\n" );
+ }
+ }
+
+ $page->doEditContent( ContentHandler::makeContent( $text, $title ), '', EDIT_NEW );
+
+ $wgCapitalLinks = $oldCapitalLinks;
+ }
+
+ /**
+ * Steal a callback function from the primary parser, save it for
+ * application to our scary parser. If the hook is not installed,
+ * abort processing of this file.
+ *
+ * @param string $name
+ * @return bool True if tag hook is present
+ */
+ public function requireHook( $name ) {
+ global $wgParser;
+
+ $wgParser->firstCallInit(); // make sure hooks are loaded.
+
+ if ( isset( $wgParser->mTagHooks[$name] ) ) {
+ $this->hooks[$name] = $wgParser->mTagHooks[$name];
+ } else {
+ echo " This test suite requires the '$name' hook extension, skipping.\n";
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Steal a callback function from the primary parser, save it for
+ * application to our scary parser. If the hook is not installed,
+ * abort processing of this file.
+ *
+ * @param string $name
+ * @return bool True if function hook is present
+ */
+ public function requireFunctionHook( $name ) {
+ global $wgParser;
+
+ $wgParser->firstCallInit(); // make sure hooks are loaded.
+
+ if ( isset( $wgParser->mFunctionHooks[$name] ) ) {
+ $this->functionHooks[$name] = $wgParser->mFunctionHooks[$name];
+ } else {
+ echo " This test suite requires the '$name' function hook extension, skipping.\n";
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Steal a callback function from the primary parser, save it for
+ * application to our scary parser. If the hook is not installed,
+ * abort processing of this file.
+ *
+ * @param string $name
+ * @return bool True if function hook is present
+ */
+ public function requireTransparentHook( $name ) {
+ global $wgParser;
+
+ $wgParser->firstCallInit(); // make sure hooks are loaded.
+
+ if ( isset( $wgParser->mTransparentTagHooks[$name] ) ) {
+ $this->transparentHooks[$name] = $wgParser->mTransparentTagHooks[$name];
+ } else {
+ echo " This test suite requires the '$name' transparent hook extension, skipping.\n";
+ return false;
+ }
+
+ return true;
+ }
+
+ private function wellFormed( $text ) {
+ $html =
+ Sanitizer::hackDocType() .
+ '<html>' .
+ $text .
+ '</html>';
+
+ $parser = xml_parser_create( "UTF-8" );
+
+ # case folding violates XML standard, turn it off
+ xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, false );
+
+ if ( !xml_parse( $parser, $html, true ) ) {
+ $err = xml_error_string( xml_get_error_code( $parser ) );
+ $position = xml_get_current_byte_index( $parser );
+ $fragment = $this->extractFragment( $html, $position );
+ $this->mXmlError = "$err at byte $position:\n$fragment";
+ xml_parser_free( $parser );
+
+ return false;
+ }
+
+ xml_parser_free( $parser );
+
+ return true;
+ }
+
+ private function extractFragment( $text, $position ) {
+ $start = max( 0, $position - 10 );
+ $before = $position - $start;
+ $fragment = '...' .
+ $this->term->color( 34 ) .
+ substr( $text, $start, $before ) .
+ $this->term->color( 0 ) .
+ $this->term->color( 31 ) .
+ $this->term->color( 1 ) .
+ substr( $text, $position, 1 ) .
+ $this->term->color( 0 ) .
+ $this->term->color( 34 ) .
+ substr( $text, $position + 1, 9 ) .
+ $this->term->color( 0 ) .
+ '...';
+ $display = str_replace( "\n", ' ', $fragment );
+ $caret = ' ' .
+ str_repeat( ' ', $before ) .
+ $this->term->color( 31 ) .
+ '^' .
+ $this->term->color( 0 );
+
+ return "$display\n$caret";
+ }
+
+ static function getFakeTimestamp( &$parser, &$ts ) {
+ $ts = 123; //parsed as '1970-01-01T00:02:03Z'
+ return true;
+ }
+}
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
new file mode 100644
index 00000000..f915922f
--- /dev/null
+++ b/tests/parser/parserTests.txt
@@ -0,0 +1,21904 @@
+# MediaWiki Parser test cases
+# Some taken from http://meta.wikimedia.org/wiki/Parser_testing
+# All (C) their respective authors and released under the GPL
+#
+# The syntax should be fairly self-explanatory.
+#
+# Currently supported test options:
+# One of the following three:
+#
+# (default) generate HTML output
+# pst apply pre-save transform
+# msg apply message transform
+#
+# Plus any combination of these:
+#
+# cat add category links
+# ill add inter-language links
+# subpage enable subpages (disabled by default)
+# noxml don't check for XML well formdness
+# title=[[XXX]] run test using article title XXX
+# language=XXX set content language to XXX for this test
+# variant=XXX set the variant of language for this test (eg zh-tw)
+# disabled do not run test
+# parsoid parsoid-specific options (not run by PHP parser unless
+# the test includes an html/php section)
+# php php-only test (not run by the parsoid parser unless
+# the test includes an html/parsoid section)
+# showtitle make the first line the title
+# comment run through Linker::formatComment() instead of main parser
+# local format section links in edit comment text as local links
+# notoc disable table of contents
+# thumbsize=NNN set the default thumb size to NNNpx for this test
+#
+# You can also set the following parser properties via test options:
+# wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
+# wgLinkHolderBatchSize, wgRawHtml
+#
+# For testing purposes, temporary articles can created:
+# !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
+# where '/' denotes a newline.
+
+# This is the standard article assumed to exist.
+!! article
+Main Page
+!! text
+blah blah
+!! endarticle
+
+!!article
+Foo
+!!text
+FOO
+!!endarticle
+
+!!article
+Template:Foo
+!!text
+FOO
+!!endarticle
+
+!! article
+Template:Blank
+!! text
+!! endarticle
+
+!! article
+Template:pipe
+!! text
+|
+!! endarticle
+
+!!article
+MediaWiki:bad image list
+!!text
+* [[File:Bad.jpg]] except [[Nasty page]]
+!!endarticle
+
+!! article
+Template:inner list
+!! text
+* item 1
+!! endarticle
+
+!! article
+Template:tbl-start
+!! text
+{|
+!! endarticle
+
+!! article
+Template:tbl-end
+!! text
+|}
+!! endarticle
+
+!! article
+Template:echo
+!! text
+{{{1}}}
+!! endarticle
+
+!! article
+Template:echo_with_span
+!! text
+<span>{{{1}}}</span>
+!! endarticle
+
+!! article
+Template:echo_with_div
+!! text
+<div>{{{1}}}</div>
+!! endarticle
+
+!! article
+Template:attr_str
+!! text
+{{{1}}}="{{{2}}}"
+!! endarticle
+
+!! article
+Template:table_attribs
+!! text
+<noinclude>
+|</noinclude>style="color: red"| Foo
+!! endarticle
+
+!! article
+Template:table_cells
+!! text
+{{table_attribs}} || Bar || Baz
+!! endarticle
+
+!! article
+Template:image_attribs
+!! text
+<noinclude>
+[[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
+!! endarticle
+
+!! article
+A?b
+!! text
+Weirdo titles!
+!! endarticle
+
+!!article
+Template:Bullet
+!!text
+* Bar
+!!endarticle
+
+!!article
+Template:OpenTable
+!!text
+{|
+!!endarticle
+
+###
+### Basic tests
+###
+!! test
+Blank input
+!! wikitext
+!! html
+!! end
+
+
+!! test
+Simple paragraph
+!! wikitext
+This is a simple paragraph.
+!! html
+<p>This is a simple paragraph.
+</p>
+!! end
+
+!! test
+Paragraphs with extra newline spacing
+!! wikitext
+foo
+
+bar
+
+
+baz
+
+
+
+booz
+!! html
+<p>foo
+</p><p>bar
+</p><p><br />
+baz
+</p><p><br />
+</p><p>booz
+</p>
+!! end
+
+!! test
+Paragraphs with newline spacing with comment lines in between
+!! wikitext
+----
+a
+<!--foo-->
+b
+----
+a
+<!--foo--><!--More than 1 comment, still stripped-->
+b
+----
+a
+ <!--foo--> <!----> <!-- bar -->
+b
+----
+a
+<!--foo-->
+
+b
+----
+a
+
+<!--foo-->
+b
+----
+a
+<!--foo-->
+
+
+b
+----
+a
+
+
+<!--foo-->
+b
+----
+!! html
+<hr />
+<p>a
+b
+</p>
+<hr />
+<p>a
+b
+</p>
+<hr />
+<p>a
+b
+</p>
+<hr />
+<p>a
+</p><p>b
+</p>
+<hr />
+<p>a
+</p><p>b
+</p>
+<hr />
+<p>a
+</p><p><br />
+b
+</p>
+<hr />
+<p>a
+</p><p><br />
+b
+</p>
+<hr />
+
+!! end
+
+!! test
+Paragraphs with newline spacing with non-empty white-space lines in between
+!! wikitext
+----
+a
+
+b
+----
+a
+
+
+b
+----
+!! html
+<hr />
+<p>a
+</p><p>b
+</p>
+<hr />
+<p>a
+</p><p><br />
+b
+</p>
+<hr />
+
+!! end
+
+!! test
+Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
+!! wikitext
+----
+a
+ <!--foo-->
+b
+----
+a
+ <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
+b
+----
+a
+
+<!--foo-->
+ <!--bar-->
+b
+----
+a
+
+ <!--foo-->
+ <!--bar-->
+
+b
+----
+!! html
+<hr />
+<p>a
+b
+</p>
+<hr />
+<p>a
+b
+</p>
+<hr />
+<p>a
+</p><p>b
+</p>
+<hr />
+<p>a
+</p><p><br />
+b
+</p>
+<hr />
+
+!! end
+
+!! test
+Extra newlines: More paragraphs with indented comment
+!! wikitext
+a
+
+ <!--boo-->
+
+b
+!! html
+<p>a
+</p><p><br />
+b
+</p>
+!!end
+
+!! test
+Extra newlines followed by heading
+!! wikitext
+a
+
+
+
+=b=
+[[a]]
+
+
+=b=
+!! html
+<p>a
+</p><p><br />
+</p>
+<h1><span class="mw-headline" id="b">b</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: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
+<p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
+</p><p><br />
+</p>
+<h1><span class="mw-headline" id="b_2">b</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: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
+
+!! end
+
+!! test
+Extra newlines between heading and content are swallowed
+!! wikitext
+=b=
+
+
+
+[[a]]
+!! html
+<h1><span class="mw-headline" id="b">b</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: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
+<p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
+</p>
+!! end
+
+!! test
+Parsing an URL
+!! wikitext
+http://fr.wikipedia.org/wiki/🍺
+<!-- EasterEgg we love beer, better be able be able to link to it -->
+!! html
+<p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
+</p>
+!! end
+
+# Note that the html+tidy output removes the spaces after the <li>,
+# which is a bug (http://sourceforge.net/p/tidy/bugs/945/, etc).
+# This is an issue for all tests with lists. We intentionally do
+# *not* add html+tidy clauses for these, as we don't want to
+# document/test the broken behavior. (Parsoid matches the non-tidy
+# output in these cases.)
+
+!! test
+Simple list
+!! wikitext
+* Item 1
+* Item 2
+!! html
+<ul><li> Item 1</li>
+<li> Item 2</li></ul>
+
+!! end
+
+!! test
+Italics and bold
+!! wikitext
+* plain
+* plain''italic''plain
+* plain''italic''plain''italic''plain
+* plain'''bold'''plain
+* plain'''bold'''plain'''bold'''plain
+* plain''italic''plain'''bold'''plain
+* plain'''bold'''plain''italic''plain
+* plain''italic'''bold-italic'''italic''plain
+* plain'''bold''bold-italic''bold'''plain
+* plain'''''bold-italic'''italic''plain
+* plain'''''bold-italic''bold'''plain
+* plain''italic'''bold-italic'''''plain
+* plain'''bold''bold-italic'''''plain
+* plain l'''italic''plain
+* plain l''''bold''' plain
+!! html
+<ul><li> plain</li>
+<li> plain<i>italic</i>plain</li>
+<li> plain<i>italic</i>plain<i>italic</i>plain</li>
+<li> plain<b>bold</b>plain</li>
+<li> plain<b>bold</b>plain<b>bold</b>plain</li>
+<li> plain<i>italic</i>plain<b>bold</b>plain</li>
+<li> plain<b>bold</b>plain<i>italic</i>plain</li>
+<li> plain<i>italic<b>bold-italic</b>italic</i>plain</li>
+<li> plain<b>bold<i>bold-italic</i>bold</b>plain</li>
+<li> plain<i><b>bold-italic</b>italic</i>plain</li>
+<li> plain<b><i>bold-italic</i>bold</b>plain</li>
+<li> plain<i>italic<b>bold-italic</b></i>plain</li>
+<li> plain<b>bold<i>bold-italic</i></b>plain</li>
+<li> plain l'<i>italic</i>plain</li>
+<li> plain l'<b>bold</b> plain</li></ul>
+
+!! end
+
+# this example taken from the [[simple:Moon]] article (bug 47326)
+!! test
+Italics and possessives (1)
+!! wikitext
+obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
+!! html
+<p>obtained by <i><a href="/index.php?title=Lunar_Prospector&amp;action=edit&amp;redlink=1" class="new" title="Lunar Prospector (page does not exist)">Lunar Prospector</a>'</i>s gamma-ray spectrometer
+</p>
+!! end
+
+# this example taken from [[en:Flaming Pie]] (bug 49926)
+!! test
+Italics and possessives (2)
+!! wikitext
+'''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
+!! html
+<p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
+</p>
+!! end
+
+# this example taken from [[en:Dictionary]] (bug 49926)
+!! test
+Italics and possessives (3)
+!! wikitext
+The first monolingual dictionary written in a Romance language was ''Sebastián Covarrubias''' ''Tesoro de la lengua castellana o española'', published in 1611 in Madrid. In 1612 the first edition of the ''Vocabolario dell'[[Accademia della Crusca]]'', for Italian, was published. In 1690 in Rotterdam was published, posthumously, the ''Dictionnaire Universel''.
+!! html
+<p>The first monolingual dictionary written in a Romance language was <i>Sebastián Covarrubias'</i> <i>Tesoro de la lengua castellana o española</i>, published in 1611 in Madrid. In 1612 the first edition of the <i>Vocabolario dell'<a href="/index.php?title=Accademia_della_Crusca&amp;action=edit&amp;redlink=1" class="new" title="Accademia della Crusca (page does not exist)">Accademia della Crusca</a></i>, for Italian, was published. In 1690 in Rotterdam was published, posthumously, the <i>Dictionnaire Universel</i>.
+</p>
+!! end
+
+
+###
+### 2-quote opening sequence tests
+###
+!! test
+Italics and bold: 2-quote opening sequence: (2,2)
+!! wikitext
+''foo''
+!! html
+<p><i>foo</i>
+</p>
+!!end
+
+
+!! test
+Italics and bold: 2-quote opening sequence: (2,3)
+!! options
+parsoid=wt2html
+!! wikitext
+''foo'''
+!! html/*
+<p><i>foo'</i>
+</p>
+!!end
+
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: 2-quote opening sequence: (2,3) w/ nowiki
+!! wikitext
+''<nowiki>foo'</nowiki>''
+!! html
+<p><i>foo'</i>
+</p>
+!! end
+
+
+!! test
+Italics and bold: 2-quote opening sequence: (2,4)
+!! options
+parsoid=wt2html
+!! wikitext
+''foo''''
+!! html/*
+<p><i>foo''</i>
+</p>
+!!end
+
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
+!! wikitext
+''<nowiki>foo''</nowiki>''
+!! html
+<p><i>foo''</i>
+</p>
+!! end
+
+
+# The PHP parser strips the empty tags out for giggles; parsoid doesn't.
+!! test
+Italics and bold: 2-quote opening sequence: (2,5)
+!! options
+parsoid=wt2html
+!! wikitext
+''foo'''''
+!! html/php
+<p><i>foo</i>
+</p>
+!! html/parsoid
+<p><i>foo</i><b></b>
+</p>
+!!end
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
+!! wikitext
+''foo'''''<nowiki/>'''
+!! html/php
+<p><i>foo</i>
+</p>
+!! html/parsoid
+<p><i>foo</i><b></b>
+</p>
+!! end
+
+
+###
+### 3-quote opening sequence tests
+###
+
+!! test
+Italics and bold: 3-quote opening sequence: (3,2)
+!! wikitext
+'''foo''
+!! html
+<p>'<i>foo</i>
+</p>
+!!end
+
+
+!! test
+Italics and bold: 3-quote opening sequence: (3,3)
+!! wikitext
+'''foo'''
+!! html
+<p><b>foo</b>
+</p>
+!!end
+
+
+!! test
+Italics and bold: 3-quote opening sequence: (3,4)
+!! options
+parsoid=wt2html
+!! wikitext
+'''foo''''
+!! html/*
+<p><b>foo'</b>
+</p>
+!!end
+
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: 3-quote opening sequence: (3,4) w/ nowiki
+!! wikitext
+'''<nowiki>foo'</nowiki>'''
+!! html
+<p><b>foo'</b>
+</p>
+!! end
+
+
+# The PHP parser strips the empty tags out for giggles; parsoid doesn't.
+!! test
+Italics and bold: 3-quote opening sequence: (3,5)
+!! options
+parsoid=wt2html
+!! wikitext
+'''foo'''''
+!! html/php
+<p><b>foo</b>
+</p>
+!! html/parsoid
+<p><b>foo</b><i></i>
+</p>
+!!end
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
+!! wikitext
+'''foo'''''<nowiki/>''
+!! html/php
+<p><b>foo</b>
+</p>
+!! html/parsoid
+<p><b>foo</b><i></i>
+</p>
+!! end
+
+
+###
+### 4-quote opening sequence tests
+###
+
+!! test
+Italics and bold: 4-quote opening sequence: (4,2)
+!! options
+parsoid=wt2html
+!! wikitext
+''''foo''
+!! html/*
+<p>''<i>foo</i>
+</p>
+!!end
+
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
+!! wikitext
+<nowiki>''</nowiki>''foo''
+!! html
+<p>''<i>foo</i>
+</p>
+!! end
+
+
+!! test
+Italics and bold: 4-quote opening sequence: (4,3)
+!! wikitext
+''''foo'''
+!! html
+<p>'<b>foo</b>
+</p>
+!!end
+
+
+!! test
+Italics and bold: 4-quote opening sequence: (4,4)
+!! options
+parsoid=wt2html
+!! wikitext
+''''foo''''
+!! html/*
+<p>'<b>foo'</b>
+</p>
+!!end
+
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
+!! wikitext
+''''<nowiki>foo'</nowiki>'''
+!! html
+<p>'<b>foo'</b>
+</p>
+!! end
+
+
+# The PHP parser strips the empty tags out for giggles; parsoid doesn't.
+!! test
+Italics and bold: 4-quote opening sequence: (4,5)
+!! options
+parsoid=wt2html
+!! wikitext
+''''foo'''''
+!! html/php
+<p>'<b>foo</b>
+</p>
+!! html/parsoid
+<p>'<b>foo</b><i></i>
+</p>
+!!end
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
+!! wikitext
+''''foo'''''<nowiki/>''
+!! html/php
+<p>'<b>foo</b>
+</p>
+!! html/parsoid
+<p>'<b>foo</b><i></i>
+</p>
+!! end
+
+
+###
+### 5-quote opening sequence tests
+###
+
+!! test
+Italics and bold: 5-quote opening sequence: (5,2)
+!! options
+parsoid=wt2html
+!! wikitext
+'''''foo''
+!! html/*
+<p><b><i>foo</i></b>
+</p>
+!!end
+
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+# skipping wt2html and html2html because it wants to put <i> before <b>
+!! test
+Italics and bold: 5-quote opening sequence: (5,2+3)
+!! options
+parsoid=wt2wt,html2wt
+!! wikitext
+'''''foo'''''
+!! html
+<p><b><i>foo</i></b>
+</p>
+!! end
+
+!! test
+Italics and bold: 5-quote opening sequence: (5,3)
+!! options
+parsoid=wt2html
+!! wikitext
+'''''foo'''
+!! html/*
+<p><i><b>foo</b></i>
+</p>
+!!end
+
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: 5-quote opening sequence: (5,3+2)
+!! wikitext
+'''''foo'''''
+!! html
+<p><i><b>foo</b></i>
+</p>
+!! end
+
+
+!! test
+Italics and bold: 5-quote opening sequence: (5,4)
+!! options
+parsoid=wt2html
+!! wikitext
+'''''foo''''
+!! html/*
+<p><i><b>foo'</b></i>
+</p>
+!!end
+
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: 5-quote opening sequence: (5,4+2) w/ nowiki
+!! wikitext
+'''''<nowiki>foo'</nowiki>'''''
+!! html
+<p><i><b>foo'</b></i>
+</p>
+!! end
+
+
+!! test
+Italics and bold: 5-quote opening sequence: (5,5)
+!! wikitext
+'''''foo'''''
+!! html
+<p><i><b>foo</b></i>
+</p>
+!!end
+
+###
+### multiple quote sequences in a line
+###
+!! test
+Italics and bold: multiple quote sequences: (2,4,2)
+!! options
+parsoid=wt2html
+!! wikitext
+''foo''''bar''
+!! html/*
+<p><i>foo'<b>bar</b></i>
+</p>
+!!end
+
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
+!! wikitext
+''<nowiki>foo'</nowiki>'''bar'''''
+!! html
+<p><i>foo'<b>bar</b></i>
+</p>
+!! end
+
+
+!! test
+Italics and bold: multiple quote sequences: (2,4,3)
+!! options
+parsoid=wt2html
+!! wikitext
+''foo''''bar'''
+!! html/*
+<p><i>foo'<b>bar</b></i>
+</p>
+!!end
+
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
+!! wikitext
+''<nowiki>foo'</nowiki>'''bar'''''
+!! html
+<p><i>foo'<b>bar</b></i>
+</p>
+!! end
+
+
+!! test
+Italics and bold: multiple quote sequences: (2,4,4)
+!! options
+parsoid=wt2html
+!! wikitext
+''foo''''bar''''
+!! html/*
+<p><i>foo'<b>bar'</b></i>
+</p>
+!!end
+
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
+!! wikitext
+''<nowiki>foo'</nowiki>'''<nowiki>bar'</nowiki>'''''
+!! html
+<p><i>foo'<b>bar'</b></i>
+</p>
+!! end
+
+
+# The PHP parser strips the empty tags out for giggles; parsoid doesn't.
+!! test
+Italics and bold: multiple quote sequences: (3,4,2)
+!! options
+parsoid=wt2html
+!! wikitext
+'''foo''''bar''
+!! html/php
+<p><b>foo'</b>bar
+</p>
+!! html/parsoid
+<p><b>foo'</b>bar<i></i>
+</p>
+!!end
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
+!! options
+parsoid
+!! wikitext
+'''<nowiki>foo'</nowiki>'''bar''<nowiki/>''
+!! html/php
+<p><b>foo'</b>bar
+</p>
+!! html/parsoid
+<p><b><span typeof="mw:Nowiki">foo'</span></b>bar<i></i>
+</p>
+!! end
+
+
+# The PHP parser strips the empty tags out for giggles; parsoid doesn't.
+!! test
+Italics and bold: multiple quote sequences: (3,4,3)
+!! options
+parsoid=wt2html
+!! wikitext
+'''foo''''bar'''
+!! html/php
+<p><b>foo'</b>bar
+</p>
+!! html/parsoid
+<p><b>foo'</b>bar<b></b>
+</p>
+!!end
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+!! test
+Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
+!! wikitext
+'''<nowiki>foo'</nowiki>'''bar'''<nowiki/>'''
+!! html/php
+<p><b>foo'</b>bar
+</p>
+!! html/parsoid
+<p><b><span typeof="mw:Nowiki">foo'</span></b>bar<b></b>
+</p>
+!! end
+
+###
+### other quote tests
+###
+!! test
+Italics and bold: other quote tests: (2,3,5)
+!! wikitext
+''this is about '''foo's family'''''
+!! html
+<p><i>this is about <b>foo's family</b></i>
+</p>
+!!end
+
+
+!! test
+Italics and bold: other quote tests: (2,(3,3),2)
+!! wikitext
+''this is about '''foo's''' family''
+!! html
+<p><i>this is about <b>foo's</b> family</i>
+</p>
+!!end
+
+
+!! test
+Italics and bold: other quote tests: (3,2,3,2)
+!! options
+parsoid=wt2html
+!! wikitext
+'''this is about ''foo'''s family''
+!! html/*
+<p><b>this is about <i>foo</i></b><i>s family</i>
+</p>
+!!end
+
+
+# same html as previous, but wikitext adjusted to match parsoid html2wt
+# add 'parsoid' option to use 'parsoid' normalization of the placeholder
+!! test
+Italics and bold: other quote tests: (3,2,3+2+2,2)
+!! options
+parsoid
+!! wikitext
+'''this is about ''foo'''''<nowiki/>''s family''
+!! html/*
+<p><b>this is about <i>foo</i></b><i>s family</i>
+</p>
+!! end
+
+
+!! test
+Italics and bold: other quote tests: (3,2,3,3)
+!! options
+!! wikitext
+'''this is about ''foo'''s family'''
+!! html
+<p>'<i>this is about </i>foo<b>s family</b>
+</p>
+!!end
+
+
+!! test
+Italics and bold: other quote tests: (3,(2,2),3)
+!! wikitext
+'''this is about ''foo's'' family'''
+!! html
+<p><b>this is about <i>foo's</i> family</b>
+</p>
+!!end
+
+
+!! test
+Italicized possessive
+!! wikitext
+The ''[[Main Page]]'''s talk page.
+!! html
+<p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
+</p>
+!! end
+
+!! test
+Parsoid only: Quote balancing context should be restricted to td/th cells on the same wikitext line
+(Requires tidy for PHP parser output to be fixed up)
+!! options
+parsoid=wt2html,wt2wt
+!! wikitext
+{|
+!''a!!''b
+|''a||''b
+|}
+!! html/php+tidy
+<table>
+<tr>
+<th><i>a</i></th>
+<th><i>b</i></th>
+<td><i>a</i></td>
+<td><i>b</i></td>
+</tr>
+</table>
+!! html/parsoid
+<table>
+<tbody><tr><th><i>a</i></th><th><i>b</i></th>
+<td><i>a</i></td><td><i>b</i></td></tr>
+</tbody></table>
+!! end
+
+###
+### Non-html5 tags
+###
+
+!! test
+Non-html5 tags should be accepted
+!! wikitext
+<center>''foo''</center>
+<big>''foo''</big>
+<font>''foo''</font>
+<strike>''foo''</strike>
+<tt>''foo''</tt>
+!! html
+<center><i>foo</i></center>
+<p><big><i>foo</i></big>
+<font><i>foo</i></font>
+<strike><i>foo</i></strike>
+<tt><i>foo</i></tt>
+</p>
+!! end
+
+!! test
+<wbr> is valid wikitext (bug 52468)
+!! wikitext
+<wbr>
+!! html
+<p><wbr />
+</p>
+!! end
+
+# <strike> is HTML4, <s> is HTML4/5.
+!! test
+<s> or <strike> for strikethrough
+!! wikitext
+<strike>strike</strike>
+
+<s>s</s>
+!! html
+<p><strike>strike</strike>
+</p><p><s>s</s>
+</p>
+!! end
+
+## a not permitted
+## i,b,br omitted
+!! test
+Text-level semantic html elements in wikitext
+!! wikitext
+<em>text</em>
+<strong>text</strong>
+<small>text</small>
+<s>text</s>
+<cite>text</cite>
+<q>text</q>
+<dfn>text</dfn>
+<abbr>text</abbr>
+<data>text</data>
+<time>text</time>
+<code>text</code>
+<var>text</var>
+<samp>text</samp>
+<kbd>text</kbd>
+<sub>text</sub>
+<u>text</u>
+<mark>text</mark>
+<ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
+<bdi>text</bdi>
+<bdo>text</bdo>
+<span>text</span>
+<wbr />
+!! html
+<p><em>text</em>
+<strong>text</strong>
+<small>text</small>
+<s>text</s>
+<cite>text</cite>
+<q>text</q>
+<dfn>text</dfn>
+<abbr>text</abbr>
+<data>text</data>
+<time>text</time>
+<code>text</code>
+<var>text</var>
+<samp>text</samp>
+<kbd>text</kbd>
+<sub>text</sub>
+<u>text</u>
+<mark>text</mark>
+<ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
+<bdi>text</bdi>
+<bdo>text</bdo>
+<span>text</span>
+<wbr />
+</p>
+!! end
+
+# test cases taken from
+# http://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
+!! test
+Ruby markup (W3C-style)
+!! wikitext
+; Mono-ruby for individual base characters
+: <ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
+; Group ruby
+: <ruby>今日<rt>きょう</rt></ruby>
+; Jukugo ruby
+: <ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
+; Inline ruby
+: <ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
+; Double-sided ruby
+: <ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
+<ruby>
+<rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
+<rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
+<rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
+</ruby>
+!! html
+<dl><dt> Mono-ruby for individual base characters</dt>
+<dd> <ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
+<dt> Group ruby</dt>
+<dd> <ruby>今日<rt>きょう</rt></ruby></dd>
+<dt> Jukugo ruby</dt>
+<dd> <ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
+<dt> Inline ruby</dt>
+<dd> <ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
+<dt> Double-sided ruby</dt>
+<dd> <ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby></dd></dl>
+<p><ruby>
+<rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
+<rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
+<rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
+</ruby>
+</p>
+!! end
+
+# There is a tidy bug here: http://sourceforge.net/p/tidy/bugs/946/
+!! test
+Non-word characters don't terminate tag names (bug 17663, 40670, 52022)
+!! wikitext
+<b→> doesn't work! </b→>
+
+<bä> doesn't work! </bä>
+
+<boo> works fine </boo>
+
+<s.foo>s.foo</s.foo>
+
+<sub-ID#1>
+!! html
+<p>&lt;b→&gt; doesn't work! &lt;/b→&gt;
+</p><p>&lt;bä&gt; doesn't work! &lt;/bä&gt;
+</p><p>&lt;boo&gt; works fine &lt;/boo&gt;
+</p><p>&lt;s.foo&gt;s.foo&lt;/s.foo&gt;
+</p><p>&lt;sub-ID#1&gt;
+</p>
+!! end
+
+!! test
+Isolated close tags should be treated as literal text (bug 52760)
+!! wikitext
+</b>
+
+<s.foo>s</s>
+!! html
+<p>&lt;/b&gt;
+</p><p>&lt;s.foo&gt;s&lt;/s&gt;
+</p>
+!! end
+
+###
+### Special characters
+###
+
+!! test
+Bare pipe character (bug 52363)
+!! wikitext
+|
+!! html
+<p>|
+</p>
+!! end
+
+!! test
+Bare pipe character from a template (bug 52363)
+!! wikitext
+{{pipe}}
+!! html
+<p>|
+</p>
+!! end
+
+###
+### <nowiki> test cases
+###
+
+!! test
+<nowiki> unordered list
+!! wikitext
+<nowiki>* This is not an unordered list item.</nowiki>
+!! html
+<p>* This is not an unordered list item.
+</p>
+!! end
+
+!! test
+<nowiki> spacing
+!! wikitext
+<nowiki>Lorem ipsum dolor
+
+sed abit.
+ sed nullum.
+
+:and a colon
+</nowiki>
+!! html
+<p>Lorem ipsum dolor
+
+sed abit.
+ sed nullum.
+
+:and a colon
+
+</p>
+!! end
+
+!! test
+nowiki 3
+!! wikitext
+:There is not nowiki.
+:There is <nowiki>nowiki</nowiki>.
+
+#There is not nowiki.
+#There is <nowiki>nowiki</nowiki>.
+
+*There is not nowiki.
+*There is <nowiki>nowiki</nowiki>.
+!! html
+<dl><dd>There is not nowiki.</dd>
+<dd>There is nowiki.</dd></dl>
+<ol><li>There is not nowiki.</li>
+<li>There is nowiki.</li></ol>
+<ul><li>There is not nowiki.</li>
+<li>There is nowiki.</li></ul>
+
+!! end
+
+!! test
+Entities inside <nowiki>
+!! wikitext
+<nowiki>&lt;</nowiki>
+!! html
+<p>&lt;
+</p>
+!! end
+
+!! test
+Entities inside template parameters
+!! options
+parsoid
+!! wikitext
+{{echo|&ndash;}}
+!! html
+<p><span typeof="mw:Transclusion mw:Entity" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&amp;ndash;"}},"i":0}}]}'>&ndash;</span>
+</p>
+!! end
+
+!! test
+Properly escape nowiki when combined with other wiki markup
+!! options
+parsoid=html2wt
+!! wikitext
+<nowiki>* &lt;/nowiki&gt;</nowiki> tag
+!! html
+<p>* &lt;/nowiki&gt; tag</p>
+!! end
+
+###
+### Comments
+###
+!! test
+Comments and Indent-Pre
+!! wikitext
+<!-- comment 1 --> asdf
+
+<!-- comment 1 --> asdf
+<!-- comment 2 -->
+
+<!-- comment 1 --> asdf
+<!-- comment 2 -->xyz
+
+<!-- comment 1 --> asdf
+<!-- comment 2 --> xyz
+!! html
+<pre>asdf
+</pre>
+<pre>asdf
+</pre>
+<pre>asdf
+</pre>
+<p>xyz
+</p>
+<pre>asdf
+xyz
+</pre>
+!! end
+
+!! test
+Comment test 2a
+!! wikitext
+asdf
+<!-- comment 1 -->
+jkl
+!! html
+<p>asdf
+jkl
+</p>
+!! end
+
+!! test
+Comment test 2b
+!! wikitext
+asdf
+<!-- comment 1 -->
+
+jkl
+!! html
+<p>asdf
+</p><p>jkl
+</p>
+!! end
+
+!! test
+Comment test 3
+!! wikitext
+asdf
+<!-- comment 1 -->
+<!-- comment 2 -->
+jkl
+!! html
+<p>asdf
+jkl
+</p>
+!! end
+
+!! test
+Comment test 4
+!! wikitext
+asdf<!-- comment 1 -->jkl
+!! html
+<p>asdfjkl
+</p>
+!! end
+
+!! test
+Comment spacing
+!! wikitext
+a
+ <!-- foo --> b <!-- bar -->
+c
+!! html
+<p>a
+</p>
+<pre> b
+</pre>
+<p>c
+</p>
+!! end
+
+!! test
+Comment whitespace
+!! wikitext
+<!-- returns a single newline, not nothing, since the newline after > is not stripped -->
+!! html
+
+!! end
+
+!! test
+Comment semantics and delimiters
+!! wikitext
+<!-- --><!----><!-----><!------>
+!! html
+
+!! end
+
+!! test
+Comment semantics and delimiters, redux
+!! wikitext
+<!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
+-- foo -- funky huh? ... -->
+!! html
+
+!! end
+
+!! test
+Comment semantics and delimiters: directors cut
+!! wikitext
+<!-- ... However we like to keep things simple and somewhat XML-ish so we eat
+everything starting with < followed by !-- until the first -- and > we see,
+that wouldn't be valid XML however, since in XML -- has to terminate a comment
+-->-->
+!! html
+<p>--&gt;
+</p>
+!! end
+
+!! test
+Comment semantics: nesting
+!! wikitext
+<!--<!-- no, we're not going to do anything fancy here -->-->
+!! html
+<p>--&gt;
+</p>
+!! end
+
+!! test
+Comment semantics: unclosed comment at end
+!! wikitext
+<!--This comment will run out to the end of the document
+!! html
+
+!! end
+
+!! test
+Comment in template title
+!! wikitext
+{{f<!---->oo}}
+!! html
+<p>FOO
+</p>
+!! end
+
+!! test
+Comment on its own line post-expand
+!! wikitext
+a
+{{blank}}<!---->
+b
+!! html
+<p>a
+</p><p>b
+</p>
+!! end
+
+!! test
+Comment on its own line post-expand with non-significant whitespace
+!! wikitext
+a
+ {{blank}} <!---->
+b
+!! html
+<p>a
+</p><p>b
+</p>
+!! end
+
+!! test
+Multiple comments should still parse as SOL-transparent
+!! options
+parsoid=wt2html,wt2wt
+!! wikitext
+<!--c1-->*a
+<!--c2--><!--c3--><!--c4-->*b
+!! html
+<ul>
+<li>a
+</li>
+<li>b
+</li>
+</ul>
+!! end
+
+###
+### paragraph wrapping tests
+###
+!! test
+No block tags
+!! wikitext
+a
+
+b
+!! html
+<p>a
+</p><p>b
+</p>
+!! end
+
+!! test
+Block tag on one line (<div>)
+!! wikitext
+a <div>foo</div>
+
+b
+!! html
+a <div>foo</div>
+<p>b
+</p>
+!! html+tidy
+<p>a</p>
+<div>foo</div>
+<p>b</p>
+!! end
+
+!! test
+Block tag on one line (<blockquote>)
+!! wikitext
+a <blockquote>foo</blockquote>
+
+b
+!! html
+a <blockquote>foo</blockquote>
+<p>b
+</p>
+!! html+tidy
+<p>a</p>
+<blockquote>
+<p>foo</p>
+</blockquote>
+<p>b</p>
+!! end
+
+!! test
+Block tag on both lines (<div>)
+!! wikitext
+a <div>foo</div>
+
+b <div>foo</div>
+!! html
+a <div>foo</div>
+b <div>foo</div>
+
+!! html+tidy
+<p>a</p>
+<div>foo</div>
+<p>b</p>
+<div>foo</div>
+!! end
+
+!! test
+Block tag on both lines (<blockquote>)
+!! wikitext
+a <blockquote>foo</blockquote>
+
+b <blockquote>foo</blockquote>
+!! html
+a <blockquote>foo</blockquote>
+b <blockquote>foo</blockquote>
+
+!! html+tidy
+<p>a</p>
+<blockquote>
+<p>foo</p>
+</blockquote>
+<p>b</p>
+<blockquote>
+<p>foo</p>
+</blockquote>
+!! end
+
+!! test
+Multiple lines without block tags
+!! wikitext
+<div>foo</div> a
+b
+c
+d<!--foo--> e
+x <div>foo</div> z
+!! html
+<div>foo</div> a
+<p>b
+c
+d e
+</p>
+x <div>foo</div> z
+
+!! html+tidy
+<div>foo</div>
+<p>a</p>
+<p>b c d e</p>
+<p>x</p>
+<div>foo</div>
+<p>z</p>
+!! end
+
+!! test
+Empty lines between lines with block tags
+!! wikitext
+<div></div>
+
+
+<div></div>a
+
+b
+<div>a</div>b
+
+<div>b</div>d
+
+
+<div>e</div>
+!! html
+<div></div>
+<p><br />
+</p>
+<div></div>a
+<p>b
+</p>
+<div>a</div>b
+<div>b</div>d
+<p><br />
+</p>
+<div>e</div>
+
+!! html+tidy
+<p><br /></p>
+<p>a</p>
+<p>b</p>
+<div>a</div>
+<p>b</p>
+<div>b</div>
+<p>d</p>
+<p><br /></p>
+<div>e</div>
+!! end
+
+## PHP parser emits output which is broken
+## XXX The parsoid output doesn't match the tidy output.
+!! test
+Unclosed HTML p-tags should be handled properly
+!! wikitext
+<div><p>foo</div>
+a
+
+b
+!! html/php+tidy
+<div>
+<p>foo&lt;/div&gt;</p>
+<p>a</p>
+b</div>
+!! html/parsoid
+<div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
+<p>a</p>
+<p>b</p>
+!! end
+
+###
+### Preformatted text
+###
+!! test
+Preformatted text
+!! wikitext
+ This is some
+ Preformatted text
+ With ''italic''
+ And '''bold'''
+ And a [[Main Page|link]]
+!! html
+<pre>This is some
+Preformatted text
+With <i>italic</i>
+And <b>bold</b>
+And a <a href="/wiki/Main_Page" title="Main Page">link</a>
+</pre>
+!! end
+
+!! test
+Tabs don't trigger preformatted text
+!! wikitext
+ This is not
+ preformatted text.
+ This is preformatted text.
+ So is this.
+!! html
+<p> This is not
+ preformatted text.
+</p>
+<pre>This is preformatted text.
+ So is this.
+</pre>
+!! end
+
+!! test
+Ident preformatting with inline content
+!! wikitext
+ a
+ ''b''
+!! html
+<pre>a
+<i>b</i>
+</pre>
+!! end
+
+!! test
+<pre> with <nowiki> inside (compatibility with 1.6 and earlier)
+!! wikitext
+<pre><nowiki>
+<b>
+<cite>
+<em>
+</nowiki></pre>
+!! html
+<pre>
+&lt;b&gt;
+&lt;cite&gt;
+&lt;em&gt;
+</pre>
+
+!! end
+
+!! test
+Regression with preformatted in <center>
+!! wikitext
+<center>
+ Blah
+</center>
+!! html
+<center>
+<pre>Blah
+</pre>
+</center>
+
+!! end
+
+!! test
+Bug 52763: Preformatted in <blockquote>
+!! wikitext
+<blockquote>
+ Blah
+{|
+|
+ indented cell (no pre-wrapping!)
+|}
+</blockquote>
+!! html
+<blockquote>
+<p> Blah
+</p>
+<table>
+<tr>
+<td>
+<p> indented cell (no pre-wrapping!)
+</p>
+</td></tr></table>
+</blockquote>
+
+!! end
+
+!! test
+Bug 51086: Double newlines in blockquotes should be turned into paragraphs
+!! wikitext
+<blockquote>
+Foo
+
+Bar
+</blockquote>
+!! html
+<blockquote>
+<p>Foo
+</p><p>Bar
+</p>
+</blockquote>
+
+!! end
+
+!! test
+Bug 15491: <ins>/<del> in blockquote
+!! wikitext
+<blockquote>
+Foo <del>bar</del> <ins>baz</ins> quux
+</blockquote>
+!! html
+<blockquote>
+<p>Foo <del>bar</del> <ins>baz</ins> quux
+</p>
+</blockquote>
+
+!! end
+
+# Note that the p-wrapping is newline sensitive, which could be
+# considered a bug: tidy will wrap only the 'Foo' in the example
+# below in a <p> tag. (see comment 23-25 of bug #6200)
+!! test
+Bug 15491: <ins>/<del> in blockquote (2)
+!! wikitext
+<blockquote>Foo <del>bar</del> <ins>baz</ins> quux
+</blockquote>
+!! html
+<blockquote>Foo <del>bar</del> <ins>baz</ins> quux
+</blockquote>
+
+!! html+tidy
+<blockquote>
+<p>Foo</p>
+<del>bar</del> <ins>baz</ins> quux</blockquote>
+!! end
+
+!! test
+<pre> with attributes (bug 3202)
+!! wikitext
+<pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
+!! html
+<pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
+
+!! end
+
+!! test
+<pre> with width attribute (bug 3202)
+!! wikitext
+<pre width="8">Narrow screen goodies</pre>
+!! html
+<pre width="8">Narrow screen goodies</pre>
+
+!! end
+
+!! test
+<pre> with forbidden attribute (bug 3202)
+!! wikitext
+<pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
+!! html
+<pre width="8">Narrow screen goodies</pre>
+
+!! end
+
+!! test
+Entities inside <pre>
+!! wikitext
+<pre>&lt;</pre>
+!! html
+<pre>&lt;</pre>
+
+!! end
+
+!! test
+<pre> with forbidden attribute values (bug 3202)
+!! wikitext
+<pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
+!! html
+<pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
+
+!! end
+
+!! test
+<nowiki> inside <pre> (bug 13238)
+!! wikitext
+<pre>
+<nowiki>
+</pre>
+<pre>
+<nowiki></nowiki>
+</pre>
+<pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
+!! html
+<pre>
+&lt;nowiki&gt;
+</pre>
+<pre>
+
+</pre>
+<pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
+
+!! end
+
+!! test
+<nowiki> and <pre> preference (first one wins)
+!! wikitext
+<pre>
+<nowiki>
+</pre>
+</nowiki>
+</pre>
+
+<nowiki>
+<pre>
+<nowiki>
+</pre>
+</nowiki>
+</pre>
+
+!! html
+<pre>
+&lt;nowiki&gt;
+</pre>
+<p>&lt;/nowiki&gt;
+&lt;/pre&gt;
+</p><p>
+&lt;pre&gt;
+&lt;nowiki&gt;
+&lt;/pre&gt;
+
+&lt;/pre&gt;
+</p>
+!! end
+
+!! test
+</pre> inside nowiki
+!! wikitext
+<nowiki></pre></nowiki>
+!! html
+<p>&lt;/pre&gt;
+</p>
+!! end
+
+!! test
+Empty pre; pre inside other HTML tags (bug 54946)
+!! wikitext
+a
+
+<div><pre>
+foo
+</pre></div>
+<pre></pre>
+!! html
+<p>a
+</p>
+<div><pre>
+foo
+</pre></div>
+<pre></pre>
+
+!! html+tidy
+<p>a</p>
+<div>
+<pre>
+foo
+</pre></div>
+!! end
+
+!! test
+HTML pre followed by indent-pre
+!! wikitext
+<pre>foo</pre>
+ bar
+!! html
+<pre>foo</pre>
+<pre>bar
+</pre>
+!! end
+
+!!test
+Block tag pre
+!!options
+parsoid
+!! wikitext
+<p><pre>foo</pre></p>
+!! html
+<p data-parsoid='{"stx":"html","autoInsertedEnd":true}'></p><pre data-parsoid='{"stx":"html"}'>foo</pre><p data-parsoid='{"autoInsertedStart":true,"stx":"html"}'></p>
+!!end
+
+!!test
+Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
+!! wikitext
+ {{echo|}}
+!! html
+
+!!end
+
+!!test
+Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
+!! wikitext
+ {{echo|
+foo}}
+!! html
+<p>foo
+</p>
+!!end
+
+!! test
+Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
+!! wikitext
+ {{echo|a
+b}}
+!! html
+<pre>a
+</pre>
+<p>b
+</p>
+!!end
+
+!! test
+Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
+!! wikitext
+ {{echo|a
+b
+c
+ d
+e
+}}
+!! html
+<pre>a
+</pre>
+<p>b
+c
+</p>
+<pre>d
+</pre>
+<p>e
+</p>
+!!end
+
+!!test
+Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
+!! wikitext
+{{echo| foo}}
+
+{{echo| foo}}{{echo| bar}}
+
+{{echo| foo}}
+{{echo| bar}}
+
+{{echo|<!--cmt--> foo}}
+
+<!--cmt-->{{echo| foo}}
+
+{{echo|{{echo| }}bar}}
+!! html
+<pre>foo
+</pre>
+<pre>foo bar
+</pre>
+<pre>foo
+bar
+</pre>
+<pre>foo
+</pre>
+<pre>foo
+</pre>
+<pre>bar
+</pre>
+!!end
+
+!! test
+Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
+!! wikitext
+{{echo| }}a
+
+{{echo|
+ }}a
+
+{{echo|
+ b}}
+
+{{echo|a
+ }}b
+
+{{echo|a
+}} b
+!! html
+<pre>a
+</pre>
+<p><br />
+</p>
+<pre>a
+</pre>
+<p><br />
+</p>
+<pre>b
+</pre>
+<p>a
+</p>
+<pre>b
+</pre>
+<p>a
+</p>
+<pre>b
+</pre>
+!!end
+
+!! test
+Things that look like <pre> tags aren't treated as such
+!! wikitext
+Barack Obama <President> of the United States
+<President></President>
+!! html
+<p>Barack Obama &lt;President&gt; of the United States
+&lt;President&gt;&lt;/President&gt;
+</p>
+!! end
+
+## PHP parser discards the "<pre " string
+!! test
+Handle broken pre-like tags (bug 64025)
+!! options
+parsoid=wt2html
+!! wikitext
+{{echo|<pre <pre>x</pre>}}
+
+<table><pre </table>
+!! html/php
+<pre>x</pre>
+<table><pre></pre></table>
+
+!! html/parsoid
+<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre &lt;pre>x&lt;/pre>"}},"i":0}}]}'>&lt;pre </span>
+<pre>x</pre>
+
+<span>&lt;pre </span>
+<table></table>
+!! end
+
+!! test
+Parsoid: handle pre with space after attribute
+!! options
+parsoid=wt2html
+!! wikitext
+<pre style="width:50%;" >{{echo|foo}}</pre>
+!! html
+<pre style="width:50%;">{{echo|foo}}</pre>
+!! end
+
+# TODO / maybe: fix wt2wt for this
+!! test
+Parsoid: Don't paragraph-wrap fosterable content
+!! options
+parsoid=wt2html
+!! wikitext
+{|
+<td></td>
+<td></td>
+
+
+
+|}
+!! html
+<table>
+
+<tbody>
+<tr>
+<td></td>
+
+<td></td></tr>
+
+
+
+</tbody></table>
+!! end
+
+!! test
+Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
+!! options
+parsoid=wt2html
+!! wikitext
+{|
+<td>
+<td>
+</td>
+
+
+
+|}
+!! html
+<table>
+
+<tbody>
+<tr>
+<td></td>
+
+<td>
+</td></tr>
+
+
+
+</tbody></table>
+!! end
+
+
+#--------------------------------------------------------------------
+# Transclusion parameter whitespace stripping tests
+# Behavior is different for positional and named parameters
+#--------------------------------------------------------------------
+!! test
+Templates: Strip leading and trailing whitespace from named-param values
+!! wikitext
+{{echo|1= a }}
+
+{{echo|1= {{echo|b}} }}
+
+{{echo| 1 =
+ c }}
+
+{{echo| 1 =
+* d
+}}
+!! html
+<p>a
+</p><p>b
+</p><p>c
+</p>
+<ul><li> d</li></ul>
+
+!! end
+
+!! test
+Templates: Don't strip whitespace from positional-param values
+!! wikitext
+{{echo|a }}
+
+{{echo|{{echo|b}} }}
+
+{{echo| c
+}}
+
+{{echo| {{echo|d}}
+}}
+
+{{echo|
+ e}}
+
+{{echo|
+* f}}
+
+{{echo|
+ }}g
+!! html
+<p>a
+</p><p>b
+</p>
+<pre>c
+</pre>
+<p><br />
+</p>
+<pre>d
+</pre>
+<p><br />
+</p>
+<pre>e
+</pre>
+<p><br />
+</p>
+<ul><li> f</li></ul>
+<p><br />
+</p>
+<pre>g
+</pre>
+!! end
+
+!! test
+Templates: Handle empty comment-and-ws-only lines correctly
+!! wikitext
+{{echo|foo
+<!--should be ignored-->
+ <!--should be ignored as well-->
+bar}}
+!! html
+<p>foo
+bar
+</p>
+!! end
+
+!! test
+Templates: Handle comments in the target
+!! wikitext
+{{echo
+<!-- should be ignored -->
+|foo}}
+
+{{echo<!-- should be ignored -->
+|foo}}
+
+{{echo<!-- should be ignored -->|foo}}
+
+{{<!-- should be ignored -->echo|foo}}
+!!html/parsoid
+<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n&lt;!-- should be ignored -->\n","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
+
+<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo&lt;!-- should be ignored -->\n","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
+
+<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo&lt;!-- should be ignored -->","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
+
+<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
+!!end
+
+#--------------------------------------------------------------------
+# Transclusion parameter escaping tests
+#--------------------------------------------------------------------
+!! test
+Templates: Parsoid parameter escaping test 1
+!! options
+parsoid
+!! wikitext
+{{echo|[foo]|{{echo|[bar]}}}}
+!! html
+<p about="#mwt1" typeof="mw:Transclusion"
+data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
+!! end
+
+!! test
+Parsoid: Pipes in external links in template parameter
+!! options
+parsoid
+!! wikitext
+{{echo|[{{echo|http://example.com}} link]}}
+!! html
+<p><a rel="mw:ExtLink" href="http://example.com" about="#mwt31" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{echo|http://example.com}} link]"}},"i":0}}]}'>link</a></p>
+!! end
+
+!! test
+Parsoid: pipe in transclusion parameter
+!! options
+parsoid
+!! wikitext
+{{echo|http://foo.com/a&#124;b}}
+!! html
+<p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
+typeof="mw:Transclusion"
+data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"http://foo.com/a&amp;#124;b"}},"i":0}}]}'>http://foo.com/a|b</a></p>
+!! end
+
+!! test
+Parsoid: Pipe in external link target and content in template parameter
+!! options
+parsoid=html2wt,wt2wt
+!! wikitext
+{{echo|[http://foo.com/a&#124;b a&#124;b]}}
+!! html
+<p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
+typeof="mw:Transclusion"
+data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
+"params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
+!! end
+
+!! test
+Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
+!! options
+parsoid
+!! wikitext
+{{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
+!! html
+<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]"}},"i":0}}]}'>[Main Page bar]</p>
+!! end
+
+!! test
+Templates: Don't escape already nowiki-escaped text in template parameters
+!! options
+parsoid=html2wt,wt2wt
+!! wikitext
+{{echo|foo<nowiki>|</nowiki>bar}}
+{{echo|<nowiki>&lt;div&gt;</nowiki>}}
+{{echo|<nowiki></nowiki>}}
+!! html
+<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo<nowiki>|</nowiki>bar"}},"i":0}}]}'}'>foo</span><span typeof="mw:Nowiki" about="#mwt1">|</span><span about="#mwt1">bar</span>
+<span typeof="mw:Transclusion mw:Nowiki" about="#mwt2" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<nowiki>&amp;lt;div&amp;gt;</nowiki>"}},"i":0}}]}'><span typeof="mw:Entity">&lt;</span>div<span typeof="mw:Entity">&gt;</span></span>
+<span typeof="mw:Transclusion mw:Nowiki" about="#mwt3" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<nowiki></nowiki>"}},"i":0}}]}'></span>
+</p>
+!! end
+
+## Bug 52824
+!! test
+Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
+!! options
+parsoid=html2wt,wt2wt
+!! wikitext
+{{echo|{{echo|1=bar}}}}
+!! html
+<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{echo|1=bar}}"}},"i":0}}]}'>bar</p>
+!! end
+
+## Bug 56733
+!! test
+Templates parameters with special tokenizing behavior dont get modified because of arg escaping
+!! options
+parsoid
+!! wikitext
+{{echo|a : b}}
+!! html
+<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a : b"}},"i":0}}]}'>a<span typeof="mw:Placeholder" data-parsoid='{"isDisplayHack":true}'> </span>: b</p>
+!! end
+
+###
+### Parsoid-centric tests for testing RT edge cases for pre
+###
+
+!!test
+1a. Indent-Pre and Comments
+!! wikitext
+ a
+<!--a-->
+c
+!! html
+<pre>a
+</pre>
+<p>c
+</p>
+!!end
+
+!!test
+1b. Indent-Pre and Comments
+!! wikitext
+ a
+ <!--a-->
+c
+!! html
+<pre>a
+</pre>
+<p>c
+</p>
+!!end
+
+!!test
+1c. Indent-Pre and Comments
+!! wikitext
+<!--a--> a
+
+ <!--a--> a
+!! html
+<pre> a
+</pre>
+<pre> a
+</pre>
+!!end
+
+!!test
+1d. Indent-Pre and Comments
+(Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
+!! wikitext
+<!--a--> a
+
+ <!--b-->b
+!! html
+<pre>a
+</pre>
+<pre>b
+</pre>
+!!end
+
+!!test
+2a. Indent-Pre and tables
+!! wikitext
+ {|
+ |-
+ !h1!!h2
+ |foo||bar
+ |}
+!! html
+<table>
+
+<tr>
+<th>h1</th>
+<th>h2
+</th>
+<td>foo</td>
+<td>bar
+</td></tr></table>
+
+!!end
+
+!!test
+2b. Indent-Pre and tables
+!! wikitext
+ {|
+ |-
+|foo
+|}
+!! html
+<table>
+
+<tr>
+<td>foo
+</td></tr></table>
+
+!!end
+
+!!test
+2c. Indent-Pre and tables (bug 42252)
+!! wikitext
+{|
+ |+ foo
+ ! | bar
+|}
+!! html
+<table>
+<caption> foo
+</caption>
+<tr>
+<th> bar
+</th></tr></table>
+
+!!end
+
+!!test
+2d. Indent-Pre and tables
+!! wikitext
+ a
+ {|
+ | b
+ |}
+!! html/php
+<pre>a
+</pre>
+<table>
+<tr>
+<td> b
+</td></tr></table>
+
+!! html/parsoid
+<pre>a</pre>
+
+<table>
+
+<tbody>
+<tr>
+<td> b</td></tr>
+ </tbody></table>
+!!end
+
+!!test
+2e. Indent-Pre and table-line syntax
+!! wikitext
+ a
+ | b
+ | c
+!! html/php
+<pre>a
+| b
+| c
+</pre>
+!!end
+
+!!test
+2f. Indent-pre started by table-line syntax
+!! wikitext
+a
+ | b
+ | c
+!! html/php
+<p>a
+</p>
+<pre>| b
+| c
+</pre>
+!! html/parsoid
+<p>a</p>
+<pre>
+| b
+| c</pre>
+!!end
+
+!!test
+3a. Indent-Pre and block tags (single-line html)
+!! wikitext
+ a <p> foo </p>
+ b <div> foo </div>
+ c <blockquote> foo </blockquote>
+ <span> foo </span>
+!! html
+ a <p> foo </p>
+ b <div> foo </div>
+ c <blockquote> foo </blockquote>
+<pre><span> foo </span>
+</pre>
+!! html+tidy
+<p>a</p>
+<p>foo</p>
+<p>b</p>
+<div>foo</div>
+<p>c</p>
+<blockquote>
+<p>foo</p>
+</blockquote>
+<pre>
+<span> foo </span>
+</pre>
+!! end
+
+!!test
+3b. Indent-Pre and block tags (multi-line html)
+!! wikitext
+ a <span>foo</span>
+ b <div> foo </div>
+!! html
+<pre>a <span>foo</span>
+</pre>
+ b <div> foo </div>
+
+!! html+tidy
+<pre>
+a <span>foo</span>
+</pre>
+<p>b</p>
+<div>foo</div>
+!!end
+
+!!test
+3c. Indent-Pre and block tags (pre-content on separate line)
+!! wikitext
+<p>
+ foo
+</p>
+
+<div>
+ foo
+</div>
+
+<center>
+ foo
+</center>
+
+<blockquote>
+ foo
+</blockquote>
+
+<blockquote>
+<pre>
+foo
+</pre>
+</blockquote>
+
+<table><tr><td>
+ foo
+</td></tr></table>
+
+<ul><li>
+ foo
+</li></ul>
+
+!! html
+<p>
+ foo
+</p>
+<div>
+<pre>foo
+</pre>
+</div>
+<center>
+<pre>foo
+</pre>
+</center>
+<blockquote>
+<p> foo
+</p>
+</blockquote>
+<blockquote>
+<pre>
+foo
+</pre>
+</blockquote>
+<table><tr><td>
+<pre>foo
+</pre>
+</td></tr></table>
+<ul><li>
+ foo
+</li></ul>
+
+!!end
+
+!!test
+4. Indent-Pre and extension tags
+!! wikitext
+ a <gallery>
+File:foobar.jpg
+</gallery>
+!! html
+ a <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="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
+ <div class="gallerytext">
+ </div>
+ </div></li>
+</ul>
+
+!! html+tidy
+<p>a</p>
+<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="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div>
+</div>
+<div class="gallerytext"></div>
+</div>
+</li>
+</ul>
+!!end
+
+!! test
+Table wikitext syntax outside wiki-tables
+!! wikitext
+a
+! not a table heading
+|- not a table row
+| not a table cell
+| class="foo bar" | baz
+b
+|}
+|-
+c
+!! html
+<p>a
+! not a table heading
+|- not a table row
+| not a table cell
+| class="foo bar" | baz
+b
+|}
+|-
+c
+</p>
+!! end
+
+!!test
+Render paragraphs when indent-pre is suppressed in blocklevels
+!! wikitext
+<blockquote>
+ foo
+
+ bar
+</blockquote>
+!! html
+<blockquote>
+<p> foo
+</p><p> bar
+</p>
+</blockquote>
+
+!!end
+
+!!test
+4. Multiple spaces at start-of-line
+!! wikitext
+ <p> foo </p>
+ foo
+ {|
+|foo
+|}
+!! html
+ <p> foo </p>
+<pre> foo
+</pre>
+<table>
+<tr>
+<td>foo
+</td></tr></table>
+
+!!end
+
+## NOTE: the leading white-space chars on empty line are significant
+!! test
+5a. White-space in indent-pre
+!! wikitext
+ a<br />
+
+ b
+!! html
+<pre>a<br />
+
+b
+</pre>
+!! end
+
+## NOTE: the leading white-space chars on empty line are significant
+!! test
+5b. White-space in indent-pre
+!! wikitext
+ a
+
+ b
+
+
+ c
+!! html
+<pre>a
+
+b
+
+
+c
+</pre>
+!! end
+
+!! test
+5c. White-space in indent-pre
+!! wikitext
+ ''a''
+ ''b''
+ ''c''
+!! html
+<pre><i>a</i>
+ <i>b</i>
+ <i>c</i>
+</pre>
+!! end
+
+!! test
+6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
+!! wikitext
+ a
+
+ <!-- continue -->
+ b
+
+ c
+
+d
+!! html
+<pre>a
+
+b
+</pre>
+<pre>c
+
+</pre>
+<p>d
+</p>
+!! end
+
+!! test
+7a. Indent-pre and category links
+!! options
+parsoid=wt2html,wt2wt
+!! wikitext
+ [[Category:foo]] <!-- No pre-wrapping -->
+{{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
+!! html
+ <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre-wrapping -->
+<span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":" [[Category:foo]]"}},"i":0}}]}'> </span>
+<link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1"> <!-- No pre-wrapping -->
+!! end
+
+!! test
+7b. Indent-pre and category links
+!! options
+parsoid=wt2html,wt2wt
+!! wikitext
+ [[Category:foo]] a
+ [[Category:foo]] {{echo|b}}
+!! html
+<pre>
+<link rel="mw:PageProp/Category" href="./Category:Foo"> a
+
+<link rel="mw:PageProp/Category" href="./Category:Foo"> <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"b"}},"i":0}}]}'>b</span></pre>
+!! end
+
+###
+### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
+###
+
+!!test
+HTML-pre: 1. embedded newlines
+!! wikitext
+<pre>foo</pre>
+
+<pre>
+foo
+</pre>
+
+<pre>
+
+foo
+</pre>
+
+<pre>
+
+
+foo
+</pre>
+!! html
+<pre>foo</pre>
+<pre>
+foo
+</pre>
+<pre>
+
+foo
+</pre>
+<pre>
+
+
+foo
+</pre>
+
+!! html/parsoid
+<pre data-parsoid='{"stx":"html"}'>foo</pre>
+
+<pre data-parsoid='{"stx":"html","strippedNL":"\n"}'>
+foo
+</pre>
+
+<pre data-parsoid='{"stx":"html"}'>
+
+foo
+</pre>
+
+<pre data-parsoid='{"stx":"html"}'>
+
+
+foo
+</pre>
+!!end
+
+!! test
+HTML-pre: big spaces
+!! wikitext
+<pre>
+
+
+
+
+haha
+
+
+
+
+haha
+
+
+
+
+</pre>
+!! html
+<pre>
+
+
+
+
+haha
+
+
+
+
+haha
+
+
+
+
+</pre>
+
+!! html/parsoid
+<pre data-parsoid='{"stx":"html"}'>
+
+
+
+
+haha
+
+
+
+
+haha
+
+
+
+
+</pre>
+!! end
+
+!!test
+HTML-pre: 2: indented text
+!! wikitext
+<pre>
+ foo
+</pre>
+!! html
+<pre>
+ foo
+</pre>
+
+!!end
+
+!!test
+HTML-pre: 3: other wikitext
+!! wikitext
+<pre>
+* foo
+# bar
+= no-h =
+'' no-italic ''
+[[ NoLink ]]
+</pre>
+!! html
+<pre>
+* foo
+# bar
+= no-h =
+'' no-italic ''
+[[ NoLink ]]
+</pre>
+
+!!end
+
+###
+### Definition lists
+###
+!! test
+Simple definition
+!! wikitext
+; name : Definition
+!! html
+<dl><dt> name&#160;</dt>
+<dd> Definition</dd></dl>
+
+!! end
+
+!! test
+Definition list for indentation only
+!! wikitext
+: Indented text
+!! html
+<dl><dd> Indented text</dd></dl>
+
+!! end
+
+!! test
+Definition list with no space
+!! wikitext
+;name:Definition
+!! html
+<dl><dt>name</dt>
+<dd>Definition</dd></dl>
+
+!!end
+
+!! test
+Definition list with URL link
+!! wikitext
+; http://example.com/ : definition
+!! html
+<dl><dt> <a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&#160;</dt>
+<dd> definition</dd></dl>
+
+!! end
+
+!! test
+Definition list with bracketed URL link
+!! wikitext
+;[http://www.example.com/ Example]:Something about it
+!! html
+<dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
+<dd>Something about it</dd></dl>
+
+!! end
+
+!! test
+Definition list with wikilink containing colon
+!! wikitext
+; [[Help:FAQ]]: The least-read page on Wikipedia
+!! html
+<dl><dt> <a href="/index.php?title=Help:FAQ&amp;action=edit&amp;redlink=1" class="new" title="Help:FAQ (page does not exist)">Help:FAQ</a></dt>
+<dd> The least-read page on Wikipedia</dd></dl>
+
+!! end
+
+# At Brion's and JeLuF's insistence... :)
+!! test
+Definition list with news link containing colon
+!! wikitext
+; news:alt.wikipedia.rox: This isn't even a real newsgroup!
+!! html
+<dl><dt> <a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
+<dd> This isn't even a real newsgroup!</dd></dl>
+
+!! end
+
+!! test
+Malformed definition list with colon
+!! wikitext
+; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
+!! html
+<dl><dt> <a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a> -- don't crash or enter an infinite loop</dt></dl>
+
+!! end
+
+!! test
+Definition lists: colon in external link text
+!! wikitext
+; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
+!! html
+<dl><dt> <a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia&#160;: The Next Generation</a></dt>
+<dd> OK, I made that up</dd></dl>
+
+!! end
+
+!! test
+Definition lists: colon in HTML attribute
+!! wikitext
+;<b style="display: inline">bold</b>
+!! html
+<dl><dt><b style="display: inline">bold</b></dt></dl>
+
+!! end
+
+!! test
+Definition lists: self-closed tag
+!! wikitext
+;one<br/>two : two-line fun
+!! html
+<dl><dt>one<br />two&#160;</dt>
+<dd> two-line fun</dd></dl>
+
+!! end
+
+!! test
+Bug 11748: Literal closing tags
+!! wikitext
+<dl>
+<dt>test 1</dt>
+<dd>test test test test test</dd>
+<dt>test 2</dt>
+<dd>test test test test test</dd>
+</dl>
+!! html
+<dl>
+<dt>test 1</dt>
+<dd>test test test test test</dd>
+<dt>test 2</dt>
+<dd>test test test test test</dd>
+</dl>
+
+!! end
+
+!! test
+Definition and unordered list using wiki syntax nested in unordered list using html tags.
+!! wikitext
+<ul><li>
+; term : description
+* unordered
+</li></ul>
+!! html
+<ul><li>
+<dl><dt> term&#160;</dt>
+<dd> description</dd></dl>
+<ul><li> unordered</li></ul>
+</li></ul>
+
+!! end
+
+!! test
+
+Definition list with empty definition and following paragraph
+!! wikitext
+; term:
+Paragraph text
+!! html
+<dl><dt> term</dt>
+<dd></dd></dl>
+<p>Paragraph text
+</p>
+!! end
+
+!! test
+Nested definition lists using html syntax
+!! wikitext
+<dl><dt>x</dt>
+<dd>a</dd>
+<dd>b</dd></dl>
+
+!! end
+
+!! test
+Definition Lists: No nesting: Multiple dd's
+!! wikitext
+;x
+:a
+:b
+!! html
+<dl><dt>x</dt>
+<dd>a</dd>
+<dd>b</dd></dl>
+
+!! end
+
+!! test
+Definition Lists: Indentation: Regular
+!! wikitext
+:i1
+::i2
+:::i3
+!! html
+<dl><dd>i1
+<dl><dd>i2
+<dl><dd>i3</dd></dl></dd></dl></dd></dl>
+
+!! end
+
+!! test
+Definition Lists: Indentation: Missing 1st level
+!! wikitext
+::i2
+:::i3
+!! html
+<dl><dd><dl><dd>i2
+<dl><dd>i3</dd></dl></dd></dl></dd></dl>
+
+!! end
+
+!! test
+Definition Lists: Indentation: Multi-level indent
+!! wikitext
+:::i3
+!! html
+<dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
+
+!! end
+
+!! test
+Definition Lists: Hacky use to indent tables
+!! wikitext
+::{|
+|foo
+|bar
+|}
+this text
+should be left alone
+!! html
+<dl><dd><dl><dd><table>
+<tr>
+<td>foo
+</td>
+<td>bar
+</td></tr></table></dd></dl></dd></dl>
+<p>this text
+should be left alone
+</p>
+!! end
+
+!! test
+Definition Lists: Hacky use to indent tables, with comments (bug 63979)
+!! wikitext
+<!-- foo -->
+::{|
+|foo
+|bar
+|}<!-- bar -->
+this text
+should be left alone
+!! html/parsoid
+<!-- foo -->
+<dl><dd><dl><dd><table><tr>
+<td>foo</td>
+<td>bar</td>
+</tr></table><!-- bar --></dd></dl></dd></dl>
+<p>this text
+should be left alone</p>
+!! end
+
+!! test
+Definition Lists: Hacky use to indent tables, with comment before table
+!! wikitext
+::<!-- foo -->{|
+|foo
+|}
+!! html/parsoid
+<dl><dd><dl><dd><!-- foo --><table><tr>
+<td>foo</td>
+</tr></table></dd></dl></dd></dl>
+!! end
+
+# Bug 52473
+!! test
+Definition Lists: Hacky use to indent tables (WS-insensitive)
+!! options
+parsoid
+!! wikitext
+: {|
+|a
+|}
+!! html
+<dl>
+<dd> <table><tr><td>a</td></tr></table> </dd>
+</dl>
+!! end
+## The PHP parser treats : items (dd) without a corresponding ; item (dt)
+## as an empty dt item. It also ignores all but the last ";" when followed
+## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
+## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
+## ";"s.
+##
+## Ex: ";;t2 ::d2" is transformed into:
+##
+## <dl>
+## <dt>t2 </dt>
+## <dd>
+## <dl>
+## <dt></dt>
+## <dd>d2</dd>
+## </dl>
+## </dd>
+## </dl>
+##
+## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
+## So, the same wikitext above (;;t2 ::d2) is transformed into:
+##
+## <dl>
+## <dt>
+## <dl>
+## <dt>t2 </dt>
+## <dd>:d2</dd>
+## </dl>
+## </dt>
+## </dl>
+##
+## All Parsoid only definition list tests have this difference.
+##
+## See also: https://bugzilla.wikimedia.org/show_bug.cgi?id=6569
+## and http://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
+
+!! test
+Table / list interaction: indented table with lists in table contents
+!! wikitext
+:{|
+|-
+| a
+* b
+|-
+| c
+* d
+|}
+!! html
+<dl><dd><table>
+
+<tr>
+<td> a
+<ul><li> b</li></ul>
+</td></tr>
+<tr>
+<td> c
+<ul><li> d</li></ul>
+</td></tr></table></dd></dl>
+
+!! end
+
+!!test
+Table / list interaction: lists nested in tables nested in indented lists
+!! wikitext
+:{|
+|
+:a
+:b
+|
+*c
+*d
+|}
+
+*e
+*f
+!! html
+<dl><dd><table>
+<tr>
+<td>
+<dl><dd>a</dd>
+<dd>b</dd></dl>
+</td>
+<td>
+<ul><li>c</li>
+<li>d</li></ul>
+</td></tr></table></dd></dl>
+<ul><li>e</li>
+<li>f</li></ul>
+
+!!end
+
+!! test
+Definition Lists: Nesting: Multi-level (Parsoid only)
+!! options
+parsoid
+!! wikitext
+;t1 :d1
+;;t2 ::d2
+;;;t3 :::d3
+!! html
+<dl>
+ <dt>t1 </dt>
+ <dd>d1</dd>
+ <dt>
+ <dl>
+ <dt>t2 </dt>
+ <dd>:d2</dd>
+ <dt>
+ <dl>
+ <dt>t3 </dt>
+ <dd>::d3</dd>
+ </dl>
+ </dt>
+ </dl>
+ </dt>
+</dl>
+
+
+!! end
+
+
+!! test
+Definition Lists: Nesting: Test 2 (Parsoid only)
+!! options
+parsoid
+!! wikitext
+;t1
+::d2
+!! html
+<dl>
+ <dt>t1</dt>
+ <dd>
+ <dl>
+ <dd>d2</dd>
+ </dl>
+ </dd>
+</dl>
+
+!! end
+
+
+!! test
+Definition Lists: Nesting: Test 3 (Parsoid only)
+!! options
+parsoid
+!! wikitext
+:;t1
+::::d2
+!! html
+<dl>
+ <dd>
+ <dl>
+ <dt>t1</dt>
+ <dd>
+ <dl>
+ <dd>
+ <dl>
+ <dd>d2</dd>
+ </dl>
+ </dd>
+ </dl>
+ </dd>
+ </dl>
+ </dd>
+</dl>
+
+!! end
+
+
+!! test
+Definition Lists: Nesting: Test 4
+!! wikitext
+::;t3
+:::d3
+!! html
+<dl><dd><dl><dd><dl><dt>t3</dt>
+<dd>d3</dd></dl></dd></dl></dd></dl>
+
+!! end
+
+
+## The Parsoid team believes the following three test exposes a
+## bug in the PHP parser. (Parsoid team thinks the PHP parser is
+## wrong to close the <dl> after the <dt> containing the <ul>.)
+## It also exposes a "misfeature" in tidy, which doesn't like
+## <dl> tags with a single <dt> child; it converts the <dt> into
+## a <dd> in that case. (Parsoid leaves the <dt> alone!)
+!! test
+Definition Lists: Mixed Lists: Test 1
+!! wikitext
+:;* foo
+::* bar
+:; baz
+!! html/php
+<dl><dd><dl><dt><ul><li> foo</li>
+<li> bar</li></ul></dt></dl>
+<dl><dt> baz</dt></dl></dd></dl>
+
+!! html/php+tidy
+<dl>
+<dd>
+<dl>
+<dd>
+<ul>
+<li>foo</li>
+<li>bar</li>
+</ul>
+</dd>
+</dl>
+<dl>
+<dt>baz</dt>
+</dl>
+</dd>
+</dl>
+!! html/parsoid
+<dl>
+<dd><dl>
+<dt><ul>
+<li> foo
+</li>
+</ul></dt>
+<dd><ul>
+<li> bar
+</li>
+</ul></dd>
+<dt> baz</dt>
+</dl></dd>
+</dl>
+!! end
+
+!! test
+Definition Lists: Mixed Lists: Test 2
+!! wikitext
+*: d1
+*: d2
+!! html
+<ul><li><dl><dd> d1</dd>
+<dd> d2</dd></dl></li></ul>
+
+!! end
+
+
+!! test
+Definition Lists: Mixed Lists: Test 3
+!! wikitext
+*::: d1
+*::: d2
+!! html
+<ul><li><dl><dd><dl><dd><dl><dd> d1</dd>
+<dd> d2</dd></dl></dd></dl></dd></dl></li></ul>
+
+!! end
+
+
+!! test
+Definition Lists: Mixed Lists: Test 4
+!! wikitext
+*;d1 :d2
+*;d3 :d4
+!! html
+<ul><li><dl><dt>d1&#160;</dt>
+<dd>d2</dd>
+<dt>d3&#160;</dt>
+<dd>d4</dd></dl></li></ul>
+
+!! end
+
+
+!! test
+Definition Lists: Mixed Lists: Test 5
+!! wikitext
+*:d1
+*:: d2
+!! html
+<ul><li><dl><dd>d1
+<dl><dd> d2</dd></dl></dd></dl></li></ul>
+
+!! end
+
+
+!! test
+Definition Lists: Mixed Lists: Test 6
+!! wikitext
+#*:d1
+#*::: d3
+!! html
+<ol><li><ul><li><dl><dd>d1
+<dl><dd><dl><dd> d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
+
+!! end
+
+
+!! test
+Definition Lists: Mixed Lists: Test 7
+!! wikitext
+:* d1
+:* d2
+!! html
+<dl><dd><ul><li> d1</li>
+<li> d2</li></ul></dd></dl>
+
+!! end
+
+
+!! test
+Definition Lists: Mixed Lists: Test 8
+!! wikitext
+:* d1
+::* d2
+!! html
+<dl><dd><ul><li> d1</li></ul>
+<dl><dd><ul><li> d2</li></ul></dd></dl></dd></dl>
+
+!! end
+
+
+!! test
+Definition Lists: Mixed Lists: Test 9
+!! wikitext
+*;foo :bar
+!! html
+<ul><li><dl><dt>foo&#160;</dt>
+<dd>bar</dd></dl></li></ul>
+
+!! end
+
+
+!! test
+Definition Lists: Mixed Lists: Test 10
+!! wikitext
+*#;foo :bar
+!! html
+<ul><li><ol><li><dl><dt>foo&#160;</dt>
+<dd>bar</dd></dl></li></ol></li></ul>
+
+!! 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
+# still-open tags around until the nesting is complete.
+# (And tidy again converts <dt> to <dd> before 'bar'.)
+
+!! test
+Definition Lists: Mixed Lists: Test 11
+!! wikitext
+*#*#;*;;foo :bar
+*#*#;boo :baz
+!! html/php
+<ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
+<dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
+<dl><dt>boo&#160;</dt>
+<dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
+
+!! html/php+tidy
+<ul>
+<li>
+<ol>
+<li>
+<ul>
+<li>
+<ol>
+<li>
+<dl>
+<dt>foo&#160;</dt>
+<dd>
+<ul>
+<li>
+<dl>
+<dd>
+<dl>
+<dt>bar</dt>
+</dl>
+</dd>
+</dl>
+</li>
+</ul>
+</dd>
+</dl>
+<dl>
+<dt>boo&#160;</dt>
+<dd>baz</dd>
+</dl>
+</li>
+</ol>
+</li>
+</ul>
+</li>
+</ol>
+</li>
+</ul>
+!! html/parsoid
+<ul>
+<li>
+<ol>
+<li>
+<ul>
+<li>
+<ol>
+<li>
+<dl>
+<dt>
+<ul>
+<li>
+<dl>
+<dt>
+<dl>
+<dt>foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
+<dd data-parsoid='{"stx":"row"}'>bar</dd>
+</dl></dt>
+</dl></li>
+</ul></dt>
+<dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
+<dd data-parsoid='{"stx":"row"}'>baz</dd>
+</dl></li>
+</ol></li>
+</ul></li>
+</ol></li>
+</ul>
+!! end
+
+
+# Another case where tidy converts a <dt> to a <dd> (but Parsoid doesn't).
+!! test
+Definition Lists: Weird Ones: Test 1
+!! wikitext
+*#;*::;; foo : bar (who uses this?)
+!! html/php
+<ul><li><ol><li><dl><dt> foo&#160;</dt>
+<dd><ul><li><dl><dd><dl><dd><dl><dt><dl><dt> bar (who uses this?)</dt></dl></dd></dl></dd></dl></dd></dl></li></ul></dd></dl></li></ol></li></ul>
+
+!! html/php+tidy
+<ul>
+<li>
+<ol>
+<li>
+<dl>
+<dt>foo&#160;</dt>
+<dd>
+<ul>
+<li>
+<dl>
+<dd>
+<dl>
+<dd>
+<dl>
+<dd>
+<dl>
+<dt>bar (who uses this?)</dt>
+</dl>
+</dd>
+</dl>
+</dd>
+</dl>
+</dd>
+</dl>
+</li>
+</ul>
+</dd>
+</dl>
+</li>
+</ol>
+</li>
+</ul>
+!! html/parsoid
+<ul>
+<li>
+<ol>
+<li>
+<dl>
+<dt>
+<ul>
+<li>
+<dl>
+<dd>
+<dl>
+<dd>
+<dl>
+<dt>
+<dl>
+<dt> foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
+<dd data-parsoid='{"stx":"row"}'> bar (who uses this?)</dd>
+</dl></dt>
+</dl></dd>
+</dl></dd>
+</dl></li>
+</ul></dt>
+</dl></li>
+</ol></li>
+</ul>
+!! end
+
+###
+### External links
+###
+!! test
+External links: non-bracketed
+!! wikitext
+Non-bracketed: http://example.com
+!! html
+<p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
+</p>
+!! end
+
+# parsoid doesn't explicitly mark autonumbered links, see bug 53505
+!! test
+External links: numbered
+!! wikitext
+Numbered: [http://example.com]
+Numbered: [http://example.net]
+Numbered: [http://example.com]
+!! html/php
+<p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
+Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
+Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
+</p>
+!! html/parsoid
+<p>Numbered: <a rel="mw:ExtLink" href="http://example.com"></a>
+Numbered: <a rel="mw:ExtLink" href="http://example.net"></a>
+Numbered: <a rel="mw:ExtLink" href="http://example.com"></a></p>
+!!end
+
+!! test
+External links: specified text
+!! wikitext
+Specified text: [http://example.com link]
+!! html
+<p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
+</p>
+!!end
+
+!! test
+External links: trail
+!! wikitext
+Linktrails should not work for external links: [http://example.com link]s
+!! html
+<p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
+</p>
+!! end
+
+!! test
+External links: dollar sign in URL
+!! wikitext
+http://example.com/1$2345
+!! html
+<p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
+</p>
+!! end
+
+# parsoid doesn't explicitly mark autonumbered links, see bug 53505
+!! test
+External links: dollar sign in URL (autonumber)
+!! wikitext
+[http://example.com/1$2345]
+!! html/php
+<p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://example.com/1$2345"></a></p>
+!!end
+
+!! test
+External links: open square bracket forbidden in URL (bug 4377)
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+http://example.com/1[2345
+!! html/php
+<p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://example.com/1">http://example.com/1</a>[2345</p>
+!! end
+
+!! test
+External links: open square bracket forbidden in URL (named) (bug 4377)
+!! options
+parsoid=wt2html,html2html
+!! wikitext
+[http://example.com/1[2345]
+!! html/php
+<p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://example.com/1">[2345</a></p>
+!!end
+
+# parsoid adds a space before the link name
+!! test
+External links: open square bracket forbidden in URL (named) (bug 4377)
+Parsoid variant.
+!! wikitext
+[http://example.com/1 [2345]
+!! html
+<p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
+</p>
+!!end
+
+!! test
+External links: nowiki in URL link text (bug 6230)
+!! wikitext
+[http://example.com/ <nowiki>''example site''</nowiki>]
+!! html
+<p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
+</p>
+!! end
+
+!! test
+External links: newline forbidden in text (bug 6230 regression check)
+!! wikitext
+[http://example.com/ first
+second]
+!! html
+<p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
+second]
+</p>
+!!end
+
+!! test
+External links: Pipe char between url and text
+!! wikitext
+[http://example.com | link]
+!! html
+<p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
+</p>
+!!end
+
+!! test
+External links: protocol-relative URL in brackets
+!! wikitext
+[//example.com/ Test]
+!! html
+<p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
+</p>
+!! end
+
+# parsoid doesn't explicitly mark autonumbered links, see bug 53505
+!! test
+External links: protocol-relative URL in brackets without text
+!! wikitext
+[//example.com]
+!! html/php
+<p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="//example.com"></a></p>
+!! end
+
+!! test
+External links: protocol-relative URL in free text is left alone
+!! wikitext
+//example.com/Foo
+!! html
+<p>//example.com/Foo
+</p>
+!!end
+
+!! test
+External links: protocol-relative URL in the middle of a word is left alone (bug 30269)
+!! wikitext
+foo//example.com/Foo
+!! html
+<p>foo//example.com/Foo
+</p>
+!! end
+
+!! test
+External links: with no contents
+!! wikitext
+[http://en.wikipedia.org/wiki/Foo]
+
+[[wikipedia:Foo|Bar]]
+
+[[wikipedia:Foo|<span>Bar</span>]]
+!! html/php
+<p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
+</p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
+</p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo"></a></p>
+<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo">Bar</a></p>
+<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo"><span>Bar</span></a></p>
+!! end
+
+!! test
+External image
+!! wikitext
+External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
+!! html
+<p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
+</p>
+!! end
+
+!! test
+External image from https
+!! wikitext
+External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
+!! html
+<p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
+</p>
+!! end
+
+!! test
+External image (when not allowed)
+!! options
+wgAllowExternalImages=0
+!! wikitext
+External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
+!! html
+<p>External image: <a rel="nofollow" class="external free" href="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png">http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png</a>
+</p>
+!! end
+
+!! test
+Link to non-http image, no img tag
+!! wikitext
+Link to non-http image, no img tag: ftp://example.com/test.jpg
+!! html
+<p>Link to non-http image, no img tag: <a rel="nofollow" class="external free" href="ftp://example.com/test.jpg">ftp://example.com/test.jpg</a>
+</p>
+!! end
+
+!! test
+External links: terminating separator
+!! wikitext
+Terminating separator: http://example.com/thing,
+!! html
+<p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
+</p>
+!! end
+
+!! test
+External links: intervening separator
+!! wikitext
+Intervening separator: http://example.com/1,2,3
+!! html
+<p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
+</p>
+!! end
+
+!! test
+External links: old bug with URL in query
+!! wikitext
+Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
+!! html
+<p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
+</p>
+!! end
+
+!! test
+External links: old URL-in-URL bug, mixed protocols
+!! wikitext
+And again with mixed protocols: [ftp://example.com?url=http://example.com link]
+!! html
+<p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
+</p>
+!!end
+
+!! test
+External links: URL in text
+!! wikitext
+URL in text: [http://example.com http://example.com]
+!! html
+<p>URL in text: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
+</p>
+!! end
+
+!! test
+External links: Clickable images
+!! wikitext
+ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
+!! html
+<p>ja-style clickable images: <a rel="nofollow" class="external text" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" /></a>
+</p>
+!!end
+
+!! test
+External links: raw ampersand
+!! wikitext
+Old &amp; use: http://x&y
+!! html
+<p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
+</p>
+!! end
+
+!! test
+External links: encoded ampersand
+!! wikitext
+Old &amp; use: http://x&amp;y
+!! html/php
+<p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
+</p>
+!! html/parsoid
+<p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y">http://x&amp;y</a></p>
+!! end
+
+!! test
+External links: encoded equals (bug 6102)
+!! wikitext
+http://example.com/?foo&#61;bar
+!! html/php
+<p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
+!! end
+
+##
+## Note that parsoid doesn't explicit mark autonumbered links, nor
+## does it number them. As discussed in bug 53505, we can identify
+## autonumbered links via CSS.
+##
+
+!! test
+External links: [raw ampersand]
+!! wikitext
+Old &amp; use: [http://x&y]
+!! html/php
+<p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
+</p>
+!! html/parsoid
+<p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y"></a></p>
+!! end
+
+# note that parsoid html is identical to [raw ampersand] case; so html2wt
+# mode will return the [raw ampersand] wikitext
+!! test
+External links: [encoded ampersand]
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+Old &amp; use: [http://x&amp;y]
+!! html/php
+<p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
+</p>
+!! html/parsoid
+<p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y"></a></p>
+!! end
+
+!! test
+External links: [raw equals]
+!! wikitext
+[http://example.com/?foo=bar]
+!! html/php
+<p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://example.com/?foo=bar"></a></p>
+!! end
+
+# note that parsoid html is identical to [raw equals] case; so html2wt
+# mode will return the [raw equals] wikitext
+!! test
+External links: [encoded equals] (bug 6102)
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[http://example.com/?foo&#61;bar]
+!! html/php
+<p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://example.com/?foo=bar"></a></p>
+!! end
+
+# xxx parsoid strips the IDN character, so the round-trip tests will
+# obviously fail and are disabled. --cscott
+!! test
+External links: [IDN ignored character reference in hostname; strip it right off]
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[http://e&zwnj;xample.com/]
+!! html/php
+<p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://example.com/"></a></p>
+!! end
+
+# FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
+# Where an external link could easily circumvent the sanitization of the text of
+# a link like this (where an IDN-ignore character is in the URL somewhere), this
+# test demands a higher standard. That's a bit strange.
+#
+# Example:
+#
+# http://e‌xample.com -> [http://example.com|http://example.com]
+# [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
+#
+# The first example is sanitized, but the second is not. Any security benefits
+# from this production are trivial to circumvent. Either remove this test and
+# let the parser(s) do their thing unaccosted, or fix the inconsistency and change
+# the test accordingly.
+#
+# All our love,
+# The Parsoid team.
+# xxx parsoid strips the IDN character, so the round-trip tests will
+# obviously fail and are disabled. --cscott
+!! test
+External links: IDN ignored character reference in hostname; strip it right off
+!! options
+parsoid=wt2html,html2html
+!! wikitext
+http://e&zwnj;xample.com/
+!! html/php
+<p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://example.com/">http://example.com/</a></p>
+!! end
+
+!! test
+External links: www.jpeg.org (bug 554)
+!! wikitext
+http://www.jpeg.org
+!! html
+<p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
+</p>
+!! end
+
+# parsoid doesn't explicitly mark autonumbered links, see bug 53505
+!! test
+External links: URL within URL (original bug 2)
+!! wikitext
+[http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
+!! html/php
+<p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp"></a></p>
+!! end
+
+!! test
+BUG 361: URL inside bracketed URL
+!! wikitext
+[http://www.example.com/foo http://www.example.com/bar]
+!! html
+<p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
+</p>
+!! end
+
+!! test
+BUG 361: URL within URL, not bracketed
+!! wikitext
+http://www.example.com/foo?=http://www.example.com/bar
+!! html
+<p><a rel="nofollow" class="external free" href="http://www.example.com/foo?=http://www.example.com/bar">http://www.example.com/foo?=http://www.example.com/bar</a>
+</p>
+!! end
+
+!! test
+BUG 289: ">"-token in URL-tail
+!! wikitext
+http://www.example.com/<hello>
+!! html
+<p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
+</p>
+!!end
+
+!! test
+BUG 289: literal ">"-token in URL-tail
+!! wikitext
+http://www.example.com/<b>html</b>
+!! html
+<p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
+</p>
+!!end
+
+!! test
+BUG 289: ">"-token in bracketed URL
+!! wikitext
+[http://www.example.com/<hello> stuff]
+!! html
+<p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
+</p>
+!!end
+
+!! test
+BUG 289: literal ">"-token in bracketed URL
+!! wikitext
+[http://www.example.com/<b>html</b> stuff]
+!! html
+<p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
+</p>
+!!end
+
+!! test
+BUG 289: literal double quote at end of URL
+!! wikitext
+http://www.example.com/"hello"
+!! html
+<p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
+</p>
+!!end
+
+!! test
+BUG 289: literal double quote in bracketed URL
+!! wikitext
+[http://www.example.com/"hello" stuff]
+!! html
+<p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
+</p>
+!!end
+
+!! test
+External links: multiple legal whitespace is fine, Magnus. Don't break it please. (bug 5081)
+!! wikitext
+[http://www.example.com test]
+!! html
+<p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
+</p>
+!! end
+
+!! test
+External links: link text with spaces
+!! wikitext
+[http://www.example.com a b c]
+[http://www.example.com ''a'' ''b'']
+!! html
+<p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
+<a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
+</p>
+!! end
+
+!! test
+External links: wiki links within external link (Bug 3695)
+!! wikitext
+[http://example.com [[wikilink]] embedded in ext link]
+!! html/php
+<p><a rel="nofollow" class="external text" href="http://example.com"></a><a href="/index.php?title=Wikilink&amp;action=edit&amp;redlink=1" class="new" title="Wikilink (page does not exist)">wikilink</a><a rel="nofollow" class="external text" href="http://example.com"> embedded in ext link</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://example.com"></a><a rel="mw:WikiLink" href="./Wikilink" title="Wikilink">wikilink</a><span> embedded in ext link</span></p>
+!! end
+
+!! test
+BUG 787: Links with one slash after the url protocol are invalid
+!! wikitext
+http:/example.com
+
+[http:/example.com title]
+!! html
+<p>http:/example.com
+</p><p>[http:/example.com title]
+</p>
+!! end
+
+!! test
+Bracketed external links with template-generated invalid target
+!! wikitext
+[{{echo|http:/example.com}} title]
+!! html
+<p>[http:/example.com title]
+</p>
+!! end
+
+!! test
+Bug 2702: Mismatched <i>, <b> and <a> tags are invalid
+!! wikitext
+''[http://example.com text'']
+[http://example.com '''text]'''
+''Something [http://example.com in italic'']
+''Something [http://example.com mixed''''', even bold]'''
+'''''Now [http://example.com both''''']
+!! html
+<p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
+<a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
+<i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
+<i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
+<i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
+</p>
+!! end
+
+
+!! test
+Bug 4781: %26 in URL
+!! wikitext
+http://www.example.com/?title=AT%26T
+!! html/php
+<p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a></p>
+!! end
+
+# According to http://dev.w3.org/html5/spec/Overview.html#parsing-urls a plain
+# % is actually legal in HTML5. Any change in output would need testing though.
+!! test
+Bug 4781, 5267: %25 in URL
+!! wikitext
+http://www.example.com/?title=100%25_Bran
+!! html/php
+<p><a rel="nofollow" class="external free" href="http://www.example.com/?title=100%25_Bran">http://www.example.com/?title=100%25_Bran</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://www.example.com/?title=100%25_Bran">http://www.example.com/?title=100%25_Bran</a></p>
+!! end
+
+!! test
+Bug 4781, 5267: %28, %29 in URL
+!! wikitext
+http://www.example.com/?title=Ben-Hur_%281959_film%29
+!! html/php
+<p><a rel="nofollow" class="external free" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">http://www.example.com/?title=Ben-Hur_%281959_film%29</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">http://www.example.com/?title=Ben-Hur_%281959_film%29</a></p>
+!! end
+
+
+!! test
+Bug 4781: %26 in autonumber URL
+!! wikitext
+[http://www.example.com/?title=AT%26T]
+!! html/php
+<p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T"></a></p>
+!! end
+
+!! test
+Bug 4781, 5267: %26 in autonumber URL
+!! wikitext
+[http://www.example.com/?title=100%25_Bran]
+!! html/php
+<p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://www.example.com/?title=100%25_Bran"></a></p>
+!! end
+
+!! test
+Bug 4781, 5267: %28, %29 in autonumber URL
+!! wikitext
+[http://www.example.com/?title=Ben-Hur_%281959_film%29]
+!! html/php
+<p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
+!! end
+
+
+!! test
+Bug 4781: %26 in bracketed URL
+!! wikitext
+[http://www.example.com/?title=AT%26T link]
+!! html/php
+<p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T">link</a></p>
+!! end
+
+!! test
+Bug 4781, 5267: %25 in bracketed URL
+!! wikitext
+[http://www.example.com/?title=100%25_Bran link]
+!! html
+<p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
+</p>
+!! end
+
+!! test
+Bug 4781, 5267: %28, %29 in bracketed URL
+!! wikitext
+[http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
+!! html/php
+<p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
+!! end
+
+!! test
+External link containing a period in the anchor. (bug 63947)
+!! wikitext
+[//foo.org/bar#baz. bang]
+
+[//foo.org/bar. bang]
+!! html/php
+<p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
+</p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="//foo.org/bar#baz.">bang</a></p>
+<p><a rel="mw:ExtLink" href="//foo.org/bar.">bang</a></p>
+!! end
+
+!! test
+External link containing a single quote. (bug 63947)
+!! wikitext
+[//foo.org/bar'baz]
+
+[//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>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="//foo.org/bar'baz"></a></p>
+<p><a rel="mw:ExtLink" href="//foo.org/bar'baz">bang</a></p>
+!! end
+
+
+!! test
+External link containing a period in the anchor. (bug 63947)
+!! wikitext
+[//foo.org/bar#baz. bang]
+
+[//foo.org/bar. bang]
+!! html/php
+<p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
+</p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="//foo.org/bar#baz.">bang</a></p>
+<p><a rel="mw:ExtLink" href="//foo.org/bar.">bang</a></p>
+!! end
+
+!! test
+External link containing a single quote. (bug 63947)
+!! wikitext
+[//foo.org/bar'baz]
+
+[//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>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="//foo.org/bar'baz"></a></p>
+<p><a rel="mw:ExtLink" href="//foo.org/bar'baz">bang</a></p>
+!! end
+
+
+!! test
+External link containing double-single-quotes in text '' (bug 4598 sanity check)
+!! wikitext
+Some [http://example.com/ pretty ''italics'' and stuff]!
+!! html
+<p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
+</p>
+!! end
+
+!! test
+External link containing double-single-quotes in text embedded in italics (bug 4598 sanity check)
+!! wikitext
+''Some [http://example.com/ pretty ''italics'' and stuff]!''
+!! html
+<p><i>Some </i><a rel="nofollow" class="external text" href="http://example.com/"><i>pretty </i>italics<i> and stuff</i></a><i>!</i>
+</p>
+!! end
+
+!! test
+External link containing double-single-quotes with no space separating the url from text in italics
+!! wikitext
+[http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm''La muerte de Casagemas'' (1901) en el sitio de [[Museo Picasso (París)|Museo Picasso]].]
+!! html/php
+<p><a rel="nofollow" class="external text" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm"><i>La muerte de Casagemas</i> (1901) en el sitio de <a href="/index.php?title=Museo_Picasso_(Par%C3%ADs)&amp;action=edit&amp;redlink=1" class="new" title="Museo Picasso (París) (page does not exist)">Museo Picasso</a>.</a>
+</p>
+!! html/php+tidy
+<p><a rel="nofollow" class="external text" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm"><i>La muerte de Casagemas</i> (1901) en el sitio de</a> <a href="/index.php?title=Museo_Picasso_(Par%C3%ADs)&amp;action=edit&amp;redlink=1" class="new" title="Museo Picasso (París) (page does not exist)">Museo Picasso</a>.</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm"><i>La muerte de Casagemas</i> (1901) en el sitio de </a><a rel="mw:WikiLink" href="./Museo_Picasso_(París)" title="Museo Picasso (París)">Museo Picasso</a><span>.</span></p>
+!! end
+
+!! test
+External link with comments in link text
+!! wikitext
+[http://www.google.com Google <!-- comment -->]
+!! html
+<p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
+</p>
+!! end
+
+!! test
+URL-encoding in URL functions (single parameter)
+!! wikitext
+{{localurl:Some page|amp=&}}
+!! html
+<p>/index.php?title=Some_page&amp;amp=&amp;
+</p>
+!! end
+
+!! test
+URL-encoding in URL functions (multiple parameters)
+!! wikitext
+{{localurl:Some page|q=?&amp=&}}
+!! html
+<p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
+</p>
+!! end
+
+!! test
+Brackets in urls
+!! wikitext
+http://example.com/index.php?foozoid%5B%5D=bar
+
+http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
+!! html/php
+<p><a rel="nofollow" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a>
+</p><p><a rel="nofollow" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a></p>
+
+<p><a rel="mw:ExtLink" href="http://example.com/index.php?foozoid[]=bar">http://example.com/index.php?foozoid[]=bar</a></p>
+!! end
+
+!! test
+IPv6 urls (bug 21261)
+!! options
+disabled
+!! wikitext
+http://[2404:130:0:1000::187:2]/index.php
+!! html
+<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>
+!! end
+
+!! test
+Non-extlinks in brackets
+!! wikitext
+[foo]
+[foo bar]
+[foo ''bar'']
+[fool's] errand
+[fool's errand]
+[{{echo|foo}}]
+[{{echo|foo}} bar]
+[{{echo|foo}} ''bar'']
+[{{echo|foo}}l's] errand
+[{{echo|foo}}l's errand]
+[url={{echo|foo}}]
+[url=http://example.com]
+!! html
+<p>[foo]
+[foo bar]
+[foo <i>bar</i>]
+[fool's] errand
+[fool's errand]
+[foo]
+[foo bar]
+[foo <i>bar</i>]
+[fool's] errand
+[fool's errand]
+[url=foo]
+[url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
+</p>
+!! end
+
+!! test
+Percent encoding in external links
+!! wikitext
+[https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
+!! html/php
+<p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink"
+href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
+!! end
+
+!! test
+Use url link syntax for links where the content is equal the link target
+!! wikitext
+http://example.com
+!! html/php
+<p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></p>
+!! end
+
+!! test
+Parenthesis in external links, especially URL links
+!! wikitext
+http://example.com)
+
+http://example.com/test)
+
+http://example.com/(test)
+
+http://example.com/((test)
+
+(http://example.com/(test))
+
+(http://example.com/(test)))))
+
+http://example.com/a)b
+
+[http://example.com) foo]
+!! html/php
+<p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
+</p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
+</p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
+</p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
+</p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
+</p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
+</p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
+</p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a>)</p>
+<p><a rel="mw:ExtLink" href="http://example.com/test">http://example.com/test</a>)</p>
+<p><a rel="mw:ExtLink" href="http://example.com/(test)">http://example.com/(test)</a></p>
+<p><a rel="mw:ExtLink" href="http://example.com/((test)">http://example.com/((test)</a></p>
+<p>(<a rel="mw:ExtLink" href="http://example.com/(test))">http://example.com/(test))</a></p>
+<p>(<a rel="mw:ExtLink" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
+<p><a rel="mw:ExtLink" href="http://example.com/a)b">http://example.com/a)b</a></p>
+<p><a rel="mw:ExtLink" href="http://example.com)">foo</a></p>
+!! end
+
+!! test
+Parenthesis in external links, w/ transclusion or comment
+!! wikitext
+(http://example.com/{{echo|hi}})
+
+(http://example.com<!-- hi -->)
+!! html/php
+<p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
+</p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
+</p>
+!! html/parsoid
+<p>(<a data-mw='{"attribs":[[{"txt":"href"},{"html":"http://example.com/&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-mw=\"{&amp;quot;parts&amp;quot;:[{&amp;quot;template&amp;quot;:{&amp;quot;target&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;echo&amp;quot;,&amp;quot;href&amp;quot;:&amp;quot;./Template:Echo&amp;quot;},&amp;quot;params&amp;quot;:{&amp;quot;1&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;hi&amp;quot;}},&amp;quot;i&amp;quot;:0}}]}\" data-parsoid=\"{&amp;quot;pi&amp;quot;:[[{&amp;quot;k&amp;quot;:&amp;quot;1&amp;quot;,&amp;quot;spc&amp;quot;:[&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;]}]],&amp;quot;dsr&amp;quot;:[20,31,null,null]}\">hi&lt;/span>"}]]}' typeof="mw:ExpandedAttrs" about="#mwt2" rel="mw:ExtLink" href="http://example.com/hi" data-parsoid='{"stx":"url","a":{"href":"http://example.com/hi"},"sa":{"href":"http://example.com/{{echo|hi}}"}}'>http://example.com/hi</a>)</p>
+
+<p>(<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url","a":{"href":"http://example.com"},"sa":{"href":"http://example.com&lt;!-- hi -->"}}'>http://example.com</a>)</p>
+!! end
+
+!! test
+Replace invalid link targets when serializing
+!! options
+parsoid=html2wt
+!! html
+<a rel="mw:WikiLink" href="./]] foo [[bar">Manual</a>
+!! wikitext
+[[MediaWiki:Badtitletext|Manual]]
+!! end
+
+###
+### Quotes
+###
+
+!! test
+Quotes
+!! wikitext
+Normal text. '''Bold text.''' Normal text. ''Italic text.''
+
+Normal text. '''''Bold italic text.''''' Normal text.
+!! html
+<p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
+</p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
+</p>
+!! end
+
+
+# Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
+# parser strips. The wikitext contains just the first half of the bold
+# quote pair.
+!! test
+Unclosed and unmatched quotes
+!! wikitext
+'''''Bold italic text '''with bold deactivated''' in between.'''''
+
+'''''Bold italic text ''with italic deactivated'' in between.'''''
+
+'''Bold text..
+
+..spanning two paragraphs (should not work).'''
+
+'''Bold tag left open
+
+''Italic tag left open
+
+Normal text.
+
+<!-- Unmatching number of opening, closing tags: -->
+'''This year''''s election ''should'' beat '''last year''''s.
+
+''Tom'''s car is bigger than ''Susan'''s.
+
+Plain ''italic'''s plain
+!! html/php
+<p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
+</p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
+</p><p><b>Bold text..</b>
+</p><p>..spanning two paragraphs (should not work).
+</p><p><b>Bold tag left open</b>
+</p><p><i>Italic tag left open</i>
+</p><p>Normal text.
+</p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
+</p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
+</p><p>Plain <i>italic'</i>s plain
+</p>
+!! html/parsoid
+<p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
+</p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
+</p><p><b>Bold text..</b>
+</p><p>..spanning two paragraphs (should not work).<b></b>
+</p><p><b>Bold tag left open</b>
+</p><p><i>Italic tag left open</i>
+</p><p>Normal text.
+</p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
+</p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
+</p><p>Plain <i>italic'</i>s plain
+</p>
+!! end
+
+###
+### Tables
+###
+### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
+###
+
+# This should not produce <table></table> as <table><tr><td></td></tr></table>
+# is the bare minimum required by the spec, see:
+# http://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
+# Parsoid team replies: empty table tags are legal in HTML5
+!! test
+A table with no data.
+!! options
+parsoid=wt2html
+!! wikitext
+{||}
+!! html/php
+
+!! html/parsoid
+<table></table>
+
+!! end
+
+!! test
+A table with stray table end tags on start tag line (wt2html)
+!! options
+parsoid=wt2html
+!! wikitext
+{|style="color: red;"|}
+
+{|style="color: red;" |}
+|foo
+|}
+
+{|style="color: red;"|} id="foo"
+|foo
+|}
+
+{|style="color: red;" |} id="foo"
+|foo
+|}
+!! html
+<table style="color: red;"></table>
+
+<table style="color: red;">
+<tbody><tr>
+<td>foo</td>
+</tr></tbody>
+</table>
+
+<table style="color: red;" id="foo">
+<tbody><tr>
+<td>foo</td>
+</tr></tbody>
+</table>
+
+<table style="color: red;" id="foo">
+<tbody><tr>
+<td>foo</td>
+</tr></tbody>
+</table>
+
+!! end
+
+!! test
+A table with no data (take 2)
+!! wikitext
+{|
+|}
+!! html/parsoid
+<table></table>
+!! end
+
+# A table with nothing but a caption is invalid XHTML, we might want to render
+# this as <p>caption</p>
+# Parsoid team replies: table with only a caption is legal in HTML5
+!! test
+A table with nothing but a caption
+!! wikitext
+{|
+|+ caption
+|}
+!! html/php
+<table>
+<caption> caption
+</caption><tr><td></td></tr></table>
+
+!! html/parsoid
+<table><caption> caption</caption></table>
+!! end
+
+!! test
+A table with caption with default-spaced attributes and a table row
+!! wikitext
+{|
+|+ style="color: red;" | caption1
+|-
+| foo
+|}
+!! html
+<table>
+<caption style="color: red;"> caption1
+</caption>
+<tr>
+<td> foo
+</td></tr></table>
+
+!! end
+
+!! test
+A table with captions with non-default spaced attributes and a table row
+!! wikitext
+{|
+|+style="color: red;"|caption2
+|+ style="color: red;"| caption3
+|-
+| foo
+|}
+!! html
+<table>
+<caption style="color: red;">caption2
+</caption>
+<caption style="color: red;"> caption3
+</caption>
+<tr>
+<td> foo
+</td></tr></table>
+
+!! end
+
+!! test
+Table td-cell syntax variations
+!! wikitext
+{|
+| foo bar foo | baz
+| foo bar foo || baz
+| style='color:red;' | baz
+| style='color:red;' || baz
+|}
+!! html
+<table>
+<tr>
+<td> baz
+</td>
+<td> foo bar foo </td>
+<td> baz
+</td>
+<td style="color:red;"> baz
+</td>
+<td> style='color:red;' </td>
+<td> baz
+</td></tr></table>
+
+!! end
+
+!! test
+Simple table
+!! wikitext
+{|
+| 1 || 2
+|-
+| 3 || 4
+|}
+!! html
+<table>
+<tr>
+<td> 1 </td>
+<td> 2
+</td></tr>
+<tr>
+<td> 3 </td>
+<td> 4
+</td></tr></table>
+
+!! end
+
+!! test
+Simple table but with multiple dashes for row wikitext
+!! wikitext
+{|
+| foo
+|-----
+| bar
+|}
+!! html
+<table>
+<tr>
+<td> foo
+</td></tr>
+<tr>
+<td> bar
+</td></tr></table>
+
+!! end
+!! test
+Multiplication table
+!! wikitext
+{| border="1" cellpadding="2"
+|+Multiplication table
+|-
+! &times; !! 1 !! 2 !! 3
+|-
+! 1
+| 1 || 2 || 3
+|-
+! 2
+| 2 || 4 || 6
+|-
+! 3
+| 3 || 6 || 9
+|-
+! 4
+| 4 || 8 || 12
+|-
+! 5
+| 5 || 10 || 15
+|}
+!! html
+<table border="1" cellpadding="2">
+<caption>Multiplication table
+</caption>
+<tr>
+<th> &#215; </th>
+<th> 1 </th>
+<th> 2 </th>
+<th> 3
+</th></tr>
+<tr>
+<th> 1
+</th>
+<td> 1 </td>
+<td> 2 </td>
+<td> 3
+</td></tr>
+<tr>
+<th> 2
+</th>
+<td> 2 </td>
+<td> 4 </td>
+<td> 6
+</td></tr>
+<tr>
+<th> 3
+</th>
+<td> 3 </td>
+<td> 6 </td>
+<td> 9
+</td></tr>
+<tr>
+<th> 4
+</th>
+<td> 4 </td>
+<td> 8 </td>
+<td> 12
+</td></tr>
+<tr>
+<th> 5
+</th>
+<td> 5 </td>
+<td> 10 </td>
+<td> 15
+</td></tr></table>
+
+!! end
+
+!! test
+Accept "||" in table headings
+!! wikitext
+{|
+!h1 || h2
+|}
+!! html
+<table>
+<tr>
+<th>h1 </th>
+<th> h2
+</th></tr></table>
+
+!! end
+
+!! test
+Accept "!!" in table data
+!! wikitext
+{|
+| Foo!! ||
+|}
+!! html
+<table>
+<tr>
+<td> Foo!! </td>
+<td>
+</td></tr></table>
+
+!! html/parsoid
+<table data-parsoid='{}'>
+<tbody data-parsoid='{}'><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'></td></tr>
+</tbody></table>
+!! end
+
+!! test
+Accept "||" in indented table headings
+!! wikitext
+:{|
+!h1 || h2
+|}
+!! html
+<dl><dd><table>
+<tr>
+<th>h1 </th>
+<th> h2
+</th></tr></table></dd></dl>
+
+!! end
+
+!! test
+Accept empty attributes in td/th cells (td/th cells starting with leading ||)
+!! wikitext
+{|
+!| h1
+|| a
+|}
+!! html
+<table>
+<tr>
+<th> h1
+</th>
+<td> a
+</td></tr></table>
+
+!! end
+
+!!test
+Accept "| !" at start of line in tables (ignore !-attribute)
+!! wikitext
+{|
+|-
+| !style="color:red" | bar
+|}
+!! html
+<table>
+
+<tr>
+<td> bar
+</td></tr></table>
+
+!!end
+
+!!test
+Allow +/- in 2nd and later cells in a row, in 1st cell when td-attrs are present, or in 1st cell when there is a space between "|" and +/-
+!! wikitext
+{|
+|-
+|style='color:red;'|+1
+|style='color:blue;'|-1
+|-
+| 1 || 2 || 3
+| 1 ||+2 ||-3
+|-
+| +1
+| -1
+|}
+!! html
+<table>
+
+<tr>
+<td style="color:red;">+1
+</td>
+<td style="color:blue;">-1
+</td></tr>
+<tr>
+<td> 1 </td>
+<td> 2 </td>
+<td> 3
+</td>
+<td> 1 </td>
+<td>+2 </td>
+<td>-3
+</td></tr>
+<tr>
+<td> +1
+</td>
+<td> -1
+</td></tr></table>
+
+!!end
+
+!! test
+Table rowspan
+!! wikitext
+{| border=1
+| Cell 1, row 1
+|rowspan=2| Cell 2, row 1 (and 2)
+| Cell 3, row 1
+|-
+| Cell 1, row 2
+| Cell 3, row 2
+|}
+!! html
+<table border="1">
+<tr>
+<td> Cell 1, row 1
+</td>
+<td rowspan="2"> Cell 2, row 1 (and 2)
+</td>
+<td> Cell 3, row 1
+</td></tr>
+<tr>
+<td> Cell 1, row 2
+</td>
+<td> Cell 3, row 2
+</td></tr></table>
+
+!! end
+
+!! test
+Nested table
+!! wikitext
+{| border=1
+| &alpha;
+|
+{| bgcolor=#ABCDEF border=2
+|nested
+|-
+|table
+|}
+|the original table again
+|}
+!! html
+<table border="1">
+<tr>
+<td> &#945;
+</td>
+<td>
+<table bgcolor="#ABCDEF" border="2">
+<tr>
+<td>nested
+</td></tr>
+<tr>
+<td>table
+</td></tr></table>
+</td>
+<td>the original table again
+</td></tr></table>
+
+!! end
+
+!! test
+Invalid attributes in table cell (bug 1830)
+!! wikitext
+{|
+|Cell:|broken
+|}
+!! html
+<table>
+<tr>
+<td>broken
+</td></tr></table>
+
+!! end
+
+
+# The "|}" to close the table is missing from the input, so parsoid's
+# *2wt modes will fail.
+!! test
+Table security: embedded pipes (http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html)
+!! options
+parsoid=wt2html,html2html
+!! wikitext
+{|
+| |[ftp://|x||]" onmouseover="alert(document.cookie)">test
+!! html/php
+<table>
+<tr>
+<td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
+<td>]" onmouseover="alert(document.cookie)"&gt;test
+</td>
+</tr>
+</table>
+
+!! html/parsoid
+<table><tbody>
+<tr>
+<td><a rel="mw:ExtLink" href="ftp://|x||"></a>" onmouseover="alert(document.cookie)">test</td></tr></tbody></table>
+!! end
+
+
+!! test
+Indented table markup mixed with indented pre content (proposed in bug 6200)
+!! wikitext
+ <table>
+ <tr>
+ <td>
+ Text that should be rendered preformatted
+ </td>
+ </tr>
+ </table>
+!! html
+ <table>
+ <tr>
+ <td>
+<pre>Text that should be rendered preformatted
+</pre>
+ </td>
+ </tr>
+ </table>
+
+!! end
+
+!! test
+Template-generated table cell attributes and cell content
+!! wikitext
+{|
+|{{table_attribs}}
+| {{table_attribs}}
+|}
+!! html
+<table>
+<tr>
+<td style="color: red"> Foo
+</td>
+<td style="color: red"> Foo
+</td></tr></table>
+
+!! end
+
+!! test
+Template-generated table cell attributes and cell content (2)
+!! wikitext
+{|
+|align=center {{table_attribs}}
+|}
+!! html
+<table>
+<tr>
+<td align="center" style="color: red"> Foo
+</td></tr></table>
+
+!! end
+
+!! test
+Template-generated table cell attributes and cell content (3)
+!! wikitext
+{|
+|align=center {{table_cells}}
+|}
+!! html
+<table>
+<tr>
+<td align="center" style="color: red"> Foo </td>
+<td> Bar </td>
+<td> Baz
+</td></tr></table>
+
+!! end
+
+!! test
+Table with row followed by newlines and table heading
+!! wikitext
+{|
+|-
+
+! foo
+|}
+!! html
+<table>
+
+
+<tr>
+<th> foo
+</th></tr></table>
+
+!! end
+
+!! test
+Table with empty line following the start tag
+!! wikitext
+{|
+
+|-
+| foo
+|}
+!! html
+<table>
+
+
+<tr>
+<td> foo
+</td></tr></table>
+
+!! end
+
+# FIXME: Preserve the attribute properly (with an empty string as value) in
+# the PHP parser. Parsoid implements the behavior below.
+!! test
+Table attributes with empty value
+!! wikitext
+{|
+| style=| hello
+|}
+!! html/parsoid
+<table>
+<tbody>
+<tr>
+<td style=""> hello
+</td></tr></tbody></table>
+
+!! end
+
+!! test
+Wikitext table with a lot of comments
+!! wikitext
+{|
+<!-- c0 -->
+| foo
+<!-- c1 -->
+|- <!-- c2 -->
+<!-- c3 -->
+|<!-- c4 -->
+<!-- c5 -->
+|}
+!! html
+<table>
+<tr>
+<td> foo
+</td></tr>
+<tr>
+<td>
+</td></tr></table>
+
+!! end
+
+!! test
+Wikitext table with double-line table cell
+!! wikitext
+{|
+|a
+b
+|}
+!! html
+<table>
+<tr>
+<td>a
+<p>b
+</p>
+</td></tr></table>
+
+!! end
+
+!! test
+Table cell with a single comment
+!! wikitext
+{|
+| <!-- c1 -->
+| a
+|}
+!! html
+<table>
+<tr>
+<td>
+</td>
+<td> a
+</td></tr></table>
+
+!! end
+
+!! test
+Table-cell after a comment-only-empty-line
+!! wikitext
+{|
+|a
+<!--c1-->
+<!--c2-->| b
+|}
+!! html
+<table>
+<tr>
+<td>a
+</td>
+<td> b
+</td></tr></table>
+
+!! html/parsoid
+<table>
+<tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
+<!--c1-->
+<!--c2--><td data-parsoid='{"autoInsertedEnd":true}'> b</td></tr>
+</tbody></table>
+
+!! end
+
+!! test
+Build table with {{!}}
+!! wikitext
+{{{!}} class="wikitable"
+! header
+! second header
+{{!}}- style="color:red;"
+{{!}} data {{!}}{{!}} style="color:red;" {{!}} second data
+{{!}}}
+!! html
+<table class="wikitable">
+<tr>
+<th> header
+</th>
+<th> second header
+</th></tr>
+<tr style="color:red;">
+<td> data </td>
+<td style="color:red;"> second data
+</td></tr></table>
+
+!! end
+
+# The expected HTML structure in this test is debatable. The PHP parser does
+# not parse this kind of table at all. The main focus for Parsoid is on
+# round-tripping, so this output is ok for now. TODO: revisit!
+!! test
+Wikitext table with html-syntax row
+!! wikitext
+{|
+|-
+<td>foo</td>
+|}
+!! html/parsoid
+<table>
+<tbody>
+<tr>
+<td>foo</td></tr></tbody></table>
+!! end
+
+## Note that Parsoid output differs from PHP and PHP+tidy here.
+## The lack of <tr> tags in the PHP output is arguably a bug in the
+## PHP parser, which tidy then compounds by fostering the content
+## entirely out of the table. Parsoid recognizes the table context
+## and generates <tr> and <td> wrappers as needed. Hopefully nobody
+## depends on PHP's treatment of broken table markup!
+!! test
+Implicit <td> after a |-
+!! options
+parsoid=wt2html,wt2wt
+!! wikitext
+{|
+|-
+a
+|}
+!! html/php
+<table>
+
+a
+</table>
+
+!! html/php+tidy
+<p>a</p>
+!! html/parsoid
+<table>
+<tr><td>a</td></tr>
+</table>
+!! end
+
+# Again, Parsoid adds implicit <td>s here, PHP and Tidy strip the b out.
+!! test
+<pre> tags should be recognized in an explicit <td> context, but not in an implicit <td> context
+!! options
+parsoid=wt2html,wt2wt
+!! wikitext
+{|
+|-
+|
+ a
+|-
+ b
+|}
+!! html/php
+<table>
+
+<tr>
+<td>
+<pre>a
+</pre>
+</td></tr>
+ b
+</table>
+
+!! html/php+tidy
+<p>b</p>
+<table>
+<tr>
+<td>
+<pre>
+a
+</pre></td>
+</tr>
+</table>
+!! html/parsoid
+<table>
+<tbody>
+<tr><td><pre>a</pre></td></tr>
+<tr><td> b</td></tr>
+</tbody>
+</table>
+!! end
+
+# PHP + Tidy strips the list out of the table; Parsoid wraps it.
+!! test
+Lists should be recognized in an implicit <td> context
+!! options
+parsoid=wt2html,wt2wt
+!! wikitext
+{|
+|-
+*a
+|}
+!! html/php
+<table>
+
+<ul><li>a</li></ul>
+</table>
+
+!! html/php+tidy
+<ul>
+<li>a</li>
+</ul>
+!! html/parsoid
+<table>
+<tr>
+<td><ul>
+<li>a</li>
+</ul></td>
+</tr>
+</table>
+!! end
+
+!! test
+Parsoid: Round-trip tables directly followed by content (bug 51219)
+!! options
+parsoid=wt2html,wt2wt
+!! wikitext
+{|
+|foo
+|} bar
+
+{|
+|baz
+|}<b>quux</b>
+!! html
+<table><tbody>
+<tr>
+<td>foo</td></tr></tbody></table> bar
+<table>
+<tbody>
+<tr>
+<td>baz</td></tr></tbody></table><b>quux</b>
+!! end
+
+!! test
+Parsoid: Default to a newline after tables in new content (bug 51219)
+!! options
+parsoid=html2wt
+!! wikitext
+{|
+|foo
+|}
+<nowiki> </nowiki>bar
+{|
+|baz
+|}
+'''quux'''
+!! html
+<table><tbody>
+<tr><td>foo</td></tr></tbody></table> bar
+<table><tbody>
+<tr><td>baz</td></tr></tbody></table><b>quux</b>
+!! end
+
+!! test
+Parsoid: newline inducing block nodes don't suppress <nowiki>
+!! options
+parsoid=html2wt
+!! wikitext
+<nowiki> </nowiki>a
+
+= foo =
+!! html
+ a<h1>foo</h1>
+!! end
+
+!! test
+Parsoid: Row-syntax table headings followed by comment & table cells
+!! options
+parsoid=wt2html,wt2wt
+!! wikitext
+{|
+! foo || bar
+<!-- foo --> || baz || quux
+|}
+!! html/php
+<table>
+<tr>
+<th> foo </th>
+<th> bar
+</th>
+<td> baz </td>
+<td> quux
+</td></tr></table>
+
+!! html/parsoid
+<table>
+<tbody><tr><th> foo </th><th> bar
+<!-- foo --> </th><td> baz </td><td> quux</td></tr>
+</tbody></table>
+!! end
+
+
+# PHP throws away the (semi-broken) "foo" class here; Parsoid
+# preserves it.
+!!test
+Parsoid: Recover better from broken table attributes
+!!options
+parsoid=wt2html
+!!wikitext
+{| class="foo
+| class="bar" |
+foo
+|}
+!!html/php+tidy
+<table>
+<tr>
+<td class="bar">
+<p>foo</p>
+</td>
+</tr>
+</table>
+!!html/parsoid
+<table class="foo">
+<tr>
+<td class="bar">
+<p>foo</p></td></tr>
+</tbody></table>
+!!end
+
+!! test
+Strip unsupported table tags
+!! options
+parsoid=html2wt
+!! html
+<table>
+<thead>
+<tr>
+<th>Month</th>
+<th>Savings</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>January</td>
+<td>$100</td>
+</tr>
+<tr>
+<td>February</td>
+<td>$80</td>
+</tr>
+</tbody>
+<tfoot>
+<tr>
+<td>Sum</td>
+<td>$180</td>
+</tr>
+</tfoot>
+</table>
+!! wikitext
+{|
+
+!Month
+!Savings
+
+|January
+|$100
+
+|-
+|February
+|$80
+
+|Sum
+|$180
+
+|}
+!! end
+
+###
+### Internal links
+###
+!! test
+Plain link, capitalized
+!! wikitext
+[[Main Page]]
+!! html
+<p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
+</p>
+!! end
+
+!! test
+Plain link, uncapitalized
+!! wikitext
+[[main Page]]
+!! html
+<p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
+</p>
+!! end
+
+!! test
+Piped link
+!! wikitext
+[[Main Page|The Main Page]]
+!! html
+<p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
+</p>
+!! end
+
+!! test
+Piped link with comment in link text
+!! wikitext
+[[Main Page|The Main<!--front--> Page]]
+!! html
+<p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
+</p>
+!! end
+
+!! test
+Piped link with multiple pipe characters in link text
+!! wikitext
+[[Main Page||The|Main|Page|]]
+!! html/php
+<p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="Main_Page" title="Main Page">|The|Main|Page|</a></p>
+!! end
+
+!! test
+Broken link
+!! wikitext
+[[Zigzagzogzagzig]]
+!! html
+<p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
+</p>
+!! end
+
+!! test
+Broken link with fragment
+!! wikitext
+[[Zigzagzogzagzig#zug]]
+!! html
+<p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
+</p>
+!! end
+
+!! test
+Special page link with fragment
+!! wikitext
+[[Special:Version#anchor]]
+!! html
+<p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
+</p>
+!! end
+
+!! test
+Nonexistent special page link with fragment
+!! wikitext
+[[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
+!! html
+<p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
+</p>
+!! end
+
+!! test
+Link with prefix
+!! wikitext
+xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
+!! html
+<p>xxx<a href="/wiki/Main_Page" title="Main Page">main Page</a>, xxx<a href="/wiki/Main_Page" title="Main Page">Main Page</a>, Xxx<a href="/wiki/Main_Page" title="Main Page">main Page</a> XXX<a href="/wiki/Main_Page" title="Main Page">main Page</a>, XXX<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
+</p>
+!! end
+
+!! test
+Link with suffix
+!! wikitext
+[[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
+!! html
+<p><a href="/wiki/Main_Page" title="Main Page">Main Pagexxx</a>, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>XXX, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>!!!
+</p>
+!! end
+
+!! article
+prefixed article
+!! text
+Some text
+!! endarticle
+
+!! test
+Bug 43661: Piped links with identical prefixes
+!! wikitext
+[[prefixed article|prefixed articles with spaces]]
+
+[[prefixed article|prefixed articlesaoeu]]
+
+[[Main Page|Main Page test]]
+!! html
+<p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
+</p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
+</p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
+</p>
+!! end
+
+
+!! test
+Link with HTML entity in suffix / tail
+!! wikitext
+[[Main Page]]&quot;, [[Main Page]]&#97;
+!! html
+<p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>&quot;, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>&#97;
+</p>
+!! end
+
+!! test
+Link with 3 brackets
+!! wikitext
+[[[Main Page]]]
+!! html
+<p>[[[Main Page]]]
+</p>
+!! end
+
+!! test
+Link with 4 brackets
+!! wikitext
+[[[[Main Page]]]]
+!! html
+<p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
+</p>
+!! end
+
+!! test
+Piped link with 3 brackets
+!! wikitext
+[[[main page|the main page]]]
+!! html
+<p>[[[main page|the main page]]]
+</p>
+!! end
+
+!! test
+Piped link with extlink-like text
+!! wikitext
+[[Main Page|[bar]]]
+[[Main Page|This is a [bar]]]
+!! html
+<p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
+<a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
+</p>
+!! end
+
+!! test
+Link with multiple pipes
+!! wikitext
+[[Main Page|The|Main|Page]]
+!! html
+<p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
+</p>
+!! end
+
+# Note that parsoid does not munge anchor text; all non-space
+# characters are valid in HTML5 ids.
+!! test
+Anchor containing a #. (bug 63430)
+!! wikitext
+[[Main Page#And#Link]]
+!! html/php
+<p><a href="/wiki/Main_Page#And.23Link" title="Main Page">Main Page#And#Link</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="./Main_Page#And%23Link" title="Main Page">Main Page#And#Link</a></p>
+!! end
+
+!! test
+Link to namespaces
+!! wikitext
+[[Talk:Parser testing]], [[Meta:Disclaimers]]
+!! html
+<p><a href="/index.php?title=Talk:Parser_testing&amp;action=edit&amp;redlink=1" class="new" title="Talk:Parser testing (page does not exist)">Talk:Parser testing</a>, <a href="/index.php?title=Meta:Disclaimers&amp;action=edit&amp;redlink=1" class="new" title="Meta:Disclaimers (page does not exist)">Meta:Disclaimers</a>
+</p>
+!! end
+
+!! test
+Link with space in namespace
+!! wikitext
+[[User talk:Foo bar]]
+!! html
+<p><a href="/index.php?title=User_talk:Foo_bar&amp;action=edit&amp;redlink=1" class="new" title="User talk:Foo bar (page does not exist)">User talk:Foo bar</a>
+</p>
+!! end
+
+!! article
+MemoryAlpha:AlphaTest
+!! text
+This is an article in the MemoryAlpha namespace
+(which shadows the memoryalpha interwiki link).
+!! endarticle
+
+!! test
+Namespace takes precedence over interwiki link (bug 51680)
+!! wikitext
+[[MemoryAlpha:AlphaTest]]
+!! html
+<p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
+</p>
+!! end
+
+# The previous test doesn't work correctly in html2*, due to not recognizing the
+# link as an internal one. This one checks for the correct behavior.
+!! test
+Link to namespace preferred over interwiki with correct rel attribute
+!! options
+parsoid=html2wt,html2html
+!! wikitext
+[[MemoryAlpha:AlphaTest]]
+!! html
+<p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
+</p>
+!! end
+
+!! test
+Piped link to namespace
+!! wikitext
+[[Meta:Disclaimers|The disclaimers]]
+!! html
+<p><a href="/index.php?title=Meta:Disclaimers&amp;action=edit&amp;redlink=1" class="new" title="Meta:Disclaimers (page does not exist)">The disclaimers</a>
+</p>
+!! end
+
+!! test
+Link containing }
+!! wikitext
+[[Usually caused by a typo (oops}]]
+!! html
+<p>[[Usually caused by a typo (oops}]]
+</p>
+!! end
+
+!! article
+7% Solution
+!! text
+Just a test of an article title containing a percent.
+!! endarticle
+
+!! test
+Link containing % (not as a hex sequence)
+!! wikitext
+[[7% Solution]]
+!! html/php
+<p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a></p>
+!! end
+
+# note that the parsoid HTML is identical to the previous test output,
+# so the previous test ensures that the html2wt mode will generate the
+# "not as a hex sequence" wikitext.
+!! test
+Link containing % as a single hex sequence interpreted to char
+!! options
+parsoid=wt2wt,wt2html,html2html
+!! wikitext
+[[7%25 Solution]]
+!! html/php
+<p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a></p>
+!!end
+
+!! test
+Link containing % as a double hex sequence interpreted to hex sequence
+!! wikitext
+[[7%2525 Solution]]
+!! html
+<p>[[7%2525 Solution]]
+</p>
+!!end
+
+# note that parsoid does not munge anchor text; all non-space
+# characters are valid in HTML5 anchors.
+!! test
+Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
+Example for such a section: == < ==
+!! wikitext
+[[%23%3c]][[%23%3e]]
+!! html/php
+<p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="./Main%20Page#%3C" title="Main Page">#&lt;</a><a rel="mw:WikiLink" href="./Main%20Page#%3E" title="Main Page">#></a></p>
+!! end
+
+!! test
+Link containing "<#" and ">#" as a hex sequences
+!! wikitext
+[[%3c%23]][[%3e%23]]
+!! html
+<p>[[%3c%23]][[%3e%23]]
+</p>
+!! end
+
+!! test
+Link containing an equals sign
+!! wikitext
+[[Special:BookSources/isbn=4-00-026157-6]]
+!! html/php
+<p><a href="/wiki/Special:BookSources/isbn%3D4-00-026157-6" title="Special:BookSources/isbn=4-00-026157-6">Special:BookSources/isbn=4-00-026157-6</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="./Special:BookSources/isbn=4-00-026157-6" title="Special:BookSources/isbn=4-00-026157-6">Special:BookSources/isbn=4-00-026157-6</a></p>
+!! end
+
+!! article
+Foo~bar
+!! text
+Just a test of an article title containing a tilde.
+!! endarticle
+
+# note that links containing signatures, like [[Foo~~~~]], are
+# massaged by the pre-save transform (PST) and so the tildes are never
+# seen by the parser.
+!! test
+Link containing a tilde
+!! wikitext
+[[Foo~bar]]
+!! html/php
+<p><a href="/wiki/Foo%7Ebar" title="Foo~bar">Foo~bar</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
+!! end
+
+!! test
+Link containing double-single-quotes '' (bug 4598)
+!! 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>
+!! 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>
+!! end
+
+!! test
+Link containing double-single-quotes '' in text (bug 4598 sanity check)
+!! wikitext
+Some [[Link|pretty ''italics'' and stuff]]!
+!! html/php
+<p>Some <a href="/index.php?title=Link&amp;action=edit&amp;redlink=1" class="new" title="Link (page does not exist)">pretty <i>italics</i> and stuff</a>!
+</p>
+!! html/parsoid
+<p>Some <a rel="mw:WikiLink" href="Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
+!! end
+
+!! test
+Link containing double-single-quotes '' in text embedded in italics (bug 4598 sanity check)
+!! wikitext
+''Some [[Link|pretty ''italics'' and stuff]]!''
+!! html
+<p><i>Some <a href="/index.php?title=Link&amp;action=edit&amp;redlink=1" class="new" title="Link (page does not exist)">pretty <i>italics</i> and stuff</a>!</i>
+</p>
+!! end
+
+!! test
+Link with double quotes in title part (literal) and alternate part (interpreted)
+!! wikitext
+[[File:Denys Savchenko ''Pentecoste''.jpg]]
+
+[[''Pentecoste'']]
+
+[[''Pentecoste''|Pentecoste]]
+
+[[''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>
+!! html/parsoid
+<meta typeof="mw:Placeholder"/>
+<p><a rel="mw:WikiLink" href="''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
+<p><a rel="mw:WikiLink" href="''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
+<p><a rel="mw:WikiLink" href="''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
+!! end
+
+!! test
+Broken image links with HTML captions (bug 39700)
+!! wikitext
+[[File:Nonexistent|<script></script>]]
+[[File:Nonexistent|100px|<script></script>]]
+[[File:Nonexistent|&lt;]]
+[[File:Nonexistent|a<i>b</i>c]]
+!! html
+<p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
+<a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
+<a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
+<a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
+</p>
+!! end
+
+!! test
+Plain link to URL
+!! wikitext
+[[http://www.example.com]]
+!! html/php
+<p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
+</p>
+!! html/parsoid
+<p>[<a rel="mw:ExtLink" href="http://www.example.com"></a>]</p>
+!! end
+
+!! test
+Plain link to URL with link text
+!! wikitext
+[[http://www.example.com Link text]]
+!! html
+<p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
+</p>
+!! end
+
+!! test
+Plain link to protocol-relative URL
+!! wikitext
+[[//www.example.com]]
+!! html/php
+<p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
+</p>
+!! html/parsoid
+<p>[<a rel="mw:ExtLink" href="//www.example.com"></a>]</p>
+!! end
+
+!! test
+Plain link to protocol-relative URL with link text
+!! wikitext
+[[//www.example.com Link text]]
+!! html
+<p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
+</p>
+!! end
+
+!! test
+Plain link to page with question mark in title
+!! wikitext
+[[A?b]]
+
+[[A?b|Baz]]
+!! html
+<p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
+</p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
+</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.
+#
+# ----
+# I'm changing it to match the current output--it arguably makes more
+# sense in the light of the test above. Old expected result was:
+#<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
+#</p>
+# But I think this test is bordering on "garbage in, garbage out" anyway.
+# -- wtm
+!! test
+Piped link to URL
+!! wikitext
+Piped link to URL: [[http://www.example.com|an example URL]]
+!! html/php
+<p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
+</p>
+!! html/parsoid
+<p>Piped link to URL: [<a rel="mw:ExtLink" href="http://www.example.com|an">example URL</a>]</p>
+!! end
+
+!! test
+BUG 2: [[page|http://url/]] should link to page, not http://url/
+!! wikitext
+[[Main Page|http://url/]]
+!! html/php
+<p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
+!! end
+
+# Parsoid does not mark self-links, by design.
+!! test
+BUG 337: Escaped self-links should be bold
+!! options
+title=[[Bug462]]
+!! wikitext
+[[Bu&#103;462]] [[Bug462]]
+!! html/php
+<p><strong class="selflink">Bu&#103;462</strong> <strong class="selflink">Bug462</strong>
+</p>
+!! html/php+tidy
+<p><strong class="selflink">Bug462</strong> <strong class="selflink">Bug462</strong></p>
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
+!! end
+
+!! test
+Self-link to section should not be bold
+!! options
+title=[[Main Page]]
+!! wikitext
+[[Main Page#section]]
+!! html
+<p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
+</p>
+!! end
+
+!! article
+00
+!! text
+This is 00.
+!! endarticle
+
+!!test
+Self-link to numeric title
+!!options
+title=[[0]]
+!! wikitext
+[[0]]
+!! html
+<p><strong class="selflink">0</strong>
+</p>
+!!end
+
+!!test
+Link to numeric-equivalent title
+!!options
+title=[[0]]
+!! wikitext
+[[00]]
+!! html
+<p><a href="/wiki/00" title="00">00</a>
+</p>
+!!end
+
+!! test
+<nowiki> inside a link
+!! wikitext
+[[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
+!! html
+<p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
+</p>
+!! end
+
+!! test
+Non-breaking spaces in title
+!! wikitext
+[[&nbsp; Main &nbsp; Page &nbsp;]]
+!! html
+<p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
+</p>
+!!end
+
+!! test
+Internal link with ca linktrail, surrounded by bold apostrophes (bug 27473 primary issue)
+!! options
+language=ca
+!! wikitext
+'''[[Main Page]]'''
+!! html
+<p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
+</p>
+!! end
+
+!! test
+Internal link with ca linktrail, surrounded by italic apostrophes (bug 27473 primary issue)
+!! options
+language=ca
+!! wikitext
+''[[Main Page]]''
+!! html
+<p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
+</p>
+!! end
+
+!! test
+Internal link with en linktrail: no apostrophes (bug 27473)
+!! options
+language=en
+!! wikitext
+[[Something]]'nice
+!! html
+<p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
+</p>
+!! end
+
+!! test
+Internal link with ca linktrail with apostrophes (bug 27473)
+!! options
+language=ca
+!! wikitext
+[[Something]]'nice
+!! html
+<p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
+</p>
+!! end
+
+!! test
+Internal link with kaa linktrail with apostrophes (bug 27473)
+!! options
+language=kaa
+!! 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>
+!! end
+
+!! test
+Link with multiple ":" in a subpage-supporting namespace (bug 63636)
+!! wikitext
+[[User:Foo/Test/63636:Bar|Test]]
+!! html/php
+<p><a href="/index.php?title=User:Foo/Test/63636:Bar&amp;action=edit&amp;redlink=1" class="new" title="User:Foo/Test/63636:Bar (page does not exist)">Test</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
+!! end
+
+!! test
+Purely hash wikilink
+!! options
+title=[[User:test/123]]
+!! wikitext
+[[#a|b]]
+!! html/php
+<p><a href="#a">b</a>
+</p>
+!! html/parsoid
+<p data-parsoid='{}'><a rel="mw:WikiLink" href="../User:Test/123#a" data-parsoid='{"stx":"piped","a":{"href":"../User:Test/123#a"},"sa":{"href":"#a"}}'>b</a></p>
+!! end
+
+!! test
+1. Interaction of linktrail and template encapsulation
+!! options
+parsoid
+!! wikitext
+{{echo|[[Foo]]}}l
+!! html
+<p><a rel="mw:WikiLink" href="Foo" title="Foo" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Foo]]"}},"i":0}},"l"]}'>Fool</a></p>
+!! end
+
+!! test
+2. Interaction of linktrail and template encapsulation
+!! options
+parsoid
+!! wikitext
+{{echo|Some [[Fool]]}}s
+!! html
+<p data-parsoid='{}'><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Some [[Fool]]"}},"i":0}},"s"]}' data-parsoid='{"pi":[[{"k":"1","spc":["","","",""]}]]}'>Some </span><a rel="mw:WikiLink" href="./Fool" title="Fool" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Fool"},"sa":{"href":"Fool"},"tail":"s"}'>Fools</a></p>
+!! end
+
+!! test
+3. Interaction of linktrail and template encapsulation
+!! options
+parsoid
+!! wikitext
+{{echo|Some [[Fool]]s are '''bold and foolish'''}}
+!! html
+<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Some [[Fool]]s are &#39;&#39;&#39;bold and foolish&#39;&#39;&#39;"}},"i":0}}]}' data-parsoid='{"pi":[[{"k":"1","spc":["","","",""]}]]}'>Some <a rel="mw:WikiLink" href="./Fool" title="Fool" data-parsoid='{"stx":"simple","a":{"href":"./Fool"},"sa":{"href":"Fool"},"tail":"s"}'>Fools</a> are <b data-parsoid="{}">bold and foolish</b></p>
+!! end
+
+!! article
+Söfnuður
+!! text
+Test.
+!! endarticle
+
+!! test
+Internal link with is link prefix
+!! options
+language=is
+!! wikitext
+Aðrir mótmælenda[[söfnuður|söfnuðir]] og
+!! html
+<p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
+</p>
+!! end
+
+!! article
+Mótmælendatrú
+!! text
+Test.
+!! endarticle
+
+!! test
+Internal link with is link trail and link prefix
+!! options
+language=is
+!! wikitext
+[[mótmælendatrú|xxx]]ar
+[[mótmælendatrú]]ar
+mótmælenda[[söfnuður]]
+mótmælenda[[söfnuður|söfnuðir]]
+mótmælenda[[söfnuður|söfnuðir]]xxx
+!! html
+<p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
+<a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
+<a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
+<a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
+<a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
+</p>
+!! end
+
+!! test
+Parsoid link trail escaping
+!! options
+parsoid=html2wt,html2html
+!! wikitext
+[[apple]]<nowiki/>s
+!! html
+<p><a rel="mw:WikiLink" href="Apple" title="Apple">apple</a>s</p>
+!! end
+
+!! test
+Parsoid link prefix escaping
+!! options
+language=is
+parsoid=html2wt,html2html
+!! wikitext
+Aðrir mótmælenda<nowiki/>[[söfnuður]]
+!! html
+<p>Aðrir mótmælenda<a rel="mw:WikiLink" href="Söfnuður" title="Söfnuður">söfnuður</a></p>
+!! end
+
+!! test
+Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
+!! wikitext
+[[Foo| bar]]
+
+[[Foo| ''bar'']]
+
+[http://wp.org foo]
+
+[http://wp.org ''foo'']
+!! html
+<p><a href="/wiki/Foo" title="Foo"> bar</a>
+</p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
+</p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
+</p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
+</p>
+!! end
+
+!! test
+Parsoid: Scoped parsing should handle mixed transclusions and plain text
+!! options
+parsoid
+!! wikitext
+[[Foo|{{echo|a}} b {{echo|c}}]]
+!! html
+<p><a rel="mw:WikiLink" href="Foo" title="Foo"><span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a"}},"i":0}}]}'>a</span> b <span about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"c"}},"i":0}}]}'>c</span></a></p>
+!! end
+
+!! test
+Link with angle bracket after anchor
+!! wikitext
+[[Foo#<bar>]]
+!! html/php
+<p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
+</p>
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="./Foo#%3Cbar%3E" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo#%3Cbar%3E"},"sa":{"href":"Foo#&lt;bar>"}}'>Foo#&lt;bar></a></p>
+!! end
+
+###
+### Interwiki links (see maintenance/interwiki.sql)
+###
+
+!! test
+Inline interwiki link
+!! wikitext
+[[MeatBall:SoftSecurity]]
+!! html
+<p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
+</p>
+!! end
+
+!! test
+Inline interwiki link with empty title (bug 2372)
+!! wikitext
+[[MeatBall:]]
+!! html
+<p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
+</p>
+!! end
+
+!! test
+Interwiki link encoding conversion (bug 1636)
+!! wikitext
+*[[Wikipedia:ro:Olteni&#0355;a]]
+*[[Wikipedia:ro:Olteni&#355;a]]
+!! html
+<ul><li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteni&#355;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&#355;a</a></li></ul>
+
+!! html+tidy
+<ul>
+<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>
+!! end
+
+!! test
+Interwiki link with fragment (bug 2130)
+!! wikitext
+[[MeatBall:SoftSecurity#foo]]
+!! html
+<p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
+</p>
+!! end
+
+# Ideally the wikipedia: prefix here should be proto-relative too
+!! test
+Different interwiki prefixes mapping to the same URL
+!! wikitext
+[[:en:Foo]]
+
+[[:en:Foo|Foo]]
+
+[[wikipedia:Foo]]
+
+[[:wikipedia:Foo|Foo]]
+
+[[wikipedia:en:Foo]]
+
+[[:wikipedia:en:Foo]]
+
+[[ wikiPEdia :Foo]]
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="//en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"simple","a":{"href":"//en.wikipedia.org/wiki/Foo"},"sa":{"href":":en:Foo"},"isIW":true}'>en:Foo</a></p>
+
+<p><a rel="mw:ExtLink" href="//en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"piped","a":{"href":"//en.wikipedia.org/wiki/Foo"},"sa":{"href":":en:Foo"},"isIW":true}'>Foo</a></p>
+
+<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":"wikipedia:Foo"},"isIW":true}'>wikipedia:Foo</a></p>
+
+<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"piped","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":":wikipedia:Foo"},"isIW":true}'>Foo</a></p>
+
+<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/en:Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/en:Foo"},"sa":{"href":"wikipedia:en:Foo"},"isIW":true}'>wikipedia:en:Foo</a></p>
+
+<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/en:Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/en:Foo"},"sa":{"href":":wikipedia:en:Foo"},"isIW":true}'>wikipedia:en:Foo</a></p>
+
+<p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":" wikiPEdia :Foo"},"isIW":true}'> wikiPEdia :Foo</a></p>
+!! end
+
+!! test
+Interwiki links that cannot be represented in wiki syntax
+!! wikitext
+[[meatball:ok]]
+[[meatball:ok#foo|ok with fragment]]
+[[meatball:ok_as_well?|ok ending with ? mark]]
+[http://de.wikipedia.org/wiki/Foo?action=history has query]
+[http://de.wikipedia.org/wiki/#foo is just fragment]
+
+!! html/parsoid
+<p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?ok">meatball:ok</a>
+<a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo">ok with fragment</a>
+<a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?ok_as_well?">ok ending with ? mark</a>
+<a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
+<a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
+!! end
+
+!! test
+Interwiki links: trail
+!! options
+parsoid
+!! wikitext
+[[wikipedia:Foo|Ba]]r
+!! html
+<p data-parsoid='{}'><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"piped","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":"wikipedia:Foo"},"isIW":true,"tail":"r"}'>Bar</a></p>
+!! end
+
+!! test
+Local interwiki link
+!! wikitext
+[[local:Template:Foo]]
+!! html
+<p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
+</p>
+!! end
+
+!! test
+Local interwiki link: self-link to current page
+!! options
+title=[[Main Page]]
+!! wikitext
+[[local:Main Page]]
+!! html
+<p><strong class="selflink">local:Main Page</strong>
+</p>
+!! end
+
+!! test
+Local interwiki link: prefix only (bug 64167)
+!! wikitext
+[[local:]]
+!! html
+<p><a href="/wiki/Main_Page" title="Main Page">local:</a>
+</p>
+!! end
+
+!! test
+Local interwiki link: with additional interwiki prefix (bug 61357)
+!! wikitext
+[[local:meatball:Hello]]
+!! html
+<p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
+</p>
+!! end
+
+###
+### Interlanguage links
+### Language links (so that searching for '### language' matches..)
+###
+
+!! test
+Interlanguage link
+!! wikitext
+Blah blah blah
+[[zh:Chinese]]
+!! html/php
+<p>Blah blah blah
+</p>
+!! html/parsoid
+<p>Blah blah blah
+<link rel="mw:PageProp/Language" href="//zh.wikipedia.org/wiki/Chinese"/></p>
+!! end
+
+!! test
+Interlanguage link with spacing
+!! wikitext
+Blah blah blah
+[[ zh : Chinese ]]
+!! html/php
+<p>Blah blah blah
+</p>
+!! html/parsoid
+<p>Blah blah blah
+<link rel="mw:PageProp/Language" href="//zh.wikipedia.org/wiki/Chinese"/></p>
+!! end
+
+!! test
+Double interlanguage link
+!! wikitext
+Blah blah blah
+[[es:Spanish]]
+[[zh:Chinese]]
+!! html/php
+<p>Blah blah blah
+</p>
+!! html/parsoid
+<p>Blah blah blah
+<link rel="mw:PageProp/Language" href="//es.wikipedia.org/wiki/Spanish"/>
+<link rel="mw:PageProp/Language" href="//zh.wikipedia.org/wiki/Chinese"/></p>
+!! end
+
+!! test
+Interlanguage link variations
+!! wikitext
+Blah blah blah
+[[ es :Spanish]]
+[[ ZH :Chinese]]
+!! html/php
+<p>Blah blah blah
+</p>
+!! html/parsoid
+<p>Blah blah blah
+<link rel="mw:PageProp/Language" href="//es.wikipedia.org/wiki/Spanish" data-parsoid='{"stx":"simple","a":{"href":"//es.wikipedia.org/wiki/Spanish"},"sa":{"href":" es :Spanish"}}'/>
+<link rel="mw:PageProp/Language" href="//zh.wikipedia.org/wiki/Chinese" data-parsoid='{"stx":"simple","a":{"href":"//zh.wikipedia.org/wiki/Chinese"},"sa":{"href":" ZH :Chinese"}}'/>
+!! end
+
+!! test
+Interlanguage link, with prefix links
+!! options
+language=ln
+!! wikitext
+Blah blah blah
+[[zh:Chinese]]
+!! html/php
+<p>Blah blah blah
+</p>
+!! html/parsoid
+<p>Blah blah blah
+<link rel="mw:PageProp/Language" href="//zh.wikipedia.org/wiki/Chinese"/></p>
+!! end
+
+!! test
+Double interlanguage link, with prefix links (bug 8897)
+!! options
+language=ln
+!! wikitext
+Blah blah blah
+[[es:Spanish]]
+[[zh:Chinese]]
+!! html/php
+<p>Blah blah blah
+</p>
+!! html/parsoid
+<p>Blah blah blah
+<link rel="mw:PageProp/Language" href="//es.wikipedia.org/wiki/Spanish"/>
+<link rel="mw:PageProp/Language" href="//zh.wikipedia.org/wiki/Chinese"/></p>
+!! end
+
+!! test
+"Extra" interlanguage links (bug 32189 / gerrit 111390)
+!! wikitext
+Blah blah blah
+[[mul:Article]]
+!! html/php
+<p>Blah blah blah
+</p>
+!! html/parsoid
+<p>Blah blah blah
+<link rel="mw:PageProp/Language" title="Multilingual" href="//wikisource.org/wiki/Article"/></p>
+!! end
+
+!! test
+Parsoid-specific test: Wikilinks with &nbsp; should RT properly
+!! options
+language=ln
+!! wikitext
+[[WW&nbsp;II]]
+!! html
+<p><a href="/index.php?title=WW_II&amp;action=edit&amp;redlink=1" class="new" title="WW II (lonkásá ezalí tɛ̂)">WW&#160;II</a>
+</p>
+!! end
+
+!! test
+Parsoid bug 53221: Wikilinks should be properly entity-escaped
+!! options
+parsoid=html2wt
+!! wikitext
+He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
+
+He&amp;nbsp;llo [[He&amp;nbsp;llo]]
+!! html
+<p>He&amp;nbsp;llo <a href="Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
+<p>He&amp;nbsp;llo <a href="He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
+!! end
+
+!! test
+Parsoid: handle constructor well
+!! options
+parsoid
+!! wikitext
+[[constructor]]
+
+[[constructor:foo]]
+!! html
+<p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid="{&quot;stx&quot;:&quot;simple&quot;,&quot;a&quot;:{&quot;href&quot;:&quot;./Constructor&quot;},&quot;sa&quot;:{&quot;href&quot;:&quot;constructor&quot;}}">constructor</a></p>
+
+<p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid="{&quot;stx&quot;:&quot;simple&quot;,&quot;a&quot;:{&quot;href&quot;:&quot;./Foo&quot;},&quot;sa&quot;:{&quot;href&quot;:&quot;constructor:foo&quot;}}">constructor:foo</a></p>
+!! end
+
+!! test
+Parsoid: recognize interlanguage links without a target page
+!! options
+parsoid
+!! wikitext
+[[ko:]]
+!! html
+<p><link rel="mw:PageProp/Language" href="http://ko.wikipedia.org/wiki/"></p>
+!! end
+
+!! test
+Parsoid: recognize interwiki links without a target page
+!! options
+parsoid
+!! wikitext
+[[:ko:]]
+!! html
+<p><a rel="mw:ExtLink" href="//ko.wikipedia.org/wiki/">ko:</a></p>
+!! end
+
+!! test
+Parsoid: Bug #45209, handle interwiki links pointing to the current wiki as plain wiki links
+!! options
+parsoid
+!! wikitext
+[[en:Foo]]
+!! html
+<p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"en:Foo"}}'>Foo</a></p>
+!! end
+
+!! test
+Interlanguage link with preceding local interwiki link (bug 68085)
+!! wikitext
+Blah blah blah
+[[local:es:Spanish]]
+!! html
+<p>Blah blah blah
+<a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
+</p>
+!! end
+
+!! test
+Looks like an interlanguage link, but is actually a local interwiki
+!! wikitext
+Blah blah blah
+[[mi:Template:Foo]]
+!! html
+<p>Blah blah blah
+<a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
+</p>
+!! end
+
+###
+### Redirects, Parsoid-only
+###
+!! test
+1. Simple redirect to page
+!! options
+parsoid
+!! wikitext
+#REDIRECT [[Main Page]]
+!! html
+<link rel="mw:PageProp/redirect" href="./Main_Page">
+!! end
+
+# Only wt2html and html2html since "Main_Page" will serialize to "Main Page"
+!! test
+2. Other redirect variants
+!! options
+parsoid=wt2html,wt2wt
+!! wikitext
+#REDIRECT [[Main_Page]]
+#REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
+!! html
+<link rel="mw:PageProp/redirect" href="./Main_Page">
+<link rel="mw:PageProp/redirect" href="./%5B%5BBar%5D%5D">
+!! end
+
+!! test
+Empty redirect
+!! options
+parsoid=wt2html,wt2wt
+!! wikitext
+#REDIRECT [[]]
+!! html
+<ol>
+<li>REDIRECT [[]]</li></ol>
+!! end
+
+!! test
+Optional colon in #REDIRECT
+!! options
+# the colon is archaic syntax. we support it for wt2html, but we
+# don't care that it roundtrips back to the modern syntax.
+parsoid=wt2html,html2html
+!! wikitext
+#REDIRECT:[[Main Page]]
+!! html
+<link rel="mw:PageProp/redirect" href="./Main_Page">
+!! end
+
+!! test
+Whitespace in #REDIRECT with optional colon
+!! options
+# the colon and gratuitous whitespace is archaic syntax. we support
+# it for wt2html, but we don't care that it roundtrips back to the
+# modern syntax (without extra whitespace)
+parsoid=wt2html,html2html
+!! wikitext
+
+ #REDIRECT
+:
+[[Main Page]]
+!! html
+<link rel="mw:PageProp/redirect" href="./Main_Page">
+!! end
+
+!! test
+Piped link in #REDIRECT
+!! options
+# content after piped link is ignored. we support this syntax,
+# but don't care that the piped link is lost when we roundtrip this.
+parsoid=wt2html
+!! wikitext
+#REDIRECT [[Main Page|bar]]
+!! html
+<link rel="mw:PageProp/redirect" href="./Main_Page">
+!! end
+
+!! test
+Redirect to category
+!! options
+parsoid=wt2html
+!! wikitext
+#REDIRECT [[Category:Foo]]
+!! html
+<link rel="mw:PageProp/redirect" href="./Category:Foo"><link rel="mw:PageProp/Category" href="./Category:Foo">
+!! end
+
+!! test
+Redirect to category with URL encoding
+!! options
+parsoid=wt2html
+!! wikitext
+#REDIRECT [[Category%3AFoo]]
+!! html
+<link rel="mw:PageProp/redirect" href="./Category:Foo"><link rel="mw:PageProp/Category" href="./Category:Foo">
+!! end
+
+!! test
+Redirect to category page
+!! options
+parsoid=wt2html,html2html
+!! wikitext
+#REDIRECT [[:Category:Foo]]
+!! html
+<p><a rel="mw:WikiLink" href="Category:Foo" title="Category:Foo">Category:Foo</a></p>
+!! end
+
+!! test
+Redirect to image page (1)
+!! options
+parsoid
+!! wikitext
+#REDIRECT [[File:Wiki.png]]
+!! html
+<link rel="mw:PageProp/redirect" href="./File:Wiki.png">
+!! end
+
+!! test
+Redirect to image page (2)
+!! options
+parsoid
+!! wikitext
+#REDIRECT [[Image:Wiki.png]]
+!! html
+<link rel="mw:PageProp/redirect" href="./File:Wiki.png">
+!! end
+
+!! test
+Redirect to language
+!! options
+parsoid
+!! wikitext
+#REDIRECT [[en:File:Wiki.png]]
+!! html
+<link rel="mw:PageProp/redirect" href="File:Wiki.png">
+!! end
+
+!! test
+Redirect to interwiki
+!! options
+parsoid
+!! wikitext
+#REDIRECT [[meatball:File:Wiki.png]]
+!! html
+<link rel="mw:PageProp/redirect" href="File:Wiki.png">
+!! end
+
+!! test
+Non-English #REDIRECT
+!! options
+parsoid
+language=is
+!! wikitext
+#TILVÍSUN [[Main Page]]
+!! html
+<link rel="mw:PageProp/redirect" href="./Main_Page">
+!! end
+
+!! test
+New redirect
+!! options
+parsoid=html2wt
+!! wikitext
+Foo
+#REDIRECT [[Foo]]
+!! html
+<p>Foo<link rel="mw:PageProp/redirect" href="./Foo"></p>
+!! end
+
+##
+## XHTML tidiness
+###
+
+!! test
+<br> to <br />
+!! wikitext
+1<br>2<br />3
+!! html
+<p>1<br />2<br />3
+</p>
+!! end
+
+!! test
+Broken br tag sanitization
+!! wikitext
+</br>
+!! html/php
+<p>&lt;/br&gt;
+</p>
+!! end
+
+# TODO: Fix html2html mode (bug 51055)!
+# This </br> handling was added as part of bug 50831; but it
+# differs from how PHP+tidy handles this. We should investigate
+# this.
+!! test
+Parsoid: Broken br tag recognition
+!! options
+parsoid=wt2html
+!! wikitext
+</br>
+
+<br/ >
+!! html/php+tidy
+<p>&lt;/br&gt;</p>
+<p><br /></p>
+!! html/parsoid
+<p><br></p>
+<p><br/></p>
+!! end
+
+!! test
+Incorrecly removing closing slashes from correctly formed XHTML
+!! wikitext
+<br style="clear:both;" />
+!! html
+<p><br style="clear:both;" />
+</p>
+!! end
+
+!! test
+Failing to transform badly formed HTML into correct XHTML
+!! wikitext
+<br style="clear: left;">
+<br style="clear: right;">
+<br style="clear: both;">
+!! html
+<p><br style="clear: left;" />
+<br style="clear: right;" />
+<br style="clear: both;" />
+</p>
+!!end
+
+!! test
+Handling html with a div self-closing tag
+!! wikitext
+<div title />
+<div title/>
+<div title/ >
+<div title=bar />
+<div title=bar/>
+<div title=bar/ >
+!! html
+<p>&lt;div title /&gt;
+&lt;div title/&gt;
+</p>
+<div>
+<p>&lt;div title=bar /&gt;
+&lt;div title=bar/&gt;
+</p>
+<div title="bar/"></div>
+</div>
+
+!! end
+
+!! test
+Handling html with a br self-closing tag
+!! wikitext
+<br title />
+<br title/>
+<br title/ >
+<br title=bar />
+<br title=bar/>
+<br title=bar/ >
+!! html/php
+<p><br title="title" />
+<br title="title" />
+<br />
+<br title="bar" />
+<br title="bar" />
+<br title="bar/" />
+</p>
+!! html/parsoid
+<p><br title="" />
+<br title="" />
+<br />
+<br title="bar" />
+<br title="bar" />
+<br title="bar/" />
+</p>
+!! end
+
+!! test
+Horizontal ruler (should it add that extra space?)
+!! wikitext
+<hr>
+<hr >
+foo <hr
+> bar
+!! html
+<hr />
+<hr />
+foo <hr /> bar
+
+!! end
+
+!! test
+Horizontal ruler -- 4+ dashes render hr
+!! wikitext
+----
+!! html
+<hr />
+
+!! end
+
+!! test
+Horizontal ruler -- eats additional dashes on the same line
+!! wikitext
+---------
+!! html
+<hr />
+
+!! end
+
+!! test
+Horizontal ruler -- does not collapse dashes on consecutive lines
+!! wikitext
+----
+----
+!! html
+<hr />
+<hr />
+
+!! end
+
+!! test
+Horizontal ruler -- <4 dashes render as plain text
+!! wikitext
+---
+!! html
+<p>---
+</p>
+!! end
+
+!! test
+Horizontal ruler -- Supports content following dashes on same line
+!! wikitext
+---- Foo
+!! html
+<hr /> Foo
+
+!! html+tidy
+<hr />
+<p>Foo</p>
+!! end
+
+###
+### Block-level elements
+###
+!! test
+Common list
+!! wikitext
+*Common list
+* item 2
+*item 3
+!! html
+<ul><li>Common list</li>
+<li> item 2</li>
+<li>item 3</li></ul>
+
+!! end
+
+!! test
+Numbered list
+!! wikitext
+#Numbered list
+#item 2
+# item 3
+!! html
+<ol><li>Numbered list</li>
+<li>item 2</li>
+<li> item 3</li></ol>
+
+!! end
+
+!! test
+Mixed list
+!! wikitext
+*Mixed list
+*# with numbers
+** and bullets
+*# and numbers
+*bullets again
+**bullet level 2
+***bullet level 3
+***#Number on level 4
+**bullet level 2
+**#Number on level 3
+**#Number on level 3
+*#number level 2
+*Level 1
+*** Level 3
+#** Level 3, but ordered
+!! html
+<ul><li>Mixed list
+<ol><li> with numbers</li></ol>
+<ul><li> and bullets</li></ul>
+<ol><li> and numbers</li></ol></li>
+<li>bullets again
+<ul><li>bullet level 2
+<ul><li>bullet level 3
+<ol><li>Number on level 4</li></ol></li></ul></li>
+<li>bullet level 2
+<ol><li>Number on level 3</li>
+<li>Number on level 3</li></ol></li></ul>
+<ol><li>number level 2</li></ol></li>
+<li>Level 1
+<ul><li><ul><li> Level 3</li></ul></li></ul></li></ul>
+<ol><li><ul><li><ul><li> Level 3, but ordered</li></ul></li></ul></li></ol>
+
+!! end
+
+!! test
+Nested lists 1
+!! wikitext
+*foo
+**bar
+!! html
+<ul><li>foo
+<ul><li>bar</li></ul></li></ul>
+
+!! end
+
+!! test
+Nested lists 2
+!! wikitext
+**foo
+*bar
+!! html
+<ul><li><ul><li>foo</li></ul></li>
+<li>bar</li></ul>
+
+!! end
+
+!! test
+Nested lists 3 (first element empty)
+!! wikitext
+*
+**bar
+!! html
+<ul><li>
+<ul><li>bar</li></ul></li></ul>
+
+!! end
+
+!! test
+Nested lists 4 (first element empty)
+!! wikitext
+**
+*bar
+!! html
+<ul><li><ul><li></li></ul></li>
+<li>bar</li></ul>
+
+!! end
+
+!! test
+Nested lists 5 (both elements empty)
+!! wikitext
+**
+*
+!! html
+<ul><li><ul><li></li></ul></li>
+<li></li></ul>
+
+!! end
+
+!! test
+Nested lists 6 (both elements empty)
+!! wikitext
+*
+**
+!! html
+<ul><li>
+<ul><li></li></ul></li></ul>
+
+!! end
+
+!! test
+Nested lists 7 (skip initial nesting levels)
+!! wikitext
+*** foo
+!! html
+<ul><li><ul><li><ul><li> foo</li></ul></li></ul></li></ul>
+
+!! end
+
+!! test
+Nested lists 8 (multiple nesting transitions)
+!! wikitext
+* foo
+*** bar
+** baz
+* boo
+!! html
+<ul><li> foo
+<ul><li><ul><li> bar</li></ul></li>
+<li> baz</li></ul></li>
+<li> boo</li></ul>
+
+!! end
+
+!! test
+1. Lists with start-of-line-transparent tokens before bullets: Comments
+!! wikitext
+*foo
+*<!--cmt-->bar
+<!--cmt-->*baz
+!! html
+<ul><li>foo</li>
+<li>bar</li>
+<li>baz</li></ul>
+
+!! end
+
+!! test
+2. Lists with start-of-line-transparent tokens before bullets: Template close
+!! wikitext
+*foo {{echo|bar
+}}*baz
+!! html
+<ul><li>foo bar</li>
+<li>baz</li></ul>
+
+!! end
+
+!! test
+List items are not parsed correctly following a <pre> block (bug 785)
+!! wikitext
+* <pre>foo</pre>
+* <pre>bar</pre>
+* zar
+!! html
+<ul><li> <pre>foo</pre></li>
+<li> <pre>bar</pre></li>
+<li> zar</li></ul>
+
+!! end
+
+!! test
+List items from template
+!! wikitext
+
+{{inner list}}
+* item 2
+
+* item 0
+{{inner list}}
+* item 2
+
+* item 0
+* notSOL{{inner list}}
+* item 2
+!! html
+<ul><li> item 1</li>
+<li> item 2</li></ul>
+<ul><li> item 0</li>
+<li> item 1</li>
+<li> item 2</li></ul>
+<ul><li> item 0</li>
+<li> notSOL</li>
+<li> item 1</li>
+<li> item 2</li></ul>
+
+!! end
+
+!! test
+List interrupted by empty line or heading
+!! wikitext
+* foo
+
+** bar
+== A heading ==
+* Another list item
+!! html
+<ul><li> foo</li></ul>
+<ul><li><ul><li> bar</li></ul></li></ul>
+<h2><span class="mw-headline" id="A_heading">A heading</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 heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<ul><li> Another list item</li></ul>
+
+!!end
+
+!!test
+Multiple list tags generated by templates
+!! wikitext
+{{echo|<li>}}a
+{{echo|<li>}}b
+{{echo|<li>}}c
+!! html
+<li>a
+<li>b
+<li>c</li>
+</li>
+</li>
+
+!! html+tidy
+<ul>
+<li>a</li>
+<li>b</li>
+<li>c</li>
+</ul>
+!!end
+
+!!test
+Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
+!! wikitext
+*a
+<!--This line will NOT split the list-->
+*b
+ <!--This line will NOT split the list either-->
+*c
+ <!--foo--> <!----> <!--This line NOT split the list either-->
+*d
+!! html
+<ul><li>a</li>
+<li>b</li>
+<li>c</li>
+<li>d</li></ul>
+
+!!end
+
+!!test
+Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
+!! wikitext
+*a
+<!--This line will NOT split the list-->
+*b
+ <!--This line will NOT split the list either-->
+*c
+ <!--foo--> <!----> <!--This line NOT split the list
+ either-->
+*d
+!! html
+<ul><li>a</li>
+<li>b</li>
+<li>c</li>
+<li>d</li></ul>
+
+!!end
+
+!!test
+Test the li-hack
+(The PHP parser relies on Tidy for the hack)
+!!options
+parsoid=wt2html,wt2wt
+!! wikitext
+* foo
+* <li>li-hack
+* {{echo|<li>templated li-hack}}
+* <!--foo--> <li> unsupported li-hack with preceding comments
+
+<ul>
+<li><li>not a li-hack
+</li>
+</ul>
+!! html+tidy
+<ul>
+<li>foo</li>
+<li>li-hack</li>
+<li>templated li-hack</li>
+<li>unsupported li-hack with preceding comments</li>
+</ul>
+<ul>
+<li>not a li-hack</li>
+</ul>
+!!end
+
+!! test
+Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
+!! options
+parsoid
+!! wikitext
+# foo
+## bar
+* foo
+** bar
+: foo
+:: bar
+!! html
+<ol>
+<li> foo<ol>
+<li> bar</li>
+</ol></li>
+</ol><ul>
+<li> foo<ul>
+<li> bar</li>
+</ul></li>
+</ul><dl>
+<dd> foo<dl>
+<dd> bar</dd>
+</dl></dd>
+</dl>
+!! end
+
+!! test
+Parsoid: Test of whitespace serialization with Templated bullets
+!! options
+parsoid
+!! wikitext
+* {{bullet}}
+!! html
+<ul>
+<li> </li><li about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"bullet","href":"./Template:Bullet"},"params":{},"i":0}}]}'> Bar</li>
+</ul>
+!! end
+
+# ------------------------------------------------------------------------
+# The next set of tests are about Parsoid's ability to handle badly nested
+# tags (parse, minimize scope of fixup, and roundtrip back)
+# ------------------------------------------------------------------------
+
+!! test
+Unbalanced closing block tags break a list
+(php parser relies on Tidy to fix up)
+!! wikitext
+<div>
+*a</div><div>
+*b</div>
+!! html+tidy
+<div>
+<ul>
+<li>a</li>
+</ul>
+</div>
+<div>
+<ul>
+<li>b</li>
+</ul>
+</div>
+!! end
+
+# Parsoid fails this test, but it might be tricky to support properly.
+# See bug 68395.
+!! test
+Unbalanced closing non-block tags don't break a list
+(php parser relies on Tidy to fix up)
+!! wikitext
+<span>
+*a</span><span>
+*b</span>
+!! html/php+tidy
+<ul>
+<li><span>a</span></li>
+<li><span>b</span></li>
+</ul>
+!! html/parsoid
+<span>
+<ul>
+<li>a<span></span>
+</li>
+<li>b
+</li>
+</ul>
+</span>
+!! end
+
+!! test
+Unclosed formatting tags that straddle lists are closed and reopened
+(php parser relies on Tidy to fix up)
+!! wikitext
+# <s> a
+# b </s>
+!! html/php+tidy
+<ol>
+<li><s>a</s></li>
+<li><s>b</s></li>
+</ol>
+!! html/parsoid
+<ol>
+<li> <s> a </s>
+</li>
+<li> <s> b </s>
+</li>
+</ol>
+!! end
+
+# Parsoid fails this test, but it might be tricky to support properly.
+# See bug 68395.
+!!test
+List embedded in a non-block tag
+(Ugly Parsoid output -- worth fixing; PHP parser relies on Tidy)
+!! wikitext
+<small>
+* foo
+</small>
+!! html/php+tidy
+<ul>
+<li><small>foo</small></li>
+</ul>
+!! html/parsoid
+<small>
+<ul>
+<li> foo</li>
+</ul>
+</small>
+!!end
+
+# This is a bug in the PHP parser + tidy combination.
+# (The </tr> tag gets parsed as text and html-escaped by PHP,
+# and then fostered out of the table by tidy.)
+# We believe the Parsoid output to be correct.
+!! test
+Table with missing opening <tr> tag
+!! options
+parsoid=wt2html,wt2wt
+!! wikitext
+<table>
+<td>foo</td>
+</tr>
+</table>
+!! html/php+tidy
+<p>&lt;/tr&gt;</p>
+<table>
+<tr>
+<td>foo</td>
+</tr>
+</table>
+!! html/parsoid
+<table>
+<tr>
+<td>foo</td>
+</tr>
+</table>
+!! end
+
+###
+### Magic Words
+###
+
+# Note that the current date is hard-coded as
+# 1970-01-01T00:02:03Z (a Thursday)
+# when running parser tests. The timezone is also fixed to GMT, so
+# local date will be identical to current date.
+
+!! test
+Magic Word: {{CURRENTDAY}}
+!! wikitext
+{{CURRENTDAY}}
+!! html
+<p>1
+</p>
+!! end
+
+!! test
+Magic Word: {{CURRENTDAY2}}
+!! wikitext
+{{CURRENTDAY2}}
+!! html
+<p>01
+</p>
+!! end
+
+!! test
+Magic Word: {{CURRENTDAYNAME}}
+!! wikitext
+{{CURRENTDAYNAME}}
+!! html
+<p>Thursday
+</p>
+!! end
+
+!! test
+Magic Word: {{CURRENTDOW}}
+!! wikitext
+{{CURRENTDOW}}
+!! html
+<p>4
+</p>
+!! end
+
+!! test
+Magic Word: {{CURRENTMONTH}}
+!! wikitext
+{{CURRENTMONTH}}
+!! html
+<p>01
+</p>
+!! end
+
+!! test
+Magic Word: {{CURRENTMONTH1}}
+!! wikitext
+{{CURRENTMONTH1}}
+!! html
+<p>1
+</p>
+!! end
+
+!! test
+Magic Word: {{CURRENTMONTHABBREV}}
+!! wikitext
+{{CURRENTMONTHABBREV}}
+!! html
+<p>Jan
+</p>
+!! end
+
+!! test
+Magic Word: {{CURRENTMONTHNAME}}
+!! wikitext
+{{CURRENTMONTHNAME}}
+!! html
+<p>January
+</p>
+!! end
+
+!! test
+Magic Word: {{CURRENTMONTHNAMEGEN}}
+!! wikitext
+{{CURRENTMONTHNAMEGEN}}
+!! html
+<p>January
+</p>
+!! end
+
+!! test
+Magic Word: {{CURRENTTIME}}
+!! wikitext
+{{CURRENTTIME}}
+!! html
+<p>00:02
+</p>
+!! end
+
+!! test
+Magic Word: {{CURRENTHOUR}}
+!! wikitext
+{{CURRENTHOUR}}
+!! html
+<p>00
+</p>
+!! end
+
+!! test
+Magic Word: {{CURRENTWEEK}} (@bug 4594)
+!! wikitext
+{{CURRENTWEEK}}
+!! html
+<p>1
+</p>
+!! end
+
+!! test
+Magic Word: {{CURRENTYEAR}}
+!! wikitext
+{{CURRENTYEAR}}
+!! html
+<p>1970
+</p>
+!! end
+
+!! test
+Magic Word: {{CURRENTTIMESTAMP}}
+!! wikitext
+{{CURRENTTIMESTAMP}}
+!! html
+<p>19700101000203
+</p>
+!! end
+
+!! test
+Magic Words LOCAL (UTC)
+!! wikitext
+* {{LOCALMONTH}}
+* {{LOCALMONTH1}}
+* {{LOCALMONTHNAME}}
+* {{LOCALMONTHNAMEGEN}}
+* {{LOCALMONTHABBREV}}
+* {{LOCALDAY}}
+* {{LOCALDAY2}}
+* {{LOCALDAYNAME}}
+* {{LOCALYEAR}}
+* {{LOCALTIME}}
+* {{LOCALHOUR}}
+* {{LOCALWEEK}}
+* {{LOCALDOW}}
+* {{LOCALTIMESTAMP}}
+!! html
+<ul><li> 01</li>
+<li> 1</li>
+<li> January</li>
+<li> January</li>
+<li> Jan</li>
+<li> 1</li>
+<li> 01</li>
+<li> Thursday</li>
+<li> 1970</li>
+<li> 00:02</li>
+<li> 00</li>
+<li> 1</li>
+<li> 4</li>
+<li> 19700101000203</li></ul>
+
+!! end
+
+!! test
+Magic Word: {{FULLPAGENAME}}
+!! options
+title=[[User:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{FULLPAGENAME}}
+!! html
+<p>User:Ævar Arnfjörð Bjarmason
+</p>
+!! end
+
+!! test
+Magic Word: {{FULLPAGENAMEE}}
+!! options
+title=[[User:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{FULLPAGENAMEE}}
+!! html
+<p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
+</p>
+!! end
+
+!! test
+Magic Word: {{TALKSPACE}}
+!! options
+title=[[User:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{TALKSPACE}}
+!! html
+<p>User talk
+</p>
+!! end
+
+!! test
+Magic Word: {{TALKSPACE}}, same namespace
+!! options
+title=[[User talk:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{TALKSPACE}}
+!! html
+<p>User talk
+</p>
+!! end
+
+!! test
+Magic Word: {{TALKSPACE}}, main namespace
+!! options
+title=[[Parser Test]]
+!! wikitext
+{{TALKSPACE}}
+!! html
+<p>Talk
+</p>
+!! end
+
+!! test
+Magic Word: {{TALKSPACEE}}
+!! options
+title=[[User:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{TALKSPACEE}}
+!! html
+<p>User_talk
+</p>
+!! end
+
+!! test
+Magic Word: {{SUBJECTSPACE}}
+!! options
+title=[[User talk:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{SUBJECTSPACE}}
+!! html
+<p>User
+</p>
+!! end
+
+!! test
+Magic Word: {{SUBJECTSPACE}}, same namespace
+!! options
+title=[[User:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{SUBJECTSPACE}}
+!! html
+<p>User
+</p>
+!! end
+
+!! test
+Magic Word: {{SUBJECTSPACE}}, main namespace
+!! options
+title=[[Parser Test]]
+!! wikitext
+{{SUBJECTSPACE}}
+!! html
+
+!! end
+
+!! test
+Magic Word: {{SUBJECTSPACEE}}
+!! options
+title=[[User talk:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{SUBJECTSPACEE}}
+!! html
+<p>User
+</p>
+!! end
+
+!! test
+Magic Word: {{NAMESPACE}}
+!! options
+title=[[User:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{NAMESPACE}}
+!! html
+<p>User
+</p>
+!! end
+
+!! test
+Magic Word: {{NAMESPACEE}}
+!! options
+title=[[User:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{NAMESPACEE}}
+!! html
+<p>User
+</p>
+!! end
+
+!! test
+Magic Word: {{NAMESPACENUMBER}}
+!! options
+title=[[User:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{NAMESPACENUMBER}}
+!! html
+<p>2
+</p>
+!! end
+
+!! test
+Magic Word: {{SUBPAGENAME}}
+!! options
+title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
+!! wikitext
+{{SUBPAGENAME}}
+!! html
+<p>sub ö
+</p>
+!! end
+
+!! test
+Magic Word: {{SUBPAGENAMEE}}
+!! options
+title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
+!! wikitext
+{{SUBPAGENAMEE}}
+!! html
+<p>sub_%C3%B6
+</p>
+!! end
+
+!! test
+Magic Word: {{ROOTPAGENAME}}
+!! options
+title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
+!! wikitext
+{{ROOTPAGENAME}}
+!! html
+<p>Ævar Arnfjörð Bjarmason
+</p>
+!! end
+
+!! test
+Magic Word: {{ROOTPAGENAMEE}}
+!! options
+title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
+!! wikitext
+{{ROOTPAGENAMEE}}
+!! html
+<p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
+</p>
+!! end
+
+!! test
+Magic Word: {{BASEPAGENAME}}
+!! options
+title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
+!! wikitext
+{{BASEPAGENAME}}
+!! html
+<p>Ævar Arnfjörð Bjarmason
+</p>
+!! end
+
+!! test
+Magic Word: {{BASEPAGENAMEE}}
+!! options
+title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
+!! wikitext
+{{BASEPAGENAMEE}}
+!! html
+<p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
+</p>
+!! end
+
+!! test
+Magic Word: {{TALKPAGENAME}}
+!! options
+title=[[User:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{TALKPAGENAME}}
+!! html
+<p>User talk:Ævar Arnfjörð Bjarmason
+</p>
+!! end
+
+!! test
+Magic Word: {{TALKPAGENAMEE}}
+!! options
+title=[[User:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{TALKPAGENAMEE}}
+!! html
+<p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
+</p>
+!! end
+
+!! test
+Magic Word: {{SUBJECTPAGENAME}}
+!! options
+title=[[User talk:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{SUBJECTPAGENAME}}
+!! html
+<p>User:Ævar Arnfjörð Bjarmason
+</p>
+!! end
+
+!! test
+Magic Word: {{SUBJECTPAGENAMEE}}
+!! options
+title=[[User talk:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{SUBJECTPAGENAMEE}}
+!! html
+<p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
+</p>
+!! end
+
+!! test
+Magic Word: {{NUMBEROFFILES}}
+!! wikitext
+{{NUMBEROFFILES}}
+!! html
+<p>5
+</p>
+!! end
+
+!! test
+Magic Word: {{PAGENAME}}
+!! options
+title=[[User:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{PAGENAME}}
+!! html
+<p>Ævar Arnfjörð Bjarmason
+</p>
+!! end
+
+!! test
+Magic Word: {{PAGENAME}} with metacharacters
+!! options
+title=[['foo & bar = baz']]
+!! wikitext
+''{{PAGENAME}}''
+!! html/php
+<p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
+</p>
+!! html+tidy
+<p><i>'foo &amp; bar = baz'</i></p>
+!! end
+
+!! test
+Magic Word: {{PAGENAME}} with metacharacters (bug 26781)
+!! options
+title=[[*RFC 1234 http://example.com/]]
+!! wikitext
+{{PAGENAME}}
+!! html/php
+<p>&#42;RFC&#32;1234 http&#58;//example.com/
+</p>
+!! html+tidy
+<p>*RFC 1234 http://example.com/</p>
+!! end
+
+!! test
+Magic Word: {{PAGENAMEE}}
+!! options
+title=[[User:Ævar Arnfjörð Bjarmason]]
+!! wikitext
+{{PAGENAMEE}}
+!! html
+<p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
+</p>
+!! end
+
+!! test
+Magic Word: {{PAGENAMEE}} with metacharacters (bug 26781)
+!! options
+title=[[*RFC 1234 http://example.com/]]
+!! wikitext
+{{PAGENAMEE}}
+!! html/php
+<p>&#42;RFC_1234_http&#58;//example.com/
+</p>
+!! html+tidy
+<p>*RFC_1234_http://example.com/</p>
+!! end
+
+!! test
+Magic Word: {{REVISIONID}}
+!! wikitext
+{{REVISIONID}}
+!! html
+<p>1337
+</p>
+!! end
+
+!! test
+Magic Word: {{SCRIPTPATH}}
+!! wikitext
+{{SCRIPTPATH}}
+!! html
+<p>/
+</p>
+!! end
+
+!! test
+Magic Word: {{STYLEPATH}}
+!! wikitext
+{{STYLEPATH}}
+!! html
+<p>/skins
+</p>
+!! end
+
+!! test
+Magic Word: {{SERVER}}
+!! wikitext
+{{SERVER}}
+!! html
+<p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
+</p>
+!! end
+
+!! test
+Magic Word: {{SERVERNAME}}
+!! wikitext
+{{SERVERNAME}}
+!! html
+<p>example.org
+</p>
+!! end
+
+!! test
+Magic Word: {{SITENAME}}
+!! wikitext
+{{SITENAME}}
+!! html
+<p>MediaWiki
+</p>
+!! end
+
+!! test
+Case-sensitive magic words, when cased differently, should just be template transclusions
+!! wikitext
+{{CurrentMonth}}
+{{currentday}}
+{{cURreNTweEK}}
+{{currentHour}}
+!! html
+<p><a href="/index.php?title=Template:CurrentMonth&amp;action=edit&amp;redlink=1" class="new" title="Template:CurrentMonth (page does not exist)">Template:CurrentMonth</a>
+<a href="/index.php?title=Template:Currentday&amp;action=edit&amp;redlink=1" class="new" title="Template:Currentday (page does not exist)">Template:Currentday</a>
+<a href="/index.php?title=Template:CURreNTweEK&amp;action=edit&amp;redlink=1" class="new" title="Template:CURreNTweEK (page does not exist)">Template:CURreNTweEK</a>
+<a href="/index.php?title=Template:CurrentHour&amp;action=edit&amp;redlink=1" class="new" title="Template:CurrentHour (page does not exist)">Template:CurrentHour</a>
+</p>
+!! end
+
+!! test
+Case-insensitive magic words should still work with weird casing.
+!! wikitext
+{{sErVeRNaMe}}
+{{LCFirst:AOEU}}
+{{ucFIRST:aoeu}}
+{{SERver}}
+!! html
+<p>example.org
+aOEU
+Aoeu
+<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
+</p>
+!! end
+
+!! test
+Namespace 1 {{ns:1}}
+!! wikitext
+{{ns:1}}
+!! html
+<p>Talk
+</p>
+!! end
+
+!! test
+Namespace 1 {{ns:01}}
+!! wikitext
+{{ns:01}}
+!! html
+<p>Talk
+</p>
+!! end
+
+!! test
+Namespace 0 {{ns:0}} (bug 4783)
+!! wikitext
+{{ns:0}}
+!! html
+
+!! end
+
+!! test
+Namespace 0 {{ns:00}} (bug 4783)
+!! wikitext
+{{ns:00}}
+!! html
+
+!! end
+
+!! test
+Namespace -1 {{ns:-1}}
+!! wikitext
+{{ns:-1}}
+!! html
+<p>Special
+</p>
+!! end
+
+!! test
+Namespace User {{ns:User}}
+!! wikitext
+{{ns:User}}
+!! html
+<p>User
+</p>
+!! end
+
+!! test
+Namespace User talk {{ns:User_talk}}
+!! wikitext
+{{ns:User_talk}}
+!! html
+<p>User talk
+</p>
+!! end
+
+!! test
+Namespace User talk {{ns:uSeR tAlK}}
+!! wikitext
+{{ns:uSeR tAlK}}
+!! html
+<p>User talk
+</p>
+!! end
+
+!! test
+Namespace File {{ns:File}}
+!! wikitext
+{{ns:File}}
+!! html
+<p>File
+</p>
+!! end
+
+!! test
+Namespace File {{ns:Image}}
+!! wikitext
+{{ns:Image}}
+!! html
+<p>File
+</p>
+!! end
+
+!! test
+Namespace (lang=de) Benutzer {{ns:User}}
+!! options
+language=de
+!! wikitext
+{{ns:User}}
+!! html
+<p>Benutzer
+</p>
+!! end
+
+!! test
+Namespace (lang=de) Benutzer Diskussion {{ns:3}}
+!! options
+language=de
+!! wikitext
+{{ns:3}}
+!! html
+<p>Benutzer Diskussion
+</p>
+!! end
+
+
+!! test
+Urlencode
+!! wikitext
+{{urlencode:hi world?!}}
+{{urlencode:hi world?!|WIKI}}
+{{urlencode:hi world?!|PATH}}
+{{urlencode:hi world?!|QUERY}}
+!! html
+<p>hi+world%3F%21
+hi_world%3F!
+hi%20world%3F%21
+hi+world%3F%21
+</p>
+!! end
+
+!! test
+Magic Word: prioritize type info over data-parsoid
+!! options
+parsoid=html2wt
+!! wikitext
+__FORCETOC__
+!! html
+<meta property="mw:PageProp/forcetoc" data-parsoid='{"src":"__NOTOC__","magicSrc":"__NOTOC__"}'/>
+!! end
+
+!! test
+Magic Word: serialize on separate line (parsoid)
+!! options
+parsoid=wt2wt,html2wt
+!! wikitext
+foo
+__NOTOC__
+bar
+!! html
+foo<meta property="mw:PageProp/notoc"/>bar
+!! end
+
+!! test
+Magic Word: rt non-english wikis
+!! options
+parsoid=wt2wt
+language=de
+!! wikitext
+__NOEDITSECTION__
+!! html
+<meta property="mw:PageProp/noeditsection" data-parsoid='{"src":"__NOEDITSECTION__","magicSrc":"__NOEDITSECTION__"}'/>
+!! end
+
+###
+### Magic links
+###
+!! test
+Magic links: internal link to RFC (bug 479)
+!! wikitext
+[[RFC 123]]
+!! html
+<p><a href="/index.php?title=RFC_123&amp;action=edit&amp;redlink=1" class="new" title="RFC 123 (page does not exist)">RFC 123</a>
+</p>
+!! end
+
+!! test
+Magic links: RFC (bug 479)
+!! wikitext
+RFC 822
+!! html
+<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
+</p>
+!! end
+
+!! test
+Magic links: ISBN (bug 1937)
+!! wikitext
+ISBN 0-306-40615-2
+!! html
+<p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
+</p>
+!! end
+
+!! test
+Magic links: PMID incorrectly converts space to underscore
+!! wikitext
+PMID 1234
+!! html
+<p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
+</p>
+!! end
+
+###
+### Templates
+####
+
+!! test
+Nonexistent template
+!! wikitext
+{{thistemplatedoesnotexist}}
+!! html
+<p><a href="/index.php?title=Template:Thistemplatedoesnotexist&amp;action=edit&amp;redlink=1" class="new" title="Template:Thistemplatedoesnotexist (page does not exist)">Template:Thistemplatedoesnotexist</a>
+</p>
+!! end
+
+!! test
+Template with invalid target containing tags
+!! wikitext
+{{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
+!! html
+<p>{{a<b>b</b>|foo|a=b|a = b}}
+</p>
+!! end
+
+!! test
+Template with invalid target containing unclosed tag
+!! wikitext
+{{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
+!! html
+<p>{{a<b>|foo|a=b|a = b}}</b>
+</p>
+!! end
+
+!! test
+Template with invalid target containing wikilink
+!! wikitext
+{{[[Main Page]]}}
+!! html/php
+<p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
+</p>
+!! html/parsoid
+<p><span typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":[{"template":{"target":{"wt":"[[Main Page]]"},"params":{},"i":0}}]}'>{{</span><a rel="mw:WikiLink" href="./Main_Page" about="#mwt1">Main Page</a><span about="#mwt1">}}</span></p>
+!! end
+
+!! test
+Template with just whitespace in it, bug #68421
+!! wikitext
+{{echo|{{ }}}}
+!! html/parsoid
+<p><span typeof="mw:Transclusion mw:Nowiki" about="#mwt1" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{ }}"}},"i":0}}]}'>{{ }}</span></p>
+!! end
+
+!! article
+Template:test
+!! text
+This is a test template
+!! endarticle
+
+!! test
+Simple template
+!! wikitext
+{{test}}
+!! html
+<p>This is a test template
+</p>
+!! end
+
+!! test
+Template with explicit namespace
+!! wikitext
+{{Template:test}}
+!! html
+<p>This is a test template
+</p>
+!! end
+
+
+!! article
+Template:paramtest
+!! text
+This is a test template with parameter {{{param}}}
+!! endarticle
+
+!! test
+Template parameter
+!! wikitext
+{{paramtest|param=foo}}
+!! html
+<p>This is a test template with parameter foo
+</p>
+!! end
+
+!! article
+Template:paramtestnum
+!! text
+[[{{{1}}}|{{{2}}}]]
+!! endarticle
+
+!! test
+Template unnamed parameter
+!! wikitext
+{{paramtestnum|Main Page|the main page}}
+!! html
+<p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
+</p>
+!! end
+
+!! article
+Template:templatesimple
+!! text
+(test)
+!! endarticle
+
+!! article
+Template:templateredirect
+!! text
+#redirect [[Template:templatesimple]]
+!! endarticle
+
+!! article
+Template:templateasargtestnum
+!! text
+{{{{{1}}}}}
+!! endarticle
+
+!! article
+Template:templateasargtest
+!! text
+{{template{{{templ}}}}}
+!! endarticle
+
+!! article
+Template:templateasargtest2
+!! text
+{{{{{templ}}}}}
+!! endarticle
+
+!! test
+Template with template name as unnamed argument
+!! wikitext
+{{templateasargtestnum|templatesimple}}
+!! html
+<p>(test)
+</p>
+!! end
+
+!! test
+Template with template name as argument
+!! wikitext
+{{templateasargtest|templ=simple}}
+!! html
+<p>(test)
+</p>
+!! end
+
+!! test
+Template with template name as argument (2)
+!! wikitext
+{{templateasargtest2|templ=templatesimple}}
+!! html
+<p>(test)
+</p>
+!! end
+
+!! article
+Template:templateasargtestdefault
+!! text
+{{{{{templ|templatesimple}}}}}
+!! endarticle
+
+!! article
+Template:templa
+!! text
+'''templ'''
+!! endarticle
+
+!! test
+Template with default value
+!! wikitext
+{{templateasargtestdefault}}
+!! html
+<p>(test)
+</p>
+!! end
+
+!! test
+Template with default value (value set)
+!! wikitext
+{{templateasargtestdefault|templ=templa}}
+!! html
+<p><b>templ</b>
+</p>
+!! end
+
+!! test
+Template redirect
+!! wikitext
+{{templateredirect}}
+!! html
+<p>(test)
+</p>
+!! end
+
+!! test
+Template with argument in separate line
+!! wikitext
+{{ templateasargtest |
+ templ = simple }}
+!! html
+<p>(test)
+</p>
+!! end
+
+!! test
+Template with complex template as argument
+!! wikitext
+{{paramtest|
+ param ={{ templateasargtest |
+ templ = simple }}}}
+!! html
+<p>This is a test template with parameter (test)
+</p>
+!! end
+
+!! test
+Template with thumb image (with link in description)
+!! wikitext
+{{paramtest|
+ param =[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
+!! html/php
+This is a test template with parameter <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a> <div class="thumbcaption"><a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">caption</a></div></div></div>
+
+!! html+tidy
+<p>This is a test template with parameter</p>
+<div class="thumb tright">
+<div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a>
+<div class="thumbcaption"><a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">caption</a></div>
+</div>
+</div>
+!! end
+
+!! article
+Template:complextemplate
+!! text
+{{{1}}} {{paramtest|
+ param ={{{param}}}}}
+!! endarticle
+
+!! test
+Template with complex arguments
+!! wikitext
+{{complextemplate|
+ param ={{ templateasargtest |
+ templ = simple }}|[[Template:complextemplate|link]]}}
+!! html
+<p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
+</p>
+!! end
+
+!! test
+BUG 553: link with two variables in a piped link
+!! wikitext
+{|
+|[[{{{1}}}|{{{2}}}]]
+|}
+!! html
+<table>
+<tr>
+<td>[[{{{1}}}|{{{2}}}]]
+</td></tr></table>
+
+!! end
+
+!! test
+Magic variable as template parameter
+!! wikitext
+{{paramtest|param={{SITENAME}}}}
+!! html
+<p>This is a test template with parameter MediaWiki
+</p>
+!! end
+
+!! article
+Template:linktest
+!! text
+[[{{{param}}}|link]]
+!! endarticle
+
+!! test
+Template parameter as link source
+!! wikitext
+{{linktest|param=Main Page}}
+!! html
+<p><a href="/wiki/Main_Page" title="Main Page">link</a>
+</p>
+!! end
+
+!!test
+Template-generated attribute string (k='v')
+!! wikitext
+<span {{attr_str|id|v1}}>bar</span>
+!! html
+<p><span id="v1">bar</span>
+</p>
+!!end
+
+!!article
+Template:paramtest2
+!! text
+including another template, {{paramtest|param={{{arg}}}}}
+!! endarticle
+
+!! test
+Template passing argument to another template
+!! wikitext
+{{paramtest2|arg='hmm'}}
+!! html
+<p>including another template, This is a test template with parameter 'hmm'
+</p>
+!! end
+
+!! article
+Template:Linktest2
+!! text
+Main Page
+!! endarticle
+
+!! test
+Template as link source
+!! wikitext
+[[{{linktest2}}]]
+
+[[{{linktest2}}|Main Page]]
+
+[[{{linktest2}}]]Page
+!! html
+<p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
+</p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
+</p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
+</p>
+!! end
+
+
+!! article
+Template:loop1
+!! text
+{{loop2}}
+!! endarticle
+
+!! article
+Template:loop2
+!! text
+{{loop1}}
+!! endarticle
+
+!! test
+Template infinite loop
+!! wikitext
+{{loop1}}
+!! html
+<p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
+</p>
+!! end
+
+!! test
+Template from main namespace
+!! wikitext
+{{:Main Page}}
+!! html
+<p>blah blah
+</p>
+!! end
+
+!! article
+Template:table
+!! text
+{|
+| 1 || 2
+|-
+| 3 || 4
+|}
+!! endarticle
+
+!! test
+BUG 529: Template with table, not included at beginning of line
+!! wikitext
+foo {{table}}
+!! html
+<p>foo
+</p>
+<table>
+<tr>
+<td> 1 </td>
+<td> 2
+</td></tr>
+<tr>
+<td> 3 </td>
+<td> 4
+</td></tr></table>
+
+!! end
+
+!! test
+BUG 523: Template shouldn't eat newline (or add an extra one before table)
+!! wikitext
+foo
+{{table}}
+!! html
+<p>foo
+</p>
+<table>
+<tr>
+<td> 1 </td>
+<td> 2
+</td></tr>
+<tr>
+<td> 3 </td>
+<td> 4
+</td></tr></table>
+
+!! end
+
+!! test
+BUG 41: Template parameters shown as broken links
+!! wikitext
+{{{parameter}}}
+!! html
+<p>{{{parameter}}}
+</p>
+!! end
+
+!! test
+Template with targets containing wikilinks
+!! wikitext
+{{[[foo]]}}
+
+{{[[{{echo|foo}}]]}}
+
+{{{{echo|[[foo}}]]}}
+!! html
+<p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
+</p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
+</p><p>{{[[foo}}]]
+</p>
+!! end
+
+!! article
+Template:MSGNW test
+!! text
+''None'' of '''this''' should be
+* interpreted
+ but rather passed unmodified
+{{test}}
+<gallery>
+File:Foobar.jpg
+</gallery>
+!! endarticle
+
+# hmm, fix this or just deprecate msgnw and document its behavior?
+!! test
+msgnw keyword
+!! wikitext
+{{msgnw:MSGNW test}}
+!! html
+<p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
+&#42; interpreted
+&#32;but rather passed unmodified
+&#123;&#123;test&#125;&#125;
+&#60;gallery&#62;
+File:Foobar.jpg
+&#60;/gallery&#62;
+</p>
+!! end
+
+!! test
+int keyword
+!! wikitext
+{{int:youhavenewmessages|lots of money|not!}}
+!! html
+<p>You have lots of money (not!).
+</p>
+!! end
+
+!! article
+Template:Includes
+!! text
+Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
+!! endarticle
+
+!! test
+<includeonly> and <noinclude> being included
+!! wikitext
+{{Includes}}
+!! html
+<p>Foobar
+</p>
+!! end
+
+!! article
+Template:Includes2
+!! text
+<onlyinclude>Foo</onlyinclude>bar
+!! endarticle
+
+!! test
+<onlyinclude> being included
+!! wikitext
+{{Includes2}}
+!! html
+<p>Foo
+</p>
+!! end
+
+
+!! article
+Template:Includes3
+!! text
+<onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
+!! endarticle
+
+!! test
+<onlyinclude> and <includeonly> being included
+!! wikitext
+{{Includes3}}
+!! html
+<p>Foo
+</p>
+!! end
+
+!! test
+<includeonly> and <noinclude> on a page
+!! wikitext
+Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
+!! html
+<p>Foozar
+</p>
+!! end
+
+!! test
+Un-closed <noinclude>
+!! wikitext
+<noinclude>
+!! html
+!! end
+
+!! test
+<onlyinclude> on a page
+!! wikitext
+<onlyinclude>Foo</onlyinclude>bar
+!! html
+<p>Foobar
+</p>
+!! end
+
+!! test
+Un-closed <onlyinclude>
+!! wikitext
+<onlyinclude>
+!! html
+!! end
+
+!!test
+Self-closed noinclude, includeonly, onlyinclude tags
+!! wikitext
+<noinclude />
+<includeonly />
+<onlyinclude />
+!! html
+<p><br />
+</p>
+!!end
+
+!!test
+Unbalanced includeonly and noinclude tags
+!! wikitext
+{|
+|a</noinclude>
+|b</noinclude></noinclude>
+|c</noinclude></includeonly>
+|d</includeonly></includeonly>
+|}
+!! html
+<table>
+<tr>
+<td>a
+</td>
+<td>b
+</td>
+<td>c&lt;/includeonly&gt;
+</td>
+<td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
+</td></tr></table>
+
+!!end
+
+!! article
+Template:Includeonly section
+!! text
+<includeonly>
+==Includeonly section==
+</includeonly>
+==Section T-1==
+!!endarticle
+
+!! test
+Bug 6563: Edit link generation for section shown by <includeonly>
+!! wikitext
+{{includeonly section}}
+!! html
+<h2><span class="mw-headline" id="Includeonly_section">Includeonly section</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Includeonly_section&amp;action=edit&amp;section=T-1" title="Template:Includeonly section">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<h2><span class="mw-headline" id="Section_T-1">Section T-1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Includeonly_section&amp;action=edit&amp;section=T-2" title="Template:Includeonly section">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+
+!! end
+
+# Uses same input as the contents of [[Template:Includeonly section]]
+!! test
+Bug 6563: Section extraction for section shown by <includeonly>
+!! options
+section=T-2
+!! wikitext
+<includeonly>
+==Includeonly section==
+</includeonly>
+==Section T-2==
+!! html
+==Section T-2==
+!! end
+
+!! test
+Bug 6563: Edit link generation for section suppressed by <includeonly>
+!! wikitext
+<includeonly>
+==Includeonly section==
+</includeonly>
+==Section 1==
+!! html
+<h2><span class="mw-headline" id="Section_1">Section 1</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: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+
+!! end
+
+!! test
+Bug 6563: Section extraction for section suppressed by <includeonly>
+!! options
+section=1
+!! wikitext
+<includeonly>
+==Includeonly section==
+</includeonly>
+==Section 1==
+!! html
+==Section 1==
+!! end
+
+!! test
+Un-closed <includeonly>
+!! wikitext
+<includeonly>
+!! html
+!! end
+
+!! test
+Includes and comments at SOL
+!! wikitext
+<!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->== hu ==
+
+<noinclude>
+some
+</noinclude>* stuff
+* here
+
+<includeonly>can have stuff</includeonly>=== here ===
+
+!! html/php
+<h2><span class="mw-headline" id="hu">hu</span></h2>
+<p>some
+</p>
+<ul><li> stuff</li>
+<li> here</li></ul>
+<h3><span class="mw-headline" id="here">here</span></h3>
+
+!! html/parsoid
+<!-- comment --><meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/><!-- comment --><meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><!-- comment -->
+<h2 data-parsoid='{}'> hu </h2>
+
+<meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
+
+<p data-parsoid='{}'>some</p>
+<meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/>
+<ul data-parsoid='{}'>
+<li data-parsoid='{}'> stuff</li>
+
+<li data-parsoid='{}'> here</li></ul>
+
+<h3 data-parsoid='{}'> here </h3>
+!! end
+
+# TODO: test with DOM fragment reuse!
+!! test
+Parsoid: DOM fragment reuse
+!! options
+parsoid=wt2wt,wt2html
+!! wikitext
+a{{echo|b<table></table>c}}d
+
+a{{echo|b
+<table></table>
+c}}d
+
+{{echo|a
+
+<table></table>
+
+b}}
+!! html
+a<span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"b
+<table></table>c"}},"i":0}}]}'>b</span>
+<table about="#mwt1"></table><span about="#mwt1">c</span>d
+
+
+<p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":["a",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"b\n<table></table>\nc"}},"i":0}},"d"]}'>ab</p><span about="#mwt2">
+</span>
+<table about="#mwt2"></table><span about="#mwt2">
+</span>
+<p about="#mwt2">cd</p>
+
+
+<p about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n\n<table></table>\n\nb"}},"i":0}}]}'>a</p><span about="#mwt3">
+
+</span>
+<table about="#mwt3"></table><span about="#mwt3">
+
+</span>
+<p about="#mwt3">b</p>
+!! end
+
+!! test
+Parsoid: Merge double tds (bug 50603)
+!! options
+parsoid
+!! wikitext
+{|
+|{{echo|{{!}} foo}}
+|}
+!! html
+<table><tbody>
+<tr><td about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{!}} foo"}},"i":0}}]}'> foo</td></tr>
+</tbody></table>
+!! end
+
+!! test
+Parsoid: Merge double tds in nested transclusion content (bug 50603)
+!! options
+parsoid
+!! wikitext
+{{echo|<div>}}
+{|
+|{{echo|{{!}} foo}}
+|}
+{{echo|</div>}}
+!! html
+<div about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<div>"}},"i":0}},"\n{|\n|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{!}} foo"}},"i":1}},"\n|}\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"</div>"}},"i":2}}]}'>
+<table><tbody>
+<tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
+</tbody></table>
+</div>
+!! end
+
+###
+### <includeonly> and <noinclude> in attributes
+###
+!!test
+0. includeonly around the entire attribute
+!! wikitext
+<span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
+!! html
+<p><span id="v2">bar</span>
+</p>
+!!end
+
+!!test
+1. includeonly in html attr key
+!! wikitext
+<span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
+!! html
+<p><span id="foo">bar</span>
+</p>
+!!end
+
+!!test
+2. includeonly in html attr value
+!! wikitext
+<span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
+<span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
+!! html
+<p><span id="v1">bar</span>
+<span id="v1">bar</span>
+</p>
+!!end
+
+!!test
+3. includeonly in part of an attr value
+!! wikitext
+<span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
+!! html
+<p><span style="color:red;">bar</span>
+</p>
+!!end
+
+!!test
+4. includeonly in table attributes
+!! wikitext
+{|
+|- <noinclude>
+|-
+|a
+</noinclude>
+|- <includeonly>
+|-
+|b
+</includeonly>
+|}
+!! html
+<table>
+
+
+<tr>
+<td>a
+</td></tr>
+</table>
+
+!!end
+
+###
+### Token Stream Patcher tests
+###
+### These tests won't always pass wt2wt and other modes because
+### on serialization, the table will be output on a new line.
+### For now, we are blacklisting them, and using this to test selser.
+###
+
+!!test
+1. Table tag in SOL posn. should get reparsed correctly with valid TSR
+!!options
+parsoid=wt2html,wt2wt
+!!wikitext
+{{echo|}}{| width = '100%'
+|foo
+|}
+!!html/parsoid
+<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
+<table width="100%">
+<tbody>
+<tr>
+<td>foo</td></tr></tbody></table>
+!!end
+
+!!test
+2. Table tag in SOL posn. should get reparsed correctly with valid TSR
+!!options
+parsoid=wt2html,wt2wt
+!!wikitext
+<includeonly>a</includeonly>{| {{{b}}}
+|c
+|}
+!!html/parsoid
+<meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>a&lt;/includeonly>"'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><table about="#mwt2" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"{{{b}}}","html":"&lt;span about=\"#mwt1\" typeof=\"mw:Param\" data-parsoid=\"{&amp;quot;dsr&amp;quot;:[31,38,null,null],&amp;quot;src&amp;quot;:&amp;quot;{{{b}}}&amp;quot;}\">{{{b}}}&lt;/span>"},{"html":""}]]}' data-parsoid='{"a":{"{{{b}}}":null},"sa":{"{{{b}}}":""}}'>
+<tbody><tr><td>c</td></tr>
+</tbody></table>
+
+!!end
+
+###
+### Testing parsing of templates where a template arg
+### has the same name as the template itself.
+###
+
+!! article
+Template:quote
+!! text
+{{{quote|{{{1}}}}}}
+!! endarticle
+
+!!test
+Templates: Template Name/Arg clash: 1. Use of positional param
+!! wikitext
+{{quote|foo}}
+!! html
+<p>foo
+</p>
+!!end
+
+!!test
+Templates: Template Name/Arg clash: 2. Use of named param
+!! wikitext
+{{quote|quote=foo}}
+!! html
+<p>foo
+</p>
+!!end
+
+!!test
+Templates: Template Name/Arg clash: 3. Use of named param with empty input
+!! wikitext
+{{quote|quote}}
+!! html
+<p>quote
+</p>
+!!end
+
+###
+### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
+###
+
+!!test
+Templates: 1. Simple use
+!! wikitext
+{{echo|Foo}}
+!! html
+<p>Foo
+</p>
+!!end
+
+!!test
+Templates: 2. Inside a block tag
+!! wikitext
+<div>{{echo|Foo}}</div>
+<blockquote>{{echo|Foo}}</blockquote>
+!! html
+<div>Foo</div>
+<blockquote>Foo</blockquote>
+
+!! html+tidy
+<div>Foo</div>
+<blockquote>
+<p>Foo</p>
+</blockquote>
+!!end
+
+!!test
+Templates: P-wrapping: 1a. Templates on consecutive lines
+!! wikitext
+{{echo|Foo}}
+{{echo|bar}}
+!! html
+<p>Foo
+bar
+</p>
+!!end
+
+!!test
+Templates: P-wrapping: 1b. Templates on consecutive lines
+!! wikitext
+Foo
+
+{{echo|bar}}
+{{echo|baz}}
+!! html
+<p>Foo
+</p><p>bar
+baz
+</p>
+!!end
+
+!!test
+Templates: P-wrapping: 1c. Templates on consecutive lines
+!! wikitext
+{{echo|Foo}}
+{{echo|bar}} <div>baz</div>
+!! html
+<p>Foo
+</p>
+bar <div>baz</div>
+
+!! html+tidy
+<p>Foo</p>
+<p>bar</p>
+<div>baz</div>
+!! end
+
+!!test
+Templates: P-wrapping: 1d. Template preceded by comment-only line
+!!options
+parsoid
+!! wikitext
+<!-- foo -->
+{{echo|Bar}}
+!! html
+<!-- foo -->
+
+<p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
+!!end
+
+!!test
+Templates: Inline Text: 1. Multiple template uses
+!! wikitext
+{{echo|Foo}}bar{{echo|baz}}
+!! html
+<p>Foobarbaz
+</p>
+!!end
+
+!!test
+Templates: Inline Text: 2. Back-to-back template uses
+!! wikitext
+{{echo|Foo}}{{echo|bar}}
+!! html
+<p>Foobar
+</p>
+!!end
+
+!!test
+Templates: Block Tags: 1. Multiple template uses
+!! wikitext
+{{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
+!! html
+<div>Foo</div><div>bar</div><div>baz</div>
+
+!!end
+
+!!test
+Templates: Block Tags: 2. Back-to-back template uses
+!! wikitext
+{{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
+!! html
+<div>Foo</div><div>bar</div>
+
+!!end
+
+# This is an edge case relating to paragraph wrapping.
+!!test
+Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
+!! wikitext
+{{echo|a
+b</p>}}
+!! html/parsoid
+<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\nb&lt;/p>"}},"i":0}}]}'>a
+b</p><p></p>
+!!end
+
+!!test
+Templates: Links: 1. Simple example
+!! wikitext
+{{echo|[[Foo|bar]]}}
+!! html
+<p><a href="/wiki/Foo" title="Foo">bar</a>
+</p>
+!!end
+
+!!test
+Templates: Links: 2. Generation of link href
+!! wikitext
+[[{{echo|Foo}}|bar]]
+!! html
+<p><a href="/wiki/Foo" title="Foo">bar</a>
+</p>
+!!end
+
+!!test
+Templates: Links: 3. Generation of part of a link href
+!! wikitext
+[[Fo{{echo|o}}|bar]]
+
+[[Foo{{echo|bar}}]]
+
+[[Foo{{echo|bar}}baz]]
+
+[[Foo{{echo|bar}}|bar]]
+
+[[:Foo{{echo|bar}}]]
+
+[[:Foo{{echo|bar}}|bar]]
+!! html
+<p><a href="/wiki/Foo" title="Foo">bar</a>
+</p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
+</p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
+</p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
+</p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
+</p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
+</p>
+!!end
+
+!!test
+Templates: Links: 4. Multiple templates generating link href
+!! wikitext
+[[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
+!! html
+<p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
+</p>
+!!end
+
+!!test
+Templates: Links: 5. Generation of link text
+!! wikitext
+[[Foo|{{echo|bar}}]]
+!! html
+<p><a href="/wiki/Foo" title="Foo">bar</a>
+</p>
+!!end
+
+!!test
+Templates: Links: 5. Nested templates (only outermost template should be marked)
+!! wikitext
+{{echo|[[{{echo|Foo}}|bar]]}}
+!! html
+<p><a href="/wiki/Foo" title="Foo">bar</a>
+</p>
+!!end
+
+!!test
+Templates: HTML Tag: 1. Generation of HTML attr. key
+!! wikitext
+<div {{echo|style}}="color:red;">foo</div>
+!! html
+<div style="color:red;">foo</div>
+
+!!end
+
+!!test
+Templates: HTML Tag: 2. Generation of HTML attr. value
+!! wikitext
+<div style={{echo|'color:red;'}}>foo</div>
+!! html
+<div style="color:red;">foo</div>
+
+!!end
+
+!!test
+Templates: HTML Tag: 3. Generation of HTML attr key and value
+!! wikitext
+<div {{echo|style}}={{echo|'color:red;'}}>foo</div>
+!! html
+<div style="color:red;">foo</div>
+
+!!end
+
+!!test
+Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
+!! wikitext
+<div title="{{echo|This is a long title}} with just one piece templated">foo</div>
+!! html
+<div title="This is a long title with just one piece templated">foo</div>
+
+!!end
+
+!!test
+Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
+!! wikitext
+<div title="This is a long title with just {{echo|one piece}} templated">foo</div>
+!! html
+<div title="This is a long title with just one piece templated">foo</div>
+
+!!end
+
+!!test
+Templates: HTML Tag: 6. Generation of end piece of HTML attr value
+!! wikitext
+<div title="This is a long title with just one piece {{echo|templated}}">foo</div>
+!! html
+<div title="This is a long title with just one piece templated">foo</div>
+
+!!end
+
+!!test
+Templates: HTML Tag: 7. Generation of partial attribute key string
+!! wikitext
+<div st{{echo|yle}}="color:red;">foo</div>
+!! html
+<div style="color:red;">foo</div>
+
+!!end
+
+!!test
+Templates: HTML Tables: 1. Generating start of a HTML table
+!! wikitext
+{{echo|<table><tr><td>foo</td>}}</tr></table>
+!! html
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 2a. Generating middle of a HTML table
+!! wikitext
+<table><tr>{{echo|<td>foo</td>}}</tr></table>
+!! html
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 2b. Generating middle of a HTML table
+!! wikitext
+<table>{{echo|<tr><td>foo</td></tr>}}</table>
+!! html
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 3. Generating end of a HTML table
+!! wikitext
+<table><tr>{{echo|<td>foo</td></tr></table>}}
+!! html
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 4a. Generating a single tag of a HTML table
+!! wikitext
+{{echo|<table>}}<tr><td>foo</td></tr></table>
+!! html
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 4b. Generating a single tag of a HTML table
+!! wikitext
+<table>{{echo|<tr>}}<td>foo</td></tr></table>
+!! html
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 4c. Generating a single tag of a HTML table
+!! wikitext
+<table><tr>{{echo|<td>}}foo</td></tr></table>
+!! html
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 4d. Generating a single tag of a HTML table
+!! wikitext
+<table><tr><td>foo{{echo|</td>}}</tr></table>
+!! html
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 4e. Generating a single tag of a HTML table
+!! wikitext
+<table><tr><td>foo</td>{{echo|</tr>}}</table>
+!! html
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 4f. Generating a single tag of a HTML table
+!! wikitext
+<table><tr><td>foo</td></tr>{{echo|</table>}}
+!! html
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 5. Proper fostering of categories from inside
+!!options
+parsoid=wt2html,wt2wt
+!! wikitext
+<table>[[Category:foo1]]<tr><td>foo</td></tr></table>
+<!--Two categories (Bug 50330)-->
+<table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
+!! html
+<link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
+<!--Two categories (Bug 50330)-->
+<link rel="mw:PageProp/Category" href="./Category:Bar1"><link rel="mw:PageProp/Category" href="./Category:Bar2"><table><tbody><tr><td>foo</td></tr></tbody></table>
+!!end
+
+!!test
+Templates: Wiki Tables: 1a. Fostering of entire template content
+!! wikitext
+{|
+{{echo|a}}
+|}
+!! html
+<table>
+a
+<tr><td></td></tr></table>
+
+!! html+tidy
+<p>a</p>
+<table>
+<tr>
+<td></td>
+</tr>
+</table>
+!! end
+
+!!test
+Templates: Wiki Tables: 1b. Fostering of entire template content
+!! wikitext
+{|
+{{echo|<div>}}
+foo
+{{echo|</div>}}
+|}
+!! html
+<table>
+<div>
+<p>foo
+</p>
+</div>
+<tr><td></td></tr></table>
+
+!! html+tidy
+<div>
+<p>foo</p>
+</div>
+<table>
+<tr>
+<td></td>
+</tr>
+</table>
+!! end
+
+!!test
+Templates: Wiki Tables: 2. Fostering of partial template content
+!! wikitext
+{|
+{{echo|a
+<div>b</div>}}
+|}
+!! html
+<table>
+a
+<div>b</div>
+<tr><td></td></tr></table>
+
+!! html+tidy
+<p>a</p>
+<div>b</div>
+<table>
+<tr>
+<td></td>
+</tr>
+</table>
+!! end
+
+!!test
+Templates: Wiki Tables: 3. td-content via multiple templates
+!! wikitext
+{|
+{{echo|{{pipe}}a}}{{echo|b}}
+|}
+!! html
+<table>
+<tr>
+<td>ab
+</td></tr></table>
+
+!!end
+
+!!test
+Templates: Wiki Tables: 4. Templated tags, no content
+!! wikitext
+{{tbl-start}}
+{{tbl-end}}
+!! html
+<table>
+<tr><td></td></tr></table>
+
+!!end
+
+!!test
+Templates: Wiki Tables: 5. Templated tags, regular td-tags
+!! wikitext
+{{tbl-start}}
+|foo
+{{tbl-end}}
+!! html
+<table>
+<tr>
+<td>foo
+</td></tr></table>
+
+!!end
+
+!!test
+Templates: Wiki Tables: 6. Templated tags, templated td-tags
+!! wikitext
+{{tbl-start}}
+{{!}}foo
+{{tbl-end}}
+!! html
+<table>
+<tr>
+<td>foo
+</td></tr></table>
+
+!!end
+
+!!test
+Templates: Lists: Multi-line list-items via templates
+!! wikitext
+*{{echo|a {{nonexistent|
+unused}}}}
+*{{echo|b {{nonexistent|
+unused}}}}
+!! html
+<ul><li>a <a href="/index.php?title=Template:Nonexistent&amp;action=edit&amp;redlink=1" class="new" title="Template:Nonexistent (page does not exist)">Template:Nonexistent</a></li>
+<li>b <a href="/index.php?title=Template:Nonexistent&amp;action=edit&amp;redlink=1" class="new" title="Template:Nonexistent (page does not exist)">Template:Nonexistent</a></li></ul>
+
+!!end
+
+!!test
+Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
+!! wikitext
+{{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
+!! html
+<p><i>ab</i>c<i>d</i>e
+</p>
+!!end
+
+!!test
+Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
+(PHP parser generates misnested html)
+!! wikitext
+{{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
+!! html/parsoid
+<p><span about="#mwt1" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_span&quot;,&quot;href&quot;:&quot;./Template:Echo_with_span&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;''a&quot;}},&quot;i&quot;:0}}]}"><i>a</i></span><i about="#mwt2" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_span&quot;,&quot;href&quot;:&quot;./Template:Echo_with_span&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;b''c''d&quot;}},&quot;i&quot;:0}},{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_span&quot;,&quot;href&quot;:&quot;./Template:Echo_with_span&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;''e&quot;}},&quot;i&quot;:1}}]}"><span>b</span></i><span about="#mwt2">c</span><i about="#mwt2">d<span></span></i><span about="#mwt2">e</span></p>
+!!end
+
+!!test
+Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
+(PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
+!! options
+parsoid=wt2html,wt2wt
+!! wikitext
+{{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
+!! html
+<div about="#mwt1" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_div&quot;,&quot;href&quot;:&quot;./Template:Echo_with_div&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;''a&quot;}},&quot;i&quot;:0}}]}"><i>a</i></div>
+<div about="#mwt2" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_div&quot;,&quot;href&quot;:&quot;./Template:Echo_with_div&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;b''c''d&quot;}},&quot;i&quot;:0}}]}"><i>b</i>c<i>d</i></div>
+<div about="#mwt3" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_div&quot;,&quot;href&quot;:&quot;./Template:Echo_with_div&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;''e&quot;}},&quot;i&quot;:0}}]}">e</div>
+!!end
+
+!!test
+Templates: Ugly nesting: 4. Divs opened/closed across templates
+!! wikitext
+a<div>b{{echo|c</div>d}}e
+!! html
+a<div>bc</div>de
+
+!! html+tidy
+<p>a</p>
+<div>bc</div>
+<p>de</p>
+!! end
+
+!!test
+Templates: Ugly templates: 1. Navbox template parses badly leading to table misnesting
+(Parsoid-centric)
+!! options
+parsoid
+!! wikitext
+{|
+|{{echo|foo</table>}}
+|bar
+|}
+!! html
+<table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["{|\n|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo</table>"}},"i":0}},"\n|bar\n|}"]}'>
+
+<tbody>
+<tr>
+<td>foo</td></tr></tbody></table><span about="#mwt1">
+</span><span about="#mwt1">|bar</span><span about="#mwt1">
+|}</span>
+!!end
+
+!!test
+Templates: Ugly templates: 2. Navbox template parses badly leading to table misnesting
+(Parsoid-centric)
+!! options
+parsoid
+!! wikitext
+<table>
+ <tr>
+ <td>
+ <table>
+ <tr>
+ <td>1. {{echo|foo </table>}}</td>
+ <td> bar </td>
+ <td>2. {{echo|baz </table>}}</td>
+ </tr>
+ <tr>
+ <td>abc</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>xyz</td>
+ </tr>
+</table>
+!! html
+<table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":["<table>\n <tr>\n <td>\n <table>\n <tr>\n <td>1. ",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo </table>"}},"i":0}},"</td>\n <td> bar </td>\n <td>2. ",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"baz </table>"}},"i":1}},"</td>\n </tr>\n <tr>\n <td>abc</td>\n </tr>\n </table>\n </td>\n </tr>\n <tr>\n <td>xyz</td>\n </tr>\n</table>"]}'>
+ <tbody><tr>
+ <td>
+ <table>
+ <tbody><tr>
+ <td>1. foo </td></tr></tbody></table></td>
+ <td> bar </td>
+ <td>2. baz </td></tr></tbody></table><span about="#mwt2">
+ </span><span about="#mwt2">
+ </span><span about="#mwt2">
+ </span><span about="#mwt2">abc</span><span about="#mwt2">
+ </span><span about="#mwt2">
+ </span><span about="#mwt2">
+ </span><span about="#mwt2">
+ </span><span about="#mwt2">
+ </span><span about="#mwt2">
+ </span><span about="#mwt2">xyz</span><span about="#mwt2">
+ </span><span about="#mwt2">
+</span>
+!!end
+
+!! test
+Templates: Ugly templates: 3. newline-only template parameter
+!! wikitext
+foo {{echo|
+}}
+!! html
+<p>foo
+</p>
+!! end
+
+# This looks like a bug: a single newline triggers p/br for some reason.
+!! test
+Templates: Ugly templates: 4. newline-only template parameter inconsistency
+!! wikitext
+{{echo|
+}}
+!! html
+<p><br />
+</p>
+!! end
+
+# Bug 64017 -- ugly wikitext with fostered content generates two template ranges that
+# have a true overlap (T1-start - T2-start - T1-end - T2-end).
+!! test
+Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
+!! wikitext
+{{echo|<table>}}
+{{echo|<div>foo}}
+{{echo|</table>}}
+!! html/parsoid
+<div about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;table>"}},"i":0}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;div>foo"}},"i":1}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;/table>"}},"i":2}}]}' data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1","spc":["","","",""]}],[{"k":"1","spc":["","","",""]}],[{"k":"1","spc":["","","",""]}]]}'>foo
+</div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
+</table>
+!! end
+
+# Bug 64017 -- ugly wikitext with fostered content generates two template ranges
+# that are "identical" and generate nesting cycles in the algorithm
+!! test
+Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
+!! wikitext
+{{echo|<table><tr><td><table>}}
+{{echo|<div>}}
+{{echo|</div>}}
+!! html/parsoid
+<table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;table>&lt;tr>&lt;td>&lt;table>"}},"i":0}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;div>"}},"i":1}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;/div>"}},"i":2}}]}' data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1","spc":["","","",""]}],[{"k":"1","spc":["","","",""]}],[{"k":"1","spc":["","","",""]}]]}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>
+</div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
+</table></td></tr></tbody></table>
+!! end
+
+!!test
+Parser Functions: 1. Simple example
+!! wikitext
+{{uc:foo}}
+!! html
+<p>FOO
+</p>
+!!end
+
+!!test
+Parser Functions: 2. Nested use (only outermost should be marked up)
+!! wikitext
+{{uc:{{lc:FOO}}}}
+!! html
+<p>FOO
+</p>
+!!end
+
+###
+### Pre-save transform tests
+###
+!! test
+pre-save transform: subst:
+!! options
+PST
+!! wikitext
+{{subst:test}}
+!! html
+This is a test template
+!! end
+
+!! test
+pre-save transform: normal template
+!! options
+PST
+!! wikitext
+{{test}}
+!! html
+{{test}}
+!! end
+
+!! test
+pre-save transform: nonexistent template
+!! options
+PST
+!! wikitext
+{{thistemplatedoesnotexist}}
+!! html
+{{thistemplatedoesnotexist}}
+!! end
+
+
+!! test
+pre-save transform: subst magic variables
+!! options
+PST
+!! wikitext
+{{subst:SITENAME}}
+!! html
+MediaWiki
+!! end
+
+# This is bug 89, which I fixed. -- wtm
+!! test
+pre-save transform: subst: templates with parameters
+!! options
+pst
+!! wikitext
+{{subst:paramtest|param="something else"}}
+!! html
+This is a test template with parameter "something else"
+!! end
+
+!! article
+Template:nowikitest
+!! text
+<nowiki>'''not wiki'''</nowiki>
+!! endarticle
+
+!! test
+pre-save transform: nowiki in subst (bug 1188)
+!! options
+pst
+!! wikitext
+{{subst:nowikitest}}
+!! html
+<nowiki>'''not wiki'''</nowiki>
+!! end
+
+
+!! article
+Template:commenttest
+!! text
+This template has <!-- a comment --> in it.
+!! endarticle
+
+!! test
+pre-save transform: comment in subst (bug 1936)
+!! options
+pst
+!! wikitext
+{{subst:commenttest}}
+!! html
+This template has <!-- a comment --> in it.
+!! end
+
+!! test
+pre-save transform: unclosed tag
+!! options
+pst noxml
+!! wikitext
+<nowiki>'''not wiki'''
+!! html
+<nowiki>'''not wiki'''
+!! end
+
+!! test
+pre-save transform: mixed tag case
+!! options
+pst noxml
+!! wikitext
+<NOwiki>'''not wiki'''</noWIKI>
+!! html
+<NOwiki>'''not wiki'''</noWIKI>
+!! end
+
+!! test
+pre-save transform: unclosed comment in <nowiki>
+!! options
+pst noxml
+!! wikitext
+wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
+!! html
+wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
+!!end
+
+# Leading @ in this template definition works around a limitation
+# in parsoid's parserTests which otherwise strips the <span> from the
+# result (confusing it for a template wrapper)
+!! article
+Template:dangerous
+!!text
+@<span onmouseover="alert('crap')">Oh no</span>
+!!endarticle
+
+!!test
+(confirming safety of fix for subst bug 1936)
+!! wikitext
+{{Template:dangerous}}
+!! html
+<p>@<span>Oh no</span>
+</p>
+!! end
+
+!! test
+pre-save transform: comment containing gallery (bug 5024)
+!! options
+pst
+!! wikitext
+<!-- <gallery>data</gallery> -->
+!! html
+<!-- <gallery>data</gallery> -->
+!!end
+
+!! test
+pre-save transform: comment containing extension
+!! options
+pst
+!! wikitext
+<!-- <tag>data</tag> -->
+!! html
+<!-- <tag>data</tag> -->
+!!end
+
+!! test
+pre-save transform: comment containing nowiki
+!! options
+pst
+!! wikitext
+<!-- <nowiki>data</nowiki> -->
+!! html
+<!-- <nowiki>data</nowiki> -->
+!!end
+
+!! test
+pre-save transform: <noinclude> in subst (bug 3298)
+!! options
+pst
+!! wikitext
+{{subst:Includes}}
+!! html
+Foobar
+!! end
+
+!! test
+pre-save transform: <onlyinclude> in subst (bug 3298)
+!! options
+pst
+!! wikitext
+{{subst:Includes2}}
+!! html
+Foo
+!! end
+
+!! article
+Template:SubstTest
+!!text
+{{<includeonly>subst:</includeonly>Includes}}
+!! endarticle
+
+!! article
+Template:SafeSubstTest
+!! text
+{{<includeonly>safesubst:</includeonly>Includes}}
+!! endarticle
+
+!! test
+bug 22297: safesubst: works during PST
+!! options
+pst
+!! wikitext
+{{subst:SafeSubstTest}}{{safesubst:SubstTest}}
+!! html
+FoobarFoobar
+!! end
+
+!! test
+bug 22297: safesubst: works during normal parse
+!! wikitext
+{{SafeSubstTest}}
+!! html
+<p>Foobar
+</p>
+!! end
+
+!! test
+subst: does not work during normal parse
+!! wikitext
+{{SubstTest}}
+!! html
+<p>{{subst:Includes}}
+</p>
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick")
+!! options
+pst
+!! wikitext
+[[Article (context)|]]
+[[Bar:Article|]]
+[[:Bar:Article|]]
+[[Bar:Article (context)|]]
+[[:Bar:Article (context)|]]
+[[|Article]]
+[[|Article (context)]]
+[[Bar:X (Y) Z|]]
+[[:Bar:X (Y) Z|]]
+!! html
+[[Article (context)|Article]]
+[[Bar:Article|Article]]
+[[:Bar:Article|Article]]
+[[Bar:Article (context)|Article]]
+[[:Bar:Article (context)|Article]]
+[[Article]]
+[[Article (context)]]
+[[Bar:X (Y) Z|X (Y) Z]]
+[[:Bar:X (Y) Z|X (Y) Z]]
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick") with interwiki prefix
+!! options
+pst
+!! wikitext
+[[interwiki:Article|]]
+[[:interwiki:Article|]]
+[[interwiki:Bar:Article|]]
+[[:interwiki:Bar:Article|]]
+!! html
+[[interwiki:Article|Article]]
+[[:interwiki:Article|Article]]
+[[interwiki:Bar:Article|Bar:Article]]
+[[:interwiki:Bar:Article|Bar:Article]]
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick") with parens in title
+!! options
+pst title=[[Somearticle (context)]]
+!! wikitext
+[[|Article]]
+!! html
+[[Article (context)|Article]]
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick") with comma in title
+!! options
+pst title=[[Someplace, Somewhere]]
+!! wikitext
+[[|Otherplace]]
+[[Otherplace, Elsewhere|]]
+[[Otherplace, Elsewhere, Anywhere|]]
+!! html
+[[Otherplace, Somewhere|Otherplace]]
+[[Otherplace, Elsewhere|Otherplace]]
+[[Otherplace, Elsewhere, Anywhere|Otherplace]]
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick") with parens and comma
+!! options
+pst title=[[Someplace (IGNORED), Somewhere]]
+!! wikitext
+[[|Otherplace]]
+[[Otherplace (place), Elsewhere|]]
+!! html
+[[Otherplace, Somewhere|Otherplace]]
+[[Otherplace (place), Elsewhere|Otherplace]]
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick") with comma and parens
+!! options
+pst title=[[Who, me? (context)]]
+!! wikitext
+[[|Yes, you.]]
+[[Me, Myself, and I (1937 song)|]]
+!! html
+[[Yes, you. (context)|Yes, you.]]
+[[Me, Myself, and I (1937 song)|Me, Myself, and I]]
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick") with namespace
+!! options
+pst title=[[Ns:Somearticle]]
+!! wikitext
+[[|Article]]
+!! html
+[[Ns:Article|Article]]
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick") with namespace and parens
+!! options
+pst title=[[Ns:Somearticle (context)]]
+!! wikitext
+[[|Article]]
+!! html
+[[Ns:Article (context)|Article]]
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick") with namespace and comma
+!! options
+pst title=[[Ns:Somearticle, Context, Whatever]]
+!! wikitext
+[[|Article]]
+!! html
+[[Ns:Article, Context, Whatever|Article]]
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick") with namespace, comma and parens
+!! options
+pst title=[[Ns:Somearticle, Context (context)]]
+!! wikitext
+[[|Article]]
+!! html
+[[Ns:Article (context)|Article]]
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick") with namespace, parens and comma
+!! options
+pst title=[[Ns:Somearticle (IGNORED), Context]]
+!! wikitext
+[[|Article]]
+!! html
+[[Ns:Article, Context|Article]]
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, bug 30149)
+!! options
+pst
+!! wikitext
+[[Article(context)|]]
+[[Bar:Article(context)|]]
+[[:Bar:Article(context)|]]
+[[|Article(context)]]
+[[Bar:X(Y)Z|]]
+[[:Bar:X(Y)Z|]]
+!! html
+[[Article(context)|Article]]
+[[Bar:Article(context)|Article]]
+[[:Bar:Article(context)|Article]]
+[[Article(context)]]
+[[Bar:X(Y)Z|X(Y)Z]]
+[[:Bar:X(Y)Z|X(Y)Z]]
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, bug 30149)
+!! options
+pst
+!! wikitext
+[[Article (context)|]]
+[[Bar:Article (context)|]]
+[[:Bar:Article (context)|]]
+[[|Article (context)]]
+[[Bar:X (Y) Z|]]
+[[:Bar:X (Y) Z|]]
+!! html
+[[Article (context)|Article]]
+[[Bar:Article (context)|Article]]
+[[:Bar:Article (context)|Article]]
+[[Article (context)]]
+[[Bar:X (Y) Z|X (Y) Z]]
+[[:Bar:X (Y) Z|X (Y) Z]]
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick") with parens and no space (Korean style, bug 30149)
+!! options
+pst
+!! wikitext
+[[Article(context)|]]
+[[Bar:Article(context)|]]
+[[:Bar:Article(context)|]]
+[[|Article(context)]]
+[[Bar:X(Y)Z|]]
+[[:Bar:X(Y)Z|]]
+!! html
+[[Article(context)|Article]]
+[[Bar:Article(context)|Article]]
+[[:Bar:Article(context)|Article]]
+[[Article(context)]]
+[[Bar:X(Y)Z|X(Y)Z]]
+[[:Bar:X(Y)Z|X(Y)Z]]
+!! end
+
+!! test
+pre-save transform: context links ("pipe trick") with commas (bug 21660)
+!! options
+pst
+!! wikitext
+[[Article (context), context|]]
+[[Article (context),context|]]
+[[Bar:Article (context), context|]]
+[[Bar:Article (context),context|]]
+[[:Bar:Article (context), context|]]
+[[:Bar:Article (context),context|]]
+!! html
+[[Article (context), context|Article]]
+[[Article (context),context|Article]]
+[[Bar:Article (context), context|Article]]
+[[Bar:Article (context),context|Article]]
+[[:Bar:Article (context), context|Article]]
+[[:Bar:Article (context),context|Article]]
+!! end
+
+!! test
+pre-save transform: trim trailing empty lines
+!! options
+pst
+!! wikitext
+Empty lines are trimmed
+
+
+
+
+!! html
+Empty lines are trimmed
+!! end
+
+!! test
+pre-save transform: Signature expansion
+!! options
+pst
+!! wikitext
+* ~~~
+* <noinclude>~~~</noinclude>
+* <includeonly>~~~</includeonly>
+* <onlyinclude>~~~</onlyinclude>
+!! html
+* [[Special:Contributions/127.0.0.1|127.0.0.1]]
+* <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
+pre-save transform: Signature expansion in nowiki tags (bug 93)
+!! options
+pst disabled
+!! wikitext
+Shall not expand:
+
+<nowiki>~~~~</nowiki>
+
+<includeonly><nowiki>~~~~</nowiki></includeonly>
+
+<noinclude><nowiki>~~~~</nowiki></noinclude>
+
+<onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
+
+{{subst:Foo}} shall be converted to FOO
+
+As well as inside noinclude/onlyinclude
+<noinclude>{{subst:Foo}}</noinclude>
+<onlyinclude>{{subst:Foo}}</onlyinclude>
+
+But not inside includeonly
+<includeonly>{{subst:Foo}}</includeonly>
+!! html
+Shall not expand:
+
+<nowiki>~~~~</nowiki>
+
+<includeonly><nowiki>~~~~</nowiki></includeonly>
+
+<noinclude><nowiki>~~~~</nowiki></noinclude>
+
+<onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
+
+FOO shall be converted to FOO
+
+As well as inside noinclude/onlyinclude
+<noinclude>FOO</noinclude>
+<onlyinclude>FOO</onlyinclude>
+
+But not inside includeonly
+<includeonly>{{subst:Foo}}</includeonly>
+!! end
+
+!! test
+Parsoid: Recognize nowiki with trailing space in tags
+!! options
+parsoid=wt2html
+!! wikitext
+<nowiki ><div>[[foo]]</nowiki >
+
+a<nowiki / >b
+
+c<nowiki />d
+
+e<nowiki/ >f
+!! html
+<p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
+<p>ab</p>
+<p>cd</p>
+<p>ef</p>
+!! end
+
+!! test
+Parsoid: Recognize nowiki with odd capitalization
+!! options
+parsoid=wt2html
+!! wikitext
+<noWikI ><div>[[foo]]</Nowiki >
+!! html
+<p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
+!! end
+
+
+!! test
+Parsoid: Escape nowiki with trailing space in tags
+!! options
+parsoid=html2wt
+!! wikitext
+&lt;nowiki &gt; foo &lt;/nowiki &gt;
+
+a&lt;nowiki /&gt;b
+
+c&lt;nowiki/ &gt;d
+!! html
+<p>&lt;nowiki &gt; foo &lt/nowiki ></p>
+<p>a&lt;nowiki /&gt;b</p>
+<p>c&lt;nowiki/ &gt;d</p>
+!! end
+
+!! test
+Parsoid: Escape weird noWikI capitalizations
+!! options
+parsoid=html2wt
+!! wikitext
+&lt;noWikI &gt; foo &lt;/NoWikI &gt;
+!! html
+<p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
+!! end
+
+###
+### Message transform tests
+###
+!! test
+message transform: magic variables
+!! options
+msg
+!! wikitext
+{{SITENAME}}
+!! html
+MediaWiki
+!! end
+
+!! test
+message transform: should not transform wiki markup
+!! options
+msg
+!! wikitext
+''test''
+!! html
+''test''
+!! end
+
+!! test
+message transform: <noinclude> in transcluded template (bug 4926)
+!! options
+msg
+!! wikitext
+{{Includes}}
+!! html
+Foobar
+!! end
+
+!! test
+message transform: <onlyinclude> in transcluded template (bug 4926)
+!! options
+msg
+!! wikitext
+{{Includes2}}
+!! html
+Foo
+!! end
+
+!! test
+{{#special:}} page name, known
+!! options
+msg
+!! wikitext
+{{#special:Recentchanges}}
+!! html
+Special:RecentChanges
+!! end
+
+!! test
+{{#special:}} page name with subpage, known
+!! options
+msg
+!! wikitext
+{{#special:Recentchanges/param}}
+!! html
+Special:RecentChanges/param
+!! end
+
+!! test
+{{#special:}} page name, unknown
+!! options
+msg
+!! wikitext
+{{#special:foobar nonexistent}}
+!! html
+Special:Foobar nonexistent
+!! end
+
+!! test
+{{#speciale:}} page name, known
+!! options
+msg
+!! wikitext
+{{#speciale:Recentchanges}}
+!! html
+Special:RecentChanges
+!! end
+
+!! test
+{{#speciale:}} page name with subpage, known
+!! options
+msg
+!! wikitext
+{{#speciale:Recentchanges/param}}
+!! html
+Special:RecentChanges/param
+!! end
+
+!! test
+{{#speciale:}} page name, unknown
+!! options
+msg
+!! wikitext
+{{#speciale:foobar nonexistent}}
+!! html
+Special:Foobar_nonexistent
+!! end
+
+###
+### Images
+###
+### For Parsoid-specific tests, see
+#### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
+
+!! test
+Simple image
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[Image:foobar.jpg]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<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" height="220" width="1941"></a></span>
+</p>
+!! end
+
+!! test
+Simple image (using File: namespace, now canonical)
+!! wikitext
+[[File:Foobar.jpg]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<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" height="220" width="1941"></a></span>
+</p>
+!! end
+
+!! test
+Right-aligned image
+!! wikitext
+[[File:Foobar.jpg|right]]
+!! html/php
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
+
+!! html/parsoid
+<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" height="220" width="1941"></a></figure>
+!! end
+
+!! test
+Image with caption
+!! wikitext
+[[File:Foobar.jpg|right|Caption text]]
+!! html/php
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
+
+!! html/parsoid
+<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" height="220" width="1941"></a><figcaption>Caption text</figcaption></figure>
+!! end
+
+!! test
+Image with caption, bug 53312 #1
+!! wikitext
+[[File:Foobar.jpg|right|Caption page stuff]]
+!! html/php
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption page stuff"><img alt="Caption page stuff" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
+
+!! html/parsoid
+<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" height="220" width="1941"></a><figcaption>Caption page stuff</figcaption></figure>
+!! end
+
+!! test
+Image with caption, bug 53312 #2
+!! wikitext
+[[File:Foobar.jpg|right|Caption page=]]
+!! html/php
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption page="><img alt="Caption page=" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
+
+!! html/parsoid
+<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" height="220" width="1941"></a><figcaption>Caption page=</figcaption></figure>
+!! end
+
+!! test
+Image with caption, bug 53312 #3
+!! wikitext
+[[File:Foobar.jpg|right|Caption page=stuff]]
+!! html/php
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption page=stuff"><img alt="Caption page=stuff" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
+
+!! html/parsoid
+<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" height="220" width="1941"></a><figcaption>Caption page=stuff</figcaption></figure>
+!! end
+
+!! test
+Allow empty links in image captions (Bug 60753)
+!! options
+thumbsize=220
+!! wikitext
+[[File:Foobar.jpg|thumb|Caption [[Link1]]
+[[]]
+[[Link2]]
+]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Caption <a href="/index.php?title=Link1&amp;action=edit&amp;redlink=1" class="new" title="Link1 (page does not exist)">Link1</a> [[]] <a href="/index.php?title=Link2&amp;action=edit&amp;redlink=1" class="new" title="Link2 (page does not exist)">Link2</a></div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Caption [[Link1]]\n[[]]\n[[Link2]]\n"}],"dsr":[0,59,2,2]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"dsr":[2,null,null,null]}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption data-parsoid='{"dsr":[null,57,null,null]}'>Caption <a rel="mw:WikiLink" href="./Link1" title="Link1" data-parsoid='{"stx":"simple","a":{"href":"./Link1"},"sa":{"href":"Link1"},"dsr":[32,41,2,2]}'>Link1</a>
+[[]]
+<a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"},"dsr":[47,56,2,2]}'>Link2</a>
+</figcaption></figure>
+!! end
+
+!! test
+Link with empty target
+!! wikitext
+[[]]
+!! html
+<p>[[]]
+</p>
+!! end
+
+!! test
+Image with empty attribute
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|right||Caption text]]
+!! html/php
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
+
+!! html/parsoid
+<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" height="220" width="1941"></a><figcaption>Caption text</figcaption></figure>
+!! end
+
+!! test
+1. Block image with individual attributes from templates
+!! wikitext
+[[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:139px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" width="137" height="16" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/206px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/274px-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 caption</div></div></div>
+
+!! html/parsoid
+<figure typeof="mw:Image/Thumb mw:ExpandedAttrs" data-mw='{"attribs":[["thumbnail",{"html":"thumb"}],["width",{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-mw=\"{&amp;quot;parts&amp;quot;:[{&amp;quot;template&amp;quot;:{&amp;quot;target&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;echo&amp;quot;,&amp;quot;href&amp;quot;:&amp;quot;./Template:Echo&amp;quot;},&amp;quot;params&amp;quot;:{&amp;quot;1&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;137px&amp;quot;}},&amp;quot;i&amp;quot;:0}}]}\" data-parsoid=\"{&amp;quot;pi&amp;quot;:[[{&amp;quot;k&amp;quot;:&amp;quot;1&amp;quot;,&amp;quot;spc&amp;quot;:[&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;]}]],&amp;quot;dsr&amp;quot;:[24,38,null,null]}\">137px&lt;/span>"}]]}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="16" width="137"/></a><figcaption>This is a caption</figcaption></figure>
+!! end
+
+!! test
+2. Block Image with individual attributes from templates
+!! wikitext
+[[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:139px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" width="137" height="16" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/206px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/274px-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 caption</div></div></div>
+
+!! html/parsoid
+<figure typeof="mw:Image/Thumb mw:ExpandedAttrs" data-mw='{"attribs":[["thumbnail",{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-mw=\"{&amp;quot;parts&amp;quot;:[{&amp;quot;template&amp;quot;:{&amp;quot;target&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;echo&amp;quot;,&amp;quot;href&amp;quot;:&amp;quot;./Template:Echo&amp;quot;},&amp;quot;params&amp;quot;:{&amp;quot;1&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;thumb&amp;quot;}},&amp;quot;i&amp;quot;:0}}]}\" data-parsoid=\"{&amp;quot;pi&amp;quot;:[[{&amp;quot;k&amp;quot;:&amp;quot;1&amp;quot;,&amp;quot;spc&amp;quot;:[&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;]}]],&amp;quot;dsr&amp;quot;:[18,32,null,null]}\">thumb&lt;/span>"}],["width",{"html":"&lt;span about=\"#mwt2\" typeof=\"mw:Transclusion\" data-mw=\"{&amp;quot;parts&amp;quot;:[{&amp;quot;template&amp;quot;:{&amp;quot;target&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;echo&amp;quot;,&amp;quot;href&amp;quot;:&amp;quot;./Template:Echo&amp;quot;},&amp;quot;params&amp;quot;:{&amp;quot;1&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;137px&amp;quot;}},&amp;quot;i&amp;quot;:0}}]}\" data-parsoid=\"{&amp;quot;pi&amp;quot;:[[{&amp;quot;k&amp;quot;:&amp;quot;1&amp;quot;,&amp;quot;spc&amp;quot;:[&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;]}]],&amp;quot;dsr&amp;quot;:[33,47,null,null]}\">137px&lt;/span>"}]]}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="16" width="137"/></a><figcaption>This is a caption</figcaption></figure>
+!! end
+
+!! test
+3. Inline image with individual attributes from templates
+!! wikitext
+[[File:Foobar.jpg|{{echo|50px}}]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" width="50" height="6" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" /></a>
+</p>
+!! html/parsoid
+<p><span typeof="mw:Image mw:ExpandedAttrs" about="#mwt2" data-mw='{"attribs":[["width",{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-mw=\"{&amp;quot;parts&amp;quot;:[{&amp;quot;template&amp;quot;:{&amp;quot;target&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;echo&amp;quot;,&amp;quot;href&amp;quot;:&amp;quot;./Template:Echo&amp;quot;},&amp;quot;params&amp;quot;:{&amp;quot;1&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;50px&amp;quot;}},&amp;quot;i&amp;quot;:0}}]}\" data-parsoid=\"{&amp;quot;pi&amp;quot;:[[{&amp;quot;k&amp;quot;:&amp;quot;1&amp;quot;,&amp;quot;spc&amp;quot;:[&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;]}]],&amp;quot;dsr&amp;quot;:[18,31,null,null]}\">50px&lt;/span>"}]]}' data-parsoid='{"optList":[{"ck":"width","ak":"{{echo|50px}}"}]}'><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/50px-Foobar.jpg" height="6" width="50" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
+!! end
+
+## Parsoid does not provide editing support for images where templates produce multiple image attributes.
+## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
+!! test
+Image with multiple attributes from the same template
+!! wikitext
+[[File:Foobar.jpg|{{image_attribs}}]]
+!! html/php
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
+
+!! html/parsoid
+<figure class="mw-default-size mw-halign-right" typeof="mw:Image mw:Placeholder"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"></a><figcaption>Caption text</figcaption></figure>
+!! end
+
+# Parsoid's output here is broken (incorrect p-wrapping); see bug 64901.
+!! test
+Image with link tails
+!! options
+thumbsize=220
+!! wikitext
+123[[File:Foobar.jpg]]456
+123[[File:Foobar.jpg|right]]456
+123[[File:Foobar.jpg|thumb]]456
+!! html/php
+<p>123<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>456
+</p>
+123<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>456
+123<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div></div></div></div>456
+
+!! html/php+tidy
+<p>123<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>456</p>
+<p>123</p>
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
+<p>456 123</p>
+<div class="thumb tright">
+<div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>
+<div class="thumbcaption">
+<div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
+</div>
+</div>
+</div>
+<p>456</p>
+!! html/parsoid
+<p>123<span class="mw-default-size" typeof="mw:Image"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"></a></span>456</p>
+123<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" height="220" width="1941"></a></figure>456
+123<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/180px-Foobar.jpg" height="25" width="220"></a></figure>456
+!! end
+
+!! test
+Image with multiple captions -- only last one is accepted
+!! wikitext
+[[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
+!! html/php
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption3 - accepted"><img alt="Caption3 - accepted" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
+
+!! html/parsoid
+<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" height="220" width="1941"></a><figcaption>Caption3 - accepted</figcaption></figure>
+!! end
+
+!! test
+Image with multiple widths -- use last
+!! wikitext
+[[File:Foobar.jpg|200px|300px|caption]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" width="300" height="34" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/450px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/600px-Foobar.jpg 2x" /></a>
+</p>
+!! 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/3/3a/Foobar.jpg" height="34" width="300"/></a></span></p>
+!! end
+
+!! test
+Image with multiple alignments -- use first (bug 48664)
+!! options
+thumbsize=220
+!! wikitext
+[[File:Foobar.jpg|thumb|left|right|center|caption]]
+
+[[File:Foobar.jpg|middle|text-top|caption]]
+!! html/php
+<div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" style="vertical-align: middle" /></a>
+</p>
+!! html/parsoid
+<figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
+<p><span class="mw-default-size mw-valign-middle" typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
+!! end
+
+!! test
+Image with width attribute at different positions
+!! wikitext
+[[File:Foobar.jpg|200px|right|Caption]]
+[[File:Foobar.jpg|right|200px|Caption]]
+[[File:Foobar.jpg|right|Caption|200px]]
+!! html/php
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div>
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div>
+<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div>
+
+!! html/parsoid
+<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/200px-Foobar.jpg" height="23" width="200"></a><figcaption>Caption</figcaption></figure>
+<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/200px-Foobar.jpg" height="23" width="200"></a><figcaption>Caption</figcaption></figure>
+<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/200px-Foobar.jpg" height="23" width="200"></a><figcaption>Caption</figcaption></figure>
+!! end
+
+# a sad bit of backward-compatibility
+!! test
+Image with size specified with pxpx (bug 13500, 51628)
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|20pxpx]]
+[[File:Foobar.jpg|200x20pxpx]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" width="20" height="2" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg 2x" /></a>
+<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/177px-Foobar.jpg" width="177" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/265px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/353px-Foobar.jpg 2x" /></a>
+</p>
+!! html/parsoid
+<p><span typeof="mw:Image"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="2" width="20"/></a></span><span typeof="mw:Image"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="20" width="177"/></a></span></p>
+!! end
+
+!! test
+Image with link parameter, wiki target
+!! wikitext
+[[File:Foobar.jpg|link=Main Page]]
+!! html/php
+<p><a href="/wiki/Main_Page" title="Main Page"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image"><a href="Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"></a></span></p>
+!! end
+
+# parsoid bug 49293 (part 1)
+!! test
+Image with link parameter, URL target
+!! wikitext
+[[File:Foobar.jpg|link=http://example.com/]]
+!! html/php
+<p><a href="http://example.com/" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image"><a href="http://example.com/"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"></a></span></p>
+!! end
+
+# parsoid bug 49293 (part 2)
+!! test
+Image with link parameter, protocol-less URL target
+!! wikitext
+[[File:Foobar.jpg|link=//example.com/]]
+!! html/php
+<p><a href="//example.com/" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image"><a href="//example.com/"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"></a></span></p>
+!! end
+
+!! test
+Image with link parameter, wgExternalLinkTarget
+!! wikitext
+[[Image:foobar.jpg|link=http://example.com/]]
+!! config
+wgExternalLinkTarget='foobar'
+!! html
+<p><a href="http://example.com/" target="foobar" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! end
+
+!! test
+Image with link parameter, wgNoFollowLinks set to false
+!! wikitext
+[[Image:foobar.jpg|link=http://example.com/]]
+!! config
+wgNoFollowLinks=false
+!! html
+<p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! end
+
+!! test
+Image with link parameter, wgNoFollowDomainExceptions
+!! wikitext
+[[Image:foobar.jpg|link=http://example.com/]]
+!! config
+wgNoFollowDomainExceptions='example.com'
+!! html
+<p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! end
+
+!! test
+Image with link parameter, wgExternalLinkTarget, unnamed parameter
+!! wikitext
+[[Image:foobar.jpg|link=http://example.com/|Title]]
+!! config
+wgExternalLinkTarget='foobar'
+!! html
+<p><a href="http://example.com/" title="Title" target="foobar" rel="nofollow"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! end
+
+!! test
+Image with empty link parameter
+!! wikitext
+[[File:Foobar.jpg|link=]]
+!! html/php
+<p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image"><span><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"></span></span></p>
+!! end
+
+!! test
+Image with link parameter (wiki target) and unnamed parameter
+!! wikitext
+[[File:Foobar.jpg|link=Main_Page|Title]]
+!! html/php
+<p><a href="/wiki/Main_Page" title="Title"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"Title"}'><a href="Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"></a></span></p>
+!! end
+
+!! test
+Image with link parameter (URL target) and unnamed parameter
+!! wikitext
+[[File:Foobar.jpg|link=http://example.com/|Title]]
+!! html/php
+<p><a href="http://example.com/" title="Title" rel="nofollow"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"Title"}'><a href="http://example.com/"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"></a></span></p>
+!! end
+
+!! test
+Thumbnail image with link parameter
+!! options
+thumbsize=220
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="http://example.com/"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="http://example.com/"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>Title</figcaption></figure>
+!! end
+
+!! test
+Manually-specified thumbnail image
+!! options
+thumbsize=220
+!! wikitext
+[[File:Foobar.jpg|thumb=Thumb.png|Title]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/File:Foobar.jpg"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" height="135" width="135"/></a><figcaption>Title</figcaption></figure>
+!! end
+
+!! test
+Manually-specified thumbnail image with explicit link to wiki page
+!! options
+thumbsize=220
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/Main_Page" title="Main Page"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" height="135" width="135"/></a><figcaption>Title</figcaption></figure>
+!! end
+
+!! test
+Manually-specified thumbnail image with explicit link to url
+!! options
+thumbsize=220
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="http://example.com"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="http://example.com"><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" height="135" width="135"/></a><figcaption>Title</figcaption></figure>
+!! end
+
+!! test
+Manually-specified thumbnail image with explicit no link
+!! options
+thumbsize=220
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:137px;"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><span><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" height="135" width="135"/></span><figcaption>Title</figcaption></figure>
+!! end
+
+!! test
+Manually-specified thumbnail image with explicit link and alt text
+!! options
+thumbsize=220
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/Main_Page" title="Main Page"><img alt="alttext" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="Main_Page"><img alt="alttext" resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" height="135" width="135"/></a><figcaption>Title</figcaption></figure>
+!! end
+
+!! test
+Image with frame and link
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
+!! html/php
+<div class="thumb tleft"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size mw-halign-left" typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a><figcaption>This is a test image <a rel="mw:WikiLink" href="Main_Page" title="Main Page">Main Page</a></figcaption></figure>
+!! end
+
+!! test
+Image with frame and link and explicit alt
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
+!! html/php
+<div class="thumb tleft"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Altitude" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size mw-halign-left" typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img alt="Altitude" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a><figcaption>This is a test image <a rel="mw:WikiLink" href="Main_Page" title="Main Page">Main Page</a></figcaption></figure>
+!! end
+
+!! test
+Image with wiki markup in implicit alt
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[Image:Foobar.jpg|testing '''bold''' in alt]]
+
+[[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="testing bold in alt"><img alt="testing bold in alt" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p><p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="testing bold in alt" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image" data-mw="{&quot;caption&quot;:&quot;testing '''bold''' in alt&quot;}"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
+<p><span class="mw-default-size" typeof="mw:Image"><a href="File:Foobar.jpg"><img alt="testing bold in alt" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
+!! end
+
+###################
+# Conflicting image format options.
+# First option specified should 'win'.
+# All three cases in each test should be identical.
+
+!! test
+Image with 'frameless' first.
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|frameless|caption]]
+
+[[File:Foobar.jpg|frameless|frame|caption]]
+
+[[File:Foobar.jpg|frameless|thumb|caption]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
+</p><p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
+</p><p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image/Frameless" data-mw='{"caption":"caption"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a></span></p>
+<p><span class="mw-default-size" typeof="mw:Image/Frameless" data-mw='{"caption":"caption"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a></span></p>
+<p><span class="mw-default-size" typeof="mw:Image/Frameless" data-mw='{"caption":"caption"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a></span></p>
+!! end
+
+!! test
+Image with 'frame' first.
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|frame|caption]]
+[[File:Foobar.jpg|frame|frameless|caption]]
+[[File:Foobar.jpg|frame|thumb|caption]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a><figcaption>caption</figcaption></figure><figure class="mw-default-size" typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a><figcaption>caption</figcaption></figure><figure class="mw-default-size" typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a><figcaption>caption</figcaption></figure>
+!! end
+
+!! test
+Image with 'thumb' first.
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|thumb|caption]]
+[[File:Foobar.jpg|thumb|frameless|caption]]
+[[File:Foobar.jpg|thumb|frame|caption]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>caption</figcaption></figure><figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>caption</figcaption></figure><figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
+!! end
+
+###################
+# Image sizing.
+# See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
+# and https://bugzilla.wikimedia.org/show_bug.cgi?id=62258
+# Foobar has actual size of 1941x220
+# 1. Thumbs & frameless always reduce, can't be enlarged unless it's
+# a scalable format.
+# 2. Framed images always ignore size options; always render at default size.
+# 3. "Unspecified format" and border are the only types which can be
+# enlarged.
+
+!! test
+Image: "unspecified format" and border enlarge
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|2000px]]
+
+[[File:Foobar.jpg|border|2000px]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="2000" height="227" /></a>
+</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/3/3a/Foobar.jpg" 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" height="227" width="2000"/></a></span></p>
+!! end
+
+!! test
+Image: "unspecified format" and border reduce
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|1000px]]
+
+[[File:Foobar.jpg|border|1000px]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/1000px-Foobar.jpg" width="1000" height="113" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/1500px-Foobar.jpg 1.5x, http://example.com/images/3/3a/Foobar.jpg 2x" /></a>
+</p><p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/1000px-Foobar.jpg" width="1000" height="113" class="thumbborder" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/1500px-Foobar.jpg 1.5x, http://example.com/images/3/3a/Foobar.jpg 2x" /></a>
+</p>
+!! html/parsoid
+<p><span typeof="mw:Image"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="113" width="1000"/></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" height="113" width="1000"/></a></span></p>
+!! end
+
+!! test
+Image: thumbs reduce
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|thumb|50px]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:52px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" width="50" height="6" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" 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/3/3a/Foobar.jpg" height="6" width="50"/></a></figure>
+!! end
+
+!! test
+Image: bitmap thumbs can't be enlarged past original size, but vector can.
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|thumb|2000px]]
+
+[[File:Foobar.svg|thumb|2000px]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div></div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:2002px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" width="2000" height="1500" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/3000px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/4000px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div></div></div></div>
+
+!! html/parsoid
+<figure typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></figure>
+<figure typeof="mw:Image/Thumb"><a href="File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" height="1500" width="2000"/></a></figure>
+!! end
+
+!! test
+Image: frameless can reduce in size
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|frameless|50px]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" width="50" height="6" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" /></a>
+</p>
+!! html/parsoid
+<p><span typeof="mw:Image/Frameless"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="6" width="50"/></a></span></p>
+!! end
+
+!! test
+Image: bitmap frameless can't be enlarged past original size, but vector can
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|frameless|2000px]]
+
+[[File:Foobar.svg|frameless|2000px]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p><p><a href="/wiki/File:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" width="2000" height="1500" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/3000px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/4000px-Foobar.svg.png 2x" /></a>
+</p>
+!! html/parsoid
+<p><span typeof="mw:Image/Frameless"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
+<p><span typeof="mw:Image/Frameless"><a href="File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" height="1500" width="2000"/></a></span></p>
+!! end
+
+!! test
+Image: framed images are always unscaled.
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|frame]]
+
+[[File:Foobar.jpg|frame|50px]]
+
+[[File:Foobar.jpg|frame|50x50px]]
+
+[[File:Foobar.jpg|frame|2000px]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></figure><figure typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></figure><figure typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></figure><figure typeof="mw:Image/Frame"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></figure>
+!! end
+
+###################
+
+!! test
+Link to image page- image page normally doesn't exists, hence edit link
+Add test with existing image page
+#<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
+!! wikitext
+[[:Image:test]]
+!! html
+<p><a href="/index.php?title=File:Test&amp;action=edit&amp;redlink=1" class="new" title="File:Test (page does not exist)">Image:test</a>
+</p>
+!! end
+
+!! test
+bug 18784 Link to non-existent image page with caption should use caption as link text
+!! wikitext
+[[:Image:test|caption]]
+!! html
+<p><a href="/index.php?title=File:Test&amp;action=edit&amp;redlink=1" class="new" title="File:Test (page does not exist)">caption</a>
+</p>
+!! end
+
+!! test
+Frameless image caption with a free URL
+!! wikitext
+[[File:Foobar.jpg|http://example.com]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="http://example.com"><img alt="http://example.com" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"http://example.com"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
+!! end
+
+!! test
+Thumbnail image caption with a free URL
+!! options
+thumbsize=220
+!! wikitext
+[[File:Foobar.jpg|thumb|http://example.com]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></figcaption></figure>
+!! end
+
+!! test
+Thumbnail image caption with a free URL and explicit alt
+!! options
+thumbsize=220
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Alteration" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img alt="Alteration" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></figcaption></figure>
+!! end
+
+!! test
+SVG thumbnails with no language set
+!! options
+!! wikitext
+[[File:Foobar.svg|thumb|caption]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" height="165" width="220"/></a><figcaption>caption</figcaption></figure>
+!! end
+
+!! test
+SVG thumbnails with language de
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.svg|thumb|caption|lang=de]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=File:Foobar.svg&amp;lang=de" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/langde-180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/langde-270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/langde-360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" lang="de" height="165" width="220"/></a><figcaption>caption</figcaption></figure>
+!! end
+
+!! test
+SVG thumbnails with invalid language code
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[File:Foobar.svg|thumb|caption|lang=invalid.language.code]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div>lang=invalid.language.code</div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" height="165" width="220"/></a><figcaption>lang=invalid.language.code</figcaption></figure>
+!! end
+
+!! test
+BUG 1887: A ISBN with a thumbnail
+!! wikitext
+[[File:Foobar.jpg|thumb|ISBN 1235467890]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a href="/wiki/Special:BookSources/1235467890" class="internal mw-magiclink-isbn">ISBN 1235467890</a></div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption><a href="Special:BookSources/1235467890" rel="mw:ExtLink">ISBN 1235467890</a></figcaption></figure>
+!! end
+
+!! test
+BUG 1887: A RFC with a thumbnail
+!! wikitext
+[[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>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>This is <a href="//tools.ietf.org/html/rfc12354" rel="mw:ExtLink">RFC 12354</a></figcaption></figure>
+!! end
+
+!! test
+BUG 1887: A mailto link with a thumbnail
+!! wikitext
+[[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Please <a rel="nofollow" class="external free" href="mailto:nobody@example.com">mailto:nobody@example.com</a></div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>Please <a rel="mw:ExtLink" href="mailto:nobody@example.com">mailto:nobody@example.com</a></figcaption></figure>
+!! end
+
+# Pending resolution to bug 368
+!! test
+BUG 648: Frameless image caption with a link
+!! wikitext
+[[File:Foobar.jpg|text with a [[link]] in it]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"text with a [[link]] in it"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
+!! end
+
+!! test
+BUG 648: Frameless image caption with a link (suffix)
+!! wikitext
+[[File:Foobar.jpg|text with a [[link]]foo in it]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a linkfoo in it"><img alt="text with a linkfoo in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"text with a [[link]]foo in it"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
+!! end
+
+!! test
+BUG 648: Frameless image caption with an interwiki link
+!! wikitext
+[[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a MeatBall:Link in it"><img alt="text with a MeatBall:Link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"text with a [[MeatBall:Link]] in it"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
+!! end
+
+!! test
+BUG 648: Frameless image caption with a piped interwiki link
+!! wikitext
+[[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"text with a [[MeatBall:Link|link]] in it"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
+!! end
+
+!! test
+Escape HTML special chars in image alt text
+!! wikitext
+[[File:Foobar.jpg|& < > "]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img alt="&amp; &lt; &gt; &quot;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"&amp; &lt; > \""}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
+!! end
+
+!! test
+BUG 499: Alt text should have &#1234;, not &amp;1234;
+!! wikitext
+[[File:Foobar.jpg|&#9792;]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="♀"><img alt="♀" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"&amp;#9792;"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
+!! end
+
+!! test
+Broken image caption with link
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
+!! html/php
+<p>[[Image:Foobar.jpg|thumb|This is a broken caption. But <a href="/wiki/Main_Page" title="Main Page">this</a> is just an ordinary link.
+</p>
+!! html/parsoid
+<p>[[Image:Foobar.jpg|thumb|This is a broken caption. But <a rel="mw:WikiLink" href="Main_Page" title="Main Page">this</a> is just an ordinary link.</p>
+!! end
+
+!! test
+Image caption containing another image
+!! wikitext
+[[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is a caption with another <a href="/wiki/File:Thumb.png" class="image" title="image"><img alt="image" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" /></a> inside it!</div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption>This is a caption with another <span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"image"}'><a href="File:Thumb.png"><img resource="./File:Thumb.png" src="//example.com/images/e/ea/Thumb.png" height="135" width="135"/></a></span> inside it!</figcaption></figure>
+!! end
+
+!! test
+Image: caption containing a newline
+!! wikitext
+[[File:Foobar.jpg|This
+*is some text]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="This *is some text"><img alt="This *is some text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"This\n*is some text"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="220" width="1941"/></a></span></p>
+!!end
+
+!!test
+Image: caption containing leading space
+(The leading space should not trigger nowiki escaping in wt2wt mode)
+!! wikitext
+[[File:Foobar.jpg|thumb| bar]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>bar</div></div></div>
+
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="25" width="220"/></a><figcaption> bar</figcaption></figure>
+!!end
+
+!! test
+Image: caption containing a table
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
+{|
+! Foo !! Bar
+|-
+| Foo1 || Bar1
+|}
+and some more text.]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is an example image thumbnail caption with a table <table> <tr> <th> Foo </th> <th> Bar </th></tr> <tr> <td> Foo1 </td> <td> Bar1 </td></tr></table> and some more text.</div></div></div>
+
+!! html/parsoid
+<figure typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="23" width="200"/></a><figcaption>This is an example image thumbnail caption with a table
+<table>
+<tbody>
+<tr><th>Foo </th><th>Bar</th></tr>
+<tr>
+<td>Foo1 </td>
+<td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
+!! end
+
+!! test
+Bug 3090: External links other than http: in image captions
+!! wikitext
+[[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
+!! html/php
+<div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This caption has <a rel="nofollow" class="external text" href="irc://example.net">irc</a> and <a rel="nofollow" class="external text" href="https://example.com">Secure</a> ext links in it.</div></div></div>
+
+!! html/parsoid
+<figure typeof="mw:Image/Thumb"><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" height="23" width="200"/></a><figcaption>This caption has <a rel="mw:ExtLink" href="irc://example.net">irc</a> and <a rel="mw:ExtLink" href="https://example.com">Secure</a> ext links in it.</figcaption></figure>
+!! end
+
+!! test
+Custom class
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+[[Image:foobar.jpg|a|class=b]]
+!! html/php
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="a"><img alt="a" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="b" /></a>
+</p>
+!! html/parsoid
+<p><span class="mw-default-size b" typeof="mw:Image" data-mw='{"caption":"a"}'><a href="File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//ex