diff options
Diffstat (limited to 'tests/parser')
-rw-r--r-- | tests/parser/ParserTestResult.php | 42 | ||||
-rw-r--r-- | tests/parser/parserTest.inc | 274 | ||||
-rw-r--r-- | tests/parser/parserTests.txt | 6469 | ||||
-rw-r--r-- | tests/parser/preprocess/All_system_messages.expected | 21 | ||||
-rw-r--r-- | tests/parser/preprocess/All_system_messages.txt | 21 |
5 files changed, 5768 insertions, 1059 deletions
diff --git a/tests/parser/ParserTestResult.php b/tests/parser/ParserTestResult.php new file mode 100644 index 00000000..d9ad773d --- /dev/null +++ b/tests/parser/ParserTestResult.php @@ -0,0 +1,42 @@ +<?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 $description string 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 */ + public function isSuccess() { + return $this->expected === $this->actual; + } +} diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index ce621f4e..58ea1ed0 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -1,6 +1,8 @@ <?php /** - * Helper code for the MediaWiki parser test suite. + * 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> * http://www.mediawiki.org/ @@ -31,22 +33,22 @@ */ class ParserTest { /** - * boolean $color whereas output should be colorized + * @var bool $color whereas output should be colorized */ private $color; /** - * boolean $showOutput Show test output + * @var bool $showOutput Show test output */ private $showOutput; /** - * boolean $useTemporaryTables Use temporary tables for the temporary database + * @var bool $useTemporaryTables Use temporary tables for the temporary database */ private $useTemporaryTables = true; /** - * boolean $databaseSetupDone True if the database has been set up + * @var bool $databaseSetupDone True if the database has been set up */ private $databaseSetupDone = false; @@ -63,7 +65,7 @@ class ParserTest { private $dbClone; /** - * string $oldTablePrefix Original table prefix + * @var string $oldTablePrefix Original table prefix */ private $oldTablePrefix; @@ -141,15 +143,14 @@ class ParserTest { static function setUp() { global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache, - $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo, + $wgExtraNamespaces, $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo, $parserMemc, $wgThumbnailScriptPath, $wgScriptPath, - $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath, $wgExtensionAssetsPath, + $wgArticlePath, $wgScript, $wgStylePath, $wgExtensionAssetsPath, $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgLockManagers; $wgScript = '/index.php'; $wgScriptPath = '/'; $wgArticlePath = '/wiki/$1'; - $wgStyleSheetPath = '/skins'; $wgStylePath = '/skins'; $wgExtensionAssetsPath = '/extensions'; $wgThumbnailScriptPath = false; @@ -181,6 +182,9 @@ class ParserTest { $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 ) { @@ -211,6 +215,73 @@ class ParserTest { $wgStyleDirectory = "$IP/skins"; } + self::setupInterwikis(); + } + + /** + * 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( + '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 ), + ); + 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 ) { @@ -378,7 +449,12 @@ class ParserTest { */ 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(); @@ -418,6 +494,9 @@ class ParserTest { /** * Get a Parser object + * + * @param string $preprocessor + * @return Parser */ function getParser( $preprocessor = null ) { global $wgParserConf; @@ -487,9 +566,10 @@ class ParserTest { } elseif ( isset( $opts['comment'] ) ) { $out = Linker::formatComment( $input, $title, $local ); } elseif ( isset( $opts['preload'] ) ) { - $out = $parser->getpreloadText( $input, $title, $options ); + $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['showtitle'] ) ) { @@ -518,18 +598,23 @@ class ParserTest { } $this->teardownGlobals(); - return $this->showTestResult( $desc, $result, $out ); + + $testResult = new ParserTestResult( $desc ); + $testResult->expected = $result; + $testResult->actual = $out; + + return $this->showTestResult( $testResult ); } /** - * + * Refactored in 1.22 to use ParserTestResult */ - function showTestResult( $desc, $result, $out ) { - if ( $result === $out ) { - $this->showSuccess( $desc ); + function showTestResult( ParserTestResult $testResult ) { + if ( $testResult->isSuccess() ) { + $this->showSuccess( $testResult ); return true; } else { - $this->showFailure( $desc, $result, $out ); + $this->showFailure( $testResult ); return false; } } @@ -537,7 +622,7 @@ class ParserTest { /** * Use a regex to find out the value of an option * @param $key String: name of option val to retrieve - * @param $opts Options array to look in + * @param $opts array: Options array to look in * @param $default Mixed: default value returned if not found */ private static function getOptionValue( $key, $opts, $default ) { @@ -664,11 +749,10 @@ class ParserTest { ), 'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ), 'wgStylePath' => '/skins', - 'wgStyleSheetPath' => '/skins', 'wgSitename' => 'MediaWiki', 'wgLanguageCode' => $lang, 'wgDBprefix' => $this->db->getType() != 'oracle' ? 'parsertest_' : 'pt_', - 'wgRawHtml' => isset( $opts['rawhtml'] ), + 'wgRawHtml' => self::getOptionValue( 'wgRawHtml', $opts, false ), 'wgLang' => null, 'wgContLang' => null, 'wgNamespacesWithSubpages' => array( 0 => isset( $opts['subpage'] ) ), @@ -678,8 +762,10 @@ class ParserTest { 'wgNoFollowDomainExceptions' => array(), 'wgThumbnailScriptPath' => false, 'wgUseImageResize' => true, + 'wgSVGConverter' => 'null', + 'wgSVGConverters' => array( 'null' => 'echo "1">$output' ), 'wgLocaltimezone' => 'UTC', - 'wgAllowExternalImages' => true, + 'wgAllowExternalImages' => self::getOptionValue( 'wgAllowExternalImages', $opts, true ), 'wgUseTidy' => false, 'wgDefaultLanguageVariant' => $variant, 'wgVariantArticlePath' => false, @@ -822,43 +908,9 @@ class ParserTest { 'user_name' => 'Anonymous' ) ); } - # Hack: insert a few Wikipedia in-project interwiki prefixes, - # for testing inter-language links - $this->db->insert( 'interwiki', array( - array( 'iw_prefix' => 'wikipedia', - 'iw_url' => 'http://en.wikipedia.org/wiki/$1', - 'iw_api' => '', - 'iw_wikiid' => '', - 'iw_local' => 0 ), - array( 'iw_prefix' => 'meatball', - 'iw_url' => 'http://www.usemod.com/cgi-bin/mb.pl?$1', - 'iw_api' => '', - 'iw_wikiid' => '', - 'iw_local' => 0 ), - array( 'iw_prefix' => 'zh', - 'iw_url' => 'http://zh.wikipedia.org/wiki/$1', - 'iw_api' => '', - 'iw_wikiid' => '', - 'iw_local' => 1 ), - array( 'iw_prefix' => 'es', - 'iw_url' => 'http://es.wikipedia.org/wiki/$1', - 'iw_api' => '', - 'iw_wikiid' => '', - 'iw_local' => 1 ), - array( 'iw_prefix' => 'fr', - 'iw_url' => 'http://fr.wikipedia.org/wiki/$1', - 'iw_api' => '', - 'iw_wikiid' => '', - 'iw_local' => 1 ), - array( 'iw_prefix' => 'ru', - 'iw_url' => 'http://ru.wikipedia.org/wiki/$1', - 'iw_api' => '', - 'iw_wikiid' => '', - 'iw_local' => 1 ), - ) ); - # Update certain things in site_stats - $this->db->insert( 'site_stats', array( 'ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1 ) ); + $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(); @@ -866,19 +918,52 @@ class ParserTest { # 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' => 12345, + 'size' => 7881, 'width' => 1941, 'height' => 220, - 'bits' => 24, + 'bits' => 8, 'media_type' => MEDIATYPE_BITMAP, 'mime' => 'image/jpeg', 'metadata' => serialize( array() ), - 'sha1' => wfBaseConvert( '', 16, 36, 31 ), + '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' => 24, + '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]] @@ -891,7 +976,7 @@ class ParserTest { 'media_type' => MEDIATYPE_BITMAP, 'mime' => 'image/jpeg', 'metadata' => serialize( array() ), - 'sha1' => wfBaseConvert( '', 16, 36, 31 ), + 'sha1' => wfBaseConvert( '3', 16, 36, 31 ), 'fileExists' => true ), $this->db->timestamp( '20010115123500' ), $user ); } @@ -922,8 +1007,11 @@ class ParserTest { $tables = $this->listTables(); foreach ( $tables as $table ) { - $sql = $this->db->getType() == 'oracle' ? "DROP TABLE pt_$table DROP CONSTRAINTS" : "DROP TABLE `parsertest_$table`"; - $this->db->query( $sql ); + 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' ) { @@ -960,9 +1048,15 @@ class ParserTest { wfMkdirParents( $dir . '/3/3a', null, __METHOD__ ); copy( "$IP/skins/monobook/headbg.jpg", "$dir/3/3a/Foobar.jpg" ); + wfMkdirParents( $dir . '/e/ea', null, __METHOD__ ); + copy( "$IP/skins/monobook/wiki.png", "$dir/e/ea/Thumb.png" ); wfMkdirParents( $dir . '/0/09', null, __METHOD__ ); copy( "$IP/skins/monobook/headbg.jpg", "$dir/0/09/Bad.jpg" ); - + wfMkdirParents( $dir . '/f/ff', null, __METHOD__ ); + copy( "$IP/skins/monobook/headbg.jpg", "$dir/f/ff/Foobar.svg" ); + file_put_contents( "$dir/f/ff/Foobar.svg", + '<?xml version="1.0" encoding="utf-8"?>' . + '<svg xmlns="http://www.w3.org/2000/svg" />' ); return $dir; } @@ -1008,8 +1102,18 @@ class ParserTest { "$dir/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg", "$dir/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg", + "$dir/e/ea/Thumb.png", + "$dir/0/09/Bad.jpg", + "$dir/f/ff/Foobar.svg", + "$dir/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png", + "$dir/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png", + "$dir/thumb/f/ff/Foobar.svg/langde-270px-Foobar.svg.png", + "$dir/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png", + "$dir/thumb/f/ff/Foobar.svg/langde-180px-Foobar.svg.png", + "$dir/thumb/f/ff/Foobar.svg/langde-360px-Foobar.svg.png", + "$dir/math/f/a/5/fa50b8b616463173474302ca3e63586b.png", ) ); @@ -1023,7 +1127,13 @@ class ParserTest { "$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/thumb", @@ -1070,10 +1180,12 @@ class ParserTest { /** * Print a happy success message. * - * @param $desc String: the test name + * Refactored in 1.22 to use ParserTestResult + * + * @param $testResult ParserTestResult * @return Boolean */ - protected function showSuccess( $desc ) { + protected function showSuccess( ParserTestResult $testResult ) { if ( $this->showProgress ) { print $this->term->color( '1;32' ) . 'PASSED' . $this->term->reset() . "\n"; } @@ -1085,28 +1197,29 @@ class ParserTest { * Print a failure message and provide some explanatory output * about what went wrong if so configured. * - * @param $desc String: the test name - * @param $result String: expected HTML output - * @param $html String: actual HTML output + * Refactored in 1.22 to use ParserTestResult + * + * @param $testResult ParserTestResult * @return Boolean */ - protected function showFailure( $desc, $result, $html ) { + 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( $desc ); + $this->showTesting( $testResult->description ); } print $this->term->color( '31' ) . 'FAILED!' . $this->term->reset() . "\n"; if ( $this->showOutput ) { - print "--- Expected ---\n$result\n--- Actual ---\n$html\n"; + print "--- Expected ---\n{$testResult->expected}\n"; + print "--- Actual ---\n{$testResult->actual}\n"; } if ( $this->showDiffs ) { - print $this->quickDiff( $result, $html ); - if ( !$this->wellFormed( $html ) ) { + print $this->quickDiff( $testResult->expected, $testResult->actual ); + if ( !$this->wellFormed( $testResult->actual ) ) { print "XML error: $this->mXmlError\n"; } } @@ -1125,7 +1238,9 @@ class ParserTest { * @param $outFileTail String: tailing for the output file name * @return String */ - protected function quickDiff( $input, $output, $inFileTail = 'expected', $outFileTail = 'actual' ) { + 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(); @@ -1141,9 +1256,10 @@ class ParserTest { global $wgDiff3; // we assume that people with diff3 also have usual diff - $diff = ( wfIsWindows() && !$wgDiff3 ) - ? `fc $shellInfile $shellOutfile` - : `diff -au $shellInfile $shellOutfile`; + $shellCommand = ( wfIsWindows() && !$wgDiff3 ) ? 'fc' : 'diff -au'; + + $diff = wfShellExec( "$shellCommand $shellInfile $shellOutfile" ); + unlink( $infile ); unlink( $outfile ); @@ -1343,7 +1459,7 @@ class ParserTest { } static function getFakeTimestamp( &$parser, &$ts ) { - $ts = 123; + $ts = 123; //parsed as '1970-01-01T00:02:03Z' return true; } } diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index f0603e75..02a66b51 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -26,6 +26,11 @@ # 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 +# +# 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 @@ -117,11 +122,30 @@ Template:table_attribs !! 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 + ### ### Basic tests ### @@ -165,6 +189,206 @@ baz !! end !! test +Paragraphs with newline spacing with comment lines in between +!! input +---- +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 +---- +!! result +<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 +!! input +---- +a + +b +---- +a + + +b +---- +!! result +<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 +!! input +---- +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 +---- +!! result +<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 +!! input +a + + <!--boo--> + +b +!!result +<p>a +</p><p><br /> +b +</p> +!!end + +!! test +Extra newlines followed by heading +!! input +a + + + +=b= +[[a]] + + +=b= +!! result +<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&action=edit&section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<p><a href="/index.php?title=A&action=edit&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&action=edit&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 +!! input +=b= + + + +[[a]] +!! result +<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&action=edit&section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<p><a href="/index.php?title=A&action=edit&redlink=1" class="new" title="A (page does not exist)">a</a> +</p> +!! end + +!! test Parsing an URL !! input http://fr.wikipedia.org/wiki/🍺 @@ -180,9 +404,12 @@ Simple list * Item 1 * Item 2 !! result -<ul><li> Item 1 -</li><li> Item 2 -</li></ul> +<ul> +<li> Item 1 +</li> +<li> Item 2 +</li> +</ul> !! end @@ -205,25 +432,72 @@ Italics and bold * plain l'''italic''plain * plain l''''bold''' plain !! result -<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> +<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) +!! input +obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer +!! result +<p>obtained by <i><a href="/index.php?title=Lunar_Prospector&action=edit&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) +!! input +'''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes +!! result +<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) +!! input +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''. +!! result +<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&action=edit&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 ### @@ -258,13 +532,26 @@ Italics and bold: 2-quote opening sequence: (2,4) !! test -Italics and bold: 2-quote opening sequence: (2,5) +Italics and bold: 2-quote opening sequence: (2,5) (php) +!! options +php !! input ''foo''''' !! result <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) (parsoid) +!! options +parsoid +!! input +''foo''''' +!! result +<p><i>foo</i><b></b> +</p> +!!end ### @@ -302,13 +589,26 @@ Italics and bold: 3-quote opening sequence: (3,4) !! test -Italics and bold: 3-quote opening sequence: (3,5) +Italics and bold: 3-quote opening sequence: (3,5) (php) +!! options +php !! input '''foo''''' !! result <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) (parsoid) +!! options +parsoid +!! input +'''foo''''' +!! result +<p><b>foo</b><i></i> +</p> +!!end ### @@ -346,13 +646,26 @@ Italics and bold: 4-quote opening sequence: (4,4) !! test -Italics and bold: 4-quote opening sequence: (4,5) +Italics and bold: 4-quote opening sequence: (4,5) (php) +!! options +php !! input ''''foo''''' !! result <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) (parsoid) +!! options +parsoid +!! input +''''foo''''' +!! result +<p>'<b>foo</b><i></i> +</p> +!!end ### @@ -361,6 +674,7 @@ Italics and bold: 4-quote opening sequence: (4,5) !! test Italics and bold: 5-quote opening sequence: (5,2) +!! options !! input '''''foo'' !! result @@ -432,23 +746,49 @@ Italics and bold: multiple quote sequences: (2,4,4) !! test -Italics and bold: multiple quote sequences: (3,4,2) +Italics and bold: multiple quote sequences: (3,4,2) (php) +!! options +php !! input '''foo''''bar'' !! result <p><b>foo'</b>bar </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) (parsoid) +!! options +parsoid +!! input +'''foo''''bar'' +!! result +<p><b>foo'</b>bar<i></i> +</p> +!!end !! test -Italics and bold: multiple quote sequences: (3,4,3) +Italics and bold: multiple quote sequences: (3,4,3) (php) +!! options +php !! input '''foo''''bar''' !! result <p><b>foo'</b>bar </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) (parsoid) +!! options +parsoid +!! input +'''foo''''bar''' +!! result +<p><b>foo'</b>bar<b></b> +</p> +!!end ### ### other quote tests @@ -485,6 +825,7 @@ Italics and bold: other quote tests: (3,2,3,2) !! test Italics and bold: other quote tests: (3,2,3,3) +!! options !! input '''this is about ''foo'''s family''' !! result @@ -512,6 +853,23 @@ The ''[[Main Page]]'''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 +!! input +{| +!''a!!''b +|''a||''b +|} +!! result +<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 ### @@ -533,6 +891,74 @@ Non-html5 tags should be accepted </p> !! end +!! test +<wbr> is valid wikitext (bug 52468) +!! input +<wbr> +!! result +<p><wbr /> +</p> +!! end + +# <strike> is HTML4, <s> is HTML4/5. +!! test +<s> or <strike> for strikethrough +!! input +<strike>strike</strike> + +<s>s</s> +!! result +<p><strike>strike</strike> +</p><p><s>s</s> +</p> +!! end + +!! test +Non-word characters don't terminate tag names (bug 17663, 40670, 52022) +!! input +<b→> doesn't work! </b> + +<bä> doesn't work! </b> + +<boo> works fine </b> + +<s.foo>foo</s> + +<s.foo>s.foo</s.foo> + +<sub-ID#1> +!! result +<p><b→> doesn't work! </b> +</p><p><bä> doesn't work! </b> +</p><p><boo> works fine </b> +</p><p><s.foo>foo</s> +</p><p><s.foo>s.foo</s.foo> +</p><p><sub-ID#1> +</p> +!! end + +### +### Special characters +### + +!! test +Bare pipe character (bug 52363) +!! input +| +!! result +<p>| +</p> +!! end + +!! test +Bare pipe character from a template (bug 52363) +!! input +{{pipe}} +!! result +<p>| +</p> +!! end + ### ### <nowiki> test cases ### @@ -579,15 +1005,24 @@ nowiki 3 *There is not nowiki. *There is <nowiki>nowiki</nowiki>. !! result -<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> +<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 @@ -600,6 +1035,16 @@ Entities inside <nowiki> </p> !! end +!! test +Entities inside template parameters +!! options +parsoid +!! input +{{echo|–}} +!! result +<p><span typeof="mw:Transclusion mw:Entity" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&ndash;"}},"i":0}}]}'>–</span> +</p> +!! end ### ### Comments @@ -781,7 +1226,7 @@ b !! end ### -### paragraph wraping tests +### paragraph wrapping tests ### !! test No block tags @@ -794,8 +1239,9 @@ b </p><p>b </p> !! end + !! test -Block tag on one line +Block tag on one line (<div>) !! input a <div>foo</div> @@ -807,7 +1253,19 @@ a <div>foo</div> !! end !! test -Block tag on both lines +Block tag on one line (<blockquote>) +!! input +a <blockquote>foo</blockquote> + +b +!! result +a <blockquote>foo</blockquote> +<p>b +</p> +!! end + +!! test +Block tag on both lines (<div>) !! input a <div>foo</div> @@ -819,6 +1277,18 @@ b <div>foo</div> !! end !! test +Block tag on both lines (<blockquote>) +!! input +a <blockquote>foo</blockquote> + +b <blockquote>foo</blockquote> +!! result +a <blockquote>foo</blockquote> +b <blockquote>foo</blockquote> + +!! end + +!! test Multiple lines without block tags !! input <div>foo</div> a @@ -837,7 +1307,7 @@ x <div>foo</div> z !! end !! test -Empty lines between block tags to test open p-tags are closed between the block tags +Empty lines between lines with block tags !! input <div></div> @@ -845,6 +1315,12 @@ Empty lines between block tags to test open p-tags are closed between the block <div></div>a b +<div>a</div>b + +<div>b</div>d + + +<div>e</div> !! result <div></div> <p><br /> @@ -852,6 +1328,12 @@ b <div></div>a <p>b </p> +<div>a</div>b +<div>b</div>d +<p><br /> +</p> +<div>e</div> + !! end ### @@ -875,6 +1357,22 @@ And a <a href="/wiki/Main_Page" title="Main Page">link</a> !! end !! test +Tabs don't trigger preformatted text +!! input + This is not + preformatted text. + This is preformatted text. + So is this. +!! result +<p> This is not + preformatted text. +</p> +<pre>This is preformatted text. + So is this. +</pre> +!! end + +!! test Ident preformatting with inline content !! input a @@ -916,17 +1414,61 @@ Regression with preformatted in <center> !! end -# Expected output in the following test is not really expected (there should be -# <pre> in the output) -- it's only testing for well-formedness. !! test -Bug 6200: Preformatted in <blockquote> +Bug 52763: Preformatted in <blockquote> !! input <blockquote> Blah </blockquote> !! result <blockquote> - Blah +<p> Blah +</p> +</blockquote> + +!! end + +!! test +Bug 51086: Double newlines in blockquotes should be turned into paragraphs +!! input +<blockquote> +Foo + +Bar +</blockquote> +!! result +<blockquote> +<p>Foo +</p><p>Bar +</p> +</blockquote> + +!! end + +!! test +Bug 15491: <ins>/<del> in blockquote +!! input +<blockquote> +Foo <del>bar</del> <ins>baz</ins> quux +</blockquote> +!! result +<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) +!! input +<blockquote>Foo <del>bar</del> <ins>baz</ins> quux +</blockquote> +!! result +<blockquote>Foo <del>bar</del> <ins>baz</ins> quux </blockquote> !! end @@ -1156,53 +1698,224 @@ Templates: Indent-Pre: 1f: Wrapping should be based on expanded content </pre> !!end +# TODO / maybe: fix wt2wt for this !! test -Templates: Single-line variant of parameter whitespace stripping test +Parsoid: Don't paragraph-wrap fosterable content +!! options +parsoid=wt2html !! input -{{echo| a}} +{| +<td></td> +<td></td> -{{echo|1= a}} -{{echo|{{echo| a}}}} -{{echo|1={{echo| a}}}} +|} +!! result +<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 +!! input +{| +<td> +<td> +</td> + + + +|} +!! result +<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 +!! input +{{echo|1= a }} + +{{echo|1= {{echo|b}} }} + +{{echo| 1 = + c }} + +{{echo| 1 = +* d +}} !! result -<pre>a -</pre> -<p>a -</p> -<pre>a -</pre> <p>a +</p><p>b +</p><p>c </p> +<ul> +<li> d +</li> +</ul> + !! end !! test -Templates: Strip whitespace from named parameters, but not positional ones +Templates: Don't strip whitespace from positional-param values !! input -{{echo| - foo}} +{{echo|a }} + +{{echo|{{echo|b}} }} + +{{echo| c +}} + +{{echo| {{echo|d}} +}} {{echo| -* foo}} + e}} -{{echo| 1 = - foo}} +{{echo| +* f}} -{{echo| 1 = -* foo}} +{{echo| + }}g !! result -<pre>foo +<p>a +</p><p>b +</p> +<pre>c </pre> <p><br /> </p> -<ul><li> foo -</li></ul> +<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 +!! input +{{echo|foo +<!--should be ignored--> + <!--should be ignored as well--> +bar}} +!! result <p>foo +bar </p> -<ul><li> foo -</li></ul> +!! end +#-------------------------------------------------------------------- +# Transclusion parameter escaping tests +#-------------------------------------------------------------------- +!! test +Templates: Parsoid parameter escaping test 1 +!! options +parsoid +!! input +{{echo|[foo]|{{echo|[bar]}}}} +!! result +<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 +!! input +{{echo|[{{echo|http://example.com}} link]}} +!! result +<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 +!! input +{{echo|http://foo.com/a|b}} +!! result +<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&#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 +!! input +{{echo|[http://foo.com/a|b a|b]}} +!! result +<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 +Templates: Dont escape already nowiki-escaped text in template parameters +!! options +parsoid=html2wt,wt2wt +!! input +{{echo|foo<nowiki>|</nowiki>bar}} +{{echo|<nowiki><div></nowiki>}} +{{echo|<nowiki></nowiki>}} +!! result +<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>&lt;div&gt;</nowiki>"}},"i":0}}]}'><span typeof="mw:Entity"><</span>div<span typeof="mw:Entity">></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 +!! input +{{echo|{{echo|1=bar}}}} +!! result +<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 ### @@ -1249,6 +1962,20 @@ c !!end !!test +1d. Indent-Pre and Comments +(Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order) +!!input +<!--a--> a + + <!--b-->b +!!result +<pre>a +</pre> +<pre>b +</pre> +!!end + +!!test 2a. Indent-Pre and tables !!input {| @@ -1307,10 +2034,12 @@ c !!input <p> foo </p> <div> foo </div> + <blockquote> foo </blockquote> <span> foo </span> !!result <p> foo </p> <div> foo </div> + <blockquote> foo </blockquote> <pre><span> foo </span> </pre> !!end @@ -1334,6 +2063,12 @@ c foo </blockquote> +<blockquote> +<pre> +foo +</pre> +</blockquote> + <table><tr><td> foo </td></tr></table> @@ -1355,7 +2090,13 @@ c </pre> </center> <blockquote> - foo +<p> foo +</p> +</blockquote> +<blockquote> +<pre> +foo +</pre> </blockquote> <table><tr><td> <pre>foo @@ -1400,6 +2141,56 @@ b </pre> !! end +!! test +6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content +!! input + a + + <!-- continue --> + b + + c + +d +!! result +<pre>a + +b +</pre> +<pre>c + +</pre> +<p>d +</p> +!! end + +!! test +7a. Indent-pre and category links +!! options +parsoid=wt2html,wt2wt +!! input + [[Category:foo]] <!-- No pre-wrapping --> +{{echo| [[Category:foo]]}} <!-- No pre-wrapping --> +!! result + <link rel="mw:WikiLink/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:WikiLink/Category" href="./Category:Foo" about="#mwt1"> <!-- No pre-wrapping --> +!! end + +!! test +7b. Indent-pre and category links +!! options +parsoid=wt2html,wt2wt +!! input + [[Category:foo]] a + [[Category:foo]] {{echo|b}} +!! result +<pre> +<link rel="mw:WikiLink/Category" href="./Category:Foo"> a + +<link rel="mw:WikiLink/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) ### @@ -1482,8 +2273,11 @@ Simple definition !! input ; name : Definition !! result -<dl><dt> name </dt><dd> Definition -</dd></dl> +<dl> +<dt> name </dt> +<dd> Definition +</dd> +</dl> !! end @@ -1492,8 +2286,10 @@ Definition list for indentation only !! input : Indented text !! result -<dl><dd> Indented text -</dd></dl> +<dl> +<dd> Indented text +</dd> +</dl> !! end @@ -1502,8 +2298,11 @@ Definition list with no space !! input ;name:Definition !! result -<dl><dt>name</dt><dd>Definition -</dd></dl> +<dl> +<dt>name</dt> +<dd>Definition +</dd> +</dl> !!end @@ -1512,8 +2311,11 @@ Definition list with URL link !! input ; http://example.com/ : definition !! result -<dl><dt> <a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> </dt><dd> definition -</dd></dl> +<dl> +<dt> <a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> </dt> +<dd> definition +</dd> +</dl> !! end @@ -1522,8 +2324,11 @@ Definition list with bracketed URL link !! input ;[http://www.example.com/ Example]:Something about it !! result -<dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt><dd>Something about it -</dd></dl> +<dl> +<dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt> +<dd>Something about it +</dd> +</dl> !! end @@ -1532,8 +2337,11 @@ Definition list with wikilink containing colon !! input ; [[Help:FAQ]]: The least-read page on Wikipedia !! result -<dl><dt> <a href="/index.php?title=Help:FAQ&action=edit&redlink=1" class="new" title="Help:FAQ (page does not exist)">Help:FAQ</a></dt><dd> The least-read page on Wikipedia -</dd></dl> +<dl> +<dt> <a href="/index.php?title=Help:FAQ&action=edit&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 @@ -1543,8 +2351,11 @@ Definition list with news link containing colon !! input ; news:alt.wikipedia.rox: This isn't even a real newsgroup! !! result -<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> +<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 @@ -1553,8 +2364,10 @@ Malformed definition list with colon !! input ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop !! result -<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> +<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 @@ -1563,8 +2376,11 @@ Definition lists: colon in external link text !! input ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up !! result -<dl><dt> <a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia : The Next Generation</a></dt><dd> OK, I made that up -</dd></dl> +<dl> +<dt> <a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia : The Next Generation</a></dt> +<dd> OK, I made that up +</dd> +</dl> !! end @@ -1573,8 +2389,10 @@ Definition lists: colon in HTML attribute !! input ;<b style="display: inline">bold</b> !! result -<dl><dt><b style="display: inline">bold</b> -</dt></dl> +<dl> +<dt><b style="display: inline">bold</b> +</dt> +</dl> !! end @@ -1583,8 +2401,11 @@ Definition lists: self-closed tag !! input ;one<br/>two : two-line fun !! result -<dl><dt>one<br />two </dt><dd> two-line fun -</dd></dl> +<dl> +<dt>one<br />two </dt> +<dd> two-line fun +</dd> +</dl> !! end @@ -1613,16 +2434,19 @@ Definition and unordered list using wiki syntax nested in unordered list using h <ul><li> ; term : description * unordered -</li> -</ul> +</li></ul> !! result <ul><li> -<dl><dt> term </dt><dd> description -</dd></dl> -<ul><li> unordered -</li></ul> +<dl> +<dt> term </dt> +<dd> description +</dd> +</dl> +<ul> +<li> unordered </li> </ul> +</li></ul> !! end @@ -1633,8 +2457,11 @@ Definition list with empty definition and following paragraph ; term: Paragraph text !! result -<dl><dt> term</dt><dd> -</dd></dl> +<dl> +<dt> term</dt> +<dd> +</dd> +</dl> <p>Paragraph text </p> !! end @@ -1663,10 +2490,14 @@ Definition Lists: No nesting: Multiple dd's :a :b !! result -<dl><dt>x -</dt><dd>a -</dd><dd>b -</dd></dl> +<dl> +<dt>x +</dt> +<dd>a +</dd> +<dd>b +</dd> +</dl> !! end @@ -1677,12 +2508,18 @@ Definition Lists: Indentation: Regular ::i2 :::i3 !! result -<dl><dd>i1 -<dl><dd>i2 -<dl><dd>i3 -</dd></dl> -</dd></dl> -</dd></dl> +<dl> +<dd>i1 +<dl> +<dd>i2 +<dl> +<dd>i3 +</dd> +</dl> +</dd> +</dl> +</dd> +</dl> !! end @@ -1692,11 +2529,17 @@ Definition Lists: Indentation: Missing 1st level ::i2 :::i3 !! result -<dl><dd><dl><dd>i2 -<dl><dd>i3 -</dd></dl> -</dd></dl> -</dd></dl> +<dl> +<dd><dl> +<dd>i2 +<dl> +<dd>i3 +</dd> +</dl> +</dd> +</dl> +</dd> +</dl> !! end @@ -1705,10 +2548,16 @@ Definition Lists: Indentation: Multi-level indent !! input :::i3 !! result -<dl><dd><dl><dd><dl><dd>i3 -</dd></dl> -</dd></dl> -</dd></dl> +<dl> +<dd><dl> +<dd><dl> +<dd>i3 +</dd> +</dl> +</dd> +</dl> +</dd> +</dl> !! end @@ -1732,6 +2581,21 @@ should be left alone should be left alone </p> !! end + +# Bug 52473 +!! test +Definition Lists: Hacky use to indent tables (WS-insensitive) +!! options +parsoid +!! input +: {| +|a +|} +!! result +<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 @@ -1783,13 +2647,17 @@ Table / list interaction: indented table with lists in table contents <tr> <td> a -<ul><li> b -</li></ul> +<ul> +<li> b +</li> +</ul> </td></tr> <tr> <td> c -<ul><li> d -</li></ul> +<ul> +<li> d +</li> +</ul> </td></tr></table></dd></dl> !! end @@ -1812,18 +2680,27 @@ Table / list interaction: lists nested in tables nested in indented lists <dl><dd><table> <tr> <td> -<dl><dd>a -</dd><dd>b -</dd></dl> +<dl> +<dd>a +</dd> +<dd>b +</dd> +</dl> </td> <td> -<ul><li>c -</li><li>d -</li></ul> +<ul> +<li>c +</li> +<li>d +</li> +</ul> </td></tr></table></dd></dl> -<ul><li>e -</li><li>f -</li></ul> +<ul> +<li>e +</li> +<li>f +</li> +</ul> !!end @@ -1911,32 +2788,75 @@ Definition Lists: Nesting: Test 4 ::;t3 :::d3 !! result -<dl><dd><dl><dd><dl><dt>t3 -</dt><dd>d3 -</dd></dl> -</dd></dl> -</dd></dl> +<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>.) !! test -Definition Lists: Mixed Lists: Test 1 +Definition Lists: Mixed Lists: Test 1 (php) +!! options +php !! input :;* foo ::* bar :; baz !! result -<dl><dd><dl><dt><ul><li> foo -</li><li> bar -</li></ul> -</dt></dl> -<dl><dt> baz -</dt></dl> -</dd></dl> +<dl> +<dd><dl> +<dt><ul> +<li> foo +</li> +<li> bar +</li> +</ul> +</dt> +</dl> +<dl> +<dt> baz +</dt> +</dl> +</dd> +</dl> !! end - +!! test +Definition Lists: Mixed Lists: Test 1 (parsoid) +!! options +parsoid +!! input +:;* foo +::* bar +:; baz +!! result +<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 @@ -1944,10 +2864,15 @@ Definition Lists: Mixed Lists: Test 2 *: d1 *: d2 !! result -<ul><li><dl><dd> d1 -</dd><dd> d2 -</dd></dl> -</li></ul> +<ul> +<li><dl> +<dd> d1 +</dd> +<dd> d2 +</dd> +</dl> +</li> +</ul> !! end @@ -1958,12 +2883,21 @@ Definition Lists: Mixed Lists: Test 3 *::: d1 *::: d2 !! result -<ul><li><dl><dd><dl><dd><dl><dd> d1 -</dd><dd> d2 -</dd></dl> -</dd></dl> -</dd></dl> -</li></ul> +<ul> +<li><dl> +<dd><dl> +<dd><dl> +<dd> d1 +</dd> +<dd> d2 +</dd> +</dl> +</dd> +</dl> +</dd> +</dl> +</li> +</ul> !! end @@ -1974,10 +2908,17 @@ Definition Lists: Mixed Lists: Test 4 *;d1 :d2 *;d3 :d4 !! result -<ul><li><dl><dt>d1 </dt><dd>d2 -</dd><dt>d3 </dt><dd>d4 -</dd></dl> -</li></ul> +<ul> +<li><dl> +<dt>d1 </dt> +<dd>d2 +</dd> +<dt>d3 </dt> +<dd>d4 +</dd> +</dl> +</li> +</ul> !! end @@ -1988,11 +2929,17 @@ Definition Lists: Mixed Lists: Test 5 *:d1 *:: d2 !! result -<ul><li><dl><dd>d1 -<dl><dd> d2 -</dd></dl> -</dd></dl> -</li></ul> +<ul> +<li><dl> +<dd>d1 +<dl> +<dd> d2 +</dd> +</dl> +</dd> +</dl> +</li> +</ul> !! end @@ -2003,13 +2950,23 @@ Definition Lists: Mixed Lists: Test 6 #*:d1 #*::: d3 !! result -<ol><li><ul><li><dl><dd>d1 -<dl><dd><dl><dd> d3 -</dd></dl> -</dd></dl> -</dd></dl> -</li></ul> -</li></ol> +<ol> +<li><ul> +<li><dl> +<dd>d1 +<dl> +<dd><dl> +<dd> d3 +</dd> +</dl> +</dd> +</dl> +</dd> +</dl> +</li> +</ul> +</li> +</ol> !! end @@ -2020,10 +2977,15 @@ Definition Lists: Mixed Lists: Test 7 :* d1 :* d2 !! result -<dl><dd><ul><li> d1 -</li><li> d2 -</li></ul> -</dd></dl> +<dl> +<dd><ul> +<li> d1 +</li> +<li> d2 +</li> +</ul> +</dd> +</dl> !! end @@ -2034,12 +2996,20 @@ Definition Lists: Mixed Lists: Test 8 :* d1 ::* d2 !! result -<dl><dd><ul><li> d1 -</li></ul> -<dl><dd><ul><li> d2 -</li></ul> -</dd></dl> -</dd></dl> +<dl> +<dd><ul> +<li> d1 +</li> +</ul> +<dl> +<dd><ul> +<li> d2 +</li> +</ul> +</dd> +</dl> +</dd> +</dl> !! end @@ -2049,9 +3019,14 @@ Definition Lists: Mixed Lists: Test 9 !! input *;foo :bar !! result -<ul><li><dl><dt>foo </dt><dd>bar -</dd></dl> -</li></ul> +<ul> +<li><dl> +<dt>foo </dt> +<dd>bar +</dd> +</dl> +</li> +</ul> !! end @@ -2061,51 +3036,172 @@ Definition Lists: Mixed Lists: Test 10 !! input *#;foo :bar !! result -<ul><li><ol><li><dl><dt>foo </dt><dd>bar -</dd></dl> -</li></ol> -</li></ul> +<ul> +<li><ol> +<li><dl> +<dt>foo </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. !! test -Definition Lists: Mixed Lists: Test 11 +Definition Lists: Mixed Lists: Test 11 (php) +!! options +php !! input *#*#;*;;foo :bar *#*#;boo :baz !! result -<ul><li><ol><li><ul><li><ol><li><dl><dt>foo </dt><dd><ul><li><dl><dt><dl><dt>bar -</dt></dl> -</dd></dl> -</li></ul> -</dd></dl> -<dl><dt>boo </dt><dd>baz -</dd></dl> -</li></ol> -</li></ul> -</li></ol> -</li></ul> +<ul> +<li><ol> +<li><ul> +<li><ol> +<li><dl> +<dt>foo </dt> +<dd><ul> +<li><dl> +<dt><dl> +<dt>bar +</dt> +</dl> +</dd> +</dl> +</li> +</ul> +</dd> +</dl> +<dl> +<dt>boo </dt> +<dd>baz +</dd> +</dl> +</li> +</ol> +</li> +</ul> +</li> +</ol> +</li> +</ul> !! end +!! test +Definition Lists: Mixed Lists: Test 11 (parsoid) +!! options +parsoid +!! input +*#*#;*;;foo :bar +*#*#;boo :baz +!! result +<ul> +<li> +<ol> +<li> +<ul> +<li> +<ol> +<li> +<dl> +<dt> +<ul> +<li> +<dl> +<dt> +<dl> +<dt>foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'> </span></dt> +<dd data-parsoid='{"stx":"row"}'>bar</dd> +</dl></dt> +</dl></li> +</ul></dt> +<dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'> </span></dt> +<dd data-parsoid='{"stx":"row"}'>baz</dd> +</dl></li> +</ol></li> +</ul></li> +</ol></li> +</ul> +!! end !! test -Definition Lists: Weird Ones: Test 1 +Definition Lists: Weird Ones: Test 1 (php) +!! options +php !! input *#;*::;; foo : bar (who uses this?) !! result -<ul><li><ol><li><dl><dt> foo </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> +<ul> +<li><ol> +<li><dl> +<dt> foo </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> !! end +!! test +Definition Lists: Weird Ones: Test 1 (parsoid) +!! options +parsoid +!! input +*#;*::;; foo : bar (who uses this?) +!! result +<ul> +<li> +<ol> +<li> +<dl> +<dt> +<ul> +<li> +<dl> +<dd> +<dl> +<dd> +<dl> +<dt> +<dl> +<dt> foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'> </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 @@ -2270,6 +3366,17 @@ External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png !! end !! test +External image (when not allowed) +!! options +wgAllowExternalImages=0 +!! input +External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png +!! result +<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 !! input Link to non-http image, no img tag: ftp://example.com/test.jpg @@ -2692,6 +3799,15 @@ External link containing double-single-quotes with no space separating the url f !! end !! test +External link with comments in link text +!! input +[http://www.google.com Google <!-- comment -->] +!! result +<p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a> +</p> +!! end + +!! test URL-encoding in URL functions (single parameter) !! input {{localurl:Some page|amp=&}} @@ -2763,6 +3879,28 @@ Non-extlinks in brackets </p> !! end +!! test +Parsoid: Percent encoding in external links +!! options +parsoid +!! input +[https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search] +!! result +<p><a rel="mw:ExtLink" +href="https://github.com/search?l=&q=ResourceLoader+%40wikimedia">Search</a></p> +!! end + +!! test +Parsoid: use url link syntax for links where the content is equal the link +target +!! options +parsoid +!! input +http://example.com +!! result +<p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></p> +!! end + ### ### Quotes ### @@ -2781,7 +3919,9 @@ Normal text. '''''Bold italic text.''''' Normal text. !! test -Unclosed and unmatched quotes +Unclosed and unmatched quotes (php) +!! options +php !! input '''''Bold italic text '''with bold deactivated''' in between.''''' @@ -2816,6 +3956,47 @@ Plain ''italic'''s plain </p><p>Plain <i>italic'</i>s plain </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 (parsoid) +!! options +parsoid +!! input +'''''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 +!! result +<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 @@ -2824,19 +4005,33 @@ Plain ''italic'''s plain ### # This should not produce <table></table> as <table><tr><td></td></tr></table> -# is the bare minimun required by the spec, see: +# is the bare minimum required by the spec, see: # http://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables !! test -A table with no data. +A table with no data. (php) +!! options +php +!! input +{||} +!! result +!! end +# Parsoid team replies: empty table tags are legal in HTML5 +!! test +A table with no data. (parsoid) +!! options +parsoid !! input {||} !! result +<table></table> !! end # A table with nothing but a caption is invalid XHTML, we might want to render # this as <p>caption</p> !! test -A table with nothing but a caption +A table with nothing but a caption (php) +!! options +php !! input {| |+ caption @@ -2847,6 +4042,18 @@ A table with nothing but a caption </caption><tr><td></td></tr></table> !! end +# Parsoid team replies: table with only a caption is legal in HTML5 +!! test +A table with nothing but a caption (parsoid) +!! options +parsoid +!! input +{| +|+ caption +|} +!! result +<table><caption> caption</caption></table> +!! end !! test A table with caption with default-spaced attributes and a table row @@ -3243,11 +4450,44 @@ Template-generated table cell attributes and cell content !! input {| |{{table_attribs}} +| {{table_attribs}} |} !! result <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) +!! input +{| +|align=center {{table_attribs}} +|} +!! result +<table> +<tr> +<td align="center" style="color: red"> Foo +</td></tr></table> + +!! end + +!! test +Template-generated table cell attributes and cell content (3) +!! input +{| +|align=center {{table_cells}} +|} +!! result +<table> +<tr> +<td align="center" style="color: red"> Foo </td> +<td> Bar </td> +<td> Baz </td></tr></table> !! end @@ -3270,21 +4510,40 @@ Table with row followed by newlines and table heading !! end +!! test +Table with empty line following the start tag +!! input +{| + +|- +| foo +|} +!! result +<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 !! options -disabled +parsoid !! input {| | style=| hello |} !! result <table> +<tbody> <tr> <td style=""> hello -</td></tr></table> +</td></tr></tbody></table> !! end @@ -3311,6 +4570,159 @@ Wikitext table with a lot of comments !! end +!! test +Wikitext table with double-line table cell +!! input +{| +|a +b +|} +!! result +<table> +<tr> +<td>a +<p>b +</p> +</td></tr></table> + +!! end + +!! test +Table cell with a single comment +!! input +{| +| <!-- c1 --> +| a +|} +!! result +<table> +<tr> +<td> +</td> +<td> a +</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 (Parsoid) +!! options +parsoid +!! input +{| +|- +<td>foo</td> +|} +!! result +<table> +<tbody> +<tr> +<td>foo</td></tr></tbody></table> +!! end + +!! test +Implicit <td> after a |- +(PHP parser relies on Tidy to add the missing <td> tags) +!! options +parsoid=wt2html,wt2wt +!! input +{| +|- +a +|} +!! result +<table> +<tr><td>a</td></tr> +</table> +!! end + +!! test +Pres should be recognized in an explicit <td> context, but not in an implicit <td> context +(PHP parser relies on Tidy to add the missing <td> tags) +!! options +parsoid=wt2html,wt2wt +!! input +{| +|- +| + a +|- + b +|} +!! result +<table> +<tbody> +<tr><td><pre>a</pre></td></tr> +<tr><td> b</td></tr> +</tbody> +</table> +!! end + +!! test +Lists should be recognized in an implicit <td> context +(PHP parser relies on Tidy to add the missing <td> tags) +!! options +parsoid=wt2html,wt2wt +!! input +{| +|- +*a +|} +!! result +<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 +!! input +{| +|foo +|} bar + +{| +|baz +|}<b>quux</b> +!! result +<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 +!! input +{| +|foo +|} +<nowiki> </nowiki>bar +{| +|baz +|} +'''quux''' +!! result +<table><tbody> +<tr><td>foo</td></tr></tbody></table> bar +<table><tbody> +<tr><td>baz</td></tr></tbody></table><b>quux</b> +!! end + ### ### Internal links ### @@ -3342,6 +4754,15 @@ Piped link !! end !! test +Piped link with comment in link text +!! input +[[Main Page|The Main<!--front--> Page]] +!! result +<p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a> +</p> +!! end + +!! test Broken link !! input [[Zigzagzogzagzig]] @@ -3462,6 +4883,22 @@ Link to namespaces </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) +!! input +[[MemoryAlpha:AlphaTest]] +!! result +<p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a> +</p> +!! end + !! test Piped link to namespace !! input @@ -3527,6 +4964,33 @@ Link containing "<#" and ">#" as a hex sequences !! end !! test +Link containing an equals sign +!! input +[[Special:BookSources/isbn=4-00-026157-6]] +!! result +<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> +!! 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 +!! input +[[Foo~bar]] +!! result +<p><a href="/wiki/Foo%7Ebar" title="Foo~bar">Foo~bar</a> +</p> +!! end + +!! test Link containing double-single-quotes '' (bug 4598) !! input [[Lista d''e paise d''o munno]] @@ -3787,6 +5251,69 @@ language=kaa </p> !! end +!! article +Söfnuður +!! text +Test. +!! endarticle + +!! test +Internal link with is link prefix +!! options +language=is +!! input +Aðrir mótmælenda[[söfnuður|söfnuðir]] og +!! result +<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 +!! input +[[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 +!! result +<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 +!! input +[[apple]]<nowiki/>s +!! result +<p><a rel="mw:WikiLink" href="Apple">apple</a>s</p> +!! end + +!! test +Parsoid link prefix escaping +!! options +language=is +parsoid=html2wt,html2html +!! input +Aðrir mótmælenda<nowiki/>[[söfnuður]] +!! result +<p>Aðrir mótmælenda<a rel="mw:WikiLink" href="Söfnuður">söfnuður</a></p> +!! end + !! test Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved !! input @@ -3833,9 +5360,12 @@ Interwiki link encoding conversion (bug 1636) *[[Wikipedia:ro:Olteniţa]] *[[Wikipedia:ro:Olteniţa]] !! result -<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> +<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 @@ -3848,6 +5378,12 @@ Interwiki link with fragment (bug 2130) </p> !! end + +### +### Interlanguage links +### Language links (so that searching for '### language' matches..) +### + !! test Interlanguage link !! input @@ -3905,6 +5441,189 @@ language=ln </p> !! end +!! test +Parsoid bug 53221: Wikilinks should be properly entity-escaped +!! options +parsoid=html2wt +!! input +He&nbsp;llo [[Foo|He&nbsp;llo]] + +He&nbsp;llo [[He&nbsp;llo]] +!!result +<p>He&nbsp;llo <a href="Foo" rel="mw:WikiLink">He&nbsp;llo</a></p> +<p>He&nbsp;llo <a href="He&nbsp;llo" rel="mw:WikiLink">He&nbsp;llo</a></p> +!! end + +!! test +Parsoid: handle constructor well +!! options +parsoid +!! input +[[constructor]] + +[[constructor:foo]] +!! result +<p data-parsoid="{"dsr":[0,15,0,0]}"><a rel="mw:WikiLink" href="./Constructor" data-parsoid="{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"},"dsr":[0,15,2,2]}">constructor</a></p> + + +<p data-parsoid="{"dsr":[17,36,0,0]}"><a rel="mw:WikiLink" href="./Foo" data-parsoid="{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"constructor:foo"},"dsr":[17,36,2,2]}">constructor:foo</a></p> +!! end + +!! test +Parsoid: recognize interlanguage links without a target page +!! options +parsoid +!! input +[[ko:]] +!! result +<p> +<link rel="mw:WikiLink/Language" href="http://ko.wikipedia.org/wiki/"></p> +!! end + +!! test +Parsoid: recognize interwiki links without a target page +!! options +parsoid +!! input +[[:ko:]] +!! result +<p><a rel="mw:WikiLink/Interwiki" href="http://ko.wikipedia.org/wiki/">ko:</a></p> +!! end + +### +### Redirects, Parsoid-only +### +!! test +Simple redirect to page +!! options +parsoid +!! input +#REDIRECT [[Main Page]] +!! result +<link rel="mw:PageProp/redirect" href="./Main_Page"> +!! 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 +!! input +#REDIRECT:[[Main Page]] +!! result +<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 +!! input + + #REDIRECT +: +[[Main Page]] +!! result +<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 +!! input +#REDIRECT [[Main Page|bar]] +!! result +<link rel="mw:PageProp/redirect" href="./Main_Page"> +!! end + +!! test +Redirect to category +!! options +parsoid=wt2html +!! input +#REDIRECT [[Category:Foo]] +!! result +<link rel="mw:PageProp/redirect" href="./Category:Foo"><link rel="mw:WikiLink/Category" href="./Category:Foo"> +!! end + +!! test +Redirect to category with URL encoding +!! options +parsoid=wt2html +!! input +#REDIRECT [[Category%3AFoo]] +!! result +<link rel="mw:PageProp/redirect" href="./Category:Foo"><link rel="mw:WikiLink/Category" href="./Category:Foo"> +!! end + +!! test +Redirect to category page +!! options +parsoid=wt2html,html2html +!! input +#REDIRECT [[:Category:Foo]] +!! result +<p><a rel="mw:WikiLink" href="Category:Foo">Category:Foo</a></p> +!! end + +!! test +Redirect to image page (1) +!! options +parsoid +!! input +#REDIRECT [[File:Wiki.png]] +!! result +<link rel="mw:PageProp/redirect" href="./File:Wiki.png"> +!! end + +!! test +Redirect to image page (2) +!! options +parsoid +!! input +#REDIRECT [[Image:Wiki.png]] +!! result +<link rel="mw:PageProp/redirect" href="./File:Wiki.png"> +!! end + +!! test +Redirect to language +!! options +parsoid +!! input +#REDIRECT [[en:File:Wiki.png]] +!! result +<link rel="mw:PageProp/redirect" href="File:Wiki.png"> +!! end + +!! test +Redirect to interwiki +!! options +parsoid +!! input +#REDIRECT [[meatball:File:Wiki.png]] +!! result +<link rel="mw:PageProp/redirect" href="File:Wiki.png"> +!! end + +!! test +Non-English #REDIRECT +!! options +parsoid +language=is +!! input +#TILVÍSUN [[Main Page]] +!! result +<link rel="mw:PageProp/redirect" href="./Main_Page"> +!! end + ## ## XHTML tidiness ### @@ -3920,6 +5639,8 @@ language=ln !! test Broken br tag sanitization +!! options +php !! input </br> !! result @@ -3927,6 +5648,17 @@ Broken br tag sanitization </p> !! end +# TODO: Fix html2html mode (bug 51055)! +!! test +Parsoid: Broken br tag recognition +!! options +parsoid=wt2html +!! input +</br> +!! result +<p><br></p> +!! end + !! test Incorrecly removing closing slashes from correctly formed XHTML !! input @@ -4023,7 +5755,7 @@ Horizontal ruler -- eats additional dashes on the same line !! end !! test -Horizontal ruler -- does not collaps dashes on consecutive lines +Horizontal ruler -- does not collapse dashes on consecutive lines !! input ---- ---- @@ -4061,10 +5793,14 @@ Common list * item 2 *item 3 !! result -<ul><li>Common list -</li><li> item 2 -</li><li>item 3 -</li></ul> +<ul> +<li>Common list +</li> +<li> item 2 +</li> +<li>item 3 +</li> +</ul> !! end @@ -4075,10 +5811,14 @@ Numbered list #item 2 # item 3 !! result -<ol><li>Numbered list -</li><li>item 2 -</li><li> item 3 -</li></ol> +<ol> +<li>Numbered list +</li> +<li>item 2 +</li> +<li> item 3 +</li> +</ol> !! end @@ -4101,35 +5841,67 @@ Mixed list *** Level 3 #** Level 3, but ordered !! result -<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> +<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 @@ -4139,10 +5911,14 @@ Nested lists 1 *foo **bar !! result -<ul><li>foo -<ul><li>bar -</li></ul> -</li></ul> +<ul> +<li>foo +<ul> +<li>bar +</li> +</ul> +</li> +</ul> !! end @@ -4152,10 +5928,15 @@ Nested lists 2 **foo *bar !! result -<ul><li><ul><li>foo -</li></ul> -</li><li>bar -</li></ul> +<ul> +<li><ul> +<li>foo +</li> +</ul> +</li> +<li>bar +</li> +</ul> !! end @@ -4165,10 +5946,14 @@ Nested lists 3 (first element empty) * **bar !! result -<ul><li> -<ul><li>bar -</li></ul> -</li></ul> +<ul> +<li> +<ul> +<li>bar +</li> +</ul> +</li> +</ul> !! end @@ -4178,10 +5963,15 @@ Nested lists 4 (first element empty) ** *bar !! result -<ul><li><ul><li> -</li></ul> -</li><li>bar -</li></ul> +<ul> +<li><ul> +<li> +</li> +</ul> +</li> +<li>bar +</li> +</ul> !! end @@ -4191,10 +5981,15 @@ Nested lists 5 (both elements empty) ** * !! result -<ul><li><ul><li> -</li></ul> -</li><li> -</li></ul> +<ul> +<li><ul> +<li> +</li> +</ul> +</li> +<li> +</li> +</ul> !! end @@ -4204,10 +5999,14 @@ Nested lists 6 (both elements empty) * ** !! result -<ul><li> -<ul><li> -</li></ul> -</li></ul> +<ul> +<li> +<ul> +<li> +</li> +</ul> +</li> +</ul> !! end @@ -4216,10 +6015,16 @@ Nested lists 7 (skip initial nesting levels) !! input *** foo !! result -<ul><li><ul><li><ul><li> foo -</li></ul> -</li></ul> -</li></ul> +<ul> +<li><ul> +<li><ul> +<li> foo +</li> +</ul> +</li> +</ul> +</li> +</ul> !! end @@ -4231,13 +6036,21 @@ Nested lists 8 (multiple nesting transitions) ** baz * boo !! result -<ul><li> foo -<ul><li><ul><li> bar -</li></ul> -</li><li> baz -</li></ul> -</li><li> boo -</li></ul> +<ul> +<li> foo +<ul> +<li><ul> +<li> bar +</li> +</ul> +</li> +<li> baz +</li> +</ul> +</li> +<li> boo +</li> +</ul> !! end @@ -4248,10 +6061,14 @@ Nested lists 8 (multiple nesting transitions) *<!--cmt-->bar <!--cmt-->*baz !! result -<ul><li>foo -</li><li>bar -</li><li>baz -</li></ul> +<ul> +<li>foo +</li> +<li>bar +</li> +<li>baz +</li> +</ul> !! end @@ -4261,34 +6078,268 @@ Nested lists 8 (multiple nesting transitions) *foo {{echo|bar }}*baz !! result -<ul><li>foo bar -</li><li>baz -</li></ul> +<ul> +<li>foo bar +</li> +<li>baz +</li> +</ul> + +!! end + +!! test +List items are not parsed correctly following a <pre> block (bug 785) +!! input +* <pre>foo</pre> +* <pre>bar</pre> +* zar +!! result +<ul> +<li> <pre>foo</pre> +</li> +<li> <pre>bar</pre> +</li> +<li> zar +</li> +</ul> + +!! end + +!! test +List items from template +!! input + +{{inner list}} +* item 2 + +* item 0 +{{inner list}} +* item 2 + +* item 0 +* notSOL{{inner list}} +* item 2 +!! result +<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 +!! input +* foo + +** bar +== A heading == +* Another list item +!! result +<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&action=edit&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 +!!input +{{echo|<li>}}a +{{echo|<li>}}b +{{echo|<li>}}c +!!result +<li>a +<li>b +<li>c</li> +</li> +</li> + +!!end + +!!test +Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines +!!input +*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 +!!result +<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) +!!input +*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 +!!result +<ul> +<li>a +</li> +<li>b +</li> +<li>c +</li> +<li>d +</li> +</ul> +!!end + +!!test +Test the li-hack +(Cannot test this with PHP parser since it relies on Tidy for the hack) +!!options +parsoid=wt2html,wt2wt +!!input +* 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> +!!result +<ul> +<li> foo</li> +<li>li-hack</li> +<li about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<li>templated li-hack"}}}}]}'>templated li-hack</li> +<li> <!--foo--> </li> +<li> li-hack with preceding comments</li> +</ul> + +<ul> +<li></li> +<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 +!! input +# foo +## bar +* foo +** bar +: foo +:: bar +!! result +<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 +!! input +* {{bullet}} +!! result +<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 -(Disabled since php parser generates broken html -- relies on Tidy to fix up) +(Parsoid-only since php parser generates broken html -- relies on Tidy to fix up) !! options -disabled +parsoid !! input <div> *a</div><div> *b</div> !! result <div> -<ul><li>a -</li></ul></div><div> -<ul><li>b -</li></ul></div> +<ul> +<li>a +</li> +</ul></div><div> +<ul> +<li>b +</li> +</ul></div> !! end !! test Unbalanced closing non-block tags don't break a list -(Disabled since php parser generates broken html -- relies on Tidy to fix up) +(Parsoid-only since php parser generates broken html -- relies on Tidy to fix up) !! options -disabled +parsoid !! input <span> *a</span><span> @@ -4296,23 +6347,29 @@ disabled !! result <p><span></span> </p> -<ul><li>a<span></span> -</li><li>b -</li></ul> +<ul> +<li>a<span></span> +</li> +<li>b +</li> +</ul> !! end !! test Unclosed formatting tags that straddle lists are closed and reopened -(Disabled since php parser generates broken html -- relies on Tidy to fix up) +(Parsoid-only since php parser generates broken html -- relies on Tidy to fix up) !! options -disabled +parsoid !! input # <s> a # b </s> !! result -<ol><li> <s> a </s> -</li><li> <s> b </s> -</li></ol> +<ol> +<li> <s> a </s> +</li> +<li> <s> b </s> +</li> +</ol> !! end !!test @@ -4335,88 +6392,31 @@ parsoid !!end !! test -List items are not parsed correctly following a <pre> block (bug 785) -!! input -* <pre>foo</pre> -* <pre>bar</pre> -* zar -!! result -<ul><li> <pre>foo</pre> -</li><li> <pre>bar</pre> -</li><li> zar -</li></ul> - -!! end - -!! test -List items from template +Table with missing opening <tr> tag +!! options +parsoid=wt2html,wt2wt !! input - -{{inner list}} -* item 2 - -* item 0 -{{inner list}} -* item 2 - -* item 0 -* notSOL{{inner list}} -* item 2 +<table> +<td>foo</td> +</tr> +</table> !! result -<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> - +<table> +<tr> +<td>foo</td> +</tr> +</table> !! end -!! test -List interrupted by empty line or heading -!! input -* foo - -** bar -== A heading == -* Another list item -!! result -<ul><li> foo -</li></ul> -<ul><li><ul><li> bar -</li></ul> -</li></ul> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: A heading">edit</a>]</span> <span class="mw-headline" id="A_heading"> A heading </span></h2> -<ul><li> Another list item -</li></ul> - -!!end - -!!test -Multiple list tags generated by templates -!!input -{{echo|<li>}}a -{{echo|<li>}}b -{{echo|<li>}}c -!!result -<li>a -<li>b -<li>c</li> -</li> -</li> - -!!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}} !! input @@ -4463,6 +6463,15 @@ Magic Word: {{CURRENTMONTH}} !! end !! test +Magic Word: {{CURRENTMONTH1}} +!! input +{{CURRENTMONTH1}} +!! result +<p>1 +</p> +!! end + +!! test Magic Word: {{CURRENTMONTHABBREV}} !! input {{CURRENTMONTHABBREV}} @@ -4499,6 +6508,15 @@ Magic Word: {{CURRENTTIME}} !! end !! test +Magic Word: {{CURRENTHOUR}} +!! input +{{CURRENTHOUR}} +!! result +<p>00 +</p> +!! end + +!! test Magic Word: {{CURRENTWEEK}} (@bug 4594) !! input {{CURRENTWEEK}} @@ -4517,6 +6535,66 @@ Magic Word: {{CURRENTYEAR}} !! end !! test +Magic Word: {{CURRENTTIMESTAMP}} +!! input +{{CURRENTTIMESTAMP}} +!! result +<p>19700101000203 +</p> +!! end + +!! test +Magic Words LOCAL (UTC) +!! input +* {{LOCALMONTH}} +* {{LOCALMONTH1}} +* {{LOCALMONTHNAME}} +* {{LOCALMONTHNAMEGEN}} +* {{LOCALMONTHABBREV}} +* {{LOCALDAY}} +* {{LOCALDAY2}} +* {{LOCALDAYNAME}} +* {{LOCALYEAR}} +* {{LOCALTIME}} +* {{LOCALHOUR}} +* {{LOCALWEEK}} +* {{LOCALDOW}} +* {{LOCALTIMESTAMP}} +!! result +<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]] @@ -4539,6 +6617,93 @@ title=[[User:Ævar Arnfjörð Bjarmason]] !! end !! test +Magic Word: {{TALKSPACE}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +!! input +{{TALKSPACE}} +!! result +<p>User talk +</p> +!! end + +!! test +Magic Word: {{TALKSPACE}}, same namespace +!! options +title=[[User talk:Ævar Arnfjörð Bjarmason]] +!! input +{{TALKSPACE}} +!! result +<p>User talk +</p> +!! end + +!! test +Magic Word: {{TALKSPACE}}, main namespace +!! options +title=[[Parser Test]] +!! input +{{TALKSPACE}} +!! result +<p>Talk +</p> +!! end + +!! test +Magic Word: {{TALKSPACEE}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +!! input +{{TALKSPACEE}} +!! result +<p>User_talk +</p> +!! end + +!! test +Magic Word: {{SUBJECTSPACE}} +!! options +title=[[User talk:Ævar Arnfjörð Bjarmason]] +!! input +{{SUBJECTSPACE}} +!! result +<p>User +</p> +!! end + +!! test +Magic Word: {{SUBJECTSPACE}}, same namespace +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +!! input +{{SUBJECTSPACE}} +!! result +<p>User +</p> +!! end + +!! test +Magic Word: {{SUBJECTSPACE}}, main namespace +!! options +title=[[Parser Test]] +!! input +{{SUBJECTSPACE}} +!! result + +!! end + +!! test +Magic Word: {{SUBJECTSPACEE}} +!! options +title=[[User talk:Ævar Arnfjörð Bjarmason]] +!! input +{{SUBJECTSPACEE}} +!! result +<p>User +</p> +!! end + +!! test Magic Word: {{NAMESPACE}} !! options title=[[User:Ævar Arnfjörð Bjarmason]] @@ -4572,11 +6737,121 @@ title=[[User:Ævar Arnfjörð Bjarmason]] !! end !! test +Magic Word: {{SUBPAGENAME}} +!! options +title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage +!! input +{{SUBPAGENAME}} +!! result +<p>sub ö +</p> +!! end + +!! test +Magic Word: {{SUBPAGENAMEE}} +!! options +title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage +!! input +{{SUBPAGENAMEE}} +!! result +<p>sub_%C3%B6 +</p> +!! end + +!! test +Magic Word: {{ROOTPAGENAME}} +!! options +title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage +!! input +{{ROOTPAGENAME}} +!! result +<p>Ævar Arnfjörð Bjarmason +</p> +!! end + +!! test +Magic Word: {{ROOTPAGENAMEE}} +!! options +title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage +!! input +{{ROOTPAGENAMEE}} +!! result +<p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason +</p> +!! end + +!! test +Magic Word: {{BASEPAGENAME}} +!! options +title=[[Ævar Arnfjörð Bjarmason/sub]] subpage +!! input +{{BASEPAGENAME}} +!! result +<p>Ævar Arnfjörð Bjarmason +</p> +!! end + +!! test +Magic Word: {{BASEPAGENAMEE}} +!! options +title=[[Ævar Arnfjörð Bjarmason/sub]] subpage +!! input +{{BASEPAGENAMEE}} +!! result +<p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason +</p> +!! end + +!! test +Magic Word: {{TALKPAGENAME}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +!! input +{{TALKPAGENAME}} +!! result +<p>User talk:Ævar Arnfjörð Bjarmason +</p> +!! end + +!! test +Magic Word: {{TALKPAGENAMEE}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +!! input +{{TALKPAGENAMEE}} +!! result +<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]] +!! input +{{SUBJECTPAGENAME}} +!! result +<p>User:Ævar Arnfjörð Bjarmason +</p> +!! end + +!! test +Magic Word: {{SUBJECTPAGENAMEE}} +!! options +title=[[User talk:Ævar Arnfjörð Bjarmason]] +!! input +{{SUBJECTPAGENAMEE}} +!! result +<p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason +</p> +!! end + +!! test Magic Word: {{NUMBEROFFILES}} !! input {{NUMBEROFFILES}} !! result -<p>2 +<p>4 </p> !! end @@ -4654,6 +6929,15 @@ Magic Word: {{SCRIPTPATH}} !! end !! test +Magic Word: {{STYLEPATH}} +!! input +{{STYLEPATH}} +!! result +<p>/skins +</p> +!! end + +!! test Magic Word: {{SERVER}} !! input {{SERVER}} @@ -4681,6 +6965,36 @@ Magic Word: {{SITENAME}} !! end !! test +Case-sensitive magic words, when cased differently, should just be template transclusions +!! input +{{CurrentMonth}} +{{currentday}} +{{cURreNTweEK}} +{{currentHour}} +!! result +<p><a href="/index.php?title=Template:CurrentMonth&action=edit&redlink=1" class="new" title="Template:CurrentMonth (page does not exist)">Template:CurrentMonth</a> +<a href="/index.php?title=Template:Currentday&action=edit&redlink=1" class="new" title="Template:Currentday (page does not exist)">Template:Currentday</a> +<a href="/index.php?title=Template:CURreNTweEK&action=edit&redlink=1" class="new" title="Template:CURreNTweEK (page does not exist)">Template:CURreNTweEK</a> +<a href="/index.php?title=Template:CurrentHour&action=edit&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. +!! input +{{sErVeRNaMe}} +{{LCFirst:AOEU}} +{{ucFIRST:aoeu}} +{{SERver}} +!! result +<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}} !! input {{ns:1}} @@ -5422,8 +7736,8 @@ Bug 6563: Edit link generation for section shown by <includeonly> !! input {{includeonly section}} !! result -<h2><span class="editsection">[<a href="/index.php?title=Template:Includeonly_section&action=edit&section=T-1" title="Template:Includeonly section">edit</a>]</span> <span class="mw-headline" id="Includeonly_section">Includeonly section</span></h2> -<h2><span class="editsection">[<a href="/index.php?title=Template:Includeonly_section&action=edit&section=T-2" title="Template:Includeonly section">edit</a>]</span> <span class="mw-headline" id="Section_T-1">Section T-1</span></h2> +<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&action=edit&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&action=edit&section=T-2" title="Template:Includeonly section">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -5449,7 +7763,7 @@ Bug 6563: Edit link generation for section suppressed by <includeonly> </includeonly> ==Section 1== !! result -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Section 1">edit</a>]</span> <span class="mw-headline" id="Section_1">Section 1</span></h2> +<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&action=edit&section=1" title="Edit section: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -5473,6 +7787,77 @@ Un-closed <includeonly> !! result !! end +# TODO: test with DOM fragment reuse! +!! test +Parsoid: DOM fragment reuse +!! options +parsoid=wt2wt,wt2html +!! input +a{{echo|b<table></table>c}}d + +a{{echo|b +<table></table> +c}}d + +{{echo|a + +<table></table> + +b}} +!! result +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 +!! input +{| +|{{echo|{{!}} foo}} +|} +!! result +<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 +!! input +{{echo|<div>}} +{| +|{{echo|{{!}} foo}} +|} +{{echo|</div>}} +!! result +<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 ### @@ -5569,8 +7954,10 @@ Templates: 1. Simple use Templates: 2. Inside a block tag !!input <div>{{echo|Foo}}</div> +<blockquote>{{echo|Foo}}</blockquote> !!result <div>Foo</div> +<blockquote>Foo</blockquote> !!end @@ -5612,6 +7999,19 @@ bar <div>baz</div> !!end !!test +Templates: P-wrapping: 1d. Template preceded by comment-only line +!!options +parsoid +!!input +<!-- foo --> +{{echo|Bar}} +!!result +<!-- 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 tmeplate uses !!input {{echo|Foo}}bar{{echo|baz}} @@ -5771,6 +8171,15 @@ Templates: HTML Tag: 6. Generation of end piece of HTML attr value !!end !!test +Templates: HTML Tag: 7. Generation of partial attribute key string +!!input +<div st{{echo|yle}}="color:red;">foo</div> +!!result +<div style="color:red;">foo</div> + +!!end + +!!test Templates: HTML Tables: 1. Generating start of a HTML table !!input {{echo|<table><tr><td>foo</td>}}</tr></table> @@ -5861,6 +8270,20 @@ Templates: HTML Tables: 4f. Generating a single tag of a HTML table !!end !!test +Templates: HTML Tables: 5. Proper fostering of categories from inside +!!options +parsoid=wt2html,wt2wt +!!input +<table>[[Category:foo1]]<tr><td>foo</td></tr></table> +<!--Two categories (Bug 50330)--> +<table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table> +!!result +<link rel="mw:WikiLink/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table> +<!--Two categories (Bug 50330)--> +<link rel="mw:WikiLink/Category" href="./Category:Bar1"><link rel="mw:WikiLink/Category" href="./Category:Bar2"><table><tbody><tr><td>foo</td></tr></tbody></table> +!!end + +!!test Templates: Wiki Tables: 1a. Fostering of entire template content !!input {| @@ -5967,9 +8390,12 @@ unused}}}} *{{echo|b {{nonexistent| unused}}}} !!result -<ul><li>a <a href="/index.php?title=Template:Nonexistent&action=edit&redlink=1" class="new" title="Template:Nonexistent (page does not exist)">Template:Nonexistent</a> -</li><li>b <a href="/index.php?title=Template:Nonexistent&action=edit&redlink=1" class="new" title="Template:Nonexistent (page does not exist)">Template:Nonexistent</a> -</li></ul> +<ul> +<li>a <a href="/index.php?title=Template:Nonexistent&action=edit&redlink=1" class="new" title="Template:Nonexistent (page does not exist)">Template:Nonexistent</a> +</li> +<li>b <a href="/index.php?title=Template:Nonexistent&action=edit&redlink=1" class="new" title="Template:Nonexistent (page does not exist)">Template:Nonexistent</a> +</li> +</ul> !!end @@ -5986,24 +8412,24 @@ Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo) Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span) (PHP parser generates misnested html) !! options -disabled +parsoid !!input {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}} !!result -<p><span><i>a</i></span><i><span>b</span></i><span>c</span><i>d</i><span>e</span></p> +<p><span about="#mwt1" typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo_with_span","href":"./Template:Echo_with_span"},"params":{"1":{"wt":"''a"}},"i":0}}]}"><i>a</i></span><i about="#mwt2" typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo_with_span","href":"./Template:Echo_with_span"},"params":{"1":{"wt":"b''c''d"}},"i":0}},{"template":{"target":{"wt":"echo_with_span","href":"./Template:Echo_with_span"},"params":{"1":{"wt":"''e"}},"i":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) +(PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s) !! options -disabled +parsoid=wt2html,wt2wt !!input {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}} !!result -<div><i>a</i></div> -<div><i>b</i>c<i>d</i></div> -<div>e</div> +<div about="#mwt1" typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo_with_div","href":"./Template:Echo_with_div"},"params":{"1":{"wt":"''a"}},"i":0}}]}"><i>a</i></div> +<div about="#mwt2" typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo_with_div","href":"./Template:Echo_with_div"},"params":{"1":{"wt":"b''c''d"}},"i":0}}]}"><i>b</i>c<i>d</i></div> +<div about="#mwt3" typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo_with_div","href":"./Template:Echo_with_div"},"params":{"1":{"wt":"''e"}},"i":0}}]}">e</div> !!end !!test @@ -6026,9 +8452,12 @@ parsoid |bar |} !!result -<table about="#mwt1" typeof="mw:Object/Template "> -<tbody><tr><td>foo</td></tr></tbody></table><span about="#mwt1"> -bar</span><span about="#mwt1"> +<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 @@ -6058,24 +8487,24 @@ parsoid </tr> </table> !!result -<table about="#mwt1" typeof="mw:Object/Template"> - <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="#mwt1"> - </span><span about="#mwt1"> - - abc</span><span about="#mwt1"> - </span><span about="#mwt1"> - </span><span about="#mwt1"> - </span><span about="#mwt1"> - </span><span about="#mwt1"> - - xyz</span><span about="#mwt1"> - </span><span about="#mwt1"> +<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 @@ -6237,10 +8666,13 @@ wiki<nowiki>nowiki<!--nowiki</nowiki>wiki 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> +@<span onmouseover="alert('crap')">Oh no</span> !!endarticle !!test @@ -6248,7 +8680,7 @@ Template:dangerous !! input {{Template:dangerous}} !! result -<p><span>Oh no</span> +<p>@<span>Oh no</span> </p> !! end @@ -6637,6 +9069,62 @@ But not inside includeonly <includeonly>{{subst:Foo}}</includeonly> !! end +!! test +Parsoid: Recognize nowiki with trailing space in tags +!! options +parsoid=wt2html +!! input +<nowiki ><div>[[foo]]</nowiki > + +a<nowiki / >b + +c<nowiki />d + +e<nowiki/ >f +!! result +<p><span typeof="mw:Nowiki"><div>[[foo]]</span></p> +<p>ab</p> +<p>cd</p> +<p>ef</p> +!! end + +!! test +Parsoid: Recognize nowiki with odd capitalization +!! options +parsoid=wt2html +!! input +<noWikI ><div>[[foo]]</Nowiki > +!! result +<p><span typeof="mw:Nowiki"><div>[[foo]]</span></p> +!! end + + +!! test +Parsoid: Escape nowiki with trailing space in tags +!! options +parsoid=html2wt +!! input +<nowiki > foo </nowiki > + +a<nowiki />b + +c<nowiki/ >d +!! result +<p><nowiki > foo </nowiki ></p> +<p>a<nowiki />b</p> +<p>c<nowiki/ >d</p> +!! end + +!! test +Parsoid: Escape weird noWikI capitalizations +!! options +parsoid=html2wt +!! input +<noWikI > foo </NoWikI > +!! result +<p><noWikI > foo </NoWikI ></p> +!! end + ### ### Message transform tests ### @@ -6705,9 +9193,9 @@ Special:RecentChanges/param !! options msg !! input -{{#special:foobarnonexistent}} +{{#special:foobar nonexistent}} !! result -No such special page +Special:Foobar nonexistent !! end !! test @@ -6735,16 +9223,21 @@ Special:RecentChanges/param !! options msg !! input -{{#speciale:foobarnonexistent}} +{{#speciale:foobar nonexistent}} !! result -No_such_special_page +Special:Foobar_nonexistent !! end ### ### Images ### +### For Parsoid-specific tests, see +#### http://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images + !! test -Simple image +Simple image (php) +!! options +php !! input [[Image:foobar.jpg]] !! result @@ -6753,16 +9246,20 @@ Simple image !! end !! test -Right-aligned image +Simple image (parsoid) +!! options +parsoid=wt2html !! input -[[Image:foobar.jpg|right]] +[[Image:foobar.jpg]] !! result -<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><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) +Simple image (using File: namespace, now canonical) (php) +!! options +php !! input [[File:foobar.jpg]] !! result @@ -6771,29 +9268,108 @@ Simple image (using File: namespace, now canonical) !! end !! test -Image with caption +Simple image (using File: namespace, now canonical) (parsoid) +!! options +parsoid !! input -[[Image:foobar.jpg|right|Caption text]] +[[File:Foobar.jpg]] +!! result +<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 (php) +!! options +php +!! input +[[Image:foobar.jpg|right]] +!! result +<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> + +!! end + +!! test +Right-aligned image (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|right]] +!! result +<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 (php) +!! options +php +!! input +[[File:Foobar.jpg|right|Caption text]] +!! result +<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> + +!! end + +!! test +Image with caption (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|right|Caption text]] +!! result +<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 empty attribute (php) +!! options +php +!! input +[[File:Foobar.jpg|right||Caption text]] !! result <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> !! end !! test -Image with empty attribute +Image with empty attribute (parsoid) +!! options +parsoid=wt2html +!! input +[[File:Foobar.jpg|right||Caption text]] +!! result +<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 attributes from template (php) +!! options +php !! input -[[Image:foobar.jpg|right||Caption text]] +[[File:Foobar.jpg|{{image_attribs}}]] !! result <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> !! end !! test -Image with link tails +Image with attributes from template (parsoid) +!! options +parsoid !! input -123[[Image:foobar.jpg]]456 -123[[Image:foobar.jpg|right]]456 -123[[Image:foobar.jpg|thumb]]456 +[[File:Foobar.jpg|{{image_attribs}}]] +!! result +<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 link tails (php) +!! options +php +!! input +123[[File:Foobar.jpg]]456 +123[[File:Foobar.jpg|right]]456 +123[[File:Foobar.jpg|thumb]]456 !! result <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> @@ -6803,20 +9379,48 @@ Image with link tails !! end !! test -Image with multiple captions -- only last one is accepted +Image with link tails (parsoid) +!! options +parsoid +!! input +123[[File:Foobar.jpg]]456 +123[[File:Foobar.jpg|right]]456 +123[[File:Foobar.jpg|thumb]]456 +!! result +<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="20" width="180"></a></figure>456 +!! end + +!! test +Image with multiple captions -- only last one is accepted (php) +!! options +php !! input -[[Image:foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]] +[[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]] !! result <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> !! end !! test -Image with width attribute at different positions +Image with multiple captions -- only last one is accepted (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]] +!! result +<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 width attribute at different positions (php) +!! options +php !! input -[[Image:foobar.jpg|200px|right|Caption]] -[[Image:foobar.jpg|right|200px|Caption]] -[[Image:foobar.jpg|right|Caption|200px]] +[[File:Foobar.jpg|200px|right|Caption]] +[[File:Foobar.jpg|right|200px|Caption]] +[[File:Foobar.jpg|right|Caption|200px]] !! result <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> @@ -6825,23 +9429,84 @@ Image with width attribute at different positions !! end !! test -Image with link parameter, wiki target +Image with width attribute at different positions (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|200px|right|Caption]] +[[File:Foobar.jpg|right|200px|Caption]] +[[File:Foobar.jpg|right|Caption|200px]] +!! result +<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 + +!! test +Image with link parameter, wiki target (php) +!! options +php !! input -[[Image:foobar.jpg|link=Target page]] +[[File:Foobar.jpg|link=Main Page]] !! result -<p><a href="/wiki/Target_page" title="Target page"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +<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> !! end !! test -Image with link parameter, URL target +Image with link parameter, wiki target (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|link=Main Page]] +!! result +<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 + +!! test +Image with link parameter, URL target (php) +!! options +php !! input -[[Image:foobar.jpg|link=http://example.com/]] +[[File:Foobar.jpg|link=http://example.com/]] !! result <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> !! end +# parsoid bug 49293 (part 1) +!! test +Image with link parameter, URL target (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|link=http://example.com/]] +!! result +<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 + +!! test +Image with link parameter, protocol-less URL target (php) +!! options +php +!! input +[[File:Foobar.jpg|link=//example.com/]] +!! result +<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> +!! end + +# parsoid bug 49293 (part 2) +!! test +Image with link parameter, protocol-less URL target (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|link=//example.com/]] +!! result +<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 !! input @@ -6887,34 +9552,72 @@ wgExternalLinkTarget='foobar' !! end !! test -Image with empty link parameter +Image with empty link parameter (php) +!! options +php !! input -[[Image:foobar.jpg|link=]] +[[File:Foobar.jpg|link=]] !! result <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /> </p> !! end !! test -Image with link parameter (wiki target) and unnamed parameter +Image with empty link parameter (parsoid) +!! options +parsoid !! input -[[Image:foobar.jpg|link=Target page|Title]] +[[File:Foobar.jpg|link=]] !! result -<p><a href="/wiki/Target_page" title="Title"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +<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 (php) +!! options +php +!! input +[[File:Foobar.jpg|link=Main Page|Title]] +!! result +<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> !! end !! test -Image with link parameter (URL target) and unnamed parameter +Image with link parameter (wiki target) and unnamed parameter (parsoid) +!! options +parsoid !! input -[[Image:foobar.jpg|link=http://example.com/|Title]] +[[File:Foobar.jpg|link=Main Page|Title]] +!! result +<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 (php) +!! options +php +!! input +[[File:Foobar.jpg|link=http://example.com/|Title]] !! result <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> !! end !! test +Image with link parameter (URL target) and unnamed parameter (parsoid) +!! options +parsoid +!! input +[[File:Foobar.jpg|link=http://example.com/|Title]] +!! result +<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 +php !! input [[Image:foobar.jpg|thumb|link=http://example.com/|Title]] !! result @@ -6923,6 +9626,61 @@ Thumbnail image with link parameter !! end !! test +Manually-specified thumbnail image +!! options +php +!! input +[[Image:Foobar.jpg|thumb=Thumb.png|Title]] +!! result +<div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/File:Foobar.jpg"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div> + +!! end + +!! test +Manually-specified thumbnail image with explicit link to wiki page +!! options +php +!! input +[[Image:Foobar.jpg|thumb=Thumb.png|link=Main Page|Title]] +!! result +<div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/Main_Page" title="Main Page"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div> + +!! end + +!! test +Manually-specified thumbnail image with explicit link to url +!! options +php +!! input +[[Image:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]] +!! result +<div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="http://example.com"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div> + +!! end + +!! test +Manually-specified thumbnail image with explicit no link +!! options +php +!! input +[[Image:Foobar.jpg|thumb=Thumb.png|link=|Title]] +!! result +<div class="thumb tright"><div class="thumbinner" style="width:137px;"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div> + +!! end + +!! test +Manually-specified thumbnail image with explicit link and alt text +!! options +php +!! input +[[Image:Foobar.jpg|thumb=Thumb.png|link=Main Page|alt=alttext|Title]] +!! result +<div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/Main_Page" title="Main Page"><img alt="alttext" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div> + +!! end + +!! test Image with frame and link !! input [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]] @@ -7006,6 +9764,36 @@ Thumbnail image caption with a free URL and explicit alt !! end !! test +SVG thumbnails with no language set +!! options +!! input +[[File:Foobar.svg|thumb|width=200]] +!! result +<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="180" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>width=200</div></div></div> + +!! end + +!! test +SVG thumbnails with language de +!! options +!! input +[[File:Foobar.svg|thumb|width=200|lang=de]] +!! result +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=File:Foobar.svg&lang=de" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/langde-180px-Foobar.svg.png" width="180" height="180" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/langde-270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/langde-360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>width=200</div></div></div> + +!! end + +!! test +SVG thumbnails with invalid language code +!! options +!! input +[[File:Foobar.svg|thumb|width=200|lang=invalid.language.code]] +!! result +<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="180" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>lang=invalid.language.code</div></div></div> + +!! end + +!! test BUG 1887: A ISBN with a thumbnail !! input [[Image:foobar.jpg|thumb|ISBN 1235467890]] @@ -7200,6 +9988,152 @@ wgEnableUploads=0 </p> !! end +# Parsoid-specific testing for images +# http://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images +# Currently imperfect due to a flaw in the Parsoid testrunner +# Work in progress +# THESE TESTS SHOULD BE MOVED UP and merged with the php-specific +# image tests. + +!! test +Parsoid-specific image handling - simple image with size and middle alignment +!! options +parsoid +!! input +[[Image:Foobar.jpg|50px|middle]] +!! result +<p> +<span class="mw-valign-middle" typeof="mw:Image"> +<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"> +</a> +</span> +</p> +!! end + +!! test +Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption +!! options +parsoid +!! input +[[Image:Foobar.jpg|500x10px|baseline|caption]] +!! result +<p> +<span class="mw-valign-baseline" typeof="mw:Image" data-mw="{"caption":"caption"}"> +<a href="File:Foobar.jpg"> +<img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/89px-Foobar.jpg" height="10" width="89"> +</a> +</span> +</p> +!! end + +!! test +Parsoid-specific image handling - simple image with border and size spec +!! options +parsoid +!! input +[[Image:Foobar.jpg|50px|border|caption]] +!! result +<p> +<span class="mw-image-border" typeof="mw:Image" data-mw="{"caption":"caption"}"> +<a href="File:Foobar.jpg"> +<img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" height="6" width="50"> +</a> +</span> +</p> +!! end + +!! test +Parsoid-specific image handling - thumbnail with halign, valign, and caption +!! options +parsoid +!! input +[[Image:Foobar.jpg|thumb|left|baseline|caption content]] +!! result +<figure class="mw-default-size mw-halign-left mw-valign-baseline" 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="21" width="180" /> +</a> +<figcaption>caption content</figcaption> +</figure> +!! end + +!! test +Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption +!! options +parsoid +!! input +[[Image:Foobar.jpg|thumb|50x50px|right|middle|caption]] +!! result +<figure class="mw-halign-right mw-valign-middle" typeof="mw:Image/Thumb"> +<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" /> +</a> +<figcaption>caption</figcaption> +</figure> +!! end + +!! test +Parsoid-specific image handling - framed image with specific size and caption +!! options +parsoid +!! input +[[Image:Foobar.jpg|500x50px|frame|caption]] +!! result +<figure typeof="mw:Image/Frame"> +<a href="File:Foobar.jpg"> +<img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/442px-Foobar.jpg" height="50" width="442" /> +</a> +<figcaption>caption</figcaption> +</figure> +!! end + +!! test +Parsoid-specific image handling - framed image with specific size, halign, valign, and caption +!! options +parsoid +!! input +[[Image:Foobar.jpg|500x50px|frame|left|baseline|caption]] +!! result +<figure class="mw-halign-left mw-valign-baseline" typeof="mw:Image/Frame"> +<a href="File:Foobar.jpg"> +<img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/442px-Foobar.jpg" height="50" width="442" /> +</a> +<figcaption>caption</figcaption> +</figure> +!! end + +!! test +Parsoid-specific image handling - frameless image with specific size, border, and caption +!! options +parsoid +!! input +[[Image:Foobar.jpg|frameless|500x50px|border|caption]] +!! result +<p> +<span class="mw-image-border" typeof="mw:Image/Frameless" data-mw="{"caption":"caption"}"> +<a href="File:Foobar.jpg"> +<img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/442px-Foobar.jpg" height="50" width="442" /> +</a> +</p> +!! end + +#!! test +#Parsoid-specific image handling - simple image with a formatted caption +#!! options +#parsoid +#!! input +#[[Image:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]] +#!! result +#<p> +#<span typeof="mw:Image"> +#<a class="mw-default-size" href="Image:Foobar.jpg"> +#<img alt="Foobar.jpg" class="mw-default-size" src="http://example.com/images/3/3a/Foobar.jpg" height="220" width="1941"> +#</a> +#<span>abc</span> +#</span> +#</p> + ### ### Subpages @@ -7232,6 +10166,38 @@ subpage title=[[Subpage test]] </p> !! end +# TODO: make this PHP-parser compatible! +!! test +Relative subpage noslash link +!! options +parsoid=wt2wt,wt2html,html2html +subpage title=[[Subpage test/1/2/3/4]] +!!input +[[../../subpage/]] + +[[../../subpage]] +!! result +<p><a rel="mw:WikiLink" href="Subpage_test/1/2/subpage/">subpage</a></p> +<p><a rel="mw:WikiLink" href="Subpage_test/1/2/subpage">Subpage_test/1/2/subpage</a></p> +!! end + +# TODO: make this PHP-parser compatible! +!! test +Parsoid: dot-slash prefixed wikilinks +!! options +parsoid=wt2wt,wt2html,html2html +!!input +[[./foo]] + +[[././bar]] + +[[././baz/]] +!! result +<p><a rel="mw:WikiLink" href="./Foo">foo</a></p> +<p><a rel="mw:WikiLink" href="./Bar">bar</a></p> +<p><a rel="mw:WikiLink" href="./Baz/">baz/</a></p> +!! end + !! test Disabled subpages !! input @@ -7415,6 +10381,59 @@ Bar </p> !! end +!! test +Parsoid: Serialize link to category page with colon escape +!! options +parsoid +!! input + +[[:Category:Foo]] +[[:Category:Foo|Bar]] +!! result +<p> +<a rel="mw:WikiLink" href="Category:Foo">Category:Foo</a> +<a rel="mw:WikiLink" href="Category:Foo">Bar</a> +</p> +!! end + +!! test +Parsoid: Link prefix/suffixes aren't applied to category links +!! options +parsoid=wt2html,wt2wt,html2html +language=is +!! input +x[[Category:Foo]]y +!! result +<p>x<link rel="mw:WikiLink/Category" href="Category:Foo">y</p> +!! end + +!! test +Parsoid: Serialize link to file page with colon escape +!! options +parsoid +!! input + +[[:File:Foo.png]] +[[:File:Foo.png|Bar]] +!! result +<p> +<a rel="mw:WikiLink" href="File:Foo.png">File:Foo.png</a> +<a rel="mw:WikiLink" href="File:Foo.png">Bar</a> +</p> +!! end + +!! test +Parsoid: Serialize a genuine category link without colon escape +!! options +parsoid +!! input +[[Category:Foo]] +[[Category:Foo|Bar]] +!! result +<link rel="mw:WikiLink/Category" href="Category:Foo"> +<link rel="mw:WikiLink/Category" href="Category:Foo#Bar"> +!! end + ### ### Inter-language links ### @@ -7457,13 +10476,13 @@ More ===Smaller headline=== Blah blah !! result -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Headline 1">edit</a>]</span> <span class="mw-headline" id="Headline_1"> Headline 1 </span></h2> +<h2><span class="mw-headline" id="Headline_1">Headline 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Headline 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> <p>Some text </p> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Headline 2">edit</a>]</span> <span class="mw-headline" id="Headline_2">Headline 2</span></h2> +<h2><span class="mw-headline" id="Headline_2">Headline 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> <p>More </p> -<h3><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Smaller headline">edit</a>]</span> <span class="mw-headline" id="Smaller_headline">Smaller headline</span></h3> +<h3><span class="mw-headline" id="Smaller_headline">Smaller headline</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Smaller headline">edit</a><span class="mw-editsection-bracket">]</span></span></h3> <p>Blah blah </p> !! end @@ -7480,7 +10499,7 @@ Section headings with TOC Some text ===Another headline=== !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a> <ul> @@ -7501,15 +10520,16 @@ Some text </ul> </li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Headline 1">edit</a>]</span> <span class="mw-headline" id="Headline_1"> Headline 1 </span></h2> -<h3><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Subheadline 1">edit</a>]</span> <span class="mw-headline" id="Subheadline_1"> Subheadline 1 </span></h3> -<h5><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Skipping a level">edit</a>]</span> <span class="mw-headline" id="Skipping_a_level"> Skipping a level </span></h5> -<h6><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Skipping a level">edit</a>]</span> <span class="mw-headline" id="Skipping_a_level_2"> Skipping a level </span></h6> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Headline 2">edit</a>]</span> <span class="mw-headline" id="Headline_2"> Headline 2 </span></h2> +</div> + +<h2><span class="mw-headline" id="Headline_1">Headline 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Headline 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="Subheadline_1">Subheadline 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Subheadline 1">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h5><span class="mw-headline" id="Skipping_a_level">Skipping a level</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Skipping a level">edit</a><span class="mw-editsection-bracket">]</span></span></h5> +<h6><span class="mw-headline" id="Skipping_a_level_2">Skipping a level</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Skipping a level">edit</a><span class="mw-editsection-bracket">]</span></span></h6> +<h2><span class="mw-headline" id="Headline_2">Headline 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> <p>Some text </p> -<h3><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: Another headline">edit</a>]</span> <span class="mw-headline" id="Another_headline">Another headline</span></h3> +<h3><span class="mw-headline" id="Another_headline">Another headline</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: Another headline">edit</a><span class="mw-editsection-bracket">]</span></span></h3> !! end @@ -7528,7 +10548,7 @@ Handling of sections up to level 6 and beyond ========= Level 9 Heading========= ========== Level 10 Heading========== !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a> <ul> @@ -7556,17 +10576,18 @@ Handling of sections up to level 6 and beyond </ul> </li> </ul> -</td></tr></table> -<h1><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Level 1 Heading">edit</a>]</span> <span class="mw-headline" id="Level_1_Heading"> Level 1 Heading</span></h1> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Level 2 Heading">edit</a>]</span> <span class="mw-headline" id="Level_2_Heading"> Level 2 Heading</span></h2> -<h3><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Level 3 Heading">edit</a>]</span> <span class="mw-headline" id="Level_3_Heading"> Level 3 Heading</span></h3> -<h4><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Level 4 Heading">edit</a>]</span> <span class="mw-headline" id="Level_4_Heading"> Level 4 Heading</span></h4> -<h5><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Level 5 Heading">edit</a>]</span> <span class="mw-headline" id="Level_5_Heading"> Level 5 Heading</span></h5> -<h6><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: Level 6 Heading">edit</a>]</span> <span class="mw-headline" id="Level_6_Heading"> Level 6 Heading</span></h6> -<h6><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=7" title="Edit section: = Level 7 Heading=">edit</a>]</span> <span class="mw-headline" id=".3D_Level_7_Heading.3D">= Level 7 Heading=</span></h6> -<h6><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=8" title="Edit section: == Level 8 Heading==">edit</a>]</span> <span class="mw-headline" id=".3D.3D_Level_8_Heading.3D.3D">== Level 8 Heading==</span></h6> -<h6><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=9" title="Edit section: === Level 9 Heading===">edit</a>]</span> <span class="mw-headline" id=".3D.3D.3D_Level_9_Heading.3D.3D.3D">=== Level 9 Heading===</span></h6> -<h6><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=10" title="Edit section: ==== Level 10 Heading====">edit</a>]</span> <span class="mw-headline" id=".3D.3D.3D.3D_Level_10_Heading.3D.3D.3D.3D">==== Level 10 Heading====</span></h6> +</div> + +<h1><span class="mw-headline" id="Level_1_Heading">Level 1 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Level 1 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<h2><span class="mw-headline" id="Level_2_Heading">Level 2 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Level 2 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="Level_3_Heading">Level 3 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Level 3 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h4><span class="mw-headline" id="Level_4_Heading">Level 4 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Level 4 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h4> +<h5><span class="mw-headline" id="Level_5_Heading">Level 5 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Level 5 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h5> +<h6><span class="mw-headline" id="Level_6_Heading">Level 6 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: Level 6 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h6> +<h6><span class="mw-headline" id=".3D_Level_7_Heading.3D">= Level 7 Heading=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=7" title="Edit section: = Level 7 Heading=">edit</a><span class="mw-editsection-bracket">]</span></span></h6> +<h6><span class="mw-headline" id=".3D.3D_Level_8_Heading.3D.3D">== Level 8 Heading==</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=8" title="Edit section: == Level 8 Heading==">edit</a><span class="mw-editsection-bracket">]</span></span></h6> +<h6><span class="mw-headline" id=".3D.3D.3D_Level_9_Heading.3D.3D.3D">=== Level 9 Heading===</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=9" title="Edit section: === Level 9 Heading===">edit</a><span class="mw-editsection-bracket">]</span></span></h6> +<h6><span class="mw-headline" id=".3D.3D.3D.3D_Level_10_Heading.3D.3D.3D.3D">==== Level 10 Heading====</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=10" title="Edit section: ==== Level 10 Heading====">edit</a><span class="mw-editsection-bracket">]</span></span></h6> !! end @@ -7580,7 +10601,7 @@ TOC regression (bug 9764) == title 2 == === title 2.1 === !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a> <ul> @@ -7598,13 +10619,14 @@ TOC regression (bug 9764) </ul> </li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: title 1">edit</a>]</span> <span class="mw-headline" id="title_1"> title 1 </span></h2> -<h3><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: title 1.1">edit</a>]</span> <span class="mw-headline" id="title_1.1"> title 1.1 </span></h3> -<h4><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: title 1.1.1">edit</a>]</span> <span class="mw-headline" id="title_1.1.1"> title 1.1.1 </span></h4> -<h3><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: title 1.2">edit</a>]</span> <span class="mw-headline" id="title_1.2"> title 1.2 </span></h3> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: title 2">edit</a>]</span> <span class="mw-headline" id="title_2"> title 2 </span></h2> -<h3><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: title 2.1">edit</a>]</span> <span class="mw-headline" id="title_2.1"> title 2.1 </span></h3> +</div> + +<h2><span class="mw-headline" id="title_1">title 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: title 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="title_1.1">title 1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: title 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h4><span class="mw-headline" id="title_1.1.1">title 1.1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: title 1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4> +<h3><span class="mw-headline" id="title_1.2">title 1.2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: title 1.2">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h2><span class="mw-headline" id="title_2">title 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: title 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="title_2.1">title 2.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: title 2.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3> !! end @@ -7620,7 +10642,7 @@ wgMaxTocLevel=3 == title 2 == === title 2.1 === !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a> <ul> @@ -7634,13 +10656,14 @@ wgMaxTocLevel=3 </ul> </li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: title 1">edit</a>]</span> <span class="mw-headline" id="title_1"> title 1 </span></h2> -<h3><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: title 1.1">edit</a>]</span> <span class="mw-headline" id="title_1.1"> title 1.1 </span></h3> -<h4><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: title 1.1.1">edit</a>]</span> <span class="mw-headline" id="title_1.1.1"> title 1.1.1 </span></h4> -<h3><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: title 1.2">edit</a>]</span> <span class="mw-headline" id="title_1.2"> title 1.2 </span></h3> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: title 2">edit</a>]</span> <span class="mw-headline" id="title_2"> title 2 </span></h2> -<h3><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: title 2.1">edit</a>]</span> <span class="mw-headline" id="title_2.1"> title 2.1 </span></h3> +</div> + +<h2><span class="mw-headline" id="title_1">title 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: title 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="title_1.1">title 1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: title 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h4><span class="mw-headline" id="title_1.1.1">title 1.1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: title 1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4> +<h3><span class="mw-headline" id="title_1.2">title 1.2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: title 1.2">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h2><span class="mw-headline" id="title_2">title 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: title 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="title_2.1">title 2.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: title 2.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3> !! end @@ -7655,7 +10678,7 @@ wgMaxTocLevel=3 ====Section 1.1.1.1==== ==Section 2== !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a> <ul> @@ -7664,12 +10687,13 @@ wgMaxTocLevel=3 </li> <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Section 1">edit</a>]</span> <span class="mw-headline" id="Section_1">Section 1</span></h2> -<h3><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Section 1.1">edit</a>]</span> <span class="mw-headline" id="Section_1.1">Section 1.1</span></h3> -<h4><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Section 1.1.1">edit</a>]</span> <span class="mw-headline" id="Section_1.1.1">Section 1.1.1</span></h4> -<h4><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Section 1.1.1.1">edit</a>]</span> <span class="mw-headline" id="Section_1.1.1.1">Section 1.1.1.1</span></h4> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Section 2">edit</a>]</span> <span class="mw-headline" id="Section_2">Section 2</span></h2> +</div> + +<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&action=edit&section=1" title="Edit section: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="Section_1.1">Section 1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Section 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h4><span class="mw-headline" id="Section_1.1.1">Section 1.1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Section 1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4> +<h4><span class="mw-headline" id="Section_1.1.1.1">Section 1.1.1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Section 1.1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4> +<h2><span class="mw-headline" id="Section_2">Section 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Section 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -7680,8 +10704,8 @@ Resolving duplicate section names == Foo bar == == Foo bar == !! result -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo bar">edit</a>]</span> <span class="mw-headline" id="Foo_bar"> Foo bar </span></h2> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Foo bar">edit</a>]</span> <span class="mw-headline" id="Foo_bar_2"> Foo bar </span></h2> +<h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Foo_bar_2">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -7691,8 +10715,8 @@ Resolving duplicate section names with differing case (bug 10721) == Foo bar == == Foo Bar == !! result -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo bar">edit</a>]</span> <span class="mw-headline" id="Foo_bar"> Foo bar </span></h2> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Foo Bar">edit</a>]</span> <span class="mw-headline" id="Foo_Bar_2"> Foo Bar </span></h2> +<h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Foo_Bar_2">Foo Bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -7711,10 +10735,10 @@ __NOTOC__ {{sections}} ==Section 4== !! result -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Section 0">edit</a>]</span> <span class="mw-headline" id="Section_0">Section 0</span></h2> -<h3><span class="editsection">[<a href="/index.php?title=Template:Sections&action=edit&section=T-1" title="Template:Sections">edit</a>]</span> <span class="mw-headline" id="Section_1">Section 1</span></h3> -<h2><span class="editsection">[<a href="/index.php?title=Template:Sections&action=edit&section=T-2" title="Template:Sections">edit</a>]</span> <span class="mw-headline" id="Section_2">Section 2</span></h2> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Section 4">edit</a>]</span> <span class="mw-headline" id="Section_4">Section 4</span></h2> +<h2><span class="mw-headline" id="Section_0">Section 0</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Section 0">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><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=Template:Sections&action=edit&section=T-1" title="Template:Sections">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h2><span class="mw-headline" id="Section_2">Section 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Sections&action=edit&section=T-2" title="Template:Sections">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Section_4">Section 4</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Section 4">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -7725,8 +10749,8 @@ __NOEDITSECTION__ ==Section 1== ==Section 2== !! result -<h2> <span class="mw-headline" id="Section_1">Section 1</span></h2> -<h2> <span class="mw-headline" id="Section_2">Section 2</span></h2> +<h2><span class="mw-headline" id="Section_1">Section 1</span></h2> +<h2><span class="mw-headline" id="Section_2">Section 2</span></h2> !! end @@ -7735,7 +10759,7 @@ Link inside a section heading !! input ==Section with a [[Main Page|link]] in it== !! result -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Section with a link in it">edit</a>]</span> <span class="mw-headline" id="Section_with_a_link_in_it">Section with a <a href="/wiki/Main_Page" title="Main Page">link</a> in it</span></h2> +<h2><span class="mw-headline" id="Section_with_a_link_in_it">Section with a <a href="/wiki/Main_Page" title="Main Page">link</a> in it</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Section with a link in it">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -7747,7 +10771,7 @@ __TOC__ === title 1.1 === == title 2 == !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a> <ul> @@ -7756,10 +10780,11 @@ __TOC__ </li> <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: title 1">edit</a>]</span> <span class="mw-headline" id="title_1"> title 1 </span></h2> -<h3><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: title 1.1">edit</a>]</span> <span class="mw-headline" id="title_1.1"> title 1.1 </span></h3> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: title 2">edit</a>]</span> <span class="mw-headline" id="title_2"> title 2 </span></h2> +</div> + +<h2><span class="mw-headline" id="title_1">title 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: title 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="title_1.1">title 1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: title 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h2><span class="mw-headline" id="title_2">title 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: title 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -7781,10 +10806,10 @@ The line above must have a trailing space! --> <!-- --> But just in case it doesn't... !! result -<h1><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: =">edit</a>]</span> <span class="mw-headline" id=".3D">=</span></h1> +<h1><span class="mw-headline" id=".3D">=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: =">edit</a><span class="mw-editsection-bracket">]</span></span></h1> <p>The line above must have a trailing space! </p> -<h1><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: =">edit</a>]</span> <span class="mw-headline" id=".3D_2">=</span></h1> +<h1><span class="mw-headline" id=".3D_2">=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: =">edit</a><span class="mw-editsection-bracket">]</span></span></h1> <p>But just in case it doesn't... </p> !! end @@ -7811,7 +10836,7 @@ section 5 !! result <p>The tooltips shall not show entities to the user (ie. be double escaped) </p> -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#text_.3E_text"><span class="tocnumber">1</span> <span class="toctext">text > text</span></a></li> <li class="toclevel-1 tocsection-2"><a href="#text_.3C_text"><span class="tocnumber">2</span> <span class="toctext">text < text</span></a></li> @@ -7819,20 +10844,21 @@ section 5 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li> <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: text > text">edit</a>]</span> <span class="mw-headline" id="text_.3E_text"> text > text </span></h2> +</div> + +<h2><span class="mw-headline" id="text_.3E_text">text > text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: text > text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> <p>section 1 </p> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: text < text">edit</a>]</span> <span class="mw-headline" id="text_.3C_text"> text < text </span></h2> +<h2><span class="mw-headline" id="text_.3C_text">text < text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: text < text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> <p>section 2 </p> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: text & text">edit</a>]</span> <span class="mw-headline" id="text_.26_text"> text & text </span></h2> +<h2><span class="mw-headline" id="text_.26_text">text & text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: text & text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> <p>section 3 </p> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: text ' text">edit</a>]</span> <span class="mw-headline" id="text_.27_text"> text ' text </span></h2> +<h2><span class="mw-headline" id="text_.27_text">text ' text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: text ' text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> <p>section 4 </p> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: text " text">edit</a>]</span> <span class="mw-headline" id="text_.22_text"> text " text </span></h2> +<h2><span class="mw-headline" id="text_.22_text">text " text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: text " text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> <p>section 5 </p> !! end @@ -7846,18 +10872,59 @@ Headers with excess '=' characters =''italic'' heading== ==''italic'' heading= !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li> <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li> <li class="toclevel-1 tocsection-3"><a href="#italic_heading.3D"><span class="tocnumber">3</span> <span class="toctext"><i>italic</i> heading=</span></a></li> <li class="toclevel-1 tocsection-4"><a href="#.3Ditalic_heading"><span class="tocnumber">4</span> <span class="toctext">=<i>italic</i> heading</span></a></li> </ul> -</td></tr></table> -<h1><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: foo=">edit</a>]</span> <span class="mw-headline" id="foo.3D">foo=</span></h1> -<h1><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: =foo">edit</a>]</span> <span class="mw-headline" id=".3Dfoo">=foo</span></h1> -<h1><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: italic heading=">edit</a>]</span> <span class="mw-headline" id="italic_heading.3D"><i>italic</i> heading=</span></h1> -<h1><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: =italic heading">edit</a>]</span> <span class="mw-headline" id=".3Ditalic_heading">=<i>italic</i> heading</span></h1> +</div> + +<h1><span class="mw-headline" id="foo.3D">foo=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: foo=">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<h1><span class="mw-headline" id=".3Dfoo">=foo</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: =foo">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<h1><span class="mw-headline" id="italic_heading.3D"><i>italic</i> heading=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: italic heading=">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<h1><span class="mw-headline" id=".3Ditalic_heading">=<i>italic</i> heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: =italic heading">edit</a><span class="mw-editsection-bracket">]</span></span></h1> + +!! end + +!! test +HTML headers vs TOC (bug 23393) +(__NOEDITSECTION__ for clearer output, doesn't matter here) +!! input +<h1>Header 1</h1> +== Header 1.1 == +== Header 1.2 == + +<h1>Header 2 +</h1> +== Header 2.1 == +== Header 2.2 == +__NOEDITSECTION__ +!! result +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a> +<ul> +<li class="toclevel-2 tocsection-1"><a href="#Header_1.1"><span class="tocnumber">1.1</span> <span class="toctext">Header 1.1</span></a></li> +<li class="toclevel-2 tocsection-2"><a href="#Header_1.2"><span class="tocnumber">1.2</span> <span class="toctext">Header 1.2</span></a></li> +</ul> +</li> +<li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a> +<ul> +<li class="toclevel-2 tocsection-3"><a href="#Header_2.1"><span class="tocnumber">2.1</span> <span class="toctext">Header 2.1</span></a></li> +<li class="toclevel-2 tocsection-4"><a href="#Header_2.2"><span class="tocnumber">2.2</span> <span class="toctext">Header 2.2</span></a></li> +</ul> +</li> +</ul> +</div> + +<h1><span class="mw-headline" id="Header_1">Header 1</span></h1> +<h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2> +<h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2> +<h1><span class="mw-headline" id="Header_2">Header 2</span></h1> +<h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2> +<h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2> !! end @@ -7953,7 +11020,7 @@ div with illegal double attributes !! test div with empty attribute value, space before equals !! options -disabled +parsoid !! input <div class =>HTML rocks</div> !! result @@ -7966,7 +11033,7 @@ disabled !! test div with braces in attribute value !! options -disabled +parsoid !! input <div title="{}">Foo</div> !! result @@ -7983,7 +11050,7 @@ disabled !! test div with empty attribute value, no space before equals !! options -disabled +parsoid !! input <div class=>HTML rocks</div> !! result @@ -8079,6 +11146,81 @@ I always thought &xacute; was a cute letter. ### +### Nesting tests (see bug 41545, 50604, 51081) +### + +# This test case is fixed in Parsoid by domino 1.0.12. (bug 50604) +# Note that html2wt is considerably more difficult if we use <b> in +# the test case, instead of <big> +!! test +Ensure that HTML adoption agency algorithm is properly implemented. +!! input +<big>X<big>Y</big>Z</big> +!! result +<p><big>X<big>Y</big>Z</big> +</p> +!! end + +# This was bug 41545 in the PHP parser. +!! test +Nesting of <kbd> +!! input +<kbd>X<kbd>Y</kbd>Z</kbd> +!! result +<p><kbd>X<kbd>Y</kbd>Z</kbd> +</p> +!! end + +# The following cases were bug 51081 in the PHP parser. +# Note that there are some other nestable tags (b, i, etc) which are +# not covered; see bug 51081 for discussion. +!! test +Nesting of <em> +!! input +<em>X<em>Y</em>Z</em> +!! result +<p><em>X<em>Y</em>Z</em> +</p> +!! end + +!! test +Nesting of <strong> +!! input +<strong>X<strong>Y</strong>Z</strong> +!! result +<p><strong>X<strong>Y</strong>Z</strong> +</p> +!! end + +!! test +Nesting of <q> +!! input +<q>X<q>Y</q>Z</q> +!! result +<p><q>X<q>Y</q>Z</q> +</p> +!! end + +!! test +Nesting of <ruby> +!! input +<ruby>X<ruby>Y</ruby>Z</ruby> +!! result +<p><ruby>X<ruby>Y</ruby>Z</ruby> +</p> +!! end + +!! test +Nesting of <bdo> +!! input +<bdo>X<bdo>Y</bdo>Z</bdo> +!! result +<p><bdo>X<bdo>Y</bdo>Z</bdo> +</p> +!! end + + +### ### Media links ### @@ -8470,70 +11612,6 @@ MSIE CSS safety test: comment in expression !! end -!! test -CSS safety test: vertical tab -!! input -<p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p> -!! result -<p style="/* invalid control char */">A</p> - -!! end - -!! test -MSIE CSS safety test: Fullwidth -!! input -<p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p> -<div style="top:EXPRESSION(alert())">B</div> -!! result -<p style="/* insecure input */">A</p> -<div style="/* insecure input */">B</div> - -!! end - -!! test -MSIE CSS safety test: IPA extensions -!! input -<div style="background-image:uʀʟ(javascript:alert())">A</div> -<p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p> -!! result -<div style="/* insecure input */">A</div> -<p style="/* insecure input */">B</p> - -!! end - -!! test -MSIE CSS safety test: sup/sub script -!! input -<div style="background-image:url⁽javascript:alert())">A</div> -<div style="background-image:url₍javascript:alert())">B</div> -<p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p> -!! result -<div style="/* insecure input */">A</div> -<div style="/* insecure input */">B</div> -<p style="/* insecure input */">C</p> - -!! end - -!! test -MSIE CSS safety test: Repetition markers -!! input -<p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p> -<p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p> -<p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p> -<p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p> -<p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p> -<p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p> -<p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p> -!! result -<p style="/* insecure input */">A</p> -<p style="/* insecure input */">B</p> -<p style="/* insecure input */">C</p> -<p style="/* insecure input */">D</p> -<p style="/* insecure input */">E</p> -<p style="/* insecure input */">F</p> -<p style="/* insecure input */">G</p> - -!! end !! test Table attribute legitimate extension @@ -8617,7 +11695,7 @@ Expansion of multi-line templates in attribute values (bug 6255 sanity check 2) !! end ### -### Parser hooks (see maintenance/parserTestsParserHook.php for the <tag> extension) +### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension) ### !! test Parser hook: empty input @@ -8782,7 +11860,7 @@ array ( !! end ### -### (see maintenance/parserTestsStaticParserHook.php for the <statictag> extension) +### (see tests/parser/parserTestsParserHook.php for the <statictag> extension) ### !! test @@ -9014,8 +12092,10 @@ disabled !! result <ul> <li>One -</li><li>Two -</li></ul> +</li> +<li>Two +</li> +</ul> !! end @@ -9046,8 +12126,10 @@ disabled !! result <ol> <li>One -</li><li>Two -</li></ol> +</li> +<li>Two +</li> +</ol> !! end @@ -9092,12 +12174,16 @@ disabled !! result <ul> <li>One -</li><li>Two: +</li> +<li>Two: <ul> <li>Sub-one -</li><li>Sub-two -</li></ul> -</li></ul> +</li> +<li>Sub-two +</li> +</ul> +</li> +</ul> !! end @@ -9142,21 +12228,27 @@ disabled !! result <ol> <li>One -</li><li>Two: +</li> +<li>Two: <ol> <li>Sub-one -</li><li>Sub-two -</li></ol> -</li></ol> +</li> +<li>Sub-two +</li> +</ol> +</li> +</ol> !! end !! test HTML ordered list item with parameters oddity !! input -<ol><li id="fragment">One</li></ol> +<ol><li id="fragment">One</li> +</ol> !! result -<ol><li id="fragment">One</li></ol> +<ol><li id="fragment">One</li> +</ol> !! end @@ -9208,12 +12300,13 @@ Fuzz testing: Parser14 == onmouseover= == http://__TOC__ !! result -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: onmouseover=">edit</a>]</span> <span class="mw-headline" id="onmouseover.3D"> onmouseover= </span></h2> -http://<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<h2><span class="mw-headline" id="onmouseover.3D">onmouseover=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: onmouseover=">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +http://<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li> </ul> -</td></tr></table> +</div> + !! end @@ -9223,7 +12316,7 @@ Fuzz testing: Parser14-table ==a== {| STYLE=__TOC__ !! result -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: a">edit</a>]</span> <span class="mw-headline" id="a">a</span></h2> +<h2><span class="mw-headline" id="a">a</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: a">edit</a><span class="mw-editsection-bracket">]</span></span></h2> <table style="__TOC__"> <tr><td></td></tr> </table> @@ -9369,7 +12462,7 @@ Fuzz testing: image with bogus manual thumbnail !!input [[Image:foobar.jpg|thumbnail= ]] !!result -<div class="thumb tright"><div class="thumbinner" style="width:1943px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div> !!end @@ -10380,17 +13473,33 @@ Handling of 
 in URLs !! input **irc://
a !! result -<ul><li><ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a> -</li></ul> -</li></ul> +<ul> +<li><ul> +<li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a> +</li> +</ul> +</li> +</ul> !!end !! test -5 quotes, code coverage +1 line +5 quotes, code coverage +1 line (php) +!! options +php +!! input +''''' +!! result +!! end +# The PHP parser strips the empty tags out for giggles; parsoid doesn't. +!! test +5 quotes, code coverage +1 line (parsoid) +!! options +parsoid !! input ''''' !! result +<p><b><i></i></b></p> !! end !! test @@ -10404,43 +13513,78 @@ Special:Search page linking. !! test Say the magic word +!! options +title=[[Parser test]] !! input * {{PAGENAME}} +* {{PAGENAMEE}} +* {{FULLPAGENAME}} +* {{FULLPAGENAMEE}} * {{BASEPAGENAME}} +* {{BASEPAGENAMEE}} * {{SUBPAGENAME}} * {{SUBPAGENAMEE}} -* {{BASEPAGENAME}} -* {{BASEPAGENAMEE}} +* {{ROOTPAGENAME}} +* {{ROOTPAGENAMEE}} * {{TALKPAGENAME}} * {{TALKPAGENAMEE}} * {{SUBJECTPAGENAME}} * {{SUBJECTPAGENAMEE}} * {{NAMESPACEE}} * {{NAMESPACE}} +* {{NAMESPACENUMBER}} * {{TALKSPACE}} * {{TALKSPACEE}} * {{SUBJECTSPACE}} * {{SUBJECTSPACEE}} * {{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}} !! result -<ul><li> Parser test -</li><li> Parser test -</li><li> Parser test -</li><li> Parser_test -</li><li> Parser test -</li><li> Parser_test -</li><li> Talk:Parser test -</li><li> Talk:Parser_test -</li><li> Parser test -</li><li> Parser_test -</li><li> -</li><li> -</li><li> Talk -</li><li> Talk -</li><li> -</li><li> -</li><li> <a href="/index.php?title=Template:Dynamic&action=edit&redlink=1" class="new" title="Template:Dynamic (page does not exist)">Template:Dynamic</a> -</li></ul> +<ul> +<li> Parser test +</li> +<li> Parser_test +</li> +<li> Parser test +</li> +<li> Parser_test +</li> +<li> Parser test +</li> +<li> Parser_test +</li> +<li> Parser test +</li> +<li> Parser_test +</li> +<li> Parser test +</li> +<li> Parser_test +</li> +<li> Talk:Parser test +</li> +<li> Talk:Parser_test +</li> +<li> Parser test +</li> +<li> Parser_test +</li> +<li> +</li> +<li> +</li> +<li> 0 +</li> +<li> Talk +</li> +<li> Talk +</li> +<li> +</li> +<li> +</li> +<li> <a href="/index.php?title=Template:Dynamic&action=edit&redlink=1" class="new" title="Template:Dynamic (page does not exist)">Template:Dynamic</a> +</li> +</ul> !! end ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included. @@ -10459,40 +13603,40 @@ image4 |300px| centre * image6 </gallery> !! result -<ul class="gallery"> +<ul class="gallery mw-gallery-traditional"> <li class="gallerybox" style="width: 155px"><div style="width: 155px"> - <div style="height: 150px;">Image1.png</div> + <div class="thumb" style="height: 150px;">Image1.png</div> <div class="gallerytext"> </div> </div></li> <li class="gallerybox" style="width: 155px"><div style="width: 155px"> - <div style="height: 150px;">Image2.gif</div> + <div class="thumb" style="height: 150px;">Image2.gif</div> <div class="gallerytext"> <p>|||| </p> </div> </div></li> <li class="gallerybox" style="width: 155px"><div style="width: 155px"> - <div style="height: 150px;">Image3</div> + <div class="thumb" style="height: 150px;">Image3</div> <div class="gallerytext"> </div> </div></li> <li class="gallerybox" style="width: 155px"><div style="width: 155px"> - <div style="height: 150px;">Image4</div> + <div class="thumb" style="height: 150px;">Image4</div> <div class="gallerytext"> <p>300px| centre </p> </div> </div></li> <li class="gallerybox" style="width: 155px"><div style="width: 155px"> - <div style="height: 150px;">Image5.svg</div> + <div class="thumb" style="height: 150px;">Image5.svg</div> <div class="gallerytext"> <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a> </p> </div> </div></li> <li class="gallerybox" style="width: 155px"><div style="width: 155px"> - <div style="height: 150px;">* image6</div> + <div class="thumb" style="height: 150px;">* image6</div> <div class="gallerytext"> </div> </div></li> @@ -10511,17 +13655,17 @@ image:foobar.jpg image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla. </gallery> !! result -<ul class="gallery" style="max-width: 226px;_width: 226px;"> +<ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;"> <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li> <li class="gallerybox" style="width: 105px"><div style="width: 105px"> - <div style="height: 70px;">Nonexistant.jpg</div> + <div class="thumb" style="height: 70px;">Nonexistant.jpg</div> <div class="gallerytext"> <p>caption </p> </div> </div></li> <li class="gallerybox" style="width: 105px"><div style="width: 105px"> - <div style="height: 70px;">Nonexistant.jpg</div> + <div class="thumb" style="height: 70px;">Nonexistant.jpg</div> <div class="gallerytext"> </div> </div></li> @@ -10556,7 +13700,7 @@ File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=inneralt]]|alt=galleryalt File:foobar.jpg|{{Test|unamedParam|alt=param}}|alt=galleryalt </gallery> !! result -<ul class="gallery"> +<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="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div> <div class="gallerytext"> @@ -10585,9 +13729,9 @@ image:foobar.jpg|some '''caption''' [[Main Page]] File:Foobar.jpg </gallery> !! result -<ul class="gallery"> +<ul class="gallery mw-gallery-traditional"> <li class="gallerybox" style="width: 155px"><div style="width: 155px"> - <div style="height: 150px;">Nonexistant.jpg</div> + <div class="thumb" style="height: 150px;">Nonexistant.jpg</div> <div class="gallerytext"> <p><a href="/wiki/File:Nonexistant.jpg" title="File:Nonexistant.jpg">Nonexistant.jpg</a><br /> caption @@ -10595,7 +13739,7 @@ caption </div> </div></li> <li class="gallerybox" style="width: 155px"><div style="width: 155px"> - <div style="height: 150px;">Nonexistant.jpg</div> + <div class="thumb" style="height: 150px;">Nonexistant.jpg</div> <div class="gallerytext"> <p><a href="/wiki/File:Nonexistant.jpg" title="File:Nonexistant.jpg">Nonexistant.jpg</a><br /> </p> @@ -10630,14 +13774,14 @@ image:foobar.jpg foobar.jpg </gallery> !! result -<ul class="gallery"> +<ul class="gallery mw-gallery-traditional"> <li class="gallerybox" style="width: 155px"><div style="width: 155px"> - <div style="height: 150px;">Nonexistant.jpg</div> + <div class="thumb" style="height: 150px;">Nonexistant.jpg</div> <div class="gallerytext"> </div> </div></li> <li class="gallerybox" style="width: 155px"><div style="width: 155px"> - <div style="height: 150px;">Nonexistant.jpg</div> + <div class="thumb" style="height: 150px;">Nonexistant.jpg</div> <div class="gallerytext"> </div> </div></li> @@ -10828,13 +13972,25 @@ disabled !! input :;;;:: !! result -<dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd> -</dd></dl> -</dd></dl> -</dt></dl> -</dt></dl> -</dt></dl> -</dd></dl> +<dl> +<dd><dl> +<dt><dl> +<dt><dl> +<dt><dl> +<dd><dl> +<dd> +</dd> +</dl> +</dd> +</dl> +</dt> +</dl> +</dt> +</dl> +</dt> +</dl> +</dd> +</dl> !!end @@ -10861,7 +14017,7 @@ Images with the "|" character in the comment !! test HTML with raw HTML ($wgRawHtml==true) !! options -rawhtml +wgRawHtml=1 !! input <html><script>alert(1);</script></html> !! result @@ -10930,6 +14086,45 @@ subpage title=[[Subpage test/L1/L2/L3]] </p> !! end +!! article +Subpage test/L1/L2/L3Sibling +!! text +Sibling article +!! endarticle + +!! test +Transclusion of a sibling page (one level up) +!! options +subpage title=[[Subpage test/L1/L2/L3]] +!! input +{{../L3Sibling}} +!! result +<p>Sibling article +</p> +!! end + +!! test +Transclusion of a child page +!! options +subpage title=[[Subpage test/L1/L2]] +!! input +{{/L3Sibling}} +!! result +<p>Sibling article +</p> +!! end + +!! test +Non-transclusion because of too many up levels +!! options +subpage title=[[Subpage test/L1/L2/L3]] +!! input +{{../../../../More than parent}} +!! result +<p>{{../../../../More than parent}} +</p> +!! end + !! test Definition list code coverage !! input @@ -10937,10 +14132,17 @@ Definition list code coverage ; title : def ;title: def !! result -<dl><dt> title  </dt><dd> def -</dd><dt> title </dt><dd> def -</dd><dt>title</dt><dd> def -</dd></dl> +<dl> +<dt> title  </dt> +<dd> def +</dd> +<dt> title </dt> +<dd> def +</dd> +<dt>title</dt> +<dd> def +</dd> +</dl> !! end @@ -11004,7 +14206,7 @@ Inclusion of !userCanEdit() content !! input {{MediaWiki:Fake}} !! result -<h2><span class="editsection">[<a href="/index.php?title=MediaWiki:Fake&action=edit&section=T-1" title="MediaWiki:Fake">edit</a>]</span> <span class="mw-headline" id="header">header</span></h2> +<h2><span class="mw-headline" id="header">header</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=MediaWiki:Fake&action=edit&section=T-1" title="MediaWiki:Fake">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -11019,7 +14221,7 @@ Out-of-order TOC heading levels =====5===== ==2== !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a> <ul> @@ -11034,13 +14236,14 @@ Out-of-order TOC heading levels </ul> </li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: 2">edit</a>]</span> <span class="mw-headline" id="2">2</span></h2> -<h6><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: 6">edit</a>]</span> <span class="mw-headline" id="6">6</span></h6> -<h3><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: 3">edit</a>]</span> <span class="mw-headline" id="3">3</span></h3> -<h1><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: 1">edit</a>]</span> <span class="mw-headline" id="1">1</span></h1> -<h5><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: 5">edit</a>]</span> <span class="mw-headline" id="5">5</span></h5> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: 2">edit</a>]</span> <span class="mw-headline" id="2_2">2</span></h2> +</div> + +<h2><span class="mw-headline" id="2">2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h6><span class="mw-headline" id="6">6</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: 6">edit</a><span class="mw-editsection-bracket">]</span></span></h6> +<h3><span class="mw-headline" id="3">3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: 3">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h1><span class="mw-headline" id="1">1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: 1">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<h5><span class="mw-headline" id="5">5</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: 5">edit</a><span class="mw-editsection-bracket">]</span></span></h5> +<h2><span class="mw-headline" id="2_2">2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -11147,14 +14350,11 @@ anchorencode encodes like the TOC generator: (bug 18431) {{anchorencode: _ +:.3A%3A&&]] }} __NOEDITSECTION__ !! result -<h3> <span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D"> _ +:.3A%3A&&]] </span></h3> +<h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&&]]</span></h3> <p>.2B:.3A.253A.26.26.5D.5D </p> !! end -# Expected output in the following test is not necessarily expected (there -# should probably be <p> tags inside the <blockquote> in the output) -- it's -# only testing for well-formedness. !! test Bug 6200: blockquotes and paragraph formatting !! input @@ -11167,7 +14367,8 @@ bar baz !! result <blockquote> -foo +<p>foo +</p> </blockquote> <p>bar </p> @@ -11196,6 +14397,27 @@ bar </pre> !! end +!!test +Parsing of overlapping (improperly nested) inline html tags (PHP parser) +!!options +php +!!input +<span><s>x</span></s> +!!result +<p><span><s>x</span></s></span> +</p> +!!end + +!!test +Parsing of overlapping (improperly nested) inline html tags (Parsoid) +!!options +parsoid +!!input +<span><s>x</span></s> +!!result +<p><span><s>x</s></span><s></s> +</p> +!!end ### ### Language variants related tests @@ -11229,6 +14451,17 @@ title=[[Duna]] language=sr !! end !! test +Link to a section of a variant of this title shouldn't be parsed as self-link +!! options +title=[[Duna]] language=sr +!! input +[[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links. +!! result +<p><strong class="selflink">Dуна</strong> is a self-link while <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dunа#Foo</a> and <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dуна#Foo</a> are not self-links. +</p> +!! end + +!! test Link to pages in language variants !! options language=sr @@ -11377,7 +14610,7 @@ language=sr variant=sr-ec !! input == -{Naslov}- == !! result -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Уредите одељак „Naslov“">уреди</a>]</span> <span class="mw-headline" id="-.7BNaslov.7D-"> Naslov </span></h2> +<h2><span class="mw-headline" id="-.7BNaslov.7D-">Naslov</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Уредите одељак „Naslov“">уреди</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -11491,6 +14724,30 @@ This won't take interferes with the title rule. !! end !! test +Partly disable title conversion if variant == main language code +!! options +language=zh variant=zh title=[[ZH]] showtitle +!! input +-{T|zh-cn:CN;zh-tw:TW}- +!! result +ZH +<p> +</p> +!! end + +!! test +Partly disable title conversion if variant == main language code, more +!! options +language=zh variant=zh title=[[ZH]] showtitle +!! input +-{T|TW}- +!! result +ZH +<p> +</p> +!! end + +!! test Raw output of variant escape tags (R flag) !! options language=zh variant=zh-tw @@ -11568,20 +14825,17 @@ language=sr </p> !!end -!!article -Template:Bullet -!!text -* Bar -!!endarticle - !! test Bug 529: Uncovered bullet !! input * Foo {{bullet}} !! result -<ul><li> Foo -</li><li> Bar -</li></ul> +<ul> +<li> Foo +</li> +<li> Bar +</li> +</ul> !! end @@ -11596,15 +14850,30 @@ Bug 529: Uncovered bullet leaving empty list, normally removed by tidy !! input ******* Foo {{bullet}} !! result -<ul><li><ul><li><ul><li><ul><li><ul><li><ul><li><ul><li> Foo -</li></ul> -</li></ul> -</li></ul> -</li></ul> -</li></ul> -</li></ul> -</li><li> Bar -</li></ul> +<ul> +<li><ul> +<li><ul> +<li><ul> +<li><ul> +<li><ul> +<li><ul> +<li> Foo +</li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li> Bar +</li> +</ul> !! end @@ -11636,9 +14905,12 @@ Bug 529: Uncovered bullet in parser function result !! input * Foo {{lc:{{bullet}} }} !! result -<ul><li> Foo -</li><li> bar -</li></ul> +<ul> +<li> Foo +</li> +<li> bar +</li> +</ul> !! end @@ -11694,7 +14966,7 @@ Morwen/13: Unclosed link followed by heading !! result <p>[[link </p> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: heading">edit</a>]</span> <span class="mw-headline" id="heading">heading</span></h2> +<h2><span class="mw-headline" id="heading">heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -11706,7 +14978,7 @@ HHP2.1: Heuristics for headings in preprocessor parenthetical structures !! result <p>{{foo| </p> -<h1> <span class="mw-headline" id="heading">heading</span></h1> +<h1><span class="mw-headline" id="heading">heading</span></h1> !! end @@ -11718,7 +14990,7 @@ HHP2.2: Heuristics for headings in preprocessor parenthetical structures !! result <p>{{foo| </p> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: heading">edit</a>]</span> <span class="mw-headline" id="heading">heading</span></h2> +<h2><span class="mw-headline" id="heading">heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -11808,8 +15080,6 @@ B</strong> # Bug 6200: <blockquote> should behave like <div> with respect to line breaks !! test Bug 6200: paragraphs inside blockquotes (no extra line breaks) -!! options -disabled !! input <blockquote>Line one @@ -11822,8 +15092,6 @@ Line two</blockquote> !! test Bug 6200: paragraphs inside blockquotes (extra line break on open) -!! options -disabled !! input <blockquote> Line one @@ -11839,8 +15107,6 @@ Line two</blockquote> !! test Bug 6200: paragraphs inside blockquotes (extra line break on close) -!! options -disabled !! input <blockquote>Line one @@ -11856,8 +15122,6 @@ Line two !! test Bug 6200: paragraphs inside blockquotes (extra line break on open and close) -!! options -disabled !! input <blockquote> Line one @@ -12078,7 +15342,7 @@ comment title=[[Main Page]] !! input pre-comment text /* External links */ removed bogus entries !! result -pre-comment text - <a href="/wiki/Main_Page#External_links" title="Main Page">→</a><span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span> +pre-comment text <a href="/wiki/Main_Page#External_links" title="Main Page">→</a><span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span> !!end !! test @@ -12310,6 +15574,40 @@ Screen !! end !! test +Verify that displaytitle handles inline CSS styles (bug 26547) - rejected value +!! options +showtitle +title=[[Screen]] +!! config +wgAllowDisplayTitle=true +wgRestrictDisplayTitle=true +!! input +this is not the the title +{{DISPLAYTITLE:<span style="display: none;">s</span>creen}} +!! result +<span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen +<p>this is not the the title +</p> +!! end + +!! test +Verify that displaytitle handles inline CSS styles (bug 26547) - accepted value +!! options +showtitle +title=[[Screen]] +!! config +wgAllowDisplayTitle=true +wgRestrictDisplayTitle=true +!! input +this is not the the title +{{DISPLAYTITLE:<span style="color: red;">s</span>creen}} +!! result +<span style="color: red;">s</span>creen +<p>this is not the the title +</p> +!! end + +!! test preload: check <noinclude> and <includeonly> !! options preload @@ -12533,12 +15831,13 @@ title=[[Main Page]] __TOC__ == ''Lost'' episodes == !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#Lost_episodes"><span class="tocnumber">1</span> <span class="toctext"><i>Lost</i> episodes</span></a></li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Lost episodes">edit</a>]</span> <span class="mw-headline" id="Lost_episodes"> <i>Lost</i> episodes </span></h2> +</div> + +<h2><span class="mw-headline" id="Lost_episodes"><i>Lost</i> episodes</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Lost episodes">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -12550,12 +15849,13 @@ title=[[Main Page]] __TOC__ == '''should be bold''' then normal text == !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#should_be_bold_then_normal_text"><span class="tocnumber">1</span> <span class="toctext"><b>should be bold</b> then normal text</span></a></li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: should be bold then normal text">edit</a>]</span> <span class="mw-headline" id="should_be_bold_then_normal_text"> <b>should be bold</b> then normal text </span></h2> +</div> + +<h2><span class="mw-headline" id="should_be_bold_then_normal_text"><b>should be bold</b> then normal text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: should be bold then normal text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -12567,12 +15867,13 @@ title=[[Main Page]] __TOC__ == Image [[Image:foobar.jpg]] == !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Image">edit</a>]</span> <span class="mw-headline" id="Image"> Image <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> </span></h2> +</div> + +<h2><span class="mw-headline" id="Image">Image <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></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Image">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -12584,12 +15885,13 @@ title=[[Main Page]] __TOC__ == <blockquote>Quote</blockquote> == !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Quote">edit</a>]</span> <span class="mw-headline" id="Quote"> <blockquote>Quote</blockquote> </span></h2> +</div> + +<h2><span class="mw-headline" id="Quote"><blockquote>Quote</blockquote></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Quote">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -12603,12 +15905,13 @@ __TOC__ <small>Hanc marginis exiguitas non caperet.</small> QED !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#Proof:_2_.3C_3"><span class="tocnumber">1</span> <span class="toctext">Proof: 2 < 3</span></a></li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Proof: 2 < 3">edit</a>]</span> <span class="mw-headline" id="Proof:_2_.3C_3"> Proof: 2 < 3 </span></h2> +</div> + +<h2><span class="mw-headline" id="Proof:_2_.3C_3">Proof: 2 < 3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Proof: 2 < 3">edit</a><span class="mw-editsection-bracket">]</span></span></h2> <p><small>Hanc marginis exiguitas non caperet.</small> QED </p> @@ -12622,14 +15925,15 @@ __TOC__ == <i>Foo</i> <blockquote>Bar</blockquote> == !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#Foo_Bar"><span class="tocnumber">1</span> <span class="toctext"><i>Foo</i> <b>Bar</b></span></a></li> <li class="toclevel-1 tocsection-2"><a href="#Foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext"><i>Foo</i> Bar</span></a></li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo Bar">edit</a>]</span> <span class="mw-headline" id="Foo_Bar"> <i>Foo</i> <b>Bar</b> </span></h2> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Foo Bar">edit</a>]</span> <span class="mw-headline" id="Foo_Bar_2"> <i>Foo</i> <blockquote>Bar</blockquote> </span></h2> +</div> + +<h2><span class="mw-headline" id="Foo_Bar"><i>Foo</i> <b>Bar</b></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i> <blockquote>Bar</blockquote></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -12641,14 +15945,15 @@ __TOC__ == <sup class="a > b">Evilbye</sup> == !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li> <li class="toclevel-1 tocsection-2"><a href="#b.22.3EEvilbye"><span class="tocnumber">2</span> <span class="toctext"><sup> b">Evilbye</sup></span></a></li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Hello">edit</a>]</span> <span class="mw-headline" id="Hello"> <sup class="in-h2">Hello</sup> </span></h2> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: b">Evilbye">edit</a>]</span> <span class="mw-headline" id="b.22.3EEvilbye"> <sup> b">Evilbye</sup> </span></h2> +</div> + +<h2><span class="mw-headline" id="Hello"><sup class="in-h2">Hello</sup></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Hello">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="b.22.3EEvilbye"><sup> b">Evilbye</sup></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: b">Evilbye">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -12666,7 +15971,7 @@ __TOC__ == <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> == !! result -<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div> +<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#C.2B.2B"><span class="tocnumber">1</span> <span class="toctext"><span dir="ltr">C++</span></span></a></li> <li class="toclevel-1 tocsection-2"><a href="#.D7.96.D7.91.D7.A0.D7.92.21"><span class="tocnumber">2</span> <span class="toctext"><span dir="rtl">זבנג!</span></span></a></li> @@ -12674,12 +15979,13 @@ __TOC__ <li class="toclevel-1 tocsection-4"><a href="#All_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span class="tocnumber">4</span> <span class="toctext"><span>All attributes on these span tags must be deleted from the TOC</span></span></a></li> <li class="toclevel-1 tocsection-5"><a href="#Attributes_after_dir_on_these_span_tags_must_be_deleted_from_the_TOC"><span class="tocnumber">5</span> <span class="toctext"><span dir="ltr">Attributes after dir on these span tags must be deleted from the TOC</span></span></a></li> </ul> -</td></tr></table> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: C++">edit</a>]</span> <span class="mw-headline" id="C.2B.2B"> <span dir="ltr">C++</span> </span></h2> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: זבנג!">edit</a>]</span> <span class="mw-headline" id=".D7.96.D7.91.D7.A0.D7.92.21"> <span dir="rtl">זבנג!</span> </span></h2> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: The attributes on these span tags must be deleted from the TOC">edit</a>]</span> <span class="mw-headline" id="The_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"> <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> </span></h2> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: All attributes on these span tags must be deleted from the TOC">edit</a>]</span> <span class="mw-headline" id="All_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"> <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> </span></h2> -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Attributes after dir on these span tags must be deleted from the TOC">edit</a>]</span> <span class="mw-headline" id="Attributes_after_dir_on_these_span_tags_must_be_deleted_from_the_TOC"> <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> </span></h2> +</div> + +<h2><span class="mw-headline" id="C.2B.2B"><span dir="ltr">C++</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: C++">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id=".D7.96.D7.91.D7.A0.D7.92.21"><span dir="rtl">זבנג!</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: זבנג!">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="The_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: The attributes on these span tags must be deleted from the TOC">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="All_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: All attributes on these span tags must be deleted from the TOC">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Attributes_after_dir_on_these_span_tags_must_be_deleted_from_the_TOC"><span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Attributes after dir on these span tags must be deleted from the TOC">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -12696,7 +16002,7 @@ title=[[Main Page]] !! input {{int:Bug32057}} !! result -<h2><span class="editsection">[<a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Headline text">edit</a>]</span> <span class="mw-headline" id="Headline_text"> Headline text </span></h2> +<h2><span class="mw-headline" id="Headline_text">Headline text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Headline text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -12798,7 +16104,7 @@ nowiki inside link inside heading (bug 18295) !! input ==[[foo|x<nowiki>y</nowiki>z]]== !! result -<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: xyz">edit</a>]</span> <span class="mw-headline" id="xyz"><a href="/index.php?title=Foo&action=edit&redlink=1" class="new" title="Foo (page does not exist)">xyz</a></span></h2> +<h2><span class="mw-headline" id="xyz"><a href="/index.php?title=Foo&action=edit&redlink=1" class="new" title="Foo (page does not exist)">xyz</a></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: xyz">edit</a><span class="mw-editsection-bracket">]</span></span></h2> !! end @@ -12837,7 +16143,7 @@ Gallery override link with WikiLink (bug 34852) File:foobar.jpg|caption|alt=galleryalt|link=InterWikiLink </gallery> !! result -<ul class="gallery"> +<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/InterWikiLink"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div> <div class="gallerytext"> @@ -12856,7 +16162,7 @@ Gallery override link with absolute external link (bug 34852) File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org </gallery> !! result -<ul class="gallery"> +<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="http://www.example.org"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div> <div class="gallerytext"> @@ -12875,7 +16181,7 @@ Gallery override link with malicious javascript (bug 34852) File:foobar.jpg|caption|alt=galleryalt|link=" onclick="alert('malicious javascript code!'); </gallery> !! result -<ul class="gallery"> +<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/%22_onclick%3D%22alert(%27malicious_javascript_code!%27);"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div> <div class="gallerytext"> @@ -12894,7 +16200,7 @@ Gallery with invalid title as link (bug 43964) File:foobar.jpg|link=< </gallery> !! result -<ul class="gallery"> +<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"> @@ -12925,6 +16231,19 @@ abc !! end !!test +Special parser function +!! input +{{#special:RandomPage}} +{{#special:BaDtItLe}} +{{#special:Foobar}} +!! result +<p>Special:Random +Special:Badtitle +Special:Foobar +</p> +!! end + +!!test Bug 34939 - Case insensitive link parsing ([HttP://]) !! input [HttP://MediaWiki.Org/] @@ -12951,6 +16270,30 @@ HttP://MediaWiki.Org/ </p> !! end +!!test +Disable TOC +!! options +notoc +!! input +Lead +== Section 1 == +== Section 2 == +== Section 3 == +== Section 4 == +== Section 5 == +!! result +<p>Lead +</p> + +<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&action=edit&section=1" title="Edit section: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Section_2">Section 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Section 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Section_3">Section 3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Section 3">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Section_4">Section 4</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Section 4">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Section_5">Section 5</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Section 5">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + + ### ### Parsoids-specific tests ### Parsoid-PHP parser incompatibilities @@ -12958,25 +16301,433 @@ HttP://MediaWiki.Org/ !!test 1. SOL-sensitive wikitext tokens as template-args !!options -disabled +parsoid=wt2html,wt2wt !!input {{echo|*a}} {{echo|#a}} {{echo|:a}} !!result -<p>*a -#a -:a -</p> +<span about="#mwt1" typeof="mw:Transclusion"> +</span><ul about="#mwt1"><li>a</li> +</ul> +<span about="#mwt2" typeof="mw:Transclusion"> +</span><ol about="#mwt2"><li>a</li> +</ol> +<span about="#mwt3" typeof="mw:Transclusion"> +</span><dl about="#mwt3"><dd>a</dd> +</dl> +!!end + +#### ---------------------------------------------------------------- +#### Parsoid-only testing of Parsoid's impl of <ref> and <references> +#### tags. Parsoid's output for these tags differs from that of the +#### PHP parser. +#### ---------------------------------------------------------------- + +!!test +Ref: 1. ref-location should be replaced with an index span +!!options +parsoid +!!input +A <ref>foo</ref> +B <ref name="x">foo</ref> +C <ref name="y" /> +!!result +<p>A <span about="#mwt1" class="reference" data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[1]</a></span> +B <span about="#mwt2" class="reference" data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{"name":"x"}}' id="cite_ref-x-2-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-x-2">[2]</a></span> +C <span about="#mwt3" class="reference" data-mw='{"name":"ref","attrs":{"name":"y"}}' id="cite_ref-y-3-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-y-3">[3]</a></span></p> +!!end + +!!test +Ref: 2. ref-tags with identical names should all get the same index +!!options +parsoid +!!input +A <ref name="x">foo</ref> +B <ref name="x" /> +!!result +<p>A <span about="#mwt1" class="reference" data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{"name":"x"}}' id="cite_ref-x-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-x-1">[1]</a></span> +B <span about="#mwt2" class="reference" data-mw='{"name":"ref","attrs":{"name":"x"}}' id="cite_ref-x-1-1" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-x-1">[1]</a></span></p> +!!end + +!!test +Ref: 3. spaces in ref-names should be ignored +!!options +parsoid +!!input +A <ref name="x">foo</ref> +B <ref name=" x " /> +C <ref name= x /> +!!result +<p>A <span about="#mwt1" class="reference" data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{"name":"x"}}' id="cite_ref-x-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-x-1">[1]</a></span> +B <span about="#mwt2" class="reference" data-mw='{"name":"ref","attrs":{"name":"x"}}' id="cite_ref-x-1-1" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-x-1">[1]</a></span> +C <span about="#mwt3" class="reference" data-mw='{"name":"ref","attrs":{"name":"x"}}' id="cite_ref-x-1-2" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-x-1">[1]</a></span></p> +!!end + +!!test +Ref: 4. 'constructor' should be accepted as a valid ref-name +(NOTE: constructor is a predefined property in JS and constructor as a ref-name can clash with it if not handled properly) +!!options +parsoid +!!input +A <ref name="constructor">foo</ref> +!!result +<p>A <span about="#mwt1" class="reference" data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{"name":"constructor"}}' id="cite_ref-constructor-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-constructor-1">[1]</a></span></p> +!!end + +!!test +Ref: 5. body should accept generic wikitext +!!options +parsoid +!!input +A <ref> + This is a '''[[bolded link]]''' and this is a {{echo|transclusion}} +</ref> + +<references /> +!!result +<p>A <span about="#mwt1" class="reference" data-mw='{"name":"ref","body":{"html":"This is a <b data-parsoid=\"{&quot;dsr&quot;:[19,40,3,3]}\"><a rel=\"mw:WikiLink\" href=\"./Bolded_link\" data-parsoid=\"{&quot;stx&quot;:&quot;simple&quot;,&quot;a&quot;:{&quot;href&quot;:&quot;./Bolded_link&quot;},&quot;sa&quot;:{&quot;href&quot;:&quot;bolded link&quot;},&quot;dsr&quot;:[22,37,2,2]}\">bolded link</a></b> and this is a <span about=\"#mwt5\" typeof=\"mw:Transclusion\" data-mw=\"{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;transclusion&quot;}},&quot;i&quot;:0}}]}\" data-parsoid=\"{&quot;dsr&quot;:[55,76,null,null],&quot;pi&quot;:[[{&quot;k&quot;:&quot;1&quot;,&quot;spc&quot;:[&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;]}]]}\">transclusion</span>\n"},"attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[1]</a></span></p> + +<ol class="references" typeof="mw:Extension/references" about="#mwt2" data-mw='{"name":"references","attrs":{}}'> +<li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> This is a <b><a rel="mw:WikiLink" href="./Bolded_link">bolded link</a></b> and this is a <span about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"transclusion"}},"i":0}}]}'>transclusion</span> +</li> +</ol> +!!end + +!!test +Ref: 6. indent-pres should not be output in ref-body +!!options +parsoid +!!input +A <ref> + foo + bar + baz +</ref> + +<references /> +!!result +<p>A <span about="#mwt1" class="reference" data-mw='{"name":"ref","body":{"html":"foo\n bar\n baz\n"},"attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[1]</a></span></p> + +<ol class="references" typeof="mw:Extension/references" about="#mwt3" data-mw='{"name":"references","attrs":{}}'> +<li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> foo + bar + baz +</li> +</ol> +!!end + +!!test +Ref: 7. No p-wrapping in ref-body +!!options +parsoid +!!input +A <ref> +foo + +bar + + +baz + + + +booz +</ref> + +<references /> +!!result +<p>A <span about="#mwt1" class="reference" data-mw='{"name":"ref","body":{"html":"foo\n\nbar\n\n\nbaz\n\n\n\nbooz\n"},"attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[1]</a></span></p> + +<ol about="#mwt2" class="references" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{}}'> +<li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> foo + +bar + + +baz + + + +booz +</li> +</ol> +!!end + +!!test +Ref: 8. transclusion wikitext has lower precedence +!!options +parsoid +!!input +A <ref> foo {{echo|</ref> B C}} + +<references /> +!!result +<p>A <span about="#mwt1" class="reference" data-mw='{"name":"ref","body":{"html":"foo <span typeof=\"mw:Nowiki\" data-parsoid=\"{&quot;src&quot;:&quot;{{&quot;,&quot;dsr&quot;:[12,14,0,0]}\">{{</span>echo|"},"attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[1]</a></span> B C<span typeof="mw:Nowiki">}}</span></p> + +<ol about="#mwt2" class="references" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{}}'> +<li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> foo <span typeof="mw:Nowiki">{{</span>echo|</li> +</ol> +!!end + +!!test +Ref: 9. unclosed comments should not leak out of ref-body +!!options +parsoid +!!input +A <ref> foo <!--</ref> B C + +<references /> +!!result +<p>A <span about="#mwt1" class="reference" data-mw='{"name":"ref","body":{"html":"foo <!---->"},"attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[1]</a></span> B C</p> + +<ol about="#mwt2" class="references" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{}}'> +<li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> foo <!----></li> +</ol> +!!end + +!!test +Ref: 10. Unclosed HTML tags should not leak out of ref-body +!!options +parsoid +!!input +A <ref> <b> foo </ref> B C + +<references /> +!!result +<p>A <span about="#mwt1" class="reference" data-mw='{"name":"ref","body":{"html":"<b data-parsoid=\"{&quot;stx&quot;:&quot;html&quot;,&quot;autoInsertedEnd&quot;:true,&quot;dsr&quot;:[8,16,3,0]}\"> foo </b>"},"attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[1]</a></span> B C</p> + +<ol about="#mwt2" class="references" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{}}'> +<li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> <b> foo </b></li> +</ol> +!!end + +!!test +Ref: 11. ref-tags acts like an inline element wrt P-wrapping +!!options +parsoid +!!input +A <ref>foo</ref> B +C <ref>bar</ref> D +!!result +<p>A <span about="#mwt1" class="reference" data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[1]</a></span> B +C <span about="#mwt2" class="reference" data-mw='{"name":"ref","body":{"html":"bar"},"attrs":{}}' id="cite_ref-2-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-2">[2]</a></span> D</p> +!!end + +!!test +Ref: 12. ref-tags act as trailing newline migration barrier +!!options +parsoid +!!input +<!--the newline at the end of this line moves out of the p-tag-->a + +b<!--the newline at the end of this line stays inside the p-tag--> <ref /> +<ref /> + +c +!!result +<p><!--the newline at the end of this line moves out of the p-tag-->a</p> + + +<p>b<!--the newline at the end of this line stays inside the p-tag--> <span about="#mwt1" class="reference" data-mw='{"name":"ref","attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[1]</a></span> +<span about="#mwt2" class="reference" data-mw='{"name":"ref","attrs":{}}' id="cite_ref-2-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-2">[2]</a></span></p> + + +<p>c</p> +!!end + +!!test +Ref: 13. ref-tags are not SOL-transparent and block indent-pres +!!options +parsoid +!!input +<ref>foo</ref> A +<ref>bar +</ref> B +!!result +<p><span about="#mwt1" class="reference" data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[1]</a></span> A +<span about="#mwt2" class="reference" data-mw='{"name":"ref","body":{"html":"bar\n"},"attrs":{}}' id="cite_ref-2-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-2">[2]</a></span> B</p> +!!end + +!!test +Ref: 14. A nested ref-tag should be emitted as plain text +!!options +parsoid +!!input +<ref>foo <ref>bar</ref> baz</ref> + +<references /> +!!result +<p><span about="#mwt1" class="reference" data-mw="{"name":"ref","body":{"html":"foo &lt;ref&gt;bar&lt;/ref&gt; baz"},"attrs":{}}" id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[1]</a></span></p> + +<ol class="references" typeof="mw:Extension/references" about="#mwt2" data-mw="{"name":"references","attrs":{}}"> +<li about="#cite_note-1" id="cite_note-1" data-parsoid="{}"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> foo <ref>bar</ref> baz</li> +</ol> +!!end + +!!test +Ref: 15. ref-tags with identical names should get identical indexes +!!options +parsoid +!!input +A1 <ref name="a">foo</ref> A2 <ref name="a" /> +B1 <ref name="b" /> B2 <ref name="b">bar</ref> + +<references /> +!!result +<p>A1 <span about="#mwt3" class="reference" data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{"name":"a"}}' id="cite_ref-a-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-a-1">[1]</a></span> A2 <span about="#mwt4" class="reference" data-mw='{"name":"ref","attrs":{"name":"a"}}' id="cite_ref-a-1-1" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-a-1">[1]</a></span> +B1 <span about="#mwt7" class="reference" data-mw='{"name":"ref","attrs":{"name":"b"}}' id="cite_ref-b-2-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-b-2">[2]</a></span> B2 <span about="#mwt8" class="reference" data-mw='{"name":"ref","body":{"html":"bar"},"attrs":{"name":"b"}}' id="cite_ref-b-2-1" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-b-2">[2]</a></span></p> + +<ol about="#mwt10" class="references" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-a-1" id="cite_note-a-1"><span rel="mw:referencedBy">↑ <a href="#cite_ref-a-1-0">1.0</a> <a href="#cite_ref-a-1-1">1.1</a></span> foo</li><li about="#cite_note-b-2" id="cite_note-b-2"><span rel="mw:referencedBy">↑ <a href="#cite_ref-b-2-0">2.0</a> <a href="#cite_ref-b-2-1">2.1</a></span> bar</li> +</ol> +!!end + +!!test +References: 1. references tag without any refs should be handled properly +!!options +parsoid +!!input +<references /> +!!result +<ol about="#mwt2" class="references" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{}}'></ol> +!!end + +!!test +References: 2. references tag with group only outputs references from that group +!!options +parsoid +!!input +A <ref group="a">foo</ref> +B <ref group="b">bar</ref> + +<references group='a' /> +!!result +<p>A <span about="#mwt2" class="reference" data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{"group":"a"}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[a 1]</a></span> +B <span about="#mwt4" class="reference" data-mw='{"name":"ref","body":{"html":"bar"},"attrs":{"group":"b"}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[b 1]</a></span></p> + +<ol about="#mwt6" class="references" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{"group":"a"}}'><li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> foo</li> +</ol> +!!end + +!!test +References: 3. ref list should be cleared after processing references +!!options +parsoid +!!input +A <ref>foo</ref> + +<references /> + +B <ref>bar</ref> + +<references /> +!!result +<p>A <span about="#mwt2" class="reference" data-mw='{"name":"ref","body":{"html":"foo"},"attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[1]</a></span></p> + +<ol about="#mwt4" class="references" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> foo</li> +</ol> + +<p>B <span about="#mwt6" class="reference" data-mw='{"name":"ref","body":{"html":"bar"},"attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[1]</a></span></p> + +<ol about="#mwt8" class="references" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> bar</li> +</ol> !!end +!!test +References: 4. only referenced group should be cleared after processing references +!!options +parsoid +!!input +A <ref group="a">afoo</ref> +B <ref>bfoo</ref> + +<references group="a"/> + +C <ref>cfoo</ref> + +<references /> +!!result +<p>A <span about="#mwt2" class="reference" data-mw='{"name":"ref","body":{"html":"afoo"},"attrs":{"group":"a"}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[a 1]</a></span> +B <span about="#mwt4" class="reference" data-mw='{"name":"ref","body":{"html":"bfoo"},"attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref" data-parsoid='{"src":"<ref>bfoo</ref>","dsr":[30,45,5,6]}'><a href="#cite_note-1">[1]</a></span></p> + +<ol about="#mwt6" class="references" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{"group":"a"}}'><li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> afoo</li> +</ol> + +<p>C <span about="#mwt8" class="reference" data-mw='{"name":"ref","body":{"html":"cfoo"},"attrs":{}}' id="cite_ref-2-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-2">[2]</a></span></p> + +<ol about="#mwt10" class="references" typeof="mw:Extension/references" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> bfoo</li><li about="#cite_note-2" id="cite_note-2"><span rel="mw:referencedBy"><a href="#cite_ref-2-0">↑</a></span> cfoo</li> +</ol> +!!end + +!!test +References: 5. ref tags in references should be processed while ignoring all other content +!!options +parsoid +!!input +A <ref name="a" /> +B <ref name="b">bar</ref> + +<references> +<ref name="a">foo</ref> +This should just get lost. +</references> +!!result +<p>A <span about="#mwt2" class="reference" data-mw='{"name":"ref","attrs":{"name":"a"}}' id="cite_ref-a-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-a-1">[1]</a></span> +B <span about="#mwt4" class="reference" data-mw='{"name":"ref","body":{"html":"bar"},"attrs":{"name":"b"}}' id="cite_ref-b-2-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-b-2">[2]</a></span></p> + +<ol class="references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","body":{"extsrc":"<ref name=\"a\">foo</ref>\nThis should just get lost.","html":"\n<span about=\"#mwt8\" class=\"reference\" data-mw=\"{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;foo&quot;},&quot;attrs&quot;:{&quot;name&quot;:&quot;a&quot;}}\" rel=\"dc:references\" typeof=\"mw:Extension/ref\"><a href=\"#cite_note-a-1\">[1]</a></span>\n"},"attrs":{}}'><li about="#cite_note-a-1" id="cite_note-a-1"><span rel="mw:referencedBy"><a href="#cite_ref-a-1-0">↑</a></span> foo</li><li about="#cite_note-b-2" id="cite_note-b-2"><span rel="mw:referencedBy"><a href="#cite_ref-b-2-0">↑</a></span> bar</li> +</ol> +!!end + +!!test +References: 6. <references /> from a transclusion +!!options +parsoid +!!input +{{echo|<references />}} +!!result +<ol class="references" about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<references />"}},"i":0}}]}'></ol> +!!end + +!! test +References: 7. Multiple references tags (one without and one with nested refs) should be correctly handled +!! options +parsoid +!! input +A <ref>foo bar for a</ref> +B <ref name="b" /> + +<references /> + +<references> +<ref name="b">foo</ref> +</references> +!! result +<p>A <span about="#mwt2" class="reference" data-mw='{"name":"ref","body":{"html":"foo bar for a"},"attrs":{}}' id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-1">[1]</a></span> +B <span about="#mwt4" class="reference" data-mw='{"name":"ref","attrs":{"name":"b"}}' id="cite_ref-b-2-0" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-b-2">[2]</a></span></p> + +<ol class="references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'> +<li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> foo bar for a</li> +<li about="#cite_note-b-2" id="cite_note-b-2"><span rel="mw:referencedBy"><a href="#cite_ref-b-2-0">↑</a></span> </li> +</ol> + +<ol class="references" typeof="mw:Extension/references" about="#mwt8" data-mw='{"name":"references","body":{"extsrc":"<ref name=\"b\">foo</ref>","html":"\n<span about=\"#mwt10\" class=\"reference\" data-mw=\"{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;foo&quot;},&quot;attrs&quot;:{&quot;name&quot;:&quot;b&quot;}}\" rel=\"dc:references\" typeof=\"mw:Extension/ref\"><a href=\"#cite_note-b-1\">[1]</a></span>\n"},"attrs":{}}'> +<li about="#cite_note-b-1" id="cite_note-b-1"><span rel="mw:referencedBy">↑</span> foo</li> +</ol> +!! end + +#### ---------------------------------------------------------------- #### The following section of tests are primarily to test -#### wikitext escaping capabilities of Parsoid. -#### A lot of the tests are disabled for the PHP parser either -#### because of minor newline diffs or other reasons. -#### As Parsoid serializer can handle newlines and other HTML -#### more robustly, some of these tests might get reenabled -#### for the PHP parser. +#### wikitext escaping capabilities of Parsoid. Given that +#### escaping can be done any number of ways, the wikitext (input) +#### is always adjusted to reflect how Parsoid adds nowiki +#### escape tags. +#### +#### We are marking several tests as parsoid-only since the +#### HTML in the result section is different from what the +#### PHP parser generates for it. +#### ---------------------------------------------------------------- + #### --------------- Headings --------------- #### 0. Unnested @@ -12989,45 +16740,62 @@ disabled #### ---------------------------------------- !! test Headings: 0. Unnested +!! options +parsoid !! input <nowiki>=foo=</nowiki> -<nowiki>=foo</nowiki>''a''= +<nowiki> =foo= </nowiki> +<!--cmt--> +<nowiki>=foo=</nowiki> + +=foo''a''<nowiki>=</nowiki> !! result -<p>=foo= -</p><p>=foo<i>a</i>= -</p> +<p><span typeof="mw:Nowiki">=foo=</span></p> + +<p><span typeof="mw:Nowiki"> =foo= </span> +<!--cmt--> +<span typeof="mw:Nowiki">=foo=</span></p> + +<p>=foo<i>a</i><span typeof="mw:Nowiki">=</span></p> !!end !! test Headings: 1. Nested inside html !! options -disabled +parsoid !! input =<nowiki>=foo=</nowiki>= + ==<nowiki>=foo=</nowiki>== + ===<nowiki>=foo=</nowiki>=== + ====<nowiki>=foo=</nowiki>==== + =====<nowiki>=foo=</nowiki>===== + ======<nowiki>=foo=</nowiki>====== !! result -<h1>=foo=</h1> -<h2>=foo=</h2> -<h3>=foo=</h3> -<h4>=foo=</h4> -<h5>=foo=</h5> -<h6>=foo=</h6> +<h1><span typeof="mw:Nowiki">=foo=</span></h1> +<h2><span typeof="mw:Nowiki">=foo=</span></h2> +<h3><span typeof="mw:Nowiki">=foo=</span></h3> +<h4><span typeof="mw:Nowiki">=foo=</span></h4> +<h5><span typeof="mw:Nowiki">=foo=</span></h5> +<h6><span typeof="mw:Nowiki">=foo=</span></h6> !!end !! test Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar !! options -disabled +parsoid !! input =foo= -<nowiki>*bar</nowiki> +<nowiki>*</nowiki>bar + =foo= =bar + =foo= <nowiki>=bar=</nowiki> !! result @@ -13039,44 +16807,75 @@ disabled !! test Headings: 3. Nested inside html with wikitext split by html tags !! options -disabled +parsoid !! input -=<nowiki>=</nowiki>'''bold'''foo== +=='''bold'''<nowiki>foo=</nowiki>= !! result -<h1>=<b>bold</b>foo=</h1> +<h1>=<b>bold</b><span typeof="mw:Nowiki">foo=</span></h1> !!end !! test -Headings: 4. No escaping needed (testing just h1 and h2) +Headings: 4a. No escaping needed (testing just h1 and h2) !! options -disabled +parsoid !! input ==foo= + =foo== + += =foo= = + +==foo= bar= + ===foo== + ==foo=== + =''=''foo== -=== + +=<nowiki>=</nowiki>= !! result <h1>=foo</h1> <h1>foo=</h1> +<h1> =foo= </h1> +<h1>=foo= bar</h1> <h2>=foo</h2> <h2>foo=</h2> <h1><i>=</i>foo=</h1> -<h1>=</h1> +<h1><span typeof="mw:Nowiki">=</span></h1> +!!end + +!! test +Headings: 4b. No escaping needed (inside p-tags) +!! options +parsoid +!! input +=== +=foo= x +=foo= <s></s> +!! result +<p>=== +=foo= x +=foo= <s></s> +</p> !!end !! test Headings: 5. Empty headings !! options -disabled +parsoid !! input -=<nowiki></nowiki>= -==<nowiki></nowiki>== -===<nowiki></nowiki>=== -====<nowiki></nowiki>==== -=====<nowiki></nowiki>===== -======<nowiki></nowiki>====== +=<nowiki/>= + +==<nowiki/>== + +===<nowiki/>=== + +====<nowiki/>==== + +=====<nowiki/>===== + +======<nowiki/>====== !! result <h1></h1> <h2></h2> @@ -13087,16 +16886,87 @@ disabled !!end !! test -Headings: 6. Heading chars in SOL context +Headings: 6a. Heading chars in SOL context (with trailing spaces) !! options -disabled +parsoid +!! input +<nowiki>=a=</nowiki> + +<nowiki>=a=</nowiki> + +<nowiki>=a=</nowiki> + +<nowiki>=a=</nowiki> +!! result +<p>=a=</p> +<p>=a= </p> +<p>=a= </p> +<p>=a= </p> +!!end + +!! test +Headings: 6b. Heading chars in SOL context (with trailing newlines) +!! options +parsoid !! input -<!--cmt--><nowiki>=h1=</nowiki> +<nowiki>=a= +b</nowiki> + +<nowiki>=a= +b</nowiki> + +<nowiki>=a= +b</nowiki> + +<nowiki>=a= +b</nowiki> !! result -<p><!--cmt-->=h1= +<p>=a= +b</p> +<p>=a= +b</p> +<p>=a= +b</p> +<p>=a= +b</p> </p> !!end +!! test +Headings: 6c. Heading chars in SOL context (leading newline break) +!! options +parsoid +!! input +a +<nowiki>=b=</nowiki> +!! result +<p>a +=b=</p> +!!end + +!! test +Headings: 6d. Heading chars in SOL context (with interspersed comments) +!! options +parsoid +!! input +<!--c0--><nowiki>=a=</nowiki> +<!--c1--> +<nowiki>=a=</nowiki> <!--c2--> <!--c3--> +!! result +<p><!--c0-->=a=</p> +<p><!--c1-->=a= <!--c2--> <!--c3--></p> +!!end + +!! test +Headings: 6d. Heading chars in SOL context (No escaping needed) +!! options +parsoid=html2wt +!! input +=a=<div>b</div> +!! result +=a=<div>b</div> +!!end + #### --------------- Lists --------------- #### 0. Outside nests (*foo, etc.) #### 1. Nested inside html <ul><li>*foo</li></ul> @@ -13111,9 +16981,9 @@ disabled !! test Lists: 0. Outside nests !! input -<nowiki>*foo</nowiki> +<nowiki>*</nowiki>foo -<nowiki>#foo</nowiki> +<nowiki>#</nowiki>foo !! result <p>*foo </p><p>#foo @@ -13139,22 +17009,38 @@ Lists: 1. Nested inside html #<nowiki>;foo</nowiki> !! result -<ul><li>*foo -</li></ul> -<ul><li>#foo -</li></ul> -<ul><li>:foo -</li></ul> -<ul><li>;foo -</li></ul> -<ol><li>*foo -</li></ol> -<ol><li>#foo -</li></ol> -<ol><li>:foo -</li></ol> -<ol><li>;foo -</li></ol> +<ul> +<li>*foo +</li> +</ul> +<ul> +<li>#foo +</li> +</ul> +<ul> +<li>:foo +</li> +</ul> +<ul> +<li>;foo +</li> +</ul> +<ol> +<li>*foo +</li> +</ol> +<ol> +<li>#foo +</li> +</ol> +<ol> +<li>:foo +</li> +</ol> +<ol> +<li>;foo +</li> +</ol> !!end @@ -13170,15 +17056,24 @@ Lists: 2. Inside definition lists :<nowiki>:foo</nowiki> !! result -<dl><dt>;foo -</dt></dl> -<dl><dt>:foo -</dt></dl> -<dl><dt>:foo -</dt><dd>bar -</dd></dl> -<dl><dd>:foo -</dd></dl> +<dl> +<dt>;foo +</dt> +</dl> +<dl> +<dt>:foo +</dt> +</dl> +<dl> +<dt>:foo +</dt> +<dd>bar +</dd> +</dl> +<dl> +<dd>:foo +</dd> +</dl> !!end @@ -13189,17 +17084,21 @@ Lists: 3. Only bullets at start of text should be escaped *<nowiki>*foo</nowiki>''it''*bar !! result -<ul><li>*foo*bar -</li></ul> -<ul><li>*foo<i>it</i>*bar -</li></ul> +<ul> +<li>*foo*bar +</li> +</ul> +<ul> +<li>*foo<i>it</i>*bar +</li> +</ul> !!end !! test Lists: 4. No escapes needed !! options -disabled +parsoid !! input *foo*bar @@ -13207,12 +17106,18 @@ disabled *[[Foo]]: bar !! result -<ul><li>foo*bar -</li></ul> -<ul><li><i>foo</i>*bar -</li></ul> -<ul><li><a href="Foo" rel="mw:WikiLink">Foo</a>: bar -</li></ul> +<ul> +<li>foo*bar +</li> +</ul> +<ul> +<li><i>foo</i>*bar +</li> +</ul> +<ul> +<li><a rel="mw:WikiLink" href="Foo">Foo</a>: bar +</li> +</ul> !!end !! test @@ -13224,39 +17129,54 @@ Lists: 5. No unnecessary escapes *[[bar <span><nowiki>[[foo]]</nowiki></span> -*<nowiki>]]bar </nowiki><span><nowiki>[[foo]]</nowiki></span> +*]]bar <span><nowiki>[[foo]]</nowiki></span> *=bar <span>foo]]</span>= + +* <s></s>: a !! result -<ul><li> bar <span>[[foo]]</span> -</li></ul> -<ul><li>=bar <span>[[foo]]</span> -</li></ul> -<ul><li>[[bar <span>[[foo]]</span> -</li></ul> -<ul><li>]]bar <span>[[foo]]</span> -</li></ul> -<ul><li>=bar <span>foo]]</span>= -</li></ul> +<ul> +<li> bar <span>[[foo]]</span> +</li> +</ul> +<ul> +<li>=bar <span>[[foo]]</span> +</li> +</ul> +<ul> +<li>[[bar <span>[[foo]]</span> +</li> +</ul> +<ul> +<li>]]bar <span>[[foo]]</span> +</li> +</ul> +<ul> +<li>=bar <span>foo]]</span>= +</li> +</ul> +<ul> +<li> <s></s>: a +</li> +</ul> !!end !! test Lists: 6. Escape bullets in SOL position !! options -disabled +parsoid !! input <!--cmt--><nowiki>*foo</nowiki> !! result -<p><!--cmt-->*foo -</p> +<p><!--cmt--><span typeof="mw:Nowiki">*foo</span></p> !!end !! test Lists: 7. Escape bullets in a multi-line context !! input -<nowiki>a -*b</nowiki> +a +<nowiki>*</nowiki>b !! result <p>a *b @@ -13270,18 +17190,15 @@ Lists: 7. Escape bullets in a multi-line context !! test HRs: 1. Single line !! options -disabled +parsoid !! input ----- -<nowiki>----</nowiki> ----- -<nowiki>=foo=</nowiki> ----- -<nowiki>*foo</nowiki> +----<nowiki>----</nowiki> +----=foo= +----*foo !! result -<hr/>---- -<hr/>=foo= -<hr/>*foo +<hr><span typeof="mw:Nowiki">----</span> +<hr>=foo= +<hr>*foo !! end #### --------------- Tables --------------- @@ -13344,102 +17261,92 @@ Tables: 1d. No escaping needed !! test Tables: 2a. Nested in td !! options -disabled +parsoid !! input {| |<nowiki>foo|bar</nowiki> |} !! result -<table> -<tr><td>foo|bar -</td></tr></table> - +<table><tbody><tr> +<td><span typeof="mw:Nowiki">foo|bar</span></td></tr></tbody></table> !! end !! test Tables: 2b. Nested in td !! options -disabled +parsoid !! input {| |<nowiki>foo||bar</nowiki> |''it''<nowiki>foo||bar</nowiki> |} !! result -<table> -<tr><td>foo||bar -</td><td><i>it</i>foo||bar -</td></tr></table> - +<table><tbody><tr> +<td><span typeof="mw:Nowiki">foo||bar</span></td> +<td><i>it</i><span typeof="mw:Nowiki">foo||bar</span></td></tr></tbody></table> !! end !! test Tables: 2c. Nested in td -- no escaping needed !! options -disabled +parsoid !! input {| |foo!!bar |} !! result -<table> -<tr><td>foo!!bar -</td></tr></table> +<table><tbody><tr><td>foo!!bar +</td></tr></tbody></table> !! end !! test Tables: 3a. Nested in th !! options -disabled +parsoid !! input {| !foo!bar |} !! result -<table> -<tr><th>foo!bar -</th></tr></table> +<table><tbody><tr><th>foo!bar +</th></tr></tbody></table> !! end !! test Tables: 3b. Nested in th !! options -disabled +parsoid !! input {| !<nowiki>foo!!bar</nowiki> |} !! result <table> -<tr><th>foo!!bar -</th></tr></table> - +<tbody><tr><th><span typeof="mw:Nowiki">foo!!bar</span></th></tr> +</tbody></table> !! end !! test Tables: 3c. Nested in th -- no escaping needed !! options -disabled +parsoid !! input {| -!foo||bar +!<nowiki>foo||bar</nowiki> |} !! result -<table> -<tr><th>foo||bar -</th></tr></table> - +<table><tbody><tr> +<th><span typeof="mw:Nowiki">foo||bar</span></th></tr></tbody></table> !! end !! test Tables: 4a. Escape - !! options -disabled +parsoid !! input {| -|- !-bar |- |<nowiki>-bar</nowiki> @@ -13447,17 +17354,16 @@ disabled !! result <table><tbody> <tr><th>-bar</th></tr> -<tr><td>-bar</td></tr> -</tbody></table> +<tr> +<td><span typeof="mw:Nowiki">-bar</span></td></tr></tbody></table> !! end !! test Tables: 4b. Escape + !! options -disabled +parsoid !! input {| -|- !+bar |- |<nowiki>+bar</nowiki> @@ -13465,32 +17371,48 @@ disabled !! result <table><tbody> <tr><th>+bar</th></tr> -<tr><td>+bar</td></tr> -</tbody></table> +<tr> +<td><span typeof="mw:Nowiki">+bar</span></td></tr></tbody></table> !! end !! test Tables: 4c. No escaping needed !! options -disabled +parsoid !! input {| -|- |foo-bar |foo+bar |- |''foo''-bar |''foo''+bar +|- +|foo +bar|baz ++bar +-bar |} !! result <table><tbody> <tr><td>foo-bar</td><td>foo+bar</td></tr> <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr> +<tr><td>foo +<p>bar|baz ++bar +-bar</p></td></tr> </tbody></table> !! end +### SSS FIXME: Disabled right now because accurate html2wt +### on this snippet requires data-parsoid flags that we've +### stripped out of these tests. We should scheme how we +### we want to handle these kind of tests that require +### data-parsoid flags for accurate html2wt serialization + !! test Tables: 4d. No escaping needed +!! options +disabled !! input {| ||+1 @@ -13506,7 +17428,7 @@ Tables: 4d. No escaping needed !! end -#### --------------- Links --------------- +#### --------------- Links ---------------- #### 1. Quote marks in link text #### 2. Wikilinks: Escapes needed #### 3. Wikilinks: No escapes needed @@ -13516,9 +17438,9 @@ Tables: 4d. No escaping needed !! test Links 1. Quote marks in link text !! options -disabled +parsoid !! input -[[Foo|<nowiki>Foo''boo''</nowiki>]] +[[Foo|Foo<nowiki>''boo''</nowiki>]] !! result <a rel="mw:WikiLink" href="Foo">Foo''boo''</a> !! end @@ -13526,15 +17448,18 @@ disabled !! test Links 2. WikiLinks: Escapes needed !! options -disabled +parsoid !! input [[Foo|<nowiki>[Foobar]</nowiki>]] [[Foo|<nowiki>Foobar]</nowiki>]] -[[Foo|<nowiki>x [Foobar] x</nowiki>]] +[[Foo|x [Foobar] x]] [[Foo|<nowiki>x [http://google.com g] x</nowiki>]] [[Foo|<nowiki>[[Bar]]</nowiki>]] [[Foo|<nowiki>x [[Bar]] x</nowiki>]] [[Foo|<nowiki>|Bar</nowiki>]] +[[Foo|<nowiki>]]bar</nowiki>]] +[[Foo|<nowiki>[[bar</nowiki>]] +[[Foo|<nowiki>x ]] y [[ z</nowiki>]] !! result <a href="Foo" rel="mw:WikiLink">[Foobar]</a> <a href="Foo" rel="mw:WikiLink">Foobar]</a> @@ -13543,12 +17468,15 @@ disabled <a href="Foo" rel="mw:WikiLink">[[Bar]]</a> <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a> <a href="Foo" rel="mw:WikiLink">|Bar</a> +<a href="Foo" rel="mw:WikiLink">]]bar</a> +<a href="Foo" rel="mw:WikiLink">[[bar</a> +<a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a> !! end !! test Links 3. WikiLinks: No escapes needed !! options -disabled +parsoid !! input [[Foo|[Foobar]] [[Foo|foo|bar]] @@ -13560,7 +17488,7 @@ disabled !! test Links 4. ExtLinks: Escapes needed !! options -disabled +parsoid !! input [http://google.com <nowiki>[google]</nowiki>] [http://google.com <nowiki>google]</nowiki>] @@ -13572,7 +17500,7 @@ disabled !! test Links 5. ExtLinks: No escapes needed !! options -disabled +parsoid !! input [http://google.com [google] !! result @@ -13583,26 +17511,44 @@ disabled #### 1. Quotes inside <b> and <i> #### 2. Link fragments separated by <i> and <b> tags #### 3. Link fragments inside <i> and <b> +#### 4. No escaping needed #### -------------------------------------- !! test 1. Quotes inside <b> and <i> +!! options +parsoid=html2wt,wt2wt !! input ''<nowiki>'foo'</nowiki>'' ''<nowiki>''foo''</nowiki>'' ''<nowiki>'''foo'''</nowiki>'' +''foo''<nowiki/>'s '''<nowiki>'foo'</nowiki>''' '''<nowiki>''foo''</nowiki>''' '''<nowiki>'''foo'''</nowiki>''' '''<nowiki>foo'</nowiki>''<nowiki>bar'</nowiki>''baz''' +'''foo'''<nowiki/>'s +'''foo'' +''foo''<nowiki/>' +'<nowiki/>''foo''<nowiki/>' +''''foo''' +'''foo'''<nowiki/>' +'<nowiki/>'''foo'''<nowiki/>' !! result <p><i>'foo'</i> <i>''foo''</i> <i>'''foo'''</i> +<i>foo</i>'s <b>'foo'</b> <b>''foo''</b> <b>'''foo'''</b> <b>foo'<i>bar'</i>baz</b> -</p> +<b>foo</b>'s +'<i>foo</i> +<i>foo</i>' +'<i>foo</i>' +'<b>foo</b> +<b>foo</b>' +'<b>foo</b>'</p> !! end !! test @@ -13618,7 +17564,7 @@ disabled !! end !! test -2. Link fragments inside <i> and <b> +3. Link fragments inside <i> and <b> (FIXME: Escaping one or both of [[ and ]] is also acceptable -- this is one of the shortcomings of this format) !! input @@ -13631,7 +17577,18 @@ disabled </p> !! end -#### --------------- Paragraphs --------------- +!! test +4. No escaping needed +!! input +'<span>''bar''</span>' +'<span>'''bar'''</span>' +!! result +<p>'<span><i>bar</i></span>' +'<span><b>bar</b></span>' +</p> +!! end + +#### ----------- Paragraphs --------------- #### 1. No unnecessary escapes #### -------------------------------------- @@ -13644,9 +17601,9 @@ bar <span><nowiki>[[foo]]</nowiki></span> [[bar <span><nowiki>[[foo]]</nowiki></span> -<nowiki>]]bar </nowiki><span><nowiki>[[foo]]</nowiki></span> +]]bar <span><nowiki>[[foo]]</nowiki></span> -<nowiki>=bar </nowiki><span>foo]]</span>= +=bar <span>foo]]</span><nowiki>=</nowiki> !! result <p>bar <span>[[foo]]</span> </p><p>=bar <span>[[foo]]</span> @@ -13656,31 +17613,78 @@ bar <span><nowiki>[[foo]]</nowiki></span> </p> !!end -#### --------------- PRE ------------------ -#### 1. Leading space in SOL context should be escaped -#### -------------------------------------- +#### ----------------------- PRE -------------------------- +#### 1. Leading whitespace in SOL context should be escaped +#### ------------------------------------------------------ !! test -1. Leading space in SOL context should be escaped +1. Leading whitespace in SOL context should be escaped !! options -disabled +parsoid !! input -<nowiki> foo</nowiki> -<!--cmt--><nowiki> foo</nowiki> +<nowiki> </nowiki>a + +<nowiki> </nowiki> a + +<nowiki> </nowiki>a(tab) + +<nowiki> </nowiki> a +<!--cmt--> +<nowiki> </nowiki> a + +a +<nowiki> </nowiki>b + +a +<nowiki> </nowiki>b + +a +<nowiki> </nowiki> b !! result -<p> foo -<!--cmt--> foo -</p> +<p> a</p> +<p> a</p> +<p> a(tab)</p> +<p> a</p> +<p><!--cmt--> a</p> +<p>a + b</p> +<p>a + b</p> +<p>a + b</p> +!! end + +#### --------------- Behavior Switches -------------------- +!! test +1. Valid behavior switches should be escaped +!! options +parsoid=html2wt +!! input +<nowiki>__TOC__</nowiki> +!! result +__TOC__ +!! end + +!! test +2. Invalid behavior switches should not be escaped +!! options +parsoid=html2wt +!! input +__TOO__ +__|__ +!! result +__TOO__ +__|__ !! end #### --------------- HTML tags --------------- #### 1. a tags #### 2. other tags #### 3. multi-line html tag -#### -------------------------------------- +#### ----------------------------------------- !! test 1. a tags !! options -disabled +parsoid !! input <a href="http://google.com">google</a> !! result @@ -13711,6 +17715,15 @@ disabled </p> !! end +!! test +4. extension tags +!! input +<nowiki><ref>foo</ref></nowiki> +!! result +<p><ref>foo</ref> +</p> +!! end + #### --------------- Others --------------- !! test Escaping nowikis @@ -13721,7 +17734,19 @@ Escaping nowikis </p> !! end +## The quote-char in the input is necessary for triggering the bug +!! test +(Bug 52035) Nowiki-escaping should not get tripped by " :" in text +!! options +parsoid=wt2wt,html2wt +!! input +foo's bar : +!! result +<p>foo's bar :</p> +!! end + !! test + Tag-like HTML structures are passed through as text !! input <x y> @@ -13749,16 +17774,14 @@ a>b !! end -# This fails in the PHP parser (see bug 40670, -# https://bugzilla.wikimedia.org/show_bug.cgi?id=40670), so disabled for it. +# This was a bug in the PHP parser (see bug 17663 and its dups, +# https://bugzilla.wikimedia.org/show_bug.cgi?id=17663) !! test Tag names followed by punctuation should not be recognized as tags -!! options -disabled !! input <s.ome> text !! result -<p><s.ome> text +<p><s.ome> text </p> !! end @@ -13841,14 +17864,34 @@ parsoid | style="color:red|Bar |} !! result -<table> +<table><tbody> <tr> <td title="Hello world">Foo </td><td style="color: red">Bar -</td></tr></table> +</td></tr></tbody></table> !! end +!! test +Parsoid-only: Don't wrap broken template tags in <nowiki> on wt2wt (Bug 42353) +!! options +parsoid +!! input +{{}} +!! result +{{}} +!! end + +!! test +Parsoid-only: Don't wrap broken template tags in <nowiki> on wt2wt (Bug 42353) +!! options +parsoid +!! input +}}{{ +!! result +}}{{ +!! end + !!test Accept empty td cell attribute !!input @@ -13915,6 +17958,556 @@ Empty table rows go away !! end +### +### Parsoid-centric tests for testing RTing of inter-element separators +### Edge cases not tested by existing parser tests and specific to +### Parsoid-specific serialization strategies. +### + +!!test +RT-ed inter-element separators should be valid separators +!!input +{| +|- [[foo]] +|} +!!result +<table> + +</table> + +!!end + +!!test +Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out +(Parsoid-only since PHP parser relies on Tidy for correct output) +!!options +parsoid +!!input +{| +|<small>foo +bar +|} + +{| +|<small>foo<small> +|} +!!result +!!end + +!!test +Empty TD followed by TD with tpl-generated attribute +!!input +{| +|- +| +|{{echo|style='color:red'}}|foo +|} +!!result +<table> + +<tr> +<td> +</td> +<td>foo +</td></tr></table> + +!!end + +!!test +Indented table with an empty td +!!input + {| + |- + | + |foo + |} +!!result +<table> + +<tr> +<td> +</td> +<td>foo +</td></tr></table> + +!!end + +!!test +Empty TR followed by a template-generated TR +(Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext) +!!options +parsoid +!!input +{| +|- +{{echo|<tr><td>foo</td></tr>}} +|} +!!result +<table> +<tbody> +<tr></tr> +<tr about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<tr><td>foo</td></tr>"}},"i":0}}]}'> +<td>foo</td></tr> +</tbody></table> +!!end + +## PHP and parsoid output differ for this, and since this is primarily +## for testing Parsoid's serializer, marking this Parsoid only +!!test +Empty TR followed by mixed-ws-comment line should RT correctly +!!options +parsoid +!!input +{| +|- + <!--c--> +|- +<!--c--> <!--d--> +|} +!!result +<table> +<tbody> +<tr></tr> + <!--c--> +<tr> +<!--c--> </tr><!--d--> +</tbody></table> + +!!end + +!!test +Multi-line image caption generated by templates with/without trailing newlines +!!options +parsoid +!!input +[[File:foo.jpg|thumb|300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]] +[[File:foo.jpg|thumb|300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]] +!!result +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&wpDestFile=Foo.jpg" class="new" title="File:Foo.jpg">File:Foo.jpg</a> <div class="thumbcaption">foo\nA\nB\nC</div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&wpDestFile=Foo.jpg" class="new" title="File:Foo.jpg">File:Foo.jpg</a> <div class="thumbcaption">foo\nA\nB\nC\n\n</div></div></div> + +!!end + +## PHP emits broken html for this, and since this is primarily +## a Parsoid serializer test, marking this Parsoid only +!!test +Improperly nested inline or quotes tags with whitespace in between +!!options +parsoid +!!input +<span> <s>x</span> </s> +''' ''x''' '' +!!result +<p><span> <s>x</s></span><s> </s> +<b> <i>x</i></b><i> </i> +</p> +!!end + +!!test +Encapsulate protected attributes from wt +!!options +parsoid +!!input +<div typeof="mw:placeholder stuff" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div> +!!result +<body><div data-x-typeof="mw:placeholder stuff" data-x-data-parsoid="weird" data-x-data-parsoid-other="no" data-x-about="time" data-x-rel="mw:true">foo</div> +</body> +!!end + +## Currently the p-wrapper is fragile in how adds / removes transformations. +## Having nested or stray pre tags results in the attempt to add duplicates, +## causing an assertion fail. This test tries to prevent that situation. +!!test +Ensure ParagraphWrapper can deal with stray closing pre tags +!!options +parsoid=wt2html +!!input +plain text</pre> +!!result +plain text +!!end + +!!test +Ensure fostered text content is wrapped in spans +!!options +parsoid=wt2html +!!input +<table>hi</table><table>ho</table> +!!result +<span>hi</span> +<table></table> +<span>ho</span> +<table></table> +!!end + +!!test +Encapsulation properly handles null DSR information from foster box +!!options +parsoid=wt2html,wt2wt +!!input +{{echo|<table>foo<tr><td>bar</td></tr></table>}} +!!result +<span typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":" +<table>foo +<tr> +<td>bar</td></tr></table>"}},"i":0}}]}">foo</span> +<table> +<tbody> +<tr> +<td>bar</td></tr></tbody></table> +!!end + +!!test +1. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!!input +<table>{{echo|foo<tr><td>bar</td></tr>}}</table> +!!result +<span typeof="mw:Transclusion" data-mw="{"parts":[" +<table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo +<tr> +<td>bar</td></tr>"}},"i":0}},"</table>"]}">foo</span> +<table> +<tbody> +<tr> +<td>bar</td></tr></tbody></table> +!!end + +!!test +2. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!!input +<table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table> +!!result +<div typeof="mw:Transclusion" data-mw="{"parts":[" +<table> +<div>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}},"</div> +<tr> +<td>bar</td></tr></table>"]}">foo</div> +<table> +<tbody> +<tr> +<td>bar</td></tr></tbody></table> +!!end + +!!test +3. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!!input +<table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table> +!!result +<div typeof="mw:Transclusion" data-mw="{"parts":[" +<table> +<div> +<p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo</p></div> +<tr> +<td>"}},"i":0}},"bar</td></tr></table>"]}"> +<p>foo</p></div> +<table> +<tbody> +<tr> +<td>bar</td></tr></tbody></table> +!!end + +!!test +4. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!!input +<table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table> +!!result +<div typeof="mw:Transclusion" data-mw="{"parts":[" +<table> +<div> +<p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo</p></div> +<tr> +<td>"}},"i":0}},"bar</td></tr></table>"]}"> +<p>foo</p></div> +<table> +<tbody> +<tr> +<td>bar</td></tr></tbody></table> +!!end + +!!test +5. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!!input +<table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table> +!!result +<span typeof="mw:Transclusion" data-mw="{"parts":[" +<table> +<tr> +<td> +<div> +<p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo</p></div></td>foo"}},"i":0}},"</tr></table>"]}">foo</span> +<table> +<tbody> +<tr> +<td> +<div> +<p>foo</p></div></td></tr></tbody></table> +!!end + +!!test +6. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!!input +<table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p> +!!result +<span typeof="mw:Transclusion" data-mw="{"parts":[" +<table> +<tr> +<td> +<div> +<p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo</p></div></td>foo</tr></table>"}},"i":0}}]}">foo</span> +<table> +<tbody> +<tr> +<td> +<div> +<p>foo</p></div></td></tr></tbody></table> +<p>ok</p> +!!end + +!!test +7. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!!input +<table>{{echo|<p>foo</p>}}<td>bar</td></table> +!!result +<p typeof="mw:Transclusion" data-mw="{"parts":[" +<table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":" +<p>foo</p>"}},"i":0}}," +<td>bar</td></table>"]}">foo</p> +<table> +<tbody> +<tr> +<td>bar</td></tr></tbody></table> +!!end + +!!test +8. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!!input +{{echo|a +}}{|{{echo|style='color:red'}} +|- +|b +|} +!!result +<p typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}">a</p><span typeof="mw:Transclusion" data-mw="{"parts":["{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"style":{"wt":"'color:red'"}},"i":0}},"\n|-\n|b\n|}"]}">{{{1}}}</span> +<table> +<tbody> +<tr> +<td>b</td></tr></tbody></table> +!!end + +# ----------------------------------------------------------------- +# The following section of tests are primarily to spec requirements +# around serialization of new/edited content. +# +# All these tests are marked Parsoid html2wt and html2html only +# ---------------------------------------------------------------- + +!! test +Image: Modifying size of an image +!! options +parsoid=html2wt +!! input +[[Image:Wiki.png|230x230px]] +!! result +<p data-parsoid='{"dsr":[0,24,0,0]}'><span typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"100px"}],"cacheKey":"[[Image:Wiki.png|100px]]","img":{"h":115,"w":100,"wdset":true},"dsr":[0,24,null,null]}'><a href="./File:Wiki.png" data-parsoid='{"a":{"href":"./File:Wiki.png"}}'><img resource="./File:Wiki.png" src="//upload.wikimedia.org/wikipedia/en/thumb/b/bc/Wiki.png/100px-Wiki.png" height="230" width="200" data-parsoid='{"a":{"resource":"./File:Wiki.png"},"sa":{"resource":"Image:Wiki.png"}}'></a></span></p> +!!end + +!! test +Image: New block level image should have \n before and after +!! options +parsoid=html2wt +!! input +123 +[[File:Wiki.png|right|thumb|150x150px]] +456 +!! result +<p>123</p><figure typeof="mw:Image/Thumb" class="mw-halign-right"><a href="./File:Wiki.png"><img src="http://192.168.142.128/mw/images/thumb/b/bc/Wiki.png/131px-Wiki.png" width="131" height="150" resource="./File:Wiki.png"></a></figure><p>456</p> +!!end + +# Wacky -- the leading newline in input is required because +# that is what the serializer emits. To be fixed. Not fixing +# the test because this test is required to test serialization of +# new content and preferred whitespace style. +!! test +Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does) +!! options +parsoid=html2wt +!! input + +* foo +!! result +<ul> +<li><p>foo</p></li> +</ul> +!! end + +# Wacky -- the leading newline in input is required because +# that is what the serializer emits. To be fixed. Not fixing +# the test because this test is required to test serialization of +# new content and preferred whitespace style. +!! test +Lists: Add space after bullets +!! options +parsoid=html2wt +!! input + +* foo +* bar +* <span> baz</span> +!! result +<ul> +<li>foo</li> +<li> bar</li> +<li><span> baz</span></li> +</ul> +!! end + +!! test +Parsoid: Serialize positional parameters with = in them as named parameter +!! options +parsoid=html2wt +!! input +{{echo|1 = f=oo}} + +{{echo|1 = f=oo|2 = bar}} + +<!--Orig params with data-parsoid has heuristics for handling = chars--> +<!--FIXME: But maybe the heuristic needs fixing to apply to new params as well--> +{{echo|<nowiki>f=oo</nowiki>|bar}} +!! result +<p about="#mwt1" typeof="mw:Transclusion" +data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p> + +<p about="#mwt1" typeof="mw:Transclusion" +data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p> + +<!--Orig params with data-parsoid has heuristics for handling = chars--> +<!--FIXME: But maybe the heuristic needs fixing to apply to new params as well--> +<p data-parsoid='{"pi":[[{"k":"1","spc":["","","",""]},{"k":"2","spc":["","","",""]}]]}' about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"},"2":{"wt":"bar"}},"i":0}}]}'>foo</p> +!! end + +!! test +Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes +!! options +parsoid=html2wt +!! input +<div>a +b +</div> +<div>a +b +</div> +<div> +a + +b +</div> +!! result +<div>a<p>b</p></div> +<div>a +<p>b</p></div> +<div> +a +<p>b</p></div> +!! end + +#----------------------------- +# I/B quote minimization tests +#----------------------------- + +!! test +1. I/B quote minimization: wikitext-only tags should be combined +!! options +parsoid=html2wt +!! input +''AB'' + +'''AB''' + +''A'''B''''' + +'''A''B''''' + +'''A''BC''D''' + +'''''AB''''' + +'''''AB''''' + +'''''AB''''' +!! result +<p><i>A</i><i>B</i></p> +<p><b>A</b><b>B</b></p> +<p><i>A</i><b><i>B</i></b></p> +<p><b>A</b><i><b>B</b></i></p> +<p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p> +<p><i><b>A</b></i><i><b>B</b></i></p> +<p><i><b>A</b></i><b><i>B</i></b></p> +<p><b><i>A</i></b><i><b>B</b></i></p> +!! end + +!! test +2. I/B quote minimization: wikitext and html tags should not be combined +!! options +parsoid=html2wt +!! input +''A''<i>B</i> + +''A'''''<i>B</i>''' +!! result +<p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p> +<p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p> +!! end + +!! test +3. I/B quote minimization: templated content stops minimization +!! options +parsoid=html2wt +!! input +''A''{{echo|''B''}} + +''A''{{echo|'''''B'''''}} +!! result +<p><i>A</i><i about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"''B''"}},"i":0}}]}'>B</i> +<p><i>A</i><b about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"'''''B'''''"}},"i":0}}]}'><i>B</i></b> +!! end + +!! test +4. I/B quote minimization: new content should be mimimized with adjacent old content +!! options +parsoid=html2wt +!! input +''AB'' + +'''AB''' + +''A'''B''''' +!! result +<p><i>A</i><i data-parsoid='{}'>B</i></p> +<p><b data-parsoid='{}'>A</b><b>B</b></p> +<p><i>A</i><b data-parsoid='{}'><i data-parsoid='{}'>B</i></b></p> +!! end + +# ----------------------------------------------------------------- +# End of section for Parsoid-only html2wt tests for serialization +# of new content +# ----------------------------------------------------------------- + TODO: more images more tables diff --git a/tests/parser/preprocess/All_system_messages.expected b/tests/parser/preprocess/All_system_messages.expected index 897c5fb0..078d8f0d 100644 --- a/tests/parser/preprocess/All_system_messages.expected +++ b/tests/parser/preprocess/All_system_messages.expected @@ -1239,27 +1239,6 @@ diff </td><td> <template lineStart="1"><title>int:Difference</title></template> </td></tr><tr><td> -[http://tl.wiktionary.org/w/wiki.phtml?title=MediaWiki:Disambiguations&action=edit disambiguations]<br> -[[MediaWiki_talk:Disambiguations|Talk]] -</td><td> -Disambiguation pages -</td><td> -<template lineStart="1"><title>int:Disambiguations</title></template> -</td></tr><tr><td> -[http://tl.wiktionary.org/w/wiki.phtml?title=MediaWiki:Disambiguationspage&action=edit disambiguationspage]<br> -[[MediaWiki_talk:Disambiguationspage|Talk]] -</td><td> -Wiktionary:Links_to_disambiguating_pages -</td><td> -<template lineStart="1"><title>int:Disambiguationspage</title></template> -</td></tr><tr><td> -[http://tl.wiktionary.org/w/wiki.phtml?title=MediaWiki:Disambiguationstext&action=edit disambiguationstext]<br> -[[MediaWiki_talk:Disambiguationstext|Talk]] -</td><td> -The following pages link to a &lt;i&gt;disambiguation page&lt;/i&gt;. They should link to the appropriate topic instead.&lt;br /&gt;A page is treated as dismbiguation if it is linked from $1.&lt;br /&gt;Links from other namespaces are &lt;i&gt;not&lt;/i&gt; listed here. -</td><td> -<template lineStart="1"><title>int:Disambiguationstext</title></template> -</td></tr><tr><td> [http://tl.wiktionary.org/w/wiki.phtml?title=MediaWiki:Disclaimerpage&action=edit disclaimerpage]<br> [[MediaWiki_talk:Disclaimerpage|Talk]] </td><td> diff --git a/tests/parser/preprocess/All_system_messages.txt b/tests/parser/preprocess/All_system_messages.txt index fc10d7cf..3c30da94 100644 --- a/tests/parser/preprocess/All_system_messages.txt +++ b/tests/parser/preprocess/All_system_messages.txt @@ -1239,27 +1239,6 @@ diff </td><td> {{int:Difference}} </td></tr><tr><td> -[http://tl.wiktionary.org/w/wiki.phtml?title=MediaWiki:Disambiguations&action=edit disambiguations]<br> -[[MediaWiki_talk:Disambiguations|Talk]] -</td><td> -Disambiguation pages -</td><td> -{{int:Disambiguations}} -</td></tr><tr><td> -[http://tl.wiktionary.org/w/wiki.phtml?title=MediaWiki:Disambiguationspage&action=edit disambiguationspage]<br> -[[MediaWiki_talk:Disambiguationspage|Talk]] -</td><td> -Wiktionary:Links_to_disambiguating_pages -</td><td> -{{int:Disambiguationspage}} -</td></tr><tr><td> -[http://tl.wiktionary.org/w/wiki.phtml?title=MediaWiki:Disambiguationstext&action=edit disambiguationstext]<br> -[[MediaWiki_talk:Disambiguationstext|Talk]] -</td><td> -The following pages link to a <i>disambiguation page</i>. They should link to the appropriate topic instead.<br />A page is treated as dismbiguation if it is linked from $1.<br />Links from other namespaces are <i>not</i> listed here. -</td><td> -{{int:Disambiguationstext}} -</td></tr><tr><td> [http://tl.wiktionary.org/w/wiki.phtml?title=MediaWiki:Disclaimerpage&action=edit disclaimerpage]<br> [[MediaWiki_talk:Disclaimerpage|Talk]] </td><td> |