summaryrefslogtreecommitdiff
path: root/tests/parser
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-01-28 09:50:25 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-01-28 09:50:25 -0500
commit5744df39e15f85c6cc8a9faf8924d77e76d2b216 (patch)
treea8c8dd40a94d1fa0d5377566aa5548ae55a163da /tests/parser
parent4bb2aeca1d198391ca856aa16c40b8559c68daec (diff)
parent224b22a051051f6c2e494c3a2fb4adb42898e2d1 (diff)
Merge branch 'archwiki'
Conflicts: extensions/FluxBBAuthPlugin.php extensions/SyntaxHighlight_GeSHi/README extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.i18n.php extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php extensions/SyntaxHighlight_GeSHi/geshi/docs/CHANGES extensions/SyntaxHighlight_GeSHi/geshi/docs/THANKS extensions/SyntaxHighlight_GeSHi/geshi/docs/TODO extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractClass.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractClass_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractMethod.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateClass.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateClass_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/AbstractPrivateMethod.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Class.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Class_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Constant.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Constructor.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Destructor.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Function.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Global.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/I.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Index.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Interface.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Interface_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/L.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Lminus.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Lplus.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Method.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Page.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Page_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateClass.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateClass_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateMethod.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/PrivateVariable.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/StaticMethod.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/StaticVariable.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/T.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Tminus.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Tplus.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/Variable.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/blank.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/class_folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/file.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/function_folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/next_button.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/next_button_disabled.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/package.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/package_folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/previous_button.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/previous_button_disabled.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/private_class_logo.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/tutorial.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/tutorial_folder.png extensions/SyntaxHighlight_GeSHi/geshi/docs/api/media/images/up_button.png extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.txt extensions/SyntaxHighlight_GeSHi/geshi/geshi.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/4cs.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502acme.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502kickass.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/6502tasm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/68000devpac.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/abap.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/actionscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/actionscript3.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ada.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/algol68.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/apache.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/applescript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/apt_sources.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/asm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/asp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/autoconf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/autohotkey.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/autoit.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/avisynth.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/awk.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bascomavr.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bash.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/basic4gl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bibtex.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/blitzbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/bnf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/boo.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/c.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/c_loadrunner.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/c_mac.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/caddcl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cadlisp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cfdg.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cfm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/chaiscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cil.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/clojure.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cmake.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cobol.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/coffeescript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cpp-qt.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cpp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/csharp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/css.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/cuesheet.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/d.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/dcs.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/delphi.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/diff.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/div.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/dos.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/dot.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/e.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ecmascript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/eiffel.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/email.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/epc.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/erlang.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/euphoria.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/f1.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/falcon.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/fo.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/fortran.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/freebasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/fsharp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gambas.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gdb.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/genero.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/genie.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gettext.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/glsl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gnuplot.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/go.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/groovy.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/gwbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/haskell.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/hicest.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/hq9plus.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/html4strict.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/html5.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/icon.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/idl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ini.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/inno.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/intercal.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/io.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/j.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/java.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/java5.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/javascript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/jquery.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/kixtart.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/klonec.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/klonecpp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/latex.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lb.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lisp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/llvm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/locobasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/logtalk.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lolcode.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lotusformulas.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lotusscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lsl2.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/lua.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/m68k.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/magiksf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/make.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mapbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/matlab.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mirc.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mmix.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/modula2.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/modula3.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mpasm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mxml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/mysql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/newlisp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/nsis.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oberon2.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/objc.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/objeck.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ocaml-brief.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ocaml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oobas.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oracle11.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oracle8.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oxygene.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/oz.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pascal.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pcre.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/per.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/perl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/perl6.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/php-brief.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/php.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pic16.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pike.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pixelbender.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pli.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/plsql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/postgresql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/povray.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/powerbuilder.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/powershell.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/proftpd.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/progress.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/prolog.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/properties.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/providex.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/purebasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/pycon.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/python.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/q.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/qbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/rails.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/rebol.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/reg.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/robots.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/rpmspec.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/rsplus.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/ruby.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/sas.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/scala.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/scheme.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/scilab.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/sdlbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/smalltalk.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/smarty.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/sql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/systemverilog.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/tcl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/teraterm.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/text.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/thinbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/tsql.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/typoscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/unicon.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/uscript.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vala.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vb.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vbnet.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/verilog.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vhdl.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/vim.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/visualfoxpro.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/visualprolog.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/whitespace.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/whois.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/winbatch.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/xbasic.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/xml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/xorg_conf.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/xpp.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/yaml.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/z80.php extensions/SyntaxHighlight_GeSHi/geshi/geshi/zxbasic.php
Diffstat (limited to 'tests/parser')
-rw-r--r--tests/parser/ParserTestResult.php42
-rw-r--r--tests/parser/parserTest.inc483
-rw-r--r--tests/parser/parserTests.txt9576
-rw-r--r--tests/parser/parserTestsParserHook.php22
-rw-r--r--tests/parser/preprocess/All_system_messages.expected21
-rw-r--r--tests/parser/preprocess/All_system_messages.txt21
-rw-r--r--tests/parser/preprocess/NestedTemplates.expected90
-rw-r--r--tests/parser/preprocess/NestedTemplates.txt89
8 files changed, 9441 insertions, 903 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 86e1e192..58ea1ed0 100644
--- a/tests/parser/parserTest.inc
+++ b/tests/parser/parserTest.inc
@@ -1,23 +1,27 @@
<?php
-# Copyright (C) 2004, 2010 Brion Vibber <brion@pobox.com>
-# http://www.mediawiki.org/
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-# http://www.gnu.org/copyleft/gpl.html
-
/**
+ * 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/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
* @todo Make this more independent of the configuration (and if possible the database)
* @todo document
* @file
@@ -29,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;
@@ -61,7 +65,7 @@ class ParserTest {
private $dbClone;
/**
- * string $oldTablePrefix Original table prefix
+ * @var string $oldTablePrefix Original table prefix
*/
private $oldTablePrefix;
@@ -72,6 +76,7 @@ class ParserTest {
public $regex = "";
private $savedGlobals = array();
+
/**
* Sets terminal colorization and diff/quick modes depending on OS and
* command-line options (--color and --quick).
@@ -81,14 +86,14 @@ class ParserTest {
$this->color = !wfIsWindows() && Maintenance::posix_isatty( 1 );
if ( isset( $options['color'] ) ) {
- switch( $options['color'] ) {
- case 'no':
- $this->color = false;
- break;
- case 'yes':
- default:
- $this->color = true;
- break;
+ switch ( $options['color'] ) {
+ case 'no':
+ $this->color = false;
+ break;
+ case 'yes':
+ default:
+ $this->color = true;
+ break;
}
}
@@ -100,7 +105,7 @@ class ParserTest {
$this->showProgress = !isset( $options['quiet'] );
$this->showFailure = !(
isset( $options['quiet'] )
- && ( isset( $options['record'] )
+ && ( isset( $options['record'] )
|| isset( $options['compare'] ) ) ); // redundant output
$this->showOutput = isset( $options['show-output'] );
@@ -128,6 +133,7 @@ class ParserTest {
}
$this->runDisabled = isset( $options['run-disabled'] );
+ $this->runParsoid = isset( $options['run-parsoid'] );
$this->hooks = array();
$this->functionHooks = array();
@@ -137,36 +143,38 @@ 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;
$wgLockManagers = array( array(
- 'name' => 'fsLockManager',
- 'class' => 'FSLockManager',
+ 'name' => 'fsLockManager',
+ 'class' => 'FSLockManager',
'lockDirectory' => wfTempDir() . '/test-repo/lockdir',
+ ), array(
+ 'name' => 'nullLockManager',
+ 'class' => 'NullLockManager',
) );
$wgLocalFileRepo = array(
- 'class' => 'LocalRepo',
- 'name' => 'local',
- 'url' => 'http://example.com/images',
- 'hashLevels' => 2,
+ 'class' => 'LocalRepo',
+ 'name' => 'local',
+ 'url' => 'http://example.com/images',
+ 'hashLevels' => 2,
'transformVia404' => false,
- 'backend' => new FSFileBackend( array(
- 'name' => 'local-backend',
+ 'backend' => new FSFileBackend( array(
+ 'name' => 'local-backend',
'lockManager' => 'fsLockManager',
'containerPaths' => array(
- 'local-public' => wfTempDir() . '/test-repo/public',
- 'local-thumb' => wfTempDir() . '/test-repo/thumb',
- 'local-temp' => wfTempDir() . '/test-repo/temp',
+ 'local-public' => wfTempDir() . '/test-repo/public',
+ 'local-thumb' => wfTempDir() . '/test-repo/thumb',
+ 'local-temp' => wfTempDir() . '/test-repo/temp',
'local-deleted' => wfTempDir() . '/test-repo/deleted',
)
) )
@@ -174,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 ) {
@@ -201,16 +212,83 @@ class ParserTest {
$wgRequest = $context->getRequest();
if ( $wgStyleDirectory === false ) {
- $wgStyleDirectory = "$IP/skins";
+ $wgStyleDirectory = "$IP/skins";
}
+ self::setupInterwikis();
}
- public function setupRecorder ( $options ) {
+ /**
+ * 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 ) {
if ( isset( $options['record'] ) ) {
$this->recorder = new DbTestRecorder( $this );
$this->recorder->version = isset( $options['setversion'] ) ?
- $options['setversion'] : SpecialVersion::getVersion();
+ $options['setversion'] : SpecialVersion::getVersion();
} elseif ( isset( $options['compare'] ) ) {
$this->recorder = new DbTestPreviewer( $this );
} else {
@@ -222,11 +300,10 @@ class ParserTest {
* Remove last character if it is a newline
* @group utility
*/
- static public function chomp( $s ) {
+ public static function chomp( $s ) {
if ( substr( $s, -1 ) === "\n" ) {
return substr( $s, 0, -1 );
- }
- else {
+ } else {
return $s;
}
}
@@ -372,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();
@@ -385,7 +467,7 @@ class ParserTest {
$this->teardownDatabase();
$this->recorder->report();
- } catch (DBError $e) {
+ } catch ( DBError $e ) {
echo $e->getMessage();
}
$this->recorder->end();
@@ -412,6 +494,9 @@ class ParserTest {
/**
* Get a Parser object
+ *
+ * @param string $preprocessor
+ * @return Parser
*/
function getParser( $preprocessor = null ) {
global $wgParserConf;
@@ -458,8 +543,7 @@ class ParserTest {
if ( isset( $opts['title'] ) ) {
$titleText = $opts['title'];
- }
- else {
+ } else {
$titleText = 'Parser test';
}
@@ -482,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'] ) ) {
@@ -513,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;
}
}
@@ -532,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 ) {
@@ -627,40 +717,42 @@ class ParserTest {
self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 );
$settings = array(
- 'wgServer' => 'http://Britney-Spears',
+ 'wgServer' => 'http://example.org',
'wgScript' => '/index.php',
'wgScriptPath' => '/',
'wgArticlePath' => '/wiki/$1',
'wgActionPaths' => array(),
- 'wgLockManagers' => array(
- 'name' => 'fsLockManager',
- 'class' => 'FSLockManager',
+ 'wgLockManagers' => array( array(
+ 'name' => 'fsLockManager',
+ 'class' => 'FSLockManager',
'lockDirectory' => $this->uploadDir . '/lockdir',
- ),
+ ), array(
+ 'name' => 'nullLockManager',
+ 'class' => 'NullLockManager',
+ ) ),
'wgLocalFileRepo' => array(
'class' => 'LocalRepo',
'name' => 'local',
'url' => 'http://example.com/images',
'hashLevels' => 2,
'transformVia404' => false,
- 'backend' => new FSFileBackend( array(
- 'name' => 'local-backend',
+ 'backend' => new FSFileBackend( array(
+ 'name' => 'local-backend',
'lockManager' => 'fsLockManager',
'containerPaths' => array(
- 'local-public' => $this->uploadDir,
- 'local-thumb' => $this->uploadDir . '/thumb',
- 'local-temp' => $this->uploadDir . '/temp',
+ 'local-public' => $this->uploadDir,
+ 'local-thumb' => $this->uploadDir . '/thumb',
+ 'local-temp' => $this->uploadDir . '/temp',
'local-deleted' => $this->uploadDir . '/delete',
)
) )
),
'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
'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'] ) ),
@@ -669,18 +761,20 @@ class ParserTest {
'wgNoFollowLinks' => true,
'wgNoFollowDomainExceptions' => array(),
'wgThumbnailScriptPath' => false,
- 'wgUseImageResize' => 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,
'wgGroupPermissions' => array( '*' => array(
'createaccount' => true,
- 'read' => true,
- 'edit' => true,
- 'createpage' => true,
- 'createtalk' => true,
+ 'read' => true,
+ 'edit' => true,
+ 'createpage' => true,
+ 'createtalk' => true,
) ),
'wgNamespaceProtection' => array( NS_MEDIAWIKI => 'editinterface' ),
'wgDefaultExternalStore' => array(),
@@ -747,7 +841,7 @@ class ParserTest {
$tables = array( 'user', 'user_properties', 'user_former_groups', 'page', 'page_restrictions',
'protected_titles', 'revision', 'text', 'pagelinks', 'imagelinks',
'categorylinks', 'templatelinks', 'externallinks', 'langlinks', 'iwlinks',
- 'site_stats', 'hitcounter', 'ipblocks', 'image', 'oldimage',
+ 'site_stats', 'hitcounter', 'ipblocks', 'image', 'oldimage',
'recentchanges', 'watchlist', 'interwiki', 'logging',
'querycache', 'objectcache', 'job', 'l10n_cache', 'redirect', 'querycachetwo',
'archive', 'user_groups', 'page_props', 'category', 'msg_resource', 'msg_resource_links'
@@ -810,47 +904,13 @@ class ParserTest {
# Anonymous user
$this->db->insert( 'user', array(
- 'user_id' => 0,
- 'user_name' => 'Anonymous' ) );
+ 'user_id' => 0,
+ '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();
@@ -858,34 +918,67 @@ 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,
- 'width' => 1941,
- 'height' => 220,
- 'bits' => 24,
- 'media_type' => MEDIATYPE_BITMAP,
- 'mime' => 'image/jpeg',
- 'metadata' => serialize( array() ),
- 'sha1' => wfBaseConvert( '', 16, 36, 31 ),
- 'fileExists' => true
- ), $this->db->timestamp( '20010115123500' ), $user );
+ 'size' => 7881,
+ 'width' => 1941,
+ 'height' => 220,
+ 'bits' => 8,
+ 'media_type' => MEDIATYPE_BITMAP,
+ 'mime' => 'image/jpeg',
+ 'metadata' => serialize( array() ),
+ 'sha1' => wfBaseConvert( '1', 16, 36, 31 ),
+ 'fileExists' => true
+ ), $this->db->timestamp( '20010115123500' ), $user );
+
+ $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Thumb.png' ) );
+ # again, note that size/width/height below are ignored; see above.
+ $image->recordUpload2( '', 'Upload of some lame thumbnail', 'Some lame thumbnail', array(
+ 'size' => 22589,
+ 'width' => 135,
+ 'height' => 135,
+ 'bits' => 8,
+ 'media_type' => MEDIATYPE_BITMAP,
+ 'mime' => 'image/png',
+ 'metadata' => serialize( array() ),
+ 'sha1' => wfBaseConvert( '2', 16, 36, 31 ),
+ 'fileExists' => true
+ ), $this->db->timestamp( '20130225203040' ), $user );
+
+ $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Foobar.svg' ) );
+ $image->recordUpload2( '', 'Upload of some lame SVG', 'Some lame SVG', array(
+ 'size' => 12345,
+ 'width' => 240,
+ 'height' => 180,
+ 'bits' => 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]]
$image = wfLocalFile( Title::makeTitle( NS_FILE, 'Bad.jpg' ) );
$image->recordUpload2( '', 'zomgnotcensored', 'Borderline image', array(
- 'size' => 12345,
- 'width' => 320,
- 'height' => 240,
- 'bits' => 24,
- 'media_type' => MEDIATYPE_BITMAP,
- 'mime' => 'image/jpeg',
- 'metadata' => serialize( array() ),
- 'sha1' => wfBaseConvert( '', 16, 36, 31 ),
- 'fileExists' => true
- ), $this->db->timestamp( '20010115123500' ), $user );
+ 'size' => 12345,
+ 'width' => 320,
+ 'height' => 240,
+ 'bits' => 24,
+ 'media_type' => MEDIATYPE_BITMAP,
+ 'mime' => 'image/jpeg',
+ 'metadata' => serialize( array() ),
+ 'sha1' => wfBaseConvert( '3', 16, 36, 31 ),
+ 'fileExists' => true
+ ), $this->db->timestamp( '20010115123500' ), $user );
}
public function teardownDatabase() {
@@ -899,7 +992,7 @@ class ParserTest {
$this->databaseSetupDone = false;
if ( $this->useTemporaryTables ) {
- if( $this->db->getType() == 'sqlite' ) {
+ if ( $this->db->getType() == 'sqlite' ) {
# Under SQLite the searchindex table is virtual and need
# to be explicitly destroyed. See bug 29912
# See also MediaWikiTestCase::destroyDB()
@@ -914,12 +1007,16 @@ 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' )
+ if ( $this->db->getType() == 'oracle' ) {
$this->db->query( 'BEGIN FILL_WIKI_INFO; END;' );
+ }
$this->teardownGlobals();
}
@@ -951,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;
}
@@ -964,7 +1067,7 @@ class ParserTest {
private function teardownGlobals() {
RepoGroup::destroySingleton();
FileBackendGroup::destroySingleton();
- LockManagerGroup::destroySingleton();
+ LockManagerGroup::destroySingletons();
LinkCache::singleton()->clear();
foreach ( $this->savedGlobals as $var => $val ) {
@@ -982,21 +1085,41 @@ class ParserTest {
// delete the files first, then the dirs.
self::deleteFiles(
- array (
+ array(
"$dir/3/3a/Foobar.jpg",
"$dir/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg",
"$dir/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg",
"$dir/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg",
"$dir/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg",
+ "$dir/thumb/3/3a/Foobar.jpg/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",
)
);
self::deleteDirs(
- array (
+ array(
"$dir/3/3a",
"$dir/3",
"$dir/thumb/6/65",
@@ -1004,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",
@@ -1051,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";
}
@@ -1066,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";
}
}
@@ -1106,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();
@@ -1117,14 +1251,15 @@ class ParserTest {
$outfile = "$prefix-$outFileTail";
$this->dumpToFile( $output, $outfile );
- $shellInfile = wfEscapeShellArg($infile);
- $shellOutfile = wfEscapeShellArg($outfile);
+ $shellInfile = wfEscapeShellArg( $infile );
+ $shellOutfile = wfEscapeShellArg( $outfile );
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 );
@@ -1154,7 +1289,7 @@ class ParserTest {
return preg_replace(
array( '/^(-.*)$/m', '/^(\+.*)$/m' ),
array( $this->term->color( 34 ) . '$1' . $this->term->reset(),
- $this->term->color( 31 ) . '$1' . $this->term->reset() ),
+ $this->term->color( 31 ) . '$1' . $this->term->reset() ),
$text );
}
@@ -1177,7 +1312,7 @@ class ParserTest {
* @param $line Integer: the input line number, for reporting errors
* @param $ignoreDuplicate Boolean: whether to silently ignore duplicate pages
*/
- static public function addArticle( $name, $text, $line = 'unknown', $ignoreDuplicate = '' ) {
+ public static function addArticle( $name, $text, $line = 'unknown', $ignoreDuplicate = '' ) {
global $wgCapitalLinks;
$oldCapitalLinks = $wgCapitalLinks;
@@ -1203,7 +1338,7 @@ class ParserTest {
}
}
- $page->doEdit( $text, '', EDIT_NEW );
+ $page->doEditContent( ContentHandler::makeContent( $text, $title ), '', EDIT_NEW );
$wgCapitalLinks = $oldCapitalLinks;
}
@@ -1219,7 +1354,7 @@ class ParserTest {
public function requireHook( $name ) {
global $wgParser;
- $wgParser->firstCallInit( ); // make sure hooks are loaded.
+ $wgParser->firstCallInit(); // make sure hooks are loaded.
if ( isset( $wgParser->mTagHooks[$name] ) ) {
$this->hooks[$name] = $wgParser->mTagHooks[$name];
@@ -1242,7 +1377,7 @@ class ParserTest {
public function requireFunctionHook( $name ) {
global $wgParser;
- $wgParser->firstCallInit( ); // make sure hooks are loaded.
+ $wgParser->firstCallInit(); // make sure hooks are loaded.
if ( isset( $wgParser->mFunctionHooks[$name] ) ) {
$this->functionHooks[$name] = $wgParser->mFunctionHooks[$name];
@@ -1274,9 +1409,9 @@ class ParserTest {
private function wellFormed( $text ) {
$html =
Sanitizer::hackDocType() .
- '<html>' .
- $text .
- '</html>';
+ '<html>' .
+ $text .
+ '</html>';
$parser = xml_parser_create( "UTF-8" );
@@ -1324,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 df057248..9658e8f8 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -21,9 +21,16 @@
# language=XXX set content language to XXX for this test
# variant=XXX set the variant of language for this test (eg zh-tw)
# disabled do not run test
+# parsoid parsoid-only test (not run by PHP parser)
+# php php-only test (not run by the parsoid parser)
# 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
@@ -36,19 +43,19 @@ Main Page
blah blah
!! endarticle
-!!article
+!!article
Template:Foo
!!text
FOO
!!endarticle
-!! article
+!! article
Template:Blank
!! text
!! endarticle
!! article
-Template:!
+Template:pipe
!! text
|
!! endarticle
@@ -65,6 +72,80 @@ Template:inner list
* item 1
!! endarticle
+!! article
+Template:tbl-start
+!! text
+{|
+!! endarticle
+
+!! article
+Template:tbl-end
+!! text
+|}
+!! endarticle
+
+!! article
+Template:!
+!! text
+|
+!! endarticle
+
+!! article
+Template:echo
+!! text
+{{{1}}}
+!! endarticle
+
+!! article
+Template:echo_with_span
+!! text
+<span>{{{1}}}</span>
+!! endarticle
+
+!! article
+Template:echo_with_div
+!! text
+<div>{{{1}}}</div>
+!! endarticle
+
+!! article
+Template:attr_str
+!! text
+{{{1}}}="{{{2}}}"
+!! endarticle
+
+!! article
+Template:table_attribs
+!! text
+<noinclude>
+|</noinclude>style="color: red"| Foo
+!! endarticle
+
+!! article
+Template:table_cells
+!! text
+{{table_attribs}} || Bar || Baz
+!! endarticle
+
+!! article
+Template:image_attribs
+!! text
+<noinclude>
+[[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
+!! endarticle
+
+!! article
+A?b
+!! text
+Weirdo titles!
+!! endarticle
+
+!!article
+Template:Bullet
+!!text
+* Bar
+!!endarticle
+
###
### Basic tests
###
@@ -108,14 +189,227 @@ 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&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
+<p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
+</p><p><br />
+</p>
+<h1><span class="mw-headline" id="b_2">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
+
+!! end
+
+!! test
+Extra newlines between heading and content are swallowed
+!! 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&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
+<p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
+</p>
+!! end
+
+!! test
+Parsing an URL
+!! input
+http://fr.wikipedia.org/wiki/🍺
+<!-- EasterEgg we love beer, better be able be able to link to it -->
+!! result
+<p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
+</p>
+!! end
+
+!! test
Simple list
!! input
* 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
@@ -138,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&amp;action=edit&amp;redlink=1" class="new" title="Lunar Prospector (page does not exist)">Lunar Prospector</a>'</i>s gamma-ray spectrometer
+</p>
+!! end
+
+# this example taken from [[en:Flaming Pie]] (bug 49926)
+!! test
+Italics and possessives (2)
+!! 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&amp;action=edit&amp;redlink=1" class="new" title="Accademia della Crusca (page does not exist)">Accademia della Crusca</a></i>, for Italian, was published. In 1690 in Rotterdam was published, posthumously, the <i>Dictionnaire Universel</i>.
+</p>
+!! end
+
+
###
### 2-quote opening sequence tests
###
@@ -191,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
###
@@ -235,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
###
@@ -279,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
###
@@ -294,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
@@ -365,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
@@ -418,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
@@ -426,7 +834,6 @@ Italics and bold: other quote tests: (3,2,3,3)
!!end
-
!! test
Italics and bold: other quote tests: (3,(2,2),3)
!! input
@@ -436,6 +843,122 @@ Italics and bold: other quote tests: (3,(2,2),3)
</p>
!!end
+
+!! test
+Italicized possessive
+!! input
+The ''[[Main Page]]'''s talk page.
+!! result
+<p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
+</p>
+!! end
+
+!! test
+Parsoid only: Quote balancing context should be restricted to td/th cells on the same wikitext line
+(Requires tidy for PHP parser output to be fixed up)
+!! options
+parsoid=wt2html,wt2wt
+!! 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
+###
+
+!! test
+Non-html5 tags should be accepted
+!! input
+<center>''foo''</center>
+<big>''foo''</big>
+<font>''foo''</font>
+<strike>''foo''</strike>
+<tt>''foo''</tt>
+!! result
+<center><i>foo</i></center>
+<p><big><i>foo</i></big>
+<font><i>foo</i></font>
+<strike><i>foo</i></strike>
+<tt><i>foo</i></tt>
+</p>
+!! end
+
+!! test
+<wbr> is valid wikitext (bug 52468)
+!! 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>&lt;b→&gt; doesn't work! &lt;/b&gt;
+</p><p>&lt;bä&gt; doesn't work! &lt;/b&gt;
+</p><p>&lt;boo&gt; works fine &lt;/b&gt;
+</p><p>&lt;s.foo&gt;foo&lt;/s&gt;
+</p><p>&lt;s.foo&gt;s.foo&lt;/s.foo&gt;
+</p><p>&lt;sub-ID#1&gt;
+</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
###
@@ -482,35 +1005,79 @@ 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
+!! test
+Entities inside <nowiki>
+!! input
+<nowiki>&lt;</nowiki>
+!! result
+<p>&lt;
+</p>
+!! end
+
+!! test
+Entities inside template parameters
+!! options
+parsoid
+!! input
+{{echo|&ndash;}}
+!! result
+<p><span typeof="mw:Transclusion mw:Entity" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&amp;ndash;"}},"i":0}}]}'>&ndash;</span>
+</p>
+!! end
###
### Comments
###
!! test
-Comment test 1
+Comments and Indent-Pre
!! input
<!-- comment 1 --> asdf
+
+<!-- comment 1 --> asdf
<!-- comment 2 -->
+
+<!-- comment 1 --> asdf
+<!-- comment 2 -->xyz
+
+<!-- comment 1 --> asdf
+<!-- comment 2 --> xyz
!! result
<pre>asdf
</pre>
-
+<pre>asdf
+</pre>
+<pre>asdf
+</pre>
+<p>xyz
+</p>
+<pre>asdf
+xyz
+</pre>
!! end
!! test
-Comment test 2
+Comment test 2a
!! input
asdf
<!-- comment 1 -->
@@ -522,6 +1089,19 @@ jkl
!! end
!! test
+Comment test 2b
+!! input
+asdf
+<!-- comment 1 -->
+
+jkl
+!! result
+<p>asdf
+</p><p>jkl
+</p>
+!! end
+
+!! test
Comment test 3
!! input
asdf
@@ -633,6 +1213,129 @@ b
</p>
!! end
+!! test
+Comment on its own line post-expand with non-significant whitespace
+!! input
+a
+ {{blank}} <!---->
+b
+!! result
+<p>a
+</p><p>b
+</p>
+!! end
+
+###
+### paragraph wrapping tests
+###
+!! test
+No block tags
+!! input
+a
+
+b
+!! result
+<p>a
+</p><p>b
+</p>
+!! end
+
+!! test
+Block tag on one line (<div>)
+!! input
+a <div>foo</div>
+
+b
+!! result
+a <div>foo</div>
+<p>b
+</p>
+!! end
+
+!! test
+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>
+
+b <div>foo</div>
+!! result
+a <div>foo</div>
+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
+b
+c
+d<!--foo--> e
+x <div>foo</div> z
+!! result
+<div>foo</div> a
+<p>b
+c
+d e
+</p>
+x <div>foo</div> z
+
+!! end
+
+!! test
+Empty lines between lines with block tags
+!! input
+<div></div>
+
+
+<div></div>a
+
+b
+<div>a</div>b
+
+<div>b</div>d
+
+
+<div>e</div>
+!! result
+<div></div>
+<p><br />
+</p>
+<div></div>a
+<p>b
+</p>
+<div>a</div>b
+<div>b</div>d
+<p><br />
+</p>
+<div>e</div>
+
+!! end
+
###
### Preformatted text
###
@@ -654,6 +1357,33 @@ 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
+ ''b''
+!! result
+<pre>a
+<i>b</i>
+</pre>
+!! end
+
+!! test
<pre> with <nowiki> inside (compatibility with 1.6 and earlier)
!! input
<pre><nowiki>
@@ -684,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
@@ -727,6 +1501,15 @@ Bug 6200: Preformatted in <blockquote>
!! end
!! test
+Entities inside <pre>
+!! input
+<pre>&lt;</pre>
+!! result
+<pre>&lt;</pre>
+
+!! end
+
+!! test
<pre> with forbidden attribute values (bug 3202)
!! input
<pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
@@ -787,6 +1570,700 @@ Bug 6200: Preformatted in <blockquote>
</p>
!! end
+!! test
+</pre> inside nowiki
+!! input
+<nowiki></pre></nowiki>
+!! result
+<p>&lt;/pre&gt;
+</p>
+!! end
+
+!!test
+Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
+!!input
+ {{echo|}}
+!!result
+
+!!end
+
+!!test
+Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
+!!input
+ {{echo|
+foo}}
+!!result
+<p>foo
+</p>
+!!end
+
+!! test
+Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
+!! input
+ {{echo|a
+b}}
+!!result
+<pre>a
+</pre>
+<p>b
+</p>
+!!end
+
+!! test
+Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
+!! input
+ {{echo|a
+b
+c
+ d
+e
+}}
+!!result
+<pre>a
+</pre>
+<p>b
+c
+</p>
+<pre>d
+</pre>
+<p>e
+</p>
+!!end
+
+!!test
+Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
+!!input
+{{echo| foo}}
+
+{{echo| foo}}{{echo| bar}}
+
+{{echo| foo}}
+{{echo| bar}}
+
+{{echo|<!--cmt--> foo}}
+
+<!--cmt-->{{echo| foo}}
+
+{{echo|{{echo| }}bar}}
+!!result
+<pre>foo
+</pre>
+<pre>foo bar
+</pre>
+<pre>foo
+bar
+</pre>
+<pre>foo
+</pre>
+<pre>foo
+</pre>
+<pre>bar
+</pre>
+!!end
+
+!! test
+Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
+!! input
+{{echo| }}a
+
+{{echo|
+ }}a
+
+{{echo|
+ b}}
+
+{{echo|a
+ }}b
+
+{{echo|a
+}} b
+!!result
+<pre>a
+</pre>
+<p><br />
+</p>
+<pre>a
+</pre>
+<p><br />
+</p>
+<pre>b
+</pre>
+<p>a
+</p>
+<pre>b
+</pre>
+<p>a
+</p>
+<pre>b
+</pre>
+!!end
+
+# TODO / maybe: fix wt2wt for this
+!! test
+Parsoid: Don't paragraph-wrap fosterable content
+!! options
+parsoid=wt2html
+!! input
+{|
+<td></td>
+<td></td>
+
+
+
+|}
+!! 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
+<p>a
+</p><p>b
+</p><p>c
+</p>
+<ul>
+<li> d
+</li>
+</ul>
+
+!! end
+
+!! test
+Templates: Don't strip whitespace from positional-param values
+!! input
+{{echo|a }}
+
+{{echo|{{echo|b}} }}
+
+{{echo| c
+}}
+
+{{echo| {{echo|d}}
+}}
+
+{{echo|
+ e}}
+
+{{echo|
+* f}}
+
+{{echo|
+ }}g
+!! result
+<p>a
+</p><p>b
+</p>
+<pre>c
+</pre>
+<p><br />
+</p>
+<pre>d
+</pre>
+<p><br />
+</p>
+<pre>e
+</pre>
+<p><br />
+</p>
+<ul>
+<li> f
+</li>
+</ul>
+<p><br />
+</p>
+<pre>g
+</pre>
+!! end
+
+!! test
+Templates: Handle empty comment-and-ws-only lines correctly
+!! input
+{{echo|foo
+<!--should be ignored-->
+ <!--should be ignored as well-->
+bar}}
+!! result
+<p>foo
+bar
+</p>
+!! 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&#124;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&amp;#124;b"}},"i":0}}]}'>http://foo.com/a|b</a></p>
+!! end
+
+!! test
+Parsoid: Pipe in external link target and content in template parameter
+!! options
+parsoid=html2wt,wt2wt
+!! input
+{{echo|[http://foo.com/a&#124;b a&#124;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>&lt;div&gt;</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>&amp;lt;div&amp;gt;</nowiki>"}},"i":0}}]}'><span typeof="mw:Entity">&lt;</span>div<span typeof="mw:Entity">&gt;</span></span>
+<span typeof="mw:Transclusion mw:Nowiki" about="#mwt3" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<nowiki></nowiki>"}},"i":0}}]}'></span>
+</p>
+!! end
+
+## Bug 52824
+!! test
+Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
+!! options
+parsoid=html2wt,wt2wt
+!! 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
+
+###
+### Parsoid-centric tests for testing RT edge cases for pre
+###
+
+!!test
+1a. Indent-Pre and Comments
+!!input
+ a
+<!--a-->
+c
+!!result
+<pre>a
+</pre>
+<p>c
+</p>
+!!end
+
+!!test
+1b. Indent-Pre and Comments
+!!input
+ a
+ <!--a-->
+c
+!!result
+<pre>a
+</pre>
+<p>c
+</p>
+!!end
+
+!!test
+1c. Indent-Pre and Comments
+!!input
+<!--a--> a
+
+ <!--a--> a
+!!result
+<pre> a
+</pre>
+<pre> a
+</pre>
+!!end
+
+!!test
+1d. Indent-Pre and Comments
+(Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
+!!input
+<!--a--> a
+
+ <!--b-->b
+!!result
+<pre>a
+</pre>
+<pre>b
+</pre>
+!!end
+
+!!test
+2a. Indent-Pre and tables
+!!input
+ {|
+ |-
+ !h1!!h2
+ |foo||bar
+ |}
+!!result
+<table>
+
+<tr>
+<th>h1</th>
+<th>h2
+</th>
+<td>foo</td>
+<td>bar
+</td></tr></table>
+
+!!end
+
+!!test
+2b. Indent-Pre and tables
+!!input
+ {|
+ |-
+|foo
+|}
+!!result
+<table>
+
+<tr>
+<td>foo
+</td></tr></table>
+
+!!end
+
+!!test
+2c. Indent-Pre and tables (bug 42252)
+!!input
+{|
+ |+ foo
+ ! | bar
+|}
+!!result
+<table>
+<caption> foo
+</caption>
+<tr>
+<th> bar
+</th></tr></table>
+
+!!end
+
+!!test
+3a. Indent-Pre and block tags (single-line html)
+!!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
+
+!!test
+3b. Indent-Pre and block tags (pre-content on separate line)
+!!input
+<p>
+ foo
+</p>
+
+<div>
+ foo
+</div>
+
+<center>
+ foo
+</center>
+
+<blockquote>
+ foo
+</blockquote>
+
+<blockquote>
+<pre>
+foo
+</pre>
+</blockquote>
+
+<table><tr><td>
+ foo
+</td></tr></table>
+
+<ul><li>
+ foo
+</li></ul>
+
+!!result
+<p>
+ foo
+</p>
+<div>
+<pre>foo
+</pre>
+</div>
+<center>
+<pre>foo
+</pre>
+</center>
+<blockquote>
+<p> foo
+</p>
+</blockquote>
+<blockquote>
+<pre>
+foo
+</pre>
+</blockquote>
+<table><tr><td>
+<pre>foo
+</pre>
+</td></tr></table>
+<ul><li>
+ foo
+</li></ul>
+
+!!end
+
+!!test
+4. Multiple spaces at start-of-line
+!!input
+ <p> foo </p>
+ foo
+ {|
+|foo
+|}
+!!result
+ <p> foo </p>
+<pre> foo
+</pre>
+<table>
+<tr>
+<td>foo
+</td></tr></table>
+
+!!end
+
+!! test
+5. White-space in indent-pre
+NOTE: the white-space char on 2nd line is significant
+!! input
+ a<br/>
+
+ b
+!! result
+<pre>a<br />
+
+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)
+###
+
+!!test
+HTML-pre: 1. embedded newlines
+!!input
+<pre>foo</pre>
+
+<pre>
+foo
+</pre>
+
+<pre>
+
+foo
+</pre>
+
+<pre>
+
+
+foo
+</pre>
+!!result
+<pre>foo</pre>
+<pre>
+foo
+</pre>
+<pre>
+
+foo
+</pre>
+<pre>
+
+
+foo
+</pre>
+
+!!end
+
+!!test
+HTML-pre: 2: indented text
+!!input
+<pre>
+ foo
+</pre>
+!!result
+<pre>
+ foo
+</pre>
+
+!!end
+
+!!test
+HTML-pre: 3: other wikitext
+!!input
+<pre>
+* foo
+# bar
+= no-h =
+'' no-italic ''
+[[ NoLink ]]
+</pre>
+!!result
+<pre>
+* foo
+# bar
+= no-h =
+'' no-italic ''
+[[ NoLink ]]
+</pre>
+
+!!end
###
### Definition lists
@@ -796,8 +2273,11 @@ Simple definition
!! input
; name : Definition
!! result
-<dl><dt> name&#160;</dt><dd> Definition
-</dd></dl>
+<dl>
+<dt> name&#160;</dt>
+<dd> Definition
+</dd>
+</dl>
!! end
@@ -806,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
@@ -816,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
@@ -826,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>&#160;</dt><dd> definition
-</dd></dl>
+<dl>
+<dt> <a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&#160;</dt>
+<dd> definition
+</dd>
+</dl>
!! end
@@ -836,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
@@ -846,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&amp;action=edit&amp;redlink=1" class="new" title="Help:FAQ (page does not exist)">Help:FAQ</a></dt><dd> The least-read page on Wikipedia
-</dd></dl>
+<dl>
+<dt> <a href="/index.php?title=Help:FAQ&amp;action=edit&amp;redlink=1" class="new" title="Help:FAQ (page does not exist)">Help:FAQ</a></dt>
+<dd> The least-read page on Wikipedia
+</dd>
+</dl>
!! end
@@ -857,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
@@ -867,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
@@ -877,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&#160;: 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&#160;: The Next Generation</a></dt>
+<dd> OK, I made that up
+</dd>
+</dl>
!! end
@@ -887,26 +2389,28 @@ 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
-
!! test
Definition lists: self-closed tag
!! input
;one<br/>two : two-line fun
!! result
-<dl><dt>one<br />two&#160;</dt><dd> two-line fun
-</dd></dl>
+<dl>
+<dt>one<br />two&#160;</dt>
+<dd> two-line fun
+</dd>
+</dl>
!! end
!! test
Bug 11748: Literal closing tags
-!! options
-disabled
!! input
<dl>
<dt>test 1</dt>
@@ -921,50 +2425,79 @@ disabled
<dt>test 2</dt>
<dd>test test test test test</dd>
</dl>
+
!! end
!! test
Definition and unordered list using wiki syntax nested in unordered list using html tags.
!! input
<ul><li>
-; term : description
+; term : description
* unordered
-</li>
-</ul>
+</li></ul>
!! result
<ul><li>
-<dl><dt> term&#160;</dt><dd> description
-</dd></dl>
-<ul><li> unordered
-</li></ul>
+<dl>
+<dt> term&#160;</dt>
+<dd> description
+</dd>
+</dl>
+<ul>
+<li> unordered
</li>
</ul>
+</li></ul>
!! end
!! test
+
Definition list with empty definition and following paragraph
!! input
; term:
Paragraph text
!! result
-<dl><dt> term</dt><dd>
-</dd></dl>
+<dl>
+<dt> term</dt>
+<dd>
+</dd>
+</dl>
<p>Paragraph text
</p>
!! end
!! test
+Nested definition lists using html syntax
+!! input
+<dl><dd>
+<dl>
+<dd>Foo</dd>
+</dl>
+</dd></dl>
+!! result
+<dl><dd>
+<dl>
+<dd>Foo</dd>
+</dl>
+</dd></dl>
+
+!! end
+
+!! test
Definition Lists: No nesting: Multiple dd's
!! input
;x
: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
@@ -975,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
@@ -990,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
@@ -1003,13 +2548,54 @@ 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
+!! test
+Definition Lists: Hacky use to indent tables
+!! input
+::{|
+|foo
+|bar
+|}
+this text
+should be left alone
+!! result
+<dl><dd><dl><dd><table>
+<tr>
+<td>foo
+</td>
+<td>bar
+</td></tr></table></dd></dl></dd></dl>
+<p>this text
+should be left alone
+</p>
!! end
+# 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
@@ -1042,13 +2628,86 @@ Definition Lists: Indentation: Multi-level indent
##
## All Parsoid only definition list tests have this difference.
##
-## See also: https://bugzilla.wikimedia.org/show_bug.cgi?id=6569
+## See also: https://bugzilla.wikimedia.org/show_bug.cgi?id=6569
## and http://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
!! test
+Table / list interaction: indented table with lists in table contents
+!! input
+:{|
+|-
+| a
+* b
+|-
+| c
+* d
+|}
+!! result
+<dl><dd><table>
+
+<tr>
+<td> a
+<ul>
+<li> b
+</li>
+</ul>
+</td></tr>
+<tr>
+<td> c
+<ul>
+<li> d
+</li>
+</ul>
+</td></tr></table></dd></dl>
+
+!! end
+
+!!test
+Table / list interaction: lists nested in tables nested in indented lists
+!!input
+:{|
+|
+:a
+:b
+|
+*c
+*d
+|}
+
+*e
+*f
+!!result
+<dl><dd><table>
+<tr>
+<td>
+<dl>
+<dd>a
+</dd>
+<dd>b
+</dd>
+</dl>
+</td>
+<td>
+<ul>
+<li>c
+</li>
+<li>d
+</li>
+</ul>
+</td></tr></table></dd></dl>
+<ul>
+<li>e
+</li>
+<li>f
+</li>
+</ul>
+
+!!end
+
+!! test
Definition Lists: Nesting: Multi-level (Parsoid only)
!! options
-disabled
+parsoid
!! input
;t1 :d1
;;t2 ::d2
@@ -1078,7 +2737,7 @@ disabled
!! test
Definition Lists: Nesting: Test 2 (Parsoid only)
!! options
-disabled
+parsoid
!! input
;t1
::d2
@@ -1098,7 +2757,7 @@ disabled
!! test
Definition Lists: Nesting: Test 3 (Parsoid only)
!! options
-disabled
+parsoid
!! input
:;t1
::::d2
@@ -1129,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
@@ -1162,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
@@ -1176,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
@@ -1192,10 +2908,17 @@ Definition Lists: Mixed Lists: Test 4
*;d1 :d2
*;d3 :d4
!! result
-<ul><li><dl><dt>d1&#160;</dt><dd>d2
-</dd><dt>d3&#160;</dt><dd>d4
-</dd></dl>
-</li></ul>
+<ul>
+<li><dl>
+<dt>d1&#160;</dt>
+<dd>d2
+</dd>
+<dt>d3&#160;</dt>
+<dd>d4
+</dd>
+</dl>
+</li>
+</ul>
!! end
@@ -1206,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
@@ -1221,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
@@ -1238,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
@@ -1252,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
@@ -1267,9 +3019,14 @@ Definition Lists: Mixed Lists: Test 9
!! input
*;foo :bar
!! result
-<ul><li><dl><dt>foo&#160;</dt><dd>bar
-</dd></dl>
-</li></ul>
+<ul>
+<li><dl>
+<dt>foo&#160;</dt>
+<dd>bar
+</dd>
+</dl>
+</li>
+</ul>
!! end
@@ -1279,51 +3036,172 @@ Definition Lists: Mixed Lists: Test 10
!! input
*#;foo :bar
!! result
-<ul><li><ol><li><dl><dt>foo&#160;</dt><dd>bar
-</dd></dl>
-</li></ol>
-</li></ul>
+<ul>
+<li><ol>
+<li><dl>
+<dt>foo&#160;</dt>
+<dd>bar
+</dd>
+</dl>
+</li>
+</ol>
+</li>
+</ul>
!! end
+# The Parsoid team disagrees with the PHP parser's seemingly-random
+# rules regarding dd/dt on the next two tests. Parsoid is more
+# consistent, and recognizes the shared nesting and keeps the
+# still-open tags around until the nesting is complete.
!! 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&#160;</dt><dd><ul><li><dl><dt><dl><dt>bar
-</dt></dl>
-</dd></dl>
-</li></ul>
-</dd></dl>
-<dl><dt>boo&#160;</dt><dd>baz
-</dd></dl>
-</li></ol>
-</li></ul>
-</li></ol>
-</li></ul>
+<ul>
+<li><ol>
+<li><ul>
+<li><ol>
+<li><dl>
+<dt>foo&#160;</dt>
+<dd><ul>
+<li><dl>
+<dt><dl>
+<dt>bar
+</dt>
+</dl>
+</dd>
+</dl>
+</li>
+</ul>
+</dd>
+</dl>
+<dl>
+<dt>boo&#160;</dt>
+<dd>baz
+</dd>
+</dl>
+</li>
+</ol>
+</li>
+</ul>
+</li>
+</ol>
+</li>
+</ul>
!! 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":" "}'>&nbsp;</span></dt>
+<dd data-parsoid='{"stx":"row"}'>bar</dd>
+</dl></dt>
+</dl></li>
+</ul></dt>
+<dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
+<dd data-parsoid='{"stx":"row"}'>baz</dd>
+</dl></li>
+</ol></li>
+</ul></li>
+</ol></li>
+</ul>
+!! end
!! 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&#160;</dt><dd><ul><li><dl><dd><dl><dd><dl><dt><dl><dt> bar (who uses this?)
-</dt></dl>
-</dd></dl>
-</dd></dl>
-</dd></dl>
-</li></ul>
-</dd></dl>
-</li></ol>
-</li></ul>
+<ul>
+<li><ol>
+<li><dl>
+<dt> foo&#160;</dt>
+<dd><ul>
+<li><dl>
+<dd><dl>
+<dd><dl>
+<dt><dl>
+<dt> bar (who uses this?)
+</dt>
+</dl>
+</dd>
+</dl>
+</dd>
+</dl>
+</dd>
+</dl>
+</li>
+</ul>
+</dd>
+</dl>
+</li>
+</ol>
+</li>
+</ul>
!! 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":" "}'>&nbsp;</span></dt>
+<dd data-parsoid='{"stx":"row"}'> bar (who uses this?)</dd>
+</dl></dt>
+</dl></dd>
+</dl></dd>
+</dl></li>
+</ul></dt>
+</dl></li>
+</ol></li>
+</ul>
+!! end
###
### External links
@@ -1425,6 +3303,15 @@ second]
!!end
!! test
+External links: Pipe char between url and text
+!! input
+[http://example.com | link]
+!! result
+<p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
+</p>
+!!end
+
+!! test
External links: protocol-relative URL in brackets
!! input
[//example.com/ Test]
@@ -1479,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
@@ -1730,6 +3628,17 @@ External links: multiple legal whitespace is fine, Magnus. Don't break it please
!! end
!! test
+External links: link text with spaces
+!! input
+[http://www.example.com a b c]
+[http://www.example.com ''a'' ''b'']
+!! result
+<p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
+<a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
+</p>
+!! end
+
+!! test
External links: wiki links within external link (Bug 3695)
!! input
[http://example.com [[wikilink]] embedded in ext link]
@@ -1751,6 +3660,15 @@ http:/example.com
!! end
!! test
+Bracketed external links with template-generated invalid target
+!! input
+[{{echo|http:/example.com}} title]
+!! result
+<p>[http:/example.com title]
+</p>
+!! end
+
+!! test
Bug 2702: Mismatched <i>, <b> and <a> tags are invalid
!! input
''[http://example.com text'']
@@ -1881,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=&}}
@@ -1921,6 +3848,59 @@ http://[2404:130:0:1000::187:2]/index.php
</p>
!! end
+!! test
+Non-extlinks in brackets
+!! input
+[foo]
+[foo bar]
+[foo ''bar'']
+[fool's] errand
+[fool's errand]
+[{{echo|foo}}]
+[{{echo|foo}} bar]
+[{{echo|foo}} ''bar'']
+[{{echo|foo}}l's] errand
+[{{echo|foo}}l's errand]
+[url={{echo|foo}}]
+[url=http://example.com]
+!! result
+<p>[foo]
+[foo bar]
+[foo <i>bar</i>]
+[fool's] errand
+[fool's errand]
+[foo]
+[foo bar]
+[foo <i>bar</i>]
+[fool's] errand
+[fool's errand]
+[url=foo]
+[url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
+</p>
+!! end
+
+!! test
+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=&amp;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
###
@@ -1939,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.'''''
@@ -1974,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
@@ -1982,20 +4005,34 @@ 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
-!! input
+A table with nothing but a caption (php)
+!! options
+php
+!! input
{|
|+ caption
|}
@@ -2005,13 +4042,89 @@ 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
+!! input
+{|
+|+ style="color: red;" | caption1
+|-
+| foo
+|}
+!! result
+<table>
+<caption style="color: red;"> caption1
+</caption>
+<tr>
+<td> foo
+</td></tr></table>
+
+!! end
+
+!! test
+A table with captions with non-default spaced attributes and a table row
+!! input
+{|
+|+style="color: red;"|caption2
+|+ style="color: red;"| caption3
+|-
+| foo
+|}
+!! result
+<table>
+<caption style="color: red;">caption2
+</caption>
+<caption style="color: red;"> caption3
+</caption>
+<tr>
+<td> foo
+</td></tr></table>
+
+!! end
+
+!! test
+Table td-cell syntax variations
+!! input
+{|
+| foo bar foo | baz
+| foo bar foo || baz
+| style='color:red;' | baz
+| style='color:red;' || baz
+|}
+!! result
+<table>
+<tr>
+<td> baz
+</td>
+<td> foo bar foo </td>
+<td> baz
+</td>
+<td style="color:red;"> baz
+</td>
+<td> style='color:red;' </td>
+<td> baz
+</td></tr></table>
+
+!! end
!! test
Simple table
!! input
-{|
+{|
| 1 || 2
-|-
+|-
| 3 || 4
|}
!! result
@@ -2028,6 +4141,24 @@ Simple table
!! end
!! test
+Simple table but with multiple dashes for row wikitext
+!! input
+{|
+| foo
+|-----
+| bar
+|}
+!! result
+<table>
+<tr>
+<td> foo
+</td></tr>
+<tr>
+<td> bar
+</td></tr></table>
+
+!! end
+!! test
Multiplication table
!! input
{| border="1" cellpadding="2"
@@ -2099,15 +4230,117 @@ Multiplication table
!! end
!! test
+Accept "||" in table headings
+!! input
+{|
+!h1 || h2
+|}
+!! result
+<table>
+<tr>
+<th>h1 </th>
+<th> h2
+</th></tr></table>
+
+!! end
+
+!! test
+Accept "||" in indented table headings
+!! input
+:{|
+!h1 || h2
+|}
+!! result
+<dl><dd><table>
+<tr>
+<th>h1 </th>
+<th> h2
+</th></tr></table></dd></dl>
+
+!! end
+
+!! test
+Accept empty attributes in td/th cells (td/th cells starting with leading ||)
+!! input
+{|
+!| h1
+|| a
+|}
+!! result
+<table>
+<tr>
+<th> h1
+</th>
+<td> a
+</td></tr></table>
+
+!! end
+
+!!test
+Accept "| !" at start of line in tables (ignore !-attribute)
+!!input
+{|
+|-
+| !style="color:red" | bar
+|}
+!!result
+<table>
+
+<tr>
+<td> bar
+</td></tr></table>
+
+!!end
+
+!!test
+Allow +/- in 2nd and later cells in a row, in 1st cell when td-attrs are present, or in 1st cell when there is a space between "|" and +/-
+!!input
+{|
+|-
+|style='color:red;'|+1
+|style='color:blue;'|-1
+|-
+| 1 || 2 || 3
+| 1 ||+2 ||-3
+|-
+| +1
+| -1
+|}
+!!result
+<table>
+
+<tr>
+<td style="color:red;">+1
+</td>
+<td style="color:blue;">-1
+</td></tr>
+<tr>
+<td> 1 </td>
+<td> 2 </td>
+<td> 3
+</td>
+<td> 1 </td>
+<td>+2 </td>
+<td>-3
+</td></tr>
+<tr>
+<td> +1
+</td>
+<td> -1
+</td></tr></table>
+
+!!end
+
+!! test
Table rowspan
!! input
{| border=1
-| Cell 1, row 1
-|rowspan=2| Cell 2, row 1 (and 2)
-| Cell 3, row 1
-|-
-| Cell 1, row 2
-| Cell 3, row 2
+| Cell 1, row 1
+|rowspan=2| Cell 2, row 1 (and 2)
+| Cell 3, row 1
+|-
+| Cell 1, row 2
+| Cell 3, row 2
|}
!! result
<table border="1">
@@ -2212,6 +4445,283 @@ Indented table markup mixed with indented pre content (proposed in bug 6200)
!! end
+!! test
+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
+
+!! test
+Table with row followed by newlines and table heading
+!! input
+{|
+|-
+
+! foo
+|}
+!! result
+<table>
+
+
+<tr>
+<th> foo
+</th></tr></table>
+
+!! 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
+parsoid
+!! input
+{|
+| style=| hello
+|}
+!! result
+<table>
+<tbody>
+<tr>
+<td style=""> hello
+</td></tr></tbody></table>
+
+!! end
+
+!! test
+Wikitext table with a lot of comments
+!! input
+{|
+<!-- c0 -->
+| foo
+<!-- c1 -->
+|- <!-- c2 -->
+<!-- c3 -->
+|<!-- c4 -->
+<!-- c5 -->
+|}
+!! result
+<table>
+<tr>
+<td> foo
+</td></tr>
+<tr>
+<td>
+</td></tr></table>
+
+!! 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
@@ -2244,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]]
@@ -2297,6 +4816,37 @@ Link with suffix
</p>
!! end
+!! article
+prefixed article
+!! text
+Some text
+!! endarticle
+
+!! test
+Bug 43661: Piped links with identical prefixes
+!! input
+[[prefixed article|prefixed articles with spaces]]
+
+[[prefixed article|prefixed articlesaoeu]]
+
+[[Main Page|Main Page test]]
+!! result
+<p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
+</p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
+</p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
+</p>
+!! end
+
+
+!! test
+Link with HTML entity in suffix / tail
+!! input
+[[Main Page]]&quot;, [[Main Page]]&#97;
+!! result
+<p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>&quot;, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>&#97;
+</p>
+!! end
+
!! test
Link with 3 brackets
!! input
@@ -2333,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
@@ -2398,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]]
@@ -2493,6 +5086,18 @@ Plain link to protocol-relative URL with link text
</p>
!! end
+!! test
+Plain link to page with question mark in title
+!! input
+[[A?b]]
+
+[[A?b|Baz]]
+!! result
+<p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
+</p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
+</p>
+!! end
+
# I'm fairly sure the expected result here is wrong.
# We want these to be URL links, not pseudo-pages with URLs for titles....
@@ -2646,6 +5251,87 @@ 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
+[[Foo| bar]]
+
+[[Foo| ''bar'']]
+
+[http://wp.org foo]
+
+[http://wp.org ''foo'']
+!! result
+<p><a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)"> bar</a>
+</p><p><a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)"> <i>bar</i></a>
+</p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
+</p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
+</p>
+!! end
+
###
### Interwiki links (see maintenance/interwiki.sql)
###
@@ -2674,9 +5360,12 @@ Interwiki link encoding conversion (bug 1636)
*[[Wikipedia:ro:Olteni&#0355;a]]
*[[Wikipedia:ro:Olteni&#355;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&#355;a</a>
-</li><li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteni&#355;a</a>
-</li></ul>
+<ul>
+<li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteni&#355;a</a>
+</li>
+<li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteni&#355;a</a>
+</li>
+</ul>
!! end
@@ -2689,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
@@ -2735,6 +5430,199 @@ Blah blah blah
</p>
!! end
+!! test
+Parsoid-specific test: Wikilinks with &nbsp; should RT properly
+!! options
+language=ln
+!! input
+[[WW&nbsp;II]]
+!!result
+<p><a href="/index.php?title=WW_II&amp;action=edit&amp;redlink=1" class="new" title="WW II (lonkásá ezalí tɛ̂)">WW&#160;II</a>
+</p>
+!! end
+
+!! test
+Parsoid bug 53221: Wikilinks should be properly entity-escaped
+!! options
+parsoid=html2wt
+!! input
+He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
+
+He&amp;nbsp;llo [[He&amp;nbsp;llo]]
+!!result
+<p>He&amp;nbsp;llo <a href="Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
+<p>He&amp;nbsp;llo <a href="He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
+!! end
+
+!! test
+Parsoid: handle constructor well
+!! options
+parsoid
+!! input
+[[constructor]]
+
+[[constructor:foo]]
+!! result
+<p data-parsoid="{&quot;dsr&quot;:[0,15,0,0]}"><a rel="mw:WikiLink" href="./Constructor" data-parsoid="{&quot;stx&quot;:&quot;simple&quot;,&quot;a&quot;:{&quot;href&quot;:&quot;./Constructor&quot;},&quot;sa&quot;:{&quot;href&quot;:&quot;constructor&quot;},&quot;dsr&quot;:[0,15,2,2]}">constructor</a></p>
+
+
+<p data-parsoid="{&quot;dsr&quot;:[17,36,0,0]}"><a rel="mw:WikiLink" href="./Foo" data-parsoid="{&quot;stx&quot;:&quot;simple&quot;,&quot;a&quot;:{&quot;href&quot;:&quot;./Foo&quot;},&quot;sa&quot;:{&quot;href&quot;:&quot;constructor:foo&quot;},&quot;dsr&quot;:[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
@@ -2750,6 +5638,28 @@ Blah blah blah
!! end
!! test
+Broken br tag sanitization
+!! options
+php
+!! input
+</br>
+!! result
+<p>&lt;/br&gt;
+</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
<br style="clear:both;" />
@@ -2758,7 +5668,7 @@ Incorrecly removing closing slashes from correctly formed XHTML
</p>
!! end
-!! test
+!! test
Failing to transform badly formed HTML into correct XHTML
!! input
<br style="clear: left;">
@@ -2772,6 +5682,47 @@ Failing to transform badly formed HTML into correct XHTML
!!end
!! test
+Handling html with a div self-closing tag
+!! input
+<div title />
+<div title/>
+<div title/ >
+<div title=bar />
+<div title=bar/>
+<div title=bar/ >
+!! result
+<p>&lt;div title /&gt;
+&lt;div title/&gt;
+</p>
+<div>
+<p>&lt;div title=bar /&gt;
+&lt;div title=bar/&gt;
+</p>
+<div title="bar/"></div>
+</div>
+
+!! end
+
+!! test
+Handling html with a br self-closing tag
+!! input
+<br title />
+<br title/>
+<br title/ >
+<br title=bar />
+<br title=bar/>
+<br title=bar/ >
+!! result
+<p><br title="title" />
+<br title="title" />
+<br />
+<br title="bar" />
+<br title="bar" />
+<br title="bar/" />
+</p>
+!! end
+
+!! test
Horizontal ruler (should it add that extra space?)
!! input
<hr>
@@ -2804,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
----
----
@@ -2823,6 +5774,15 @@ Horizontal ruler -- <4 dashes render as plain text
</p>
!! end
+!! test
+Horizontal ruler -- Supports content following dashes on same line
+!! input
+---- Foo
+!! result
+<hr /> Foo
+
+!! end
+
###
### Block-level elements
###
@@ -2833,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
@@ -2847,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
@@ -2873,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
@@ -2911,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
@@ -2924,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
@@ -2937,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
@@ -2950,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
@@ -2963,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
@@ -2976,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
@@ -2988,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
@@ -3003,16 +6036,56 @@ 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
+!! test
+1. Lists with start-of-line-transparent tokens before bullets: Comments
+!! input
+*foo
+*<!--cmt-->bar
+<!--cmt-->*baz
+!! result
+<ul>
+<li>foo
+</li>
+<li>bar
+</li>
+<li>baz
+</li>
+</ul>
+
+!! end
+
+!! test
+2. Lists with start-of-line-transparent tokens before bullets: Template close
+!! input
+*foo {{echo|bar
+}}*baz
+!! result
+<ul>
+<li>foo bar
+</li>
+<li>baz
+</li>
+</ul>
+
+!! end
!! test
List items are not parsed correctly following a <pre> block (bug 785)
@@ -3021,10 +6094,14 @@ List items are not parsed correctly following a <pre> block (bug 785)
* <pre>bar</pre>
* zar
!! result
-<ul><li> <pre>foo</pre>
-</li><li> <pre>bar</pre>
-</li><li> zar
-</li></ul>
+<ul>
+<li> <pre>foo</pre>
+</li>
+<li> <pre>bar</pre>
+</li>
+<li> zar
+</li>
+</ul>
!! end
@@ -3043,18 +6120,30 @@ List items from template
* 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>
+<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
@@ -3067,22 +6156,267 @@ List interrupted by empty line or heading
== 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&amp;action=edit&amp;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>
+<ul>
+<li> foo
+</li>
+</ul>
+<ul>
+<li><ul>
+<li> bar
+</li>
+</ul>
+</li>
+</ul>
+<h2><span class="mw-headline" id="A_heading">A heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: A heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<ul>
+<li> Another list item
+</li>
+</ul>
+
+!!end
+
+!!test
+Multiple list tags generated by templates
+!!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
+(Parsoid-only since php parser generates broken html -- relies on Tidy to fix up)
+!! options
+parsoid
+!! input
+<div>
+*a</div><div>
+*b</div>
+!! result
+<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
+(Parsoid-only since php parser generates broken html -- relies on Tidy to fix up)
+!! options
+parsoid
+!! input
+<span>
+*a</span><span>
+*b</span>
+!! result
+<p><span></span>
+</p>
+<ul>
+<li>a<span></span>
+</li>
+<li>b
+</li>
+</ul>
+!! end
+
+!! test
+Unclosed formatting tags that straddle lists are closed and reopened
+(Parsoid-only since php parser generates broken html -- relies on Tidy to fix up)
+!! options
+parsoid
+!! input
+# <s> a
+# b </s>
+!! result
+<ol>
+<li> <s> a </s>
+</li>
+<li> <s> b </s>
+</li>
+</ol>
+!! end
+
+!!test
+List embedded in a non-block tag
+(Ugly Parsoid output -- worth fixing; Disabled for PHP parser since it relies on Tidy)
+!! options
+parsoid
+!!input
+<small>
+* foo
+</small>
+!!result
+<p><small></small></p>
+<small>
+<ul>
+<li> foo</li>
+</ul>
+</small>
+<p><small></small></p>
+!!end
+
+!! test
+Table with missing opening <tr> tag
+!! options
+parsoid=wt2html,wt2wt
+!! input
+<table>
+<td>foo</td>
+</tr>
+</table>
+!! result
+<table>
+<tr>
+<td>foo</td>
+</tr>
+</table>
+!! end
###
### Magic Words
###
+# Note that the current date is hard-coded as
+# 1970-01-01T00:02:03Z (a Thursday)
+# when running parser tests. The timezone is also fixed to GMT, so
+# local date will be identical to current date.
+
!! test
Magic Word: {{CURRENTDAY}}
!! input
@@ -3129,6 +6463,15 @@ Magic Word: {{CURRENTMONTH}}
!! end
!! test
+Magic Word: {{CURRENTMONTH1}}
+!! input
+{{CURRENTMONTH1}}
+!! result
+<p>1
+</p>
+!! end
+
+!! test
Magic Word: {{CURRENTMONTHABBREV}}
!! input
{{CURRENTMONTHABBREV}}
@@ -3165,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}}
@@ -3183,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]]
@@ -3205,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]]
@@ -3238,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
@@ -3320,11 +6929,20 @@ Magic Word: {{SCRIPTPATH}}
!! end
!! test
+Magic Word: {{STYLEPATH}}
+!! input
+{{STYLEPATH}}
+!! result
+<p>/skins
+</p>
+!! end
+
+!! test
Magic Word: {{SERVER}}
!! input
{{SERVER}}
!! result
-<p><a rel="nofollow" class="external free" href="http://Britney-Spears">http://Britney-Spears</a>
+<p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
</p>
!! end
@@ -3333,7 +6951,7 @@ Magic Word: {{SERVERNAME}}
!! input
{{SERVERNAME}}
!! result
-<p>Britney-Spears
+<p>example.org
</p>
!! end
@@ -3347,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&amp;action=edit&amp;redlink=1" class="new" title="Template:CurrentMonth (page does not exist)">Template:CurrentMonth</a>
+<a href="/index.php?title=Template:Currentday&amp;action=edit&amp;redlink=1" class="new" title="Template:Currentday (page does not exist)">Template:Currentday</a>
+<a href="/index.php?title=Template:CURreNTweEK&amp;action=edit&amp;redlink=1" class="new" title="Template:CURreNTweEK (page does not exist)">Template:CURreNTweEK</a>
+<a href="/index.php?title=Template:CurrentHour&amp;action=edit&amp;redlink=1" class="new" title="Template:CurrentHour (page does not exist)">Template:CurrentHour</a>
+</p>
+!! end
+
+!! test
+Case-insensitive magic words should still work with weird casing.
+!! 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}}
@@ -3489,7 +7137,7 @@ Magic links: RFC (bug 479)
!! input
RFC 822
!! result
-<p><a class="external mw-magiclink-rfc" href="//tools.ietf.org/html/rfc822">RFC 822</a>
+<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
</p>
!! end
@@ -3507,7 +7155,7 @@ Magic links: PMID incorrectly converts space to underscore
!! input
PMID 1234
!! result
-<p><a class="external mw-magiclink-pmid" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
+<p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
</p>
!! end
@@ -3524,6 +7172,24 @@ Nonexistent template
</p>
!! end
+!! test
+Template with invalid target containing tags
+!! input
+{{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
+!! result
+<p>{{a<b>b</b>|foo|a=b|a = b}}
+</p>
+!! end
+
+!! test
+Template with invalid target containing unclosed tag
+!! input
+{{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
+!! result
+<p>{{a<b>|foo|a=b|a = b}}</b>
+</p>
+!! end
+
!! article
Template:test
!! text
@@ -3727,7 +7393,7 @@ Template with complex arguments
!! test
BUG 553: link with two variables in a piped link
!! input
-{|
+{|
|[[{{{1}}}|{{{2}}}]]
|}
!! result
@@ -3762,6 +7428,14 @@ Template parameter as link source
</p>
!! end
+!!test
+Template-generated attribute string (k='v')
+!!input
+<span {{attr_str|id|v1}}>bar</span>
+!!result
+<p><span id="v1">bar</span>
+</p>
+!!end
!!article
Template:paramtest2
@@ -3788,8 +7462,14 @@ Main Page
Template as link source
!! input
[[{{linktest2}}]]
+
+[[{{linktest2}}|Main Page]]
+
+[[{{linktest2}}]]Page
!! result
<p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
+</p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
+</p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
</p>
!! end
@@ -3827,9 +7507,9 @@ Template from main namespace
!! article
Template:table
!! text
-{|
+{|
| 1 || 2
-|-
+|-
| 3 || 4
|}
!! endarticle
@@ -3882,6 +7562,20 @@ BUG 41: Template parameters shown as broken links
</p>
!! end
+!! test
+Template with targets containing wikilinks
+!! input
+{{[[foo]]}}
+
+{{[[{{echo|foo}}]]}}
+
+{{{{echo|[[foo}}]]}}
+!! result
+<p>{{<a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)">foo</a>}}
+</p><p>{{<a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)">foo</a>}}
+</p><p>{{[[foo}}]]
+</p>
+!! end
!! article
Template:MSGNW test
@@ -3972,6 +7666,13 @@ Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
!! end
!! test
+Un-closed <noinclude>
+!! input
+<noinclude>
+!! result
+!! end
+
+!! test
<onlyinclude> on a page
!! input
<onlyinclude>Foo</onlyinclude>bar
@@ -3980,6 +7681,47 @@ Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
</p>
!! end
+!! test
+Un-closed <onlyinclude>
+!! input
+<onlyinclude>
+!! result
+!! end
+
+!!test
+Self-closed noinclude, includeonly, onlyinclude tags
+!!input
+<noinclude />
+<includeonly />
+<onlyinclude />
+!!result
+<p><br />
+</p>
+!!end
+
+!!test
+Unbalanced includeonly and noinclude tags
+!!input
+{|
+|a</noinclude>
+|b</noinclude></noinclude>
+|c</noinclude></includeonly>
+|d</includeonly></includeonly>
+|}
+!!result
+<table>
+<tr>
+<td>a
+</td>
+<td>b
+</td>
+<td>c&lt;/includeonly&gt;
+</td>
+<td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
+</td></tr></table>
+
+!!end
+
!! article
Template:Includeonly section
!! text
@@ -3994,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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=T-1" title="Template:Includeonly section">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<h2><span class="mw-headline" id="Section_T-1">Section T-1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Includeonly_section&amp;action=edit&amp;section=T-2" title="Template:Includeonly section">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -4021,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&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Edit section: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -4038,6 +7780,774 @@ section=1
==Section 1==
!! end
+!! test
+Un-closed <includeonly>
+!! input
+<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
+###
+!!test
+0. includeonly around the entire attribute
+!!input
+<span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
+!!result
+<p><span id="v2">bar</span>
+</p>
+!!end
+
+!!test
+1. includeonly in html attr key
+!!input
+<span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
+!!result
+<p><span id="foo">bar</span>
+</p>
+!!end
+
+!!test
+2. includeonly in html attr value
+!!input
+<span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
+<span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
+!!result
+<p><span id="v1">bar</span>
+<span id="v1">bar</span>
+</p>
+!!end
+
+!!test
+3. includeonly in part of an attr value
+!!input
+<span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
+!!result
+<p><span style="color:red;">bar</span>
+</p>
+!!end
+
+###
+### Testing parsing of templates where a template arg
+### has the same name as the template itself.
+###
+
+!! article
+Template:quote
+!! text
+{{{quote|{{{1}}}}}}
+!! endarticle
+
+!!test
+Templates: Template Name/Arg clash: 1. Use of positional param
+!!input
+{{quote|foo}}
+!!result
+<p>foo
+</p>
+!!end
+
+!!test
+Templates: Template Name/Arg clash: 2. Use of named param
+!!input
+{{quote|quote=foo}}
+!!result
+<p>foo
+</p>
+!!end
+
+!!test
+Templates: Template Name/Arg clash: 3. Use of named param with empty input
+!!input
+{{quote|quote}}
+!!result
+<p>quote
+</p>
+!!end
+
+###
+### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
+###
+
+!!test
+Templates: 1. Simple use
+!!input
+{{echo|Foo}}
+!!result
+<p>Foo
+</p>
+!!end
+
+!!test
+Templates: 2. Inside a block tag
+!!input
+<div>{{echo|Foo}}</div>
+<blockquote>{{echo|Foo}}</blockquote>
+!!result
+<div>Foo</div>
+<blockquote>Foo</blockquote>
+
+!!end
+
+!!test
+Templates: P-wrapping: 1a. Templates on consecutive lines
+!!input
+{{echo|Foo}}
+{{echo|bar}}
+!!result
+<p>Foo
+bar
+</p>
+!!end
+
+!!test
+Templates: P-wrapping: 1b. Templates on consecutive lines
+!!input
+Foo
+
+{{echo|bar}}
+{{echo|baz}}
+!!result
+<p>Foo
+</p><p>bar
+baz
+</p>
+!!end
+
+!!test
+Templates: P-wrapping: 1c. Templates on consecutive lines
+!!input
+{{echo|Foo}}
+{{echo|bar}} <div>baz</div>
+!!result
+<p>Foo
+</p>
+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}}
+!!result
+<p>Foobarbaz
+</p>
+!!end
+
+!!test
+Templates: Inline Text: 2. Back-to-back template uses
+!!input
+{{echo|Foo}}{{echo|bar}}
+!!result
+<p>Foobar
+</p>
+!!end
+
+!!test
+Templates: Block Tags: 1. Multiple template uses
+!!input
+{{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
+!!result
+<div>Foo</div><div>bar</div><div>baz</div>
+
+!!end
+
+!!test
+Templates: Block Tags: 2. Back-to-back template uses
+!!input
+{{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
+!!result
+<div>Foo</div><div>bar</div>
+
+!!end
+
+!!test
+Templates: Links: 1. Simple example
+!!input
+{{echo|[[Foo|bar]]}}
+!!result
+<p><a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)">bar</a>
+</p>
+!!end
+
+!!test
+Templates: Links: 2. Generation of link href
+!!input
+[[{{echo|Foo}}|bar]]
+!!result
+<p><a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)">bar</a>
+</p>
+!!end
+
+!!test
+Templates: Links: 3. Generation of part of a link href
+!!input
+[[Fo{{echo|o}}|bar]]
+
+[[Foo{{echo|bar}}]]
+
+[[Foo{{echo|bar}}baz]]
+
+[[Foo{{echo|bar}}|bar]]
+
+[[:Foo{{echo|bar}}]]
+
+[[:Foo{{echo|bar}}|bar]]
+!!result
+<p><a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)">bar</a>
+</p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
+</p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
+</p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
+</p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
+</p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
+</p>
+!!end
+
+!!test
+Templates: Links: 4. Multiple templates generating link href
+!!input
+[[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
+!!result
+<p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
+</p>
+!!end
+
+!!test
+Templates: Links: 5. Generation of link text
+!!input
+[[Foo|{{echo|bar}}]]
+!!result
+<p><a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)">bar</a>
+</p>
+!!end
+
+!!test
+Templates: Links: 5. Nested templates (only outermost template should be marked)
+!!input
+{{echo|[[{{echo|Foo}}|bar]]}}
+!!result
+<p><a href="/index.php?title=Foo&amp;action=edit&amp;redlink=1" class="new" title="Foo (page does not exist)">bar</a>
+</p>
+!!end
+
+!!test
+Templates: HTML Tag: 1. Generation of HTML attr. key
+!!input
+<div {{echo|style}}="color:red;">foo</div>
+!!result
+<div style="color:red;">foo</div>
+
+!!end
+
+!!test
+Templates: HTML Tag: 2. Generation of HTML attr. value
+!!input
+<div style={{echo|'color:red;'}}>foo</div>
+!!result
+<div style="color:red;">foo</div>
+
+!!end
+
+!!test
+Templates: HTML Tag: 3. Generation of HTML attr key and value
+!!input
+<div {{echo|style}}={{echo|'color:red;'}}>foo</div>
+!!result
+<div style="color:red;">foo</div>
+
+!!end
+
+!!test
+Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
+!!input
+<div title="{{echo|This is a long title}} with just one piece templated">foo</div>
+!!result
+<div title="This is a long title with just one piece templated">foo</div>
+
+!!end
+
+!!test
+Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
+!!input
+<div title="This is a long title with just {{echo|one piece}} templated">foo</div>
+!!result
+<div title="This is a long title with just one piece templated">foo</div>
+
+!!end
+
+!!test
+Templates: HTML Tag: 6. Generation of end piece of HTML attr value
+!!input
+<div title="This is a long title with just one piece {{echo|templated}}">foo</div>
+!!result
+<div title="This is a long title with just one piece templated">foo</div>
+
+!!end
+
+!!test
+Templates: HTML Tag: 7. Generation of partial attribute key string
+!!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>
+!!result
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 2a. Generating middle of a HTML table
+!!input
+<table><tr>{{echo|<td>foo</td>}}</tr></table>
+!!result
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 2b. Generating middle of a HTML table
+!!input
+<table>{{echo|<tr><td>foo</td></tr>}}</table>
+!!result
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 3. Generating end of a HTML table
+!!input
+<table><tr>{{echo|<td>foo</td></tr></table>}}
+!!result
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 4a. Generating a single tag of a HTML table
+!!input
+{{echo|<table>}}<tr><td>foo</td></tr></table>
+!!result
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 4b. Generating a single tag of a HTML table
+!!input
+<table>{{echo|<tr>}}<td>foo</td></tr></table>
+!!result
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 4c. Generating a single tag of a HTML table
+!!input
+<table><tr>{{echo|<td>}}foo</td></tr></table>
+!!result
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 4d. Generating a single tag of a HTML table
+!!input
+<table><tr><td>foo{{echo|</td>}}</tr></table>
+!!result
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 4e. Generating a single tag of a HTML table
+!!input
+<table><tr><td>foo</td>{{echo|</tr>}}</table>
+!!result
+<table><tr><td>foo</td></tr></table>
+
+!!end
+
+!!test
+Templates: HTML Tables: 4f. Generating a single tag of a HTML table
+!!input
+<table><tr><td>foo</td></tr>{{echo|</table>}}
+!!result
+<table><tr><td>foo</td></tr></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
+{|
+{{echo|a}}
+|}
+!!result
+<table>
+a
+<tr><td></td></tr></table>
+
+!!end
+
+!!test
+Templates: Wiki Tables: 1b. Fostering of entire template content
+!!input
+{|
+{{echo|<div>}}
+foo
+{{echo|</div>}}
+|}
+!!result
+<table>
+<div>
+<p>foo
+</p>
+</div>
+<tr><td></td></tr></table>
+
+!!end
+
+!!test
+Templates: Wiki Tables: 2. Fostering of partial template content
+!!input
+{|
+{{echo|a
+<div>b</div>}}
+|}
+!!result
+<table>
+a
+<div>b</div>
+<tr><td></td></tr></table>
+
+!!end
+
+!!test
+Templates: Wiki Tables: 3. td-content via multiple templates
+!!input
+{|
+{{echo|{{pipe}}a}}{{echo|b}}
+|}
+!!result
+<table>
+<tr>
+<td>ab
+</td></tr></table>
+
+!!end
+
+!!test
+Templates: Wiki Tables: 4. Templated tags, no content
+!!input
+{{tbl-start}}
+{{tbl-end}}
+!!result
+<table>
+<tr><td></td></tr></table>
+
+!!end
+
+!!test
+Templates: Wiki Tables: 5. Templated tags, regular td-tags
+!!input
+{{tbl-start}}
+|foo
+{{tbl-end}}
+!!result
+<table>
+<tr>
+<td>foo
+</td></tr></table>
+
+!!end
+
+!!test
+Templates: Wiki Tables: 6. Templated tags, templated td-tags
+!!input
+{{tbl-start}}
+{{!}}foo
+{{tbl-end}}
+!!result
+<table>
+<tr>
+<td>foo
+</td></tr></table>
+
+!!end
+
+!!test
+Templates: Lists: Multi-line list-items via templates
+!!input
+*{{echo|a {{nonexistent|
+unused}}}}
+*{{echo|b {{nonexistent|
+unused}}}}
+!!result
+<ul>
+<li>a <a href="/index.php?title=Template:Nonexistent&amp;action=edit&amp;redlink=1" class="new" title="Template:Nonexistent (page does not exist)">Template:Nonexistent</a>
+</li>
+<li>b <a href="/index.php?title=Template:Nonexistent&amp;action=edit&amp;redlink=1" class="new" title="Template:Nonexistent (page does not exist)">Template:Nonexistent</a>
+</li>
+</ul>
+
+!!end
+
+!!test
+Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
+!!input
+{{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
+!!result
+<p><i>ab</i>c<i>d</i>e
+</p>
+!!end
+
+!!test
+Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
+(PHP parser generates misnested html)
+!! options
+parsoid
+!!input
+{{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
+!!result
+<p><span about="#mwt1" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_span&quot;,&quot;href&quot;:&quot;./Template:Echo_with_span&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;''a&quot;}},&quot;i&quot;:0}}]}"><i>a</i></span><i about="#mwt2" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_span&quot;,&quot;href&quot;:&quot;./Template:Echo_with_span&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;b''c''d&quot;}},&quot;i&quot;:0}},{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_span&quot;,&quot;href&quot;:&quot;./Template:Echo_with_span&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;''e&quot;}},&quot;i&quot;:1}}]}"><span>b</span></i><span about="#mwt2">c</span><i about="#mwt2">d<span></span></i><span about="#mwt2">e</span></p>
+!!end
+
+!!test
+Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
+(PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
+!! options
+parsoid=wt2html,wt2wt
+!!input
+{{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
+!!result
+<div about="#mwt1" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_div&quot;,&quot;href&quot;:&quot;./Template:Echo_with_div&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;''a&quot;}},&quot;i&quot;:0}}]}"><i>a</i></div>
+<div about="#mwt2" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_div&quot;,&quot;href&quot;:&quot;./Template:Echo_with_div&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;b''c''d&quot;}},&quot;i&quot;:0}}]}"><i>b</i>c<i>d</i></div>
+<div about="#mwt3" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_div&quot;,&quot;href&quot;:&quot;./Template:Echo_with_div&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;''e&quot;}},&quot;i&quot;:0}}]}">e</div>
+!!end
+
+!!test
+Templates: Ugly nesting: 4. Divs opened/closed across templates
+!!input
+a<div>b{{echo|c</div>d}}e
+!!result
+a<div>bc</div>de
+
+!!end
+
+!!test
+Templates: Ugly templates: 1. Navbox template parses badly leading to table misnesting
+(Parsoid-centric)
+!! options
+parsoid
+!!input
+{|
+|{{echo|foo</table>}}
+|bar
+|}
+!!result
+<table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["{|\n|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo</table>"}},"i":0}},"\n|bar\n|}"]}'>
+
+<tbody>
+<tr>
+<td>foo</td></tr></tbody></table><span about="#mwt1">
+</span><span about="#mwt1">bar</span><span about="#mwt1">
+</span>
+!!end
+
+!!test
+Templates: Ugly templates: 2. Navbox template parses badly leading to table misnesting
+(Parsoid-centric)
+!! options
+parsoid
+!!input
+<table>
+ <tr>
+ <td>
+ <table>
+ <tr>
+ <td>1. {{echo|foo </table>}}</td>
+ <td> bar </td>
+ <td>2. {{echo|baz </table>}}</td>
+ </tr>
+ <tr>
+ <td>abc</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>xyz</td>
+ </tr>
+</table>
+!!result
+<table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":["<table>\n <tr>\n <td>\n <table>\n <tr>\n <td>1. ",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo </table>"}},"i":0}},"</td>\n <td> bar </td>\n <td>2. ",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"baz </table>"}},"i":1}},"</td>\n </tr>\n <tr>\n <td>abc</td>\n </tr>\n </table>\n </td>\n </tr>\n <tr>\n <td>xyz</td>\n </tr>\n</table>"]}'>
+ <tbody><tr>
+ <td>
+ <table>
+ <tbody><tr>
+ <td>1. foo </td></tr></tbody></table></td>
+ <td> bar </td>
+ <td>2. baz </td></tr></tbody></table><span about="#mwt2">
+ </span><span about="#mwt2">
+ </span><span about="#mwt2">
+ </span><span about="#mwt2">abc</span><span about="#mwt2">
+ </span><span about="#mwt2">
+ </span><span about="#mwt2">
+ </span><span about="#mwt2">
+ </span><span about="#mwt2">
+ </span><span about="#mwt2">
+ </span><span about="#mwt2">xyz</span><span about="#mwt2">
+ </span><span about="#mwt2">
+</span>
+!!end
+
+!! test
+Templates: Ugly templates: 3. newline-only template parameter
+!! input
+foo {{echo|
+}}
+!! result
+<p>foo
+</p>
+!! end
+
+# This looks like a bug: a single newline triggers p/br for some reason.
+!! test
+Templates: Ugly templates: 4. newline-only template parameter inconsistency
+!! input
+{{echo|
+}}
+!! result
+<p><br />
+</p>
+!! end
+
+
+!!test
+Parser Functions: 1. Simple example
+!!input
+{{uc:foo}}
+!!result
+<p>FOO
+</p>
+!!end
+
+!!test
+Parser Functions: 2. Nested use (only outermost should be marked up)
+!!input
+{{uc:{{lc:FOO}}}}
+!!result
+<p>FOO
+</p>
+!!end
+
###
### Pre-save transform tests
###
@@ -4156,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
@@ -4167,7 +8680,7 @@ Template:dangerous
!! input
{{Template:dangerous}}
!! result
-<p><span>Oh no</span>
+<p>@<span>Oh no</span>
</p>
!! end
@@ -4556,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">&lt;div&gt;[[foo]]</span></p>
+<p>ab</p>
+<p>cd</p>
+<p>ef</p>
+!! end
+
+!! test
+Parsoid: Recognize nowiki with odd capitalization
+!! options
+parsoid=wt2html
+!! input
+<noWikI ><div>[[foo]]</Nowiki >
+!! result
+<p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
+!! end
+
+
+!! test
+Parsoid: Escape nowiki with trailing space in tags
+!! options
+parsoid=html2wt
+!! input
+&lt;nowiki &gt; foo &lt;/nowiki &gt;
+
+a&lt;nowiki /&gt;b
+
+c&lt;nowiki/ &gt;d
+!! result
+<p>&lt;nowiki &gt; foo &lt/nowiki ></p>
+<p>a&lt;nowiki /&gt;b</p>
+<p>c&lt;nowiki/ &gt;d</p>
+!! end
+
+!! test
+Parsoid: Escape weird noWikI capitalizations
+!! options
+parsoid=html2wt
+!! input
+&lt;noWikI &gt; foo &lt;/NoWikI &gt;
+!! result
+<p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
+!! end
+
###
### Message transform tests
###
@@ -4624,9 +9193,9 @@ Special:RecentChanges/param
!! options
msg
!! input
-{{#special:foobarnonexistent}}
+{{#special:foobar nonexistent}}
!! result
-No such special page
+Special:Foobar nonexistent
!! end
!! test
@@ -4654,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
@@ -4672,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
@@ -4690,32 +9268,245 @@ Simple image (using File: namespace, now canonical)
!! end
!! test
-Image with caption
+Simple image (using File: namespace, now canonical) (parsoid)
+!! options
+parsoid
+!! input
+[[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 (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 parameter, wiki target
+Image with attributes from template (parsoid)
+!! options
+parsoid
!! input
-[[Image:foobar.jpg|link=Target page]]
+[[File:Foobar.jpg|{{image_attribs}}]]
!! 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>
+<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>
+123<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>456
+123<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div></div></div></div>456
+
!! end
!! test
-Image with link parameter, URL target
+Image with link tails (parsoid)
+!! options
+parsoid
!! input
-[[Image:foobar.jpg|link=http://example.com/]]
+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
+[[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 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
+[[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>
+<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>
+
+!! end
+
+!! test
+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
+[[File:Foobar.jpg|link=Main Page]]
+!! result
+<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, 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
+[[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
@@ -4761,38 +9552,131 @@ 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
+[[File:Foobar.jpg|link=]]
+!! result
+<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
-[[Image:foobar.jpg|link=Target page|Title]]
+[[File:Foobar.jpg|link=Main Page|Title]]
!! 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><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
-<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="http://example.com/"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" 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>
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="http://example.com/"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Title</div></div></div>
+
+!! 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
@@ -4866,7 +9750,7 @@ Thumbnail image caption with a free URL
!! input
[[Image:foobar.jpg|thumb|http://example.com]]
!! result
-<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" 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><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
!! end
@@ -4875,7 +9759,37 @@ Thumbnail image caption with a free URL and explicit alt
!! input
[[Image:foobar.jpg|thumb|http://example.com|alt=Alteration]]
!! result
-<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Alteration" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" 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><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Alteration" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
+
+!! 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&amp;lang=de" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/langde-180px-Foobar.svg.png" width="180" height="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
@@ -4884,7 +9798,7 @@ BUG 1887: A ISBN with a thumbnail
!! input
[[Image:foobar.jpg|thumb|ISBN 1235467890]]
!! result
-<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" 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><a href="/wiki/Special:BookSources/1235467890" class="internal mw-magiclink-isbn">ISBN 1235467890</a></div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div><a href="/wiki/Special:BookSources/1235467890" class="internal mw-magiclink-isbn">ISBN 1235467890</a></div></div></div>
!! end
@@ -4893,7 +9807,7 @@ BUG 1887: A RFC with a thumbnail
!! input
[[Image:foobar.jpg|thumb|This is RFC 12354]]
!! result
-<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" 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>This is <a class="external mw-magiclink-rfc" href="//tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
!! end
@@ -4902,7 +9816,7 @@ BUG 1887: A mailto link with a thumbnail
!! input
[[Image:foobar.jpg|thumb|Please mailto:nobody@example.com]]
!! result
-<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" 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>Please <a rel="nofollow" class="external free" href="mailto:nobody@example.com">mailto:nobody@example.com</a></div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>Please <a rel="nofollow" class="external free" href="mailto:nobody@example.com">mailto:nobody@example.com</a></div></div></div>
!! end
@@ -4975,7 +9889,7 @@ Image caption containing another image
!! input
[[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]]
!! result
-<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" 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>This is a caption with another <a href="/index.php?title=Special:Upload&amp;wpDestFile=Icon.png" class="new" title="File:Icon.png">image</a> inside it!</div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This is a caption with another <a href="/index.php?title=Special:Upload&amp;wpDestFile=Icon.png" class="new" title="File:Icon.png">image</a> inside it!</div></div></div>
!! end
@@ -4989,13 +9903,22 @@ Image caption containing a newline
</p>
!!end
+!!test
+Parsoid: Image caption containing leading space
+(The leading space should not trigger nowiki escaping in wt2wt mode)
+!! input
+[[Image:Foobar.jpg|thumb| bar]]
+!! result
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>bar</div></div></div>
+
+!!end
!! test
Bug 3090: External links other than http: in image captions
!! input
[[Image:Foobar.jpg|thumb|200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
!! result
-<div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="200" height="23" 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>This caption has <a rel="nofollow" class="external text" href="irc://example.net">irc</a> and <a rel="nofollow" class="external text" href="https://example.com">Secure</a> ext links in it.</div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>This caption has <a rel="nofollow" class="external text" href="irc://example.net">irc</a> and <a rel="nofollow" class="external text" href="https://example.com">Secure</a> ext links in it.</div></div></div>
!! end
@@ -5008,7 +9931,38 @@ Custom class
</p>
!! end
-!! article
+!! test
+Localized image handling (1).
+!! options
+language=es
+!! input
+[[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
+!! result
+<div class="floatleft"><a href="/wiki/Foo" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
+
+!! end
+
+!! test
+Localized image handling (2).
+!! options
+language=es
+!! input
+[[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
+!! result
+<div class="thumb tleft"><div class="thumbinner" style="width:182px;"><a href="/wiki/Foo" title="Foo"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/Archivo:Foobar.jpg" class="internal" title="Aumentar"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>caption</div></div></div>
+
+!! end
+
+!! test
+"border", "frameless" and "class" attributes on an image.
+!! input
+[[File:Foobar.jpg|frameless|border|class=extra|caption]]
+!! result
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="extra thumbborder" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
+</p>
+!! end
+
+!! article
File:Barfoo.jpg
!! text
#REDIRECT [[File:Barfoo.jpg]]
@@ -5034,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="{&quot;caption&quot;:&quot;caption&quot;}">
+<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="{&quot;caption&quot;:&quot;caption&quot;}">
+<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="{&quot;caption&quot;:&quot;caption&quot;}">
+<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
@@ -5066,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
@@ -5123,6 +10255,185 @@ PAGESINCATEGORY invalid title fatal (r33546 fix)
</p>
!! end
+!! test
+Category with different sort key
+!! options
+cat
+!! input
+[[Category:MediaWiki User's Guide|Foo]]
+!! result
+<a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
+!! end
+
+!! test
+Category with identical sort key
+!! options
+cat
+!! input
+[[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
+!! result
+<a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
+!! end
+
+!! test
+Category with empty sort key
+!! options
+cat
+pst
+!! input
+[[Category:MediaWiki User's Guide|]]
+!! result
+[[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
+!! end
+
+!! test
+Category with empty sort key and parentheses
+!! options
+cat
+pst
+!! input
+[[Category:Foo (bar)|]]
+!! result
+[[Category:Foo (bar)|Foo]]
+!! end
+
+!! test
+Category with link tail
+!! options
+cat
+pst
+!! input
+123[[Category:Foo]]456
+!! result
+123[[Category:Foo]]456
+!! end
+
+!! test
+Category with template
+!! options
+cat
+pst
+!! input
+[[Category:{{echo|Foo}}]]
+!! result
+[[Category:{{echo|Foo}}]]
+!! end
+
+!! test
+Category with template in sort key
+!! options
+cat
+pst
+!! input
+[[Category:Foo|{{echo|Bar}}]]
+!! result
+[[Category:Foo|{{echo|Bar}}]]
+!! end
+
+!! test
+Category with template in sort key and title
+!! options
+cat
+pst
+!! input
+[[Category:{{echo|Foo}}|{{echo|Bar}}]]
+!! result
+[[Category:{{echo|Foo}}|{{echo|Bar}}]]
+!! end
+
+!! test
+Category / paragraph interactions
+!! input
+Foo [[Category:Baz]] Bar
+
+Foo [[Category:Baz]]
+Bar
+
+Foo
+[[Category:Baz]]
+Bar
+
+Foo
+[[Category:Baz]] Bar
+
+Foo
+[[Category:Baz]]
+ [[Category:Baz]]
+[[Category:Baz]]
+Bar
+
+[[Category:Baz]]
+ [[Category:Baz]]
+[[Category:Baz]]
+
+[[Category:Baz]]
+ {{echo|[[Category:Baz]]}}
+[[Category:Baz]]
+!! result
+<p>Foo Bar
+</p><p>Foo
+Bar
+</p><p>Foo
+Bar
+</p><p>Foo Bar
+</p><p>Foo
+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
###
@@ -5138,6 +10449,19 @@ ill
es:Alimento fr:Nourriture zh:食品
!! end
+!! test
+Duplicate interlanguage links (bug 24502)
+!! options
+ill
+!! input
+[[es:1]]
+[[es:2]]
+[[fr:1]]
+[[fr:2]]
+!! result
+es:1 fr:1
+!! end
+
###
### Sections
###
@@ -5152,13 +10476,13 @@ More
===Smaller headline===
Blah blah
!! result
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=3" title="Edit section: Smaller headline">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
<p>Blah blah
</p>
!! end
@@ -5175,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>
@@ -5196,22 +10520,23 @@ Some text
</ul>
</li>
</ul>
-</td></tr></table>
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=6" title="Edit section: Another headline">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
!! end
# perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
!! test
Handling of sections up to level 6 and beyond
-!! input
+!! input
= Level 1 Heading=
== Level 2 Heading==
=== Level 3 Heading===
@@ -5223,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>
@@ -5251,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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=10" title="Edit section: ==== Level 10 Heading====">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
!! end
@@ -5275,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>
@@ -5293,13 +10619,14 @@ TOC regression (bug 9764)
</ul>
</li>
</ul>
-</td></tr></table>
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=6" title="Edit section: title 2.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
!! end
@@ -5315,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>
@@ -5329,13 +10656,14 @@ wgMaxTocLevel=3
</ul>
</li>
</ul>
-</td></tr></table>
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=6" title="Edit section: title 2.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
!! end
@@ -5350,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>
@@ -5359,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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=5" title="Edit section: Section 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -5375,8 +10704,8 @@ Resolving duplicate section names
== Foo bar ==
== Foo bar ==
!! result
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<h2><span class="mw-headline" id="Foo_bar_2">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -5386,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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<h2><span class="mw-headline" id="Foo_Bar_2">Foo Bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -5406,10 +10735,10 @@ __NOTOC__
{{sections}}
==Section 4==
!! result
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=2" title="Edit section: Section 4">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -5420,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
@@ -5430,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&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Edit section: Section with a link in it">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -5442,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>
@@ -5451,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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=3" title="Edit section: title 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -5468,7 +10798,7 @@ http://example.com [[Image:foobar.jpg]]
!!end
!! test
-Short headings with trailing space should match behaviour of Parser::doHeadings (bug 19910)
+Short headings with trailing space should match behavior of Parser::doHeadings (bug 19910)
!! input
===
The line above must have a trailing space!
@@ -5476,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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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
@@ -5506,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 &gt; text</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#text_.3C_text"><span class="tocnumber">2</span> <span class="toctext">text &lt; text</span></a></li>
@@ -5514,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&amp;action=edit&amp;section=1" title="Edit section: text > text">edit</a>]</span> <span class="mw-headline" id="text_.3E_text"> text &gt; text </span></h2>
+</div>
+
+<h2><span class="mw-headline" id="text_.3E_text">text &gt; text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: 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&amp;action=edit&amp;section=2" title="Edit section: text &lt; text">edit</a>]</span> <span class="mw-headline" id="text_.3C_text"> text &lt; text </span></h2>
+<h2><span class="mw-headline" id="text_.3C_text">text &lt; text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: text &lt; 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&amp;action=edit&amp;section=3" title="Edit section: text &amp; text">edit</a>]</span> <span class="mw-headline" id="text_.26_text"> text &amp; text </span></h2>
+<h2><span class="mw-headline" id="text_.26_text">text &amp; text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: text &amp; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>section 3
</p>
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=5" title="Edit section: text &quot; 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&amp;action=edit&amp;section=5" title="Edit section: text &quot; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>section 5
</p>
!! end
@@ -5541,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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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
@@ -5594,6 +10966,10 @@ Namespaced link must have a title (bad fragment version)
!!end
+###
+### HTML tags and HTML attributes
+###
+
!! test
div with no attributes
!! input
@@ -5639,6 +11015,49 @@ div with illegal double attributes
!!end
+# FIXME: produce empty string instead of "class" in the PHP parser, following
+# the HTML5 spec.
+!! test
+div with empty attribute value, space before equals
+!! options
+parsoid
+!! input
+<div class =>HTML rocks</div>
+!! result
+<div class="">HTML rocks</div>
+
+!! end
+
+# The PHP parser escapes the opening brace to &#123; for some reason, so
+# disabled this test for it.
+!! test
+div with braces in attribute value
+!! options
+parsoid
+!! input
+<div title="{}">Foo</div>
+!! result
+<div title="{}">Foo</div>
+!! end
+
+# This it very inconsistent in the PHP parser: it returns
+# class="class" if there is a space between the name and the equal sign (see
+# 'div with empty attribute value, space before equals'), but strips the
+# attribute completely if the space is missing. We hope that not much content
+# depends on this, so are implementing the behavior below in Parsoid for
+# consistencies' sake. Disabled for the PHP parser.
+# FIXME: fix this behavior in the PHP parser?
+!! test
+div with empty attribute value, no space before equals
+!! options
+parsoid
+!! input
+<div class=>HTML rocks</div>
+!! result
+<div class="">HTML rocks</div>
+
+!! end
+
!! test
HTML multiple attributes correction
!! input
@@ -5671,6 +11090,23 @@ DIV IN UPPERCASE
!!end
+!! test
+Non-ASCII pseudo-tags are rendered as text
+!! input
+<khyô>
+!! result
+<p>&lt;khyô&gt;
+</p>
+!! end
+
+!! test
+Pseudo-tag with URL 'name' renders as url link
+!! input
+<http://example.com/>
+!! result
+<p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
+</p>
+!! end
!! test
text with amp in the middle of nowhere
@@ -5691,6 +11127,15 @@ I always thought &eacute; was a cute letter.
!! end
!! test
+text with entity-escaped character entity-like string: eacute
+!! input
+I always thought &amp;eacute; was a cute letter.
+!! result
+<p>I always thought &amp;eacute; was a cute letter.
+</p>
+!! end
+
+!! test
text with undefined character entity: xacute
!! input
I always thought &xacute; was a cute letter.
@@ -5701,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
###
@@ -6054,6 +11574,17 @@ Bug 3244: HTML attribute safety (extension; unsafe)
!! end
+!! test
+Opera -o-link CSS
+!! input
+<div
+title="&#100;&#97;&#116;&#97;&#58;&#116;&#101;&#120;&#116;&#47;&#104;&#116;&#109;&#108;&#44;&#60;&#105;&#109;&#103;&#32;&#115;&#114;&#99;&#61;&#49;&#32;&#111;&#110;&#101;&#114;&#114;&#111;&#114;&#61;&#97;&#108;&#101;&#114;&#116;&#40;&#49;&#41;&#62;"
+style="-o-link:attr(title);-o-link-source:current">X</div>
+!! result
+<div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
+
+!! end
+
# More MSIE fun discovered by Tom Gilder
!! test
@@ -6092,6 +11623,70 @@ 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
@@ -6175,7 +11770,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
@@ -6183,9 +11778,9 @@ Parser hook: empty input
<tag></tag>
!! result
<pre>
-string(0) ""
-array(0) {
-}
+''
+array (
+)
</pre>
!! end
@@ -6197,8 +11792,8 @@ Parser hook: empty input using terminated empty elements
!! result
<pre>
NULL
-array(0) {
-}
+array (
+)
</pre>
!! end
@@ -6210,8 +11805,8 @@ Parser hook: empty input using terminated empty elements (space before)
!! result
<pre>
NULL
-array(0) {
-}
+array (
+)
</pre>
!! end
@@ -6222,9 +11817,9 @@ Parser hook: basic input
<tag>input</tag>
!! result
<pre>
-string(5) "input"
-array(0) {
-}
+'input'
+array (
+)
</pre>
!! end
@@ -6236,9 +11831,9 @@ Parser hook: case insensitive
<TAG>input</TAG>
!! result
<pre>
-string(5) "input"
-array(0) {
-}
+'input'
+array (
+)
</pre>
!! end
@@ -6250,9 +11845,9 @@ Parser hook: case insensitive, redux
<TaG>input</TAg>
!! result
<pre>
-string(5) "input"
-array(0) {
-}
+'input'
+array (
+)
</pre>
!! end
@@ -6265,9 +11860,9 @@ noxml
<tag><tag></tag></tag>
!! result
<pre>
-string(5) "<tag>"
-array(0) {
-}
+'<tag>'
+array (
+)
</pre>&lt;/tag&gt;
!! end
@@ -6278,17 +11873,13 @@ Parser hook: basic arguments
<tag width=200 height = "100" depth = '50' square></tag>
!! result
<pre>
-string(0) ""
-array(4) {
- ["width"]=>
- string(3) "200"
- ["height"]=>
- string(3) "100"
- ["depth"]=>
- string(2) "50"
- ["square"]=>
- string(6) "square"
-}
+''
+array (
+ 'width' => '200',
+ 'height' => '100',
+ 'depth' => '50',
+ 'square' => 'square',
+)
</pre>
!! end
@@ -6299,11 +11890,10 @@ Parser hook: argument containing a forward slash (bug 5344)
<tag filename='/tmp/bla'></tag>
!! result
<pre>
-string(0) ""
-array(1) {
- ["filename"]=>
- string(8) "/tmp/bla"
-}
+''
+array (
+ 'filename' => '/tmp/bla',
+)
</pre>
!! end
@@ -6315,10 +11905,9 @@ Parser hook: empty input using terminated empty elements (bug 2374)
!! result
<pre>
NULL
-array(1) {
- ["foo"]=>
- string(3) "bar"
-}
+array (
+ 'foo' => 'bar',
+)
</pre>text
!! end
@@ -6333,16 +11922,12 @@ other stuff
!! result
<pre>
NULL
-array(4) {
- ["width"]=>
- string(3) "200"
- ["height"]=>
- string(3) "100"
- ["depth"]=>
- string(2) "50"
- ["square"]=>
- string(6) "square"
-}
+array (
+ 'width' => '200',
+ 'height' => '100',
+ 'depth' => '50',
+ 'square' => 'square',
+)
</pre>
<p>other stuff
&lt;/tag&gt;
@@ -6350,7 +11935,7 @@ array(4) {
!! end
###
-### (see maintenance/parserTestsStaticParserHook.php for the <statictag> extension)
+### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
###
!! test
@@ -6468,6 +12053,30 @@ Something need to be done. foo-2 ?
!! end
!! test
+Sanitizer: Validating that <meta> and <link> work, but only for Microdata
+!! input
+<div itemscope>
+ <meta itemprop="hello" content="world">
+ <meta http-equiv="refresh" content="5">
+ <meta itemprop="hello" http-equiv="refresh" content="5">
+ <link itemprop="hello" href="{{SERVER}}">
+ <link rel="stylesheet" href="{{SERVER}}">
+ <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
+</div>
+!! result
+<div itemscope="itemscope">
+<p> <meta itemprop="hello" content="world" />
+ &lt;meta http-equiv="refresh" content="5"&gt;
+ <meta itemprop="hello" content="5" />
+</p>
+ <link itemprop="hello" href="http&#58;//example.org" />
+ &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
+ <link itemprop="hello" href="http&#58;//example.org" />
+</div>
+
+!! end
+
+!! test
Language converter: output gets cut off unexpectedly (bug 5757)
!! options
language=zh
@@ -6558,8 +12167,10 @@ disabled
!! result
<ul>
<li>One
-</li><li>Two
-</li></ul>
+</li>
+<li>Two
+</li>
+</ul>
!! end
@@ -6590,8 +12201,10 @@ disabled
!! result
<ol>
<li>One
-</li><li>Two
-</li></ol>
+</li>
+<li>Two
+</li>
+</ol>
!! end
@@ -6636,12 +12249,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
@@ -6686,21 +12303,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
@@ -6752,12 +12375,13 @@ Fuzz testing: Parser14
== onmouseover= ==
http://__TOC__
!! result
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;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&amp;action=edit&amp;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
@@ -6767,7 +12391,7 @@ Fuzz testing: Parser14-table
==a==
{| STYLE=__TOC__
!! result
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Edit section: a">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<table style="&#95;_TOC&#95;_">
<tr><td></td></tr>
</table>
@@ -6913,7 +12537,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
@@ -7420,7 +13044,7 @@ section=2
!! end
-# Formerly testing for bug 2587, now resolved by the use of unmarked sections
+# Formerly testing for bug 2587, now resolved by the use of unmarked sections
# instead of respecting commented sections
!! test
Section extraction prefixed by comment (section 1)
@@ -7445,7 +13069,7 @@ section=2
!!end
-# Formerly testing for bug 2607, now resolved by the use of unmarked sections
+# Formerly testing for bug 2607, now resolved by the use of unmarked sections
# instead of respecting HTML-style headings
!! test
Section extraction, mixed wiki and html (section 1)
@@ -7492,7 +13116,7 @@ section=1
==marked==
!!end
-# Test behaviour of bug 19910
+# Test behavior of bug 19910
!! test
Sectiion with all-equals
!! options
@@ -7924,18 +13548,34 @@ Handling of &#x0A; in URLs
!! input
**irc://&#x0A;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
Special:Search page linking.
@@ -7948,43 +13588,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&amp;action=edit&amp;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&amp;action=edit&amp;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.
@@ -8003,40 +13678,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>
@@ -8055,34 +13730,34 @@ 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>
<li class="gallerybox" style="width: 105px"><div style="width: 105px">
- <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="70" height="8" /></a></div></div>
+ <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" /></a></div></div>
<div class="gallerytext">
<p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
</p>
</div>
</div></li>
<li class="gallerybox" style="width: 105px"><div style="width: 105px">
- <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="70" height="8" /></a></div></div>
+ <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" /></a></div></div>
<div class="gallerytext">
</div>
</div></li>
<li class="gallerybox" style="width: 105px"><div style="width: 105px">
- <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a foo-bar." src="http://example.com/images/3/3a/Foobar.jpg" width="70" height="8" /></a></div></div>
+ <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a foo-bar." src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" /></a></div></div>
<div class="gallerytext">
<p>Blabla|blabla.
</p>
@@ -8100,16 +13775,16 @@ 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/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
+ <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">
-<p><a href="/wiki/File:Foobar.jpg" class="image" title="desc"><img alt="inneralt" src="http://example.com/images/3/3a/Foobar.jpg" width="20" height="2" /></a>
+<p><a href="/wiki/File:Foobar.jpg" class="image" title="desc"><img alt="inneralt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" width="20" height="2" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg 2x" /></a>
</p>
</div>
</div></li>
<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/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
+ <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">
<p>This is a test template
</p>
@@ -8129,9 +13804,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
@@ -8139,14 +13814,14 @@ 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>
</div>
</div></li>
<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="" src="http://example.com/images/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
+ <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
<div class="gallerytext">
<p><a href="/wiki/File:Foobar.jpg" title="File:Foobar.jpg">Foobar.jpg</a><br />
some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
@@ -8154,7 +13829,7 @@ some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
</div>
</div></li>
<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/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
+ <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">
<p><a href="/wiki/File:Foobar.jpg" title="File:Foobar.jpg">Foobar.jpg</a><br />
</p>
@@ -8174,24 +13849,24 @@ 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>
<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/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
+ <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
<div class="gallerytext">
</div>
</div></li>
<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/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
+ <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
<div class="gallerytext">
</div>
</div></li>
@@ -8228,7 +13903,7 @@ HTML Hex character encoding mixed case
!! test
__FORCETOC__ override
-!! input
+!! input
__NEWSECTIONLINK__
__FORCETOC__
!! result
@@ -8277,12 +13952,12 @@ Double RFC
!! input
RFC RFC 1234
!! result
-<p>RFC <a class="external mw-magiclink-rfc" href="//tools.ietf.org/html/rfc1234">RFC 1234</a>
+<p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a>
</p>
!! end
!! test
-Double RFC with a wiki link
+Double RFC with a wiki link
!! input
RFC [[RFC 1234]]
!! result
@@ -8295,7 +13970,7 @@ RFC code coverage
!! input
RFC 983&#x20;987
!! result
-<p><a class="external mw-magiclink-rfc" href="//tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
+<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
</p>
!! end
@@ -8322,7 +13997,7 @@ Width + Height sized image (using px) (height is ignored)
!! input
[[Image:foobar.jpg|640x480px]]
!! result
-<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="640" height="73" /></a>
+<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
</p>
!!end
@@ -8331,7 +14006,7 @@ Width-sized image (using px, no following whitespace)
!! input
[[Image:foobar.jpg|640px]]
!! result
-<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="640" height="73" /></a>
+<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
</p>
!!end
@@ -8340,7 +14015,7 @@ Width-sized image (using px, with following whitespace - test regression from r3
!! input
[[Image:foobar.jpg|640px ]]
!! result
-<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="640" height="73" /></a>
+<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
</p>
!!end
@@ -8349,7 +14024,7 @@ Width-sized image (using px, with preceding whitespace - test regression from r3
!! input
[[Image:foobar.jpg| 640px]]
!! result
-<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="640" height="73" /></a>
+<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
</p>
!!end
@@ -8372,13 +14047,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
@@ -8389,7 +14076,7 @@ Images with the "|" character in the comment
!! input
[[image:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
!! result
-<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" 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>An <a rel="nofollow" class="external text" href="http://test/?param1=%7Cleft%7C&amp;param2=%7Cx">external</a> URL</div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>An <a rel="nofollow" class="external text" href="http://test/?param1=%7Cleft%7C&amp;param2=%7Cx">external</a> URL</div></div></div>
!!end
@@ -8405,7 +14092,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
@@ -8474,6 +14161,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
@@ -8481,10 +14207,17 @@ Definition list code coverage
; title : def
;title: def
!! result
-<dl><dt> title &#160;</dt><dd> def
-</dd><dt> title&#160;</dt><dd> def
-</dd><dt>title</dt><dd> def
-</dd></dl>
+<dl>
+<dt> title &#160;</dt>
+<dd> def
+</dd>
+<dt> title&#160;</dt>
+<dd> def
+</dd>
+<dt>title</dt>
+<dd> def
+</dd>
+</dl>
!! end
@@ -8548,7 +14281,7 @@ Inclusion of !userCanEdit() content
!! input
{{MediaWiki:Fake}}
!! result
-<h2><span class="editsection">[<a href="/index.php?title=MediaWiki:Fake&amp;action=edit&amp;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&amp;action=edit&amp;section=T-1" title="MediaWiki:Fake">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -8563,7 +14296,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>
@@ -8578,13 +14311,14 @@ Out-of-order TOC heading levels
</ul>
</li>
</ul>
-</td></tr></table>
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=6" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -8691,14 +14425,11 @@ anchorencode encodes like the TOC generator: (bug 18431)
{{anchorencode: _ +:.3A%3A&&amp;]] }}
__NOEDITSECTION__
!! result
-<h3> <span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D"> _ +:.3A%3A&amp;&amp;]] </span></h3>
+<h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</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
@@ -8711,7 +14442,8 @@ bar
baz
!! result
<blockquote>
-foo
+<p>foo
+</p>
</blockquote>
<p>bar
</p>
@@ -8740,6 +14472,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&lt;/span&gt;</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
@@ -8755,6 +14508,33 @@ Both [[Dunav]] and [[Дунав]] are names for this river.
</p>
!!end
+!! article
+Дуна
+!! text
+content
+!! endarticle
+
+!! test
+Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
+!! options
+title=[[Duna]] language=sr
+!! input
+[[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
+!! result
+<p><a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Дуна</a> is not a self-link while <strong class="selflink">Duna</strong> and <strong class="selflink">Dуна</strong> are still self-links.
+</p>
+!! 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
@@ -8827,6 +14607,29 @@ language=sr cat
!! end
+!! article
+Category:分类
+!! text
+blah
+!! endarticle
+
+!! article
+Category:分類
+!! text
+blah
+!! endarticle
+
+!! test
+Don't convert blue categorylinks to another variant (bug 33210)
+!! options
+language=zh cat
+!! input
+[[A]][[Category:分类]]
+!! result
+<a href="/wiki/Category:%E5%88%86%E7%B1%BB" title="Category:分类">分类</a>
+!! end
+
+
!! test
Stripping -{}- tags (language variants)
!! options
@@ -8882,7 +14685,7 @@ language=sr variant=sr-ec
!! input
== -{Naslov}- ==
!! result
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Уредите одељак „Naslov“">уреди</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -8900,6 +14703,20 @@ language=zh variant=zh-tw
!! test
+Conversion around HTML tags
+!! options
+language=sr variant=sr-ec
+!! input
+-{H|span=>sr-ec:script;title=>sr-ec:src;}-
+<span title="La-{sr-el:L;sr-ec:C;}-tin">ski</span>
+!! result
+<p>
+<span title="ЛаCтин">ски</span>
+</p>
+!! end
+
+
+!! test
Explicit session-wise language variant mapping (A flag and - flag)
!! options
language=zh variant=zh-tw
@@ -8954,6 +14771,20 @@ China
!! end
!! test
+Recursive conversion of alt and title attrs shouldn't clear converter state
+!! options
+language=zh variant=zh-cn showtitle
+!! input
+-{H|zh-cn:Exclamation;zh-tw:exclamation;}-
+Should be stripped-{T|zh-cn:China;zh-tw:Taiwan}-<span title="exclamation">!</span>
+!! result
+China
+<p>
+Should be stripped<span title="Exclamation">!</span>
+</p>
+!! end
+
+!! test
Bug 24072: more test on conversion rule for title
!! options
language=zh variant=zh-tw showtitle
@@ -8968,6 +14799,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
@@ -8990,6 +14845,29 @@ Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiw
!! end
!! test
+Proper conversion of text in external links
+!! options
+language=sr variant=sr-ec
+!! input
+http://www.google.com
+gopher://www.google.com
+[http://www.google.com http://www.google.com]
+[gopher://www.google.com gopher://www.google.com]
+[https://www.google.com irc://www.google.com]
+[ftp://www.google.com www.google.com/ftp://dir]
+[//www.google.com www.google.com]
+!! result
+<p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
+<a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
+<a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
+<a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
+<a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
+<a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
+<a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
+</p>
+!! end
+
+!! test
Do not convert roman numbers to language variants
!! options
language=sr variant=sr-ec
@@ -9002,7 +14880,7 @@ Fridrih IV je car.
!! test
Unclosed language converter markup "-{"
-!! options
+!! options
language=sr
!! input
-{T|hello
@@ -9017,25 +14895,60 @@ Don't convert raw rule "-{R|=&gt;}-" to "=>"
language=sr
!! input
-{R|=&gt;}-
-!! result
+!! result
<p>=&gt;
</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
+
+# Plain MediaWiki does not remove empty lists, but tidy actually does.
+# Templates in Wikipedia rely on this behavior, as tidy has always been
+# enabled there. These tests are normally run *without* tidy, so specify the
+# full output here.
+# To test realistic parsing behavior, apply a tidy-like transformation to both
+# the expected output and your parser's output.
+!! test
+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>
!! end
@@ -9067,9 +14980,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
@@ -9125,7 +15041,7 @@ Morwen/13: Unclosed link followed by heading
!! result
<p>[[link
</p>
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Edit section: heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -9137,7 +15053,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
@@ -9149,7 +15065,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&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Edit section: heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -9239,8 +15155,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
@@ -9253,8 +15167,6 @@ Line two</blockquote>
!! test
Bug 6200: paragraphs inside blockquotes (extra line break on open)
-!! options
-disabled
!! input
<blockquote>
Line one
@@ -9270,8 +15182,6 @@ Line two</blockquote>
!! test
Bug 6200: paragraphs inside blockquotes (extra line break on close)
-!! options
-disabled
!! input
<blockquote>Line one
@@ -9287,8 +15197,6 @@ Line two
!! test
Bug 6200: paragraphs inside blockquotes (extra line break on open and close)
-!! options
-disabled
!! input
<blockquote>
Line one
@@ -9383,7 +15291,7 @@ Free external link invading image caption
!! input
[[Image:Foobar.jpg|thumb|http://x|hello]]
!! result
-<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="180" height="20" 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>hello</div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="" /></a></div>hello</div></div></div>
!! end
@@ -9416,17 +15324,6 @@ Multibyte character in padright
</p>
!! end
-!! test
-Formatted date
-!! config
-wgUseDynamicDates=1
-!! input
-[[2009-03-24]]
-!! result
-<p><span class="mw-formatted-date" title="2009-03-24"><a href="/index.php?title=2009&amp;action=edit&amp;redlink=1" class="new" title="2009 (page does not exist)">2009</a>-<a href="/index.php?title=March_24&amp;action=edit&amp;redlink=1" class="new" title="March 24 (page does not exist)">03-24</a></span>
-</p>
-!!end
-
!!test
formatdate parser function
!!input
@@ -9446,17 +15343,6 @@ formatdate parser function, with default format
!! end
!! test
-Linked date with autoformatting disabled
-!! config
-wgUseDynamicDates=false
-!! input
-[[2009-03-24]]
-!! result
-<p><a href="/index.php?title=2009-03-24&amp;action=edit&amp;redlink=1" class="new" title="2009-03-24 (page does not exist)">2009-03-24</a>
-</p>
-!! end
-
-!! test
Spacing of numbers in formatted dates
!! input
{{#formatdate:January 15}}
@@ -9466,17 +15352,6 @@ Spacing of numbers in formatted dates
!! end
!! test
-Spacing of numbers in formatted dates (linked)
-!! config
-wgUseDynamicDates=true
-!! input
-[[January 15]]
-!! result
-<p><span class="mw-formatted-date" title="01-15"><a href="/index.php?title=January_15&amp;action=edit&amp;redlink=1" class="new" title="January 15 (page does not exist)">January 15</a></span>
-</p>
-!! end
-
-!! test
formatdate parser function, with default format and on a page of which the content language is always English and different from the wiki content language
!! options
language=nl title=[[MediaWiki:Common.css]]
@@ -9542,7 +15417,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
@@ -9772,7 +15647,41 @@ Screen
<p>this is not the the title
</p>
!! 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
@@ -9782,7 +15691,7 @@ Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
!! result
Hello kind world.
!! end
-
+
!! test
preload: check <onlyinclude>
!! options
@@ -9814,7 +15723,7 @@ preload
!! end
!! test
-Play a bit with r67090 and bug 3158
+Play a bit with r67090 and bug 3158
!! options
disabled
!! input
@@ -9997,29 +15906,31 @@ 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&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Edit section: Lost episodes">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
!! test
-Bug 26375: TOC with bold
+Bug 26375: TOC with bold
!! options
title=[[Main Page]]
!! input
__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&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Edit section: should be bold then normal text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -10031,12 +15942,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&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Edit section: Image">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -10048,12 +15960,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&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Edit section: Quote">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -10067,12 +15980,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 &lt; 3</span></a></li>
</ul>
-</td></tr></table>
-<h2><span class="editsection">[<a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Proof: 2 &lt; 3">edit</a>]</span> <span class="mw-headline" id="Proof:_2_.3C_3"> Proof: 2 &lt; 3 </span></h2>
+</div>
+
+<h2><span class="mw-headline" id="Proof:_2_.3C_3">Proof: 2 &lt; 3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Proof: 2 &lt; 3">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p><small>Hanc marginis exiguitas non caperet.</small>
QED
</p>
@@ -10086,14 +16000,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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i> <blockquote>Bar</blockquote></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -10105,14 +16020,47 @@ __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"&gt;Evilbye</sup></span></a></li>
</ul>
-</td></tr></table>
-<h2><span class="editsection">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;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&amp;action=edit&amp;section=2" title="Edit section: b&quot;>Evilbye">edit</a>]</span> <span class="mw-headline" id="b.22.3EEvilbye"> <sup> b"&gt;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&amp;action=edit&amp;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"&gt;Evilbye</sup></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: b&quot;>Evilbye">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+
+!! end
+
+!! test
+span tags with directionality in TOC
+!! input
+__TOC__
+== <span dir="ltr">C++</span> ==
+
+== <span dir="rtl">זבנג!</span> ==
+
+== <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> ==
+
+== <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> ==
+
+== <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> ==
+!! result
+<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>
+<li class="toclevel-1 tocsection-3"><a href="#The_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span class="tocnumber">3</span> <span class="toctext"><span>The attributes on these span tags must be deleted from the TOC</span></span></a></li>
+<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>
+</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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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
@@ -10129,7 +16077,7 @@ title=[[Main Page]]
!! input
{{int:Bug32057}}
!! result
-<h2><span class="editsection">[<a href="/index.php?title=Main_Page&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Edit section: Headline text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -10176,6 +16124,19 @@ Strip marker in formatNum
!! end
!! test
+Check noCommafy in formatNum
+!! options
+language=be-tarask
+!! input
+{{formatnum:123456.78}}
+{{formatnum:123456.78|NOSEP}}
+!! result
+<p>123 456,78
+123456.78
+</p>
+!! end
+
+!! test
Strip marker in grammar
!! options
language=fi
@@ -10218,7 +16179,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&amp;action=edit&amp;section=1" title="Edit section: xyz">edit</a>]</span> <span class="mw-headline" id="xyz"><a href="/index.php?title=Foo&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;section=1" title="Edit section: xyz">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
!! end
@@ -10257,9 +16218,9 @@ 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/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
+ <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">
<p>caption
</p>
@@ -10276,9 +16237,9 @@ 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/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
+ <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">
<p>caption
</p>
@@ -10295,9 +16256,9 @@ 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/3/3a/Foobar.jpg" width="120" height="14" /></a></div></div>
+ <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">
<p>caption
</p>
@@ -10308,6 +16269,23 @@ File:foobar.jpg|caption|alt=galleryalt|link=" onclick="alert('malicious javascri
!! end
!!test
+Gallery with invalid title as link (bug 43964)
+!! input
+<gallery>
+File:foobar.jpg|link=<
+</gallery>
+!! result
+<ul class="gallery mw-gallery-traditional">
+ <li class="gallerybox" style="width: 155px"><div style="width: 155px">
+ <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" /></a></div></div>
+ <div class="gallerytext">
+ </div>
+ </div></li>
+</ul>
+
+!! end
+
+!!test
Language parser function
!! input
{{#language:ar}}
@@ -10328,6 +16306,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/]
@@ -10354,6 +16345,2243 @@ 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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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&amp;action=edit&amp;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
+###
+!!test
+1. SOL-sensitive wikitext tokens as template-args
+!!options
+parsoid=wt2html,wt2wt
+!!input
+{{echo|*a}}
+{{echo|#a}}
+{{echo|:a}}
+!!result
+<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=\"{&amp;quot;dsr&amp;quot;:[19,40,3,3]}\"><a rel=\"mw:WikiLink\" href=\"./Bolded_link\" data-parsoid=\"{&amp;quot;stx&amp;quot;:&amp;quot;simple&amp;quot;,&amp;quot;a&amp;quot;:{&amp;quot;href&amp;quot;:&amp;quot;./Bolded_link&amp;quot;},&amp;quot;sa&amp;quot;:{&amp;quot;href&amp;quot;:&amp;quot;bolded link&amp;quot;},&amp;quot;dsr&amp;quot;:[22,37,2,2]}\">bolded link</a></b> and this is a <span about=\"#mwt5\" typeof=\"mw:Transclusion\" data-mw=\"{&amp;quot;parts&amp;quot;:[{&amp;quot;template&amp;quot;:{&amp;quot;target&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;echo&amp;quot;,&amp;quot;href&amp;quot;:&amp;quot;./Template:Echo&amp;quot;},&amp;quot;params&amp;quot;:{&amp;quot;1&amp;quot;:{&amp;quot;wt&amp;quot;:&amp;quot;transclusion&amp;quot;}},&amp;quot;i&amp;quot;:0}}]}\" data-parsoid=\"{&amp;quot;dsr&amp;quot;:[55,76,null,null],&amp;quot;pi&amp;quot;:[[{&amp;quot;k&amp;quot;:&amp;quot;1&amp;quot;,&amp;quot;spc&amp;quot;:[&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;,&amp;quot;&amp;quot;]}]]}\">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=\"{&amp;quot;src&amp;quot;:&amp;quot;{{&amp;quot;,&amp;quot;dsr&amp;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=\"{&amp;quot;stx&amp;quot;:&amp;quot;html&amp;quot;,&amp;quot;autoInsertedEnd&amp;quot;:true,&amp;quot;dsr&amp;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="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;foo &amp;lt;ref&amp;gt;bar&amp;lt;/ref&amp;gt; baz&quot;},&quot;attrs&quot;:{}}" 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="{&quot;name&quot;:&quot;references&quot;,&quot;attrs&quot;:{}}">
+<li about="#cite_note-1" id="cite_note-1" data-parsoid="{}"><span rel="mw:referencedBy"><a href="#cite_ref-1-0">↑</a></span> foo &lt;ref&gt;bar&lt;/ref&gt; 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=\"{&amp;quot;name&amp;quot;:&amp;quot;ref&amp;quot;,&amp;quot;body&amp;quot;:{&amp;quot;html&amp;quot;:&amp;quot;foo&amp;quot;},&amp;quot;attrs&amp;quot;:{&amp;quot;name&amp;quot;:&amp;quot;a&amp;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=\"{&amp;quot;name&amp;quot;:&amp;quot;ref&amp;quot;,&amp;quot;body&amp;quot;:{&amp;quot;html&amp;quot;:&amp;quot;foo&amp;quot;},&amp;quot;attrs&amp;quot;:{&amp;quot;name&amp;quot;:&amp;quot;b&amp;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. 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
+#### 1. Nested inside html <h1>=foo=</h1>
+#### 2. Outside heading nest on a single line <h1>foo</h1>*bar
+#### 3. Nested inside html with wikitext split by html tags
+#### 4. No escape needed
+#### 5. Empty headings <h1></h1>
+#### 6. Heading chars in SOL context
+#### ----------------------------------------
+!! test
+Headings: 0. Unnested
+!! options
+parsoid
+!! input
+<nowiki>=foo=</nowiki>
+
+<nowiki> =foo= </nowiki>
+<!--cmt-->
+<nowiki>=foo=</nowiki>
+
+=foo''a''<nowiki>=</nowiki>
+!! result
+<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
+parsoid
+!! input
+=<nowiki>=foo=</nowiki>=
+
+==<nowiki>=foo=</nowiki>==
+
+===<nowiki>=foo=</nowiki>===
+
+====<nowiki>=foo=</nowiki>====
+
+=====<nowiki>=foo=</nowiki>=====
+
+======<nowiki>=foo=</nowiki>======
+!! result
+<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
+parsoid
+!! input
+=foo=
+<nowiki>*</nowiki>bar
+
+=foo=
+=bar
+
+=foo=
+<nowiki>=bar=</nowiki>
+!! result
+<h1>foo</h1>*bar
+<h1>foo</h1>=bar
+<h1>foo</h1>=bar=
+!!end
+
+!! test
+Headings: 3. Nested inside html with wikitext split by html tags
+!! options
+parsoid
+!! input
+=='''bold'''<nowiki>foo=</nowiki>=
+!! result
+<h1>=<b>bold</b><span typeof="mw:Nowiki">foo=</span></h1>
+!!end
+
+!! test
+Headings: 4a. No escaping needed (testing just h1 and h2)
+!! options
+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><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
+parsoid
+!! input
+=<nowiki/>=
+
+==<nowiki/>==
+
+===<nowiki/>===
+
+====<nowiki/>====
+
+=====<nowiki/>=====
+
+======<nowiki/>======
+!! result
+<h1></h1>
+<h2></h2>
+<h3></h3>
+<h4></h4>
+<h5></h5>
+<h6></h6>
+!!end
+
+!! test
+Headings: 6a. Heading chars in SOL context (with trailing spaces)
+!! options
+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
+<nowiki>=a=
+b</nowiki>
+
+<nowiki>=a=
+b</nowiki>
+
+<nowiki>=a=
+b</nowiki>
+
+<nowiki>=a=
+b</nowiki>
+!! result
+<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>
+#### 2. Inside definition lists
+#### 3. Only bullets at start should be escaped
+#### 4. No escapes needed
+#### 5. No unnecessary escapes
+#### 6. Escape bullets in SOL position
+#### 7. Escape bullets in a multi-line context
+#### ----------------------------------------
+
+!! test
+Lists: 0. Outside nests
+!! input
+<nowiki>*</nowiki>foo
+
+<nowiki>#</nowiki>foo
+!! result
+<p>*foo
+</p><p>#foo
+</p>
+!!end
+
+!! test
+Lists: 1. Nested inside html
+!! input
+*<nowiki>*foo</nowiki>
+
+*<nowiki>#foo</nowiki>
+
+*<nowiki>:foo</nowiki>
+
+*<nowiki>;foo</nowiki>
+
+#<nowiki>*foo</nowiki>
+
+#<nowiki>#foo</nowiki>
+
+#<nowiki>:foo</nowiki>
+
+#<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>
+
+!!end
+
+!! test
+Lists: 2. Inside definition lists
+!! input
+;<nowiki>;foo</nowiki>
+
+;<nowiki>:foo</nowiki>
+
+;<nowiki>:foo</nowiki>
+:bar
+
+:<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>
+
+!!end
+
+!! test
+Lists: 3. Only bullets at start of text should be escaped
+!! input
+*<nowiki>*foo*bar</nowiki>
+
+*<nowiki>*foo</nowiki>''it''*bar
+!! result
+<ul>
+<li>*foo*bar
+</li>
+</ul>
+<ul>
+<li>*foo<i>it</i>*bar
+</li>
+</ul>
+
+!!end
+
+!! test
+Lists: 4. No escapes needed
+!! options
+parsoid
+!! input
+*foo*bar
+
+*''foo''*bar
+
+*[[Foo]]: bar
+!! result
+<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
+Lists: 5. No unnecessary escapes
+!! input
+* bar <span><nowiki>[[foo]]</nowiki></span>
+
+*=bar <span><nowiki>[[foo]]</nowiki></span>
+
+*[[bar <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> <s></s>: a
+</li>
+</ul>
+
+!!end
+
+!! test
+Lists: 6. Escape bullets in SOL position
+!! options
+parsoid
+!! input
+<!--cmt--><nowiki>*foo</nowiki>
+!! result
+<p><!--cmt--><span typeof="mw:Nowiki">*foo</span></p>
+!!end
+
+!! test
+Lists: 7. Escape bullets in a multi-line context
+!! input
+a
+<nowiki>*</nowiki>b
+!! result
+<p>a
+*b
+</p>
+!!end
+
+#### --------------- HRs ---------------
+#### 1. Single line
+#### -----------------------------------
+
+!! test
+HRs: 1. Single line
+!! options
+parsoid
+!! input
+----<nowiki>----</nowiki>
+----=foo=
+----*foo
+!! result
+<hr><span typeof="mw:Nowiki">----</span>
+<hr>=foo=
+<hr>*foo
+!! end
+
+#### --------------- Tables ---------------
+#### 1a. Simple example
+#### 1b. No escaping needed (!foo)
+#### 1c. No escaping needed (|foo)
+#### 1d. No escaping needed (|}foo)
+####
+#### 2a. Nested in td (<td>foo|bar</td>)
+#### 2b. Nested in td (<td>foo||bar</td>)
+#### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
+####
+#### 3a. Nested in th (<th>foo!bar</th>)
+#### 3b. Nested in th (<th>foo!!bar</th>)
+#### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
+####
+#### 4a. Escape -
+#### 4b. Escape +
+#### 4c. No escaping needed
+#### --------------------------------------
+
+!! test
+Tables: 1a. Simple example
+!! input
+<nowiki>{|
+|}</nowiki>
+!! result
+<p>{|
+|}
+</p>
+!! end
+
+!! test
+Tables: 1b. No escaping needed
+!! input
+!foo
+!! result
+<p>!foo
+</p>
+!! end
+
+!! test
+Tables: 1c. No escaping needed
+!! input
+|foo
+!! result
+<p>|foo
+</p>
+!! end
+
+!! test
+Tables: 1d. No escaping needed
+!! input
+|}foo
+!! result
+<p>|}foo
+</p>
+!! end
+
+!! test
+Tables: 2a. Nested in td
+!! options
+parsoid
+!! input
+{|
+|<nowiki>foo|bar</nowiki>
+|}
+!! result
+<table><tbody><tr>
+<td><span typeof="mw:Nowiki">foo|bar</span></td></tr></tbody></table>
+!! end
+
+!! test
+Tables: 2b. Nested in td
+!! options
+parsoid
+!! input
+{|
+|<nowiki>foo||bar</nowiki>
+|''it''<nowiki>foo||bar</nowiki>
+|}
+!! result
+<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
+parsoid
+!! input
+{|
+|foo!!bar
+|}
+!! result
+<table><tbody><tr><td>foo!!bar
+</td></tr></tbody></table>
+
+!! end
+
+!! test
+Tables: 3a. Nested in th
+!! options
+parsoid
+!! input
+{|
+!foo!bar
+|}
+!! result
+<table><tbody><tr><th>foo!bar
+</th></tr></tbody></table>
+
+!! end
+
+!! test
+Tables: 3b. Nested in th
+!! options
+parsoid
+!! input
+{|
+!<nowiki>foo!!bar</nowiki>
+|}
+!! result
+<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
+parsoid
+!! input
+{|
+!<nowiki>foo||bar</nowiki>
+|}
+!! result
+<table><tbody><tr>
+<th><span typeof="mw:Nowiki">foo||bar</span></th></tr></tbody></table>
+!! end
+
+!! test
+Tables: 4a. Escape -
+!! options
+parsoid
+!! input
+{|
+!-bar
+|-
+|<nowiki>-bar</nowiki>
+|}
+!! result
+<table><tbody>
+<tr><th>-bar</th></tr>
+<tr>
+<td><span typeof="mw:Nowiki">-bar</span></td></tr></tbody></table>
+!! end
+
+!! test
+Tables: 4b. Escape +
+!! options
+parsoid
+!! input
+{|
+!+bar
+|-
+|<nowiki>+bar</nowiki>
+|}
+!! result
+<table><tbody>
+<tr><th>+bar</th></tr>
+<tr>
+<td><span typeof="mw:Nowiki">+bar</span></td></tr></tbody></table>
+!! end
+
+!! test
+Tables: 4c. No escaping needed
+!! options
+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
+||-2
+|}
+!! result
+<table>
+<tr>
+<td>+1
+</td>
+<td>-2
+</td></tr></table>
+
+!! end
+
+#### --------------- Links ----------------
+#### 1. Quote marks in link text
+#### 2. Wikilinks: Escapes needed
+#### 3. Wikilinks: No escapes needed
+#### 4. Extlinks: Escapes needed
+#### 5. Extlinks: No escapes needed
+#### --------------------------------------
+!! test
+Links 1. Quote marks in link text
+!! options
+parsoid
+!! input
+[[Foo|Foo<nowiki>''boo''</nowiki>]]
+!! result
+<a rel="mw:WikiLink" href="Foo">Foo''boo''</a>
+!! end
+
+!! test
+Links 2. WikiLinks: Escapes needed
+!! options
+parsoid
+!! input
+[[Foo|<nowiki>[Foobar]</nowiki>]]
+[[Foo|<nowiki>Foobar]</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>
+<a href="Foo" rel="mw:WikiLink">x [Foobar] x</a>
+<a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
+<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
+parsoid
+!! input
+[[Foo|[Foobar]]
+[[Foo|foo|bar]]
+!! result
+<a href="Foo" rel="mw:WikiLink">[Foobar</a>
+<a href="Foo" rel="mw:WikiLink">foo|bar</a>
+!! end
+
+!! test
+Links 4. ExtLinks: Escapes needed
+!! options
+parsoid
+!! input
+[http://google.com <nowiki>[google]</nowiki>]
+[http://google.com <nowiki>google]</nowiki>]
+!! result
+<a href="http://google.com" rel="mw:ExtLink">[google]</a>
+<a href="http://google.com" rel="mw:ExtLink">google]</a>
+!! end
+
+!! test
+Links 5. ExtLinks: No escapes needed
+!! options
+parsoid
+!! input
+[http://google.com [google]
+!! result
+<a href="http://google.com" rel="mw:ExtLink">[google</a>
+!! end
+
+#### --------------- Quotes ---------------
+#### 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>
+<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
+2. Link fragments separated by <i> and <b> tags
+!! input
+[[''foo''<nowiki>hello]]</nowiki>
+
+[['''foo'''<nowiki>hello]]</nowiki>
+!! result
+<p>[[<i>foo</i>hello]]
+</p><p>[[<b>foo</b>hello]]
+</p>
+!! end
+
+!! test
+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
+''[[foo''<nowiki>]]</nowiki>
+
+'''[[foo'''<nowiki>]]</nowiki>
+!! result
+<p><i>[[foo</i>]]
+</p><p><b>[[foo</b>]]
+</p>
+!! end
+
+!! 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
+#### --------------------------------------
+
+!! test
+1. No unnecessary escapes
+!! input
+bar <span><nowiki>[[foo]]</nowiki></span>
+
+=bar <span><nowiki>[[foo]]</nowiki></span>
+
+[[bar <span><nowiki>[[foo]]</nowiki></span>
+
+]]bar <span><nowiki>[[foo]]</nowiki></span>
+
+=bar <span>foo]]</span><nowiki>=</nowiki>
+!! result
+<p>bar <span>[[foo]]</span>
+</p><p>=bar <span>[[foo]]</span>
+</p><p>[[bar <span>[[foo]]</span>
+</p><p>]]bar <span>[[foo]]</span>
+</p><p>=bar <span>foo]]</span>=
+</p>
+!!end
+
+#### ----------------------- PRE --------------------------
+#### 1. Leading whitespace in SOL context should be escaped
+#### ------------------------------------------------------
+!! test
+1. Leading whitespace in SOL context should be escaped
+!! options
+parsoid
+!! input
+<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> 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
+parsoid
+!! input
+<a href="http://google.com">google</a>
+!! result
+&lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
+!! end
+
+!! test
+2. other tags
+!! input
+<nowiki><div>foo</div>
+<div style="color:red">foo</div></nowiki>
+!! result
+<p>&lt;div&gt;foo&lt;/div&gt;
+&lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;
+</p>
+!! end
+
+!! test
+3. multi-line html tag
+!! input
+<nowiki><div
+>foo</div
+></nowiki>
+!! result
+<p>&lt;div
+&gt;foo&lt;/div
+&gt;
+</p>
+!! end
+
+!! test
+4. extension tags
+!! input
+<nowiki><ref>foo</ref></nowiki>
+!! result
+<p>&lt;ref&gt;foo&lt;/ref&gt;
+</p>
+!! end
+
+#### --------------- Others ---------------
+!! test
+Escaping nowikis
+!! input
+&lt;nowiki&gt;foo&lt;/nowiki&gt;
+!! result
+<p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
+</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>
+
+<x.y>
+
+<x-y>
+
+1>2
+
+x<y
+
+a>b
+
+1<d e>f
+!! result
+<p>&lt;x y&gt;
+</p><p>&lt;x.y&gt;
+</p><p>&lt;x-y&gt;
+</p><p>1&gt;2
+</p><p>x&lt;y
+</p><p>a&gt;b
+</p><p>1&lt;d e&gt;f
+</p>
+!! end
+
+
+# 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
+!! input
+<s.ome> text
+!! result
+<p>&lt;s.ome&gt; text
+</p>
+!! end
+
+!! test
+HTML tag with necessary entities in attributes
+!! input
+<span title="&amp;amp;">foo</span>
+!! result
+<p><span title="&amp;amp;">foo</span>
+</p>
+!! end
+
+!! test
+HTML tag with 'unnecessary' entity encoding in attributes
+!! input
+<span title="&amp;">foo</span>
+!! result
+<p><span title="&amp;">foo</span>
+</p>
+!! end
+
+!! test
+HTML tag with broken attribute value quoting
+!! input
+<span title="Hello world>Foo</span>
+!! result
+<p><span>Foo</span>
+</p>
+!! end
+
+!! test
+Parsoid-only: HTML tag with broken attribute value quoting
+!! options
+parsoid
+!! input
+<span title="Hello world>Foo</span>
+!! result
+<p><span title="Hello world">Foo</span>
+</p>
+!! end
+
+!! test
+Table with broken attribute value quoting
+!! input
+{|
+| title="Hello world|Foo
+|}
+!! result
+<table>
+<tr>
+<td>Foo
+</td></tr></table>
+
+!! end
+
+!! test
+Table with broken attribute value quoting on consecutive lines
+!! input
+{|
+| title="Hello world|Foo
+| style="color:red|Bar
+|}
+!! result
+<table>
+<tr>
+<td>Foo
+</td>
+<td>Bar
+</td></tr></table>
+
+!! end
+
+!! test
+Parsoid-only: Table with broken attribute value quoting on consecutive lines
+!! options
+parsoid
+!! input
+{|
+| title="Hello world|Foo
+| style="color:red|Bar
+|}
+!! result
+<table><tbody>
+<tr>
+<td title="Hello world">Foo
+</td><td style="color: red">Bar
+</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
+{|
+| align="center" | foo || |
+|}
+!!result
+<table>
+<tr>
+<td align="center"> foo </td>
+<td>
+</td></tr></table>
+
+!!end
+
+!!test
+Non-empty attributes in th-cells
+!!input
+{|
+! Foo !! style="color: red" | Bar
+|}
+!!result
+<table>
+<tr>
+<th> Foo </th>
+<th style="color: red"> Bar
+</th></tr></table>
+
+!!end
+
+!!test
+Accept empty attributes in th-cells
+!!input
+{|
+!| foo !!| bar
+|}
+!!result
+<table>
+<tr>
+<th> foo </th>
+<th> bar
+</th></tr></table>
+
+!!end
+
+!!test
+Empty table rows go away
+!!input
+{|
+| Hello
+| there
+|- class="foo"
+|-
+|}
+!! result
+<table>
+<tr>
+<td> Hello
+</td>
+<td> there
+</td></tr>
+
+</table>
+
+!! 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&amp;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&amp;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="{&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;
+<table>foo
+<tr>
+<td>bar</td></tr></table>&quot;}},&quot;i&quot;: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="{&quot;parts&quot;:[&quot;
+<table>&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;foo
+<tr>
+<td>bar</td></tr>&quot;}},&quot;i&quot;:0}},&quot;</table>&quot;]}">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="{&quot;parts&quot;:[&quot;
+<table>
+<div>&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;foo&quot;}},&quot;i&quot;:0}},&quot;</div>
+<tr>
+<td>bar</td></tr></table>&quot;]}">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="{&quot;parts&quot;:[&quot;
+<table>
+<div>
+<p>&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;foo</p></div>
+<tr>
+<td>&quot;}},&quot;i&quot;:0}},&quot;bar</td></tr></table>&quot;]}">
+<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="{&quot;parts&quot;:[&quot;
+<table>
+<div>
+<p>&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;foo</p></div>
+<tr>
+<td>&quot;}},&quot;i&quot;:0}},&quot;bar</td></tr></table>&quot;]}">
+<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="{&quot;parts&quot;:[&quot;
+<table>
+<tr>
+<td>
+<div>
+<p>&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;foo</p></div></td>foo&quot;}},&quot;i&quot;:0}},&quot;</tr></table>&quot;]}">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="{&quot;parts&quot;:[&quot;
+<table>
+<tr>
+<td>
+<div>
+<p>&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;foo</p></div></td>foo</tr></table>&quot;}},&quot;i&quot;: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="{&quot;parts&quot;:[&quot;
+<table>&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;
+<p>foo</p>&quot;}},&quot;i&quot;:0}},&quot;
+<td>bar</td></table>&quot;]}">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="{&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;a\n&quot;}},&quot;i&quot;:0}}]}">a</p><span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;{|&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;style&quot;:{&quot;wt&quot;:&quot;'color:red'&quot;}},&quot;i&quot;:0}},&quot;\n|-\n|b\n|}&quot;]}">{{{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":"&#39;&#39;B&#39;&#39;"}},"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":"&#39;&#39;&#39;&#39;&#39;B&#39;&#39;&#39;&#39;&#39;"}},"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
diff --git a/tests/parser/parserTestsParserHook.php b/tests/parser/parserTestsParserHook.php
index 24d852c5..c8b3e897 100644
--- a/tests/parser/parserTestsParserHook.php
+++ b/tests/parser/parserTestsParserHook.php
@@ -34,23 +34,19 @@ class ParserTestParserHook {
}
static function dumpHook( $in, $argv ) {
- ob_start();
- var_dump(
- $in,
- $argv
- );
- $ret = ob_get_clean();
-
- return "<pre>\n$ret</pre>";
+ return "<pre>\n" .
+ var_export( $in, true ) . "\n" .
+ var_export( $argv, true ) . "\n" .
+ "</pre>";
}
static function staticTagHook( $in, $argv, $parser ) {
- if ( ! count( $argv ) ) {
+ if ( !count( $argv ) ) {
$parser->static_tag_buf = $in;
return '';
} elseif ( count( $argv ) === 1 && isset( $argv['action'] )
- && $argv['action'] === 'flush' && $in === null )
- {
+ && $argv['action'] === 'flush' && $in === null
+ ) {
// Clear the buffer, we probably don't need to
if ( isset( $parser->static_tag_buf ) ) {
$tmp = $parser->static_tag_buf;
@@ -59,12 +55,12 @@ class ParserTestParserHook {
}
$parser->static_tag_buf = null;
return $tmp;
- } else
- // wtf?
+ } else { // wtf?
return
"\nCall this extension as <statictag>string</statictag> or as" .
" <statictag action=flush/>, not in any other way.\n" .
"text: " . var_export( $in, true ) . "\n" .
"argv: " . var_export( $argv, true ) . "\n";
+ }
}
}
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
&lt;/td&gt;&lt;td&gt;
<template lineStart="1"><title>int:Difference</title></template>
&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
-[http://tl.wiktionary.org/w/wiki.phtml?title=MediaWiki:Disambiguations&amp;action=edit disambiguations]&lt;br&gt;
-[[MediaWiki_talk:Disambiguations|Talk]]
-&lt;/td&gt;&lt;td&gt;
-Disambiguation pages
-&lt;/td&gt;&lt;td&gt;
-<template lineStart="1"><title>int:Disambiguations</title></template>
-&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
-[http://tl.wiktionary.org/w/wiki.phtml?title=MediaWiki:Disambiguationspage&amp;action=edit disambiguationspage]&lt;br&gt;
-[[MediaWiki_talk:Disambiguationspage|Talk]]
-&lt;/td&gt;&lt;td&gt;
-Wiktionary:Links_to_disambiguating_pages
-&lt;/td&gt;&lt;td&gt;
-<template lineStart="1"><title>int:Disambiguationspage</title></template>
-&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
-[http://tl.wiktionary.org/w/wiki.phtml?title=MediaWiki:Disambiguationstext&amp;action=edit disambiguationstext]&lt;br&gt;
-[[MediaWiki_talk:Disambiguationstext|Talk]]
-&lt;/td&gt;&lt;td&gt;
-The following pages link to a &amp;lt;i&amp;gt;disambiguation page&amp;lt;/i&amp;gt;. They should link to the appropriate topic instead.&amp;lt;br /&amp;gt;A page is treated as dismbiguation if it is linked from $1.&amp;lt;br /&amp;gt;Links from other namespaces are &amp;lt;i&amp;gt;not&amp;lt;/i&amp;gt; listed here.
-&lt;/td&gt;&lt;td&gt;
-<template lineStart="1"><title>int:Disambiguationstext</title></template>
-&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;
[http://tl.wiktionary.org/w/wiki.phtml?title=MediaWiki:Disclaimerpage&amp;action=edit disclaimerpage]&lt;br&gt;
[[MediaWiki_talk:Disclaimerpage|Talk]]
&lt;/td&gt;&lt;td&gt;
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 &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>
-{{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>
diff --git a/tests/parser/preprocess/NestedTemplates.expected b/tests/parser/preprocess/NestedTemplates.expected
new file mode 100644
index 00000000..645626df
--- /dev/null
+++ b/tests/parser/preprocess/NestedTemplates.expected
@@ -0,0 +1,90 @@
+<root><template><title>vorlage</title></template>
+
+<tplarg lineStart="1"><title>argument</title></tplarg>
+
+Nach [[:meta:Help:Expansion#XML parse tree]]
+{<tplarg><title>vorlagenname</title></tplarg>}
+<template lineStart="1"><title> <template><title>vorlagenname</title></template></title></template>
+<template lineStart="1"><title><template><title>vorlagenname</title></template> </title></template>
+<template lineStart="1"><title><template><title>vorlagenname</title></template>erweiterung</title></template>
+
+<template lineStart="1"><title><tplarg><title>vorlagenname</title></tplarg></title></template>
+<tplarg lineStart="1"><title> <template><title>vorlagenname</title></template></title></tplarg>
+<template lineStart="1"><title> <tplarg><title>vorlagenname</title></tplarg></title></template>
+<tplarg lineStart="1"><title><template><title>vorlagenname</title></template> </title></tplarg>
+<template lineStart="1"><title><tplarg><title>vorlagenname</title></tplarg> </title></template>
+
+nur etwas erweitert
+<tplarg lineStart="1"><title><tplarg><title>vorlagenname</title></tplarg></title></tplarg>
+<tplarg lineStart="1"><title> <tplarg><title>vorlagenname</title></tplarg></title></tplarg>
+<tplarg lineStart="1"><title><tplarg><title>vorlagenname</title></tplarg> </title></tplarg>
+<template lineStart="1"><title> {<tplarg><title>vorlagenname</title></tplarg></title></template>}
+{<tplarg><title> <template><title>vorlagenname</title></template></title></tplarg>}
+<template lineStart="1"><title> <template><title> <template><title>vorlagenname</title></template></title></template></title></template>
+{<tplarg><title> <template><title>vorlagenname</title></template>} </title></tplarg>
+{<template><title><tplarg><title>vorlagenname</title></tplarg>} </title></template>
+{<tplarg><title><template><title>vorlagenname</title></template> </title></tplarg>}
+<template lineStart="1"><title> <template><title><template><title>vorlagenname</title></template> </title></template></title></template>
+<tplarg lineStart="1"><title> {<template><title>vorlagenname</title></template> </title></tplarg>}
+
+{<tplarg><title><tplarg><title> </title></tplarg></title></tplarg>}
+
+<template lineStart="1"><title><tplarg><title><tplarg><title> </title></tplarg></title></tplarg></title></template>
+<tplarg lineStart="1"><title><tplarg><title><template><title> </title></template> </title></tplarg></title></tplarg>
+<template lineStart="1"><title><tplarg><title><tplarg><title> </title></tplarg> </title></tplarg></title></template>
+{{<tplarg><title><tplarg><title> </title></tplarg>} </title></tplarg>}
+<tplarg lineStart="1"><title><template><title><tplarg><title> </title></tplarg></title></template> </title></tplarg>
+<template lineStart="1"><title><tplarg><title><tplarg><title> </title></tplarg></title></tplarg> </title></template>
+{<tplarg><title><template><title><template><title> </title></template> </title></template> </title></tplarg>}
+{<template><title><tplarg><title><template><title> </title></template> </title></tplarg>} </title></template>
+{<template><title><template><title><tplarg><title> </title></tplarg>} </title></template> </title></template>
+<template lineStart="1"><title><tplarg><title><tplarg><title> </title></tplarg> </title></tplarg> </title></template>
+<tplarg lineStart="1"><title><template><title><tplarg><title> </title></tplarg> </title></template> </title></tplarg>
+<tplarg lineStart="1"><title><tplarg><title><template><title> </title></template> </title></tplarg> </title></tplarg>
+<template lineStart="1"><title><template><title><template><title><template><title> </title></template> </title></template> </title></template> </title></template>
+
+<template lineStart="1"><title>vorlage</title></template>
+
+<tplarg lineStart="1"><title>argument</title></tplarg>
+
+Nach [[:meta:Help:Expansion#XML parse tree]]
+{<tplarg><title>vorlagenname</title></tplarg>}
+<template lineStart="1"><title> <template><title>vorlagenname</title></template></title></template>
+<template lineStart="1"><title><template><title>vorlagenname</title></template> </title></template>
+<template lineStart="1"><title><template><title>vorlagenname</title></template>erweiterung</title></template>
+
+<template lineStart="1"><title><tplarg><title>vorlagenname</title></tplarg></title></template>
+<tplarg lineStart="1"><title> <template><title>vorlagenname</title></template></title></tplarg>
+<template lineStart="1"><title> <tplarg><title>vorlagenname</title></tplarg></title></template>
+<tplarg lineStart="1"><title><template><title>vorlagenname</title></template> </title></tplarg>
+<template lineStart="1"><title><tplarg><title>vorlagenname</title></tplarg> </title></template>
+
+nur etwas erweitert
+<tplarg lineStart="1"><title><tplarg><title>vorlagenname</title></tplarg></title></tplarg>
+<tplarg lineStart="1"><title> <tplarg><title>vorlagenname</title></tplarg></title></tplarg>
+<tplarg lineStart="1"><title><tplarg><title>vorlagenname</title></tplarg> </title></tplarg>
+<template lineStart="1"><title> {<tplarg><title>vorlagenname</title></tplarg></title></template>}
+{<tplarg><title> <template><title>vorlagenname</title></template></title></tplarg>}
+<template lineStart="1"><title> <template><title> <template><title>vorlagenname</title></template></title></template></title></template>
+{<tplarg><title> <template><title>vorlagenname</title></template>} </title></tplarg>
+{<template><title><tplarg><title>vorlagenname</title></tplarg>} </title></template>
+{<tplarg><title><template><title>vorlagenname</title></template> </title></tplarg>}
+<template lineStart="1"><title> <template><title><template><title>vorlagenname</title></template> </title></template></title></template>
+<tplarg lineStart="1"><title> {<template><title>vorlagenname</title></template> </title></tplarg>}
+
+{<tplarg><title><tplarg><title> </title></tplarg></title></tplarg>}
+
+<template lineStart="1"><title><tplarg><title><tplarg><title> </title></tplarg></title></tplarg></title></template>
+<tplarg lineStart="1"><title><tplarg><title><template><title> </title></template> </title></tplarg></title></tplarg>
+<template lineStart="1"><title><tplarg><title><tplarg><title> </title></tplarg> </title></tplarg></title></template>
+{{<tplarg><title><tplarg><title> </title></tplarg>} </title></tplarg>}
+<tplarg lineStart="1"><title><template><title><tplarg><title> </title></tplarg></title></template> </title></tplarg>
+<template lineStart="1"><title><tplarg><title><tplarg><title> </title></tplarg></title></tplarg> </title></template>
+{<tplarg><title><template><title><template><title> </title></template> </title></template> </title></tplarg>}
+{<template><title><tplarg><title><template><title> </title></template> </title></tplarg>} </title></template>
+{<template><title><template><title><tplarg><title> </title></tplarg>} </title></template> </title></template>
+<template lineStart="1"><title><tplarg><title><tplarg><title> </title></tplarg> </title></tplarg> </title></template>
+<tplarg lineStart="1"><title><template><title><tplarg><title> </title></tplarg> </title></template> </title></tplarg>
+<tplarg lineStart="1"><title><tplarg><title><template><title> </title></template> </title></tplarg> </title></tplarg>
+<template lineStart="1"><title><template><title><template><title><template><title> </title></template> </title></template> </title></template> </title></template>
+</root> \ No newline at end of file
diff --git a/tests/parser/preprocess/NestedTemplates.txt b/tests/parser/preprocess/NestedTemplates.txt
new file mode 100644
index 00000000..aa9a472d
--- /dev/null
+++ b/tests/parser/preprocess/NestedTemplates.txt
@@ -0,0 +1,89 @@
+{{vorlage}}
+
+{{{argument}}}
+
+Nach [[:meta:Help:Expansion#XML parse tree]]
+{{{{vorlagenname}}}}
+{{ {{vorlagenname}}}}
+{{{{vorlagenname}} }}
+{{{{vorlagenname}}erweiterung}}
+
+{{{{{vorlagenname}}}}}
+{{{ {{vorlagenname}}}}}
+{{ {{{vorlagenname}}}}}
+{{{{{vorlagenname}} }}}
+{{{{{vorlagenname}}} }}
+
+nur etwas erweitert
+{{{{{{vorlagenname}}}}}}
+{{{ {{{vorlagenname}}}}}}
+{{{{{{vorlagenname}}} }}}
+{{ {{{{vorlagenname}}}}}}
+{{{{ {{vorlagenname}}}}}}
+{{ {{ {{vorlagenname}}}}}}
+{{{{ {{vorlagenname}}} }}}
+{{{{{{vorlagenname}}}} }}
+{{{{{{vorlagenname}} }}}}
+{{ {{{{vorlagenname}} }}}}
+{{{ {{{vorlagenname}} }}}}
+
+{{{{{{{ }}}}}}}
+
+{{{{{{{{ }}}}}}}}
+{{{{{{{{ }} }}}}}}
+{{{{{{{{ }}} }}}}}
+{{{{{{{{ }}}} }}}}
+{{{{{{{{ }}}}} }}}
+{{{{{{{{ }}}}}} }}
+{{{{{{{{ }} }} }}}}
+{{{{{{{{ }} }}}} }}
+{{{{{{{{ }}}} }} }}
+{{{{{{{{ }}} }}} }}
+{{{{{{{{ }}} }} }}}
+{{{{{{{{ }} }}} }}}
+{{{{{{{{ }} }} }} }}
+
+{{vorlage}}
+
+{{{argument}}}
+
+Nach [[:meta:Help:Expansion#XML parse tree]]
+{{{{vorlagenname}}}}
+{{ {{vorlagenname}}}}
+{{{{vorlagenname}} }}
+{{{{vorlagenname}}erweiterung}}
+
+{{{{{vorlagenname}}}}}
+{{{ {{vorlagenname}}}}}
+{{ {{{vorlagenname}}}}}
+{{{{{vorlagenname}} }}}
+{{{{{vorlagenname}}} }}
+
+nur etwas erweitert
+{{{{{{vorlagenname}}}}}}
+{{{ {{{vorlagenname}}}}}}
+{{{{{{vorlagenname}}} }}}
+{{ {{{{vorlagenname}}}}}}
+{{{{ {{vorlagenname}}}}}}
+{{ {{ {{vorlagenname}}}}}}
+{{{{ {{vorlagenname}}} }}}
+{{{{{{vorlagenname}}}} }}
+{{{{{{vorlagenname}} }}}}
+{{ {{{{vorlagenname}} }}}}
+{{{ {{{vorlagenname}} }}}}
+
+{{{{{{{ }}}}}}}
+
+{{{{{{{{ }}}}}}}}
+{{{{{{{{ }} }}}}}}
+{{{{{{{{ }}} }}}}}
+{{{{{{{{ }}}} }}}}
+{{{{{{{{ }}}}} }}}
+{{{{{{{{ }}}}}} }}
+{{{{{{{{ }} }} }}}}
+{{{{{{{{ }} }}}} }}
+{{{{{{{{ }}}} }} }}
+{{{{{{{{ }}} }}} }}
+{{{{{{{{ }}} }} }}}
+{{{{{{{{ }} }}} }}}
+{{{{{{{{ }} }} }} }}