From 0e0ffe4d17b2aea1a2da1fadc46e08b07708fe79 Mon Sep 17 00:00:00 2001
From: "C. Scott Ananian"
Date: Wed, 5 Mar 2014 14:50:35 -0500
Subject: [PATCH] Sync up with Parsoid parserTests.
This now aligns with Parsoid commit 5a274b028d774784d514439f4539507e52c8e05e
Change-Id: Ie2699166ac378f758145d41d727b18f8fa6072b4
---
tests/parser/parserTests.txt | 879 +++++++++++++++++++++++++++++++----
1 file changed, 779 insertions(+), 100 deletions(-)
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index 02863c817a..bbfea6ae71 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -1657,7 +1657,7 @@ parsoid
!!input
foo
!!result
-
foo
+
foo
!!end
!!test
@@ -2156,7 +2156,7 @@ c
!!end
!!test
-3c. Indent-Pre and block tags (multi-line html)
+3b. Indent-Pre and block tags (multi-line html)
!!input
a foo
b
foo
@@ -2168,7 +2168,7 @@ c
!!end
!!test
-3b. Indent-Pre and block tags (pre-content on separate line)
+3c. Indent-Pre and block tags (pre-content on separate line)
!!input
foo
@@ -2231,6 +2231,78 @@ foo
!!end
+!!test
+4. Indent-Pre and extension tags
+!!input
+ a
+File:foobar.jpg
+
+!!result
+ a
+
+
+
+
+
+
+
+!!end
+
+!! test
+Leading pipes outside of tables
+!! options
+parsoid
+!! input
+| foo
+!! result
+
| foo
+!! end
+
+!! test
+Leading pipes outside of tables 2
+!! options
+parsoid
+!! input
+a
+| foo
+b
+!! result
+
a
+| foo
+b
+!! end
+
+!! test
+Leading pipes outside of tables 3
+!! options
+parsoid
+!! input
+a
+| class="foo bar" | baz
+b
+!! result
+
a
+| class="foo bar" | baz
+b
+!! end
+
+!!test
+Render paragraphs when indent-pre is suppressed in blocklevels
+!!input
+
+ foo
+
+ bar
+
+!! result
+
+
foo
+
bar
+
+
+
+!!end
+
!!test
4. Multiple spaces at start-of-line
!!input
@@ -4153,9 +4225,9 @@ parsoid
(http://example.com)
!! result
-
!! end
###
@@ -5174,9 +5246,18 @@ Link with HTML entity in suffix / tail
!! test
Link with 3 brackets
!! input
-[[[main page]]]
+[[[Main Page]]]
+!! result
+
[[[Main Page]]]
+
+!! end
+
+!! test
+Link with 4 brackets
+!! input
+[[[[Main Page]]]]
!! result
-
!! end
@@ -5599,6 +5680,36 @@ language=kaa
!! end
+!! test
+1. Interaction of linktrail and template encapsulation
+!! options
+parsoid
+!! input
+{{echo|[[Foo]]}}l
+!! result
+
+!! end
+
+!! test
+3. Interaction of linktrail and template encapsulation
+!! options
+parsoid
+!! input
+{{echo|Some [[Fool]]s are '''bold and foolish'''}}
+!! result
+
!! end
!! test
@@ -5771,6 +5881,15 @@ parsoid
is just fragment
!! end
+!! test
+Interwiki links: trail
+!! options
+parsoid
+!! input
+[[wikipedia:Foo|Ba]]r
+!! result
+
!! end
+!! test
+Parsoid: Bug #45209, handle interwiki links pointing to the current wiki as plain wiki links
+!! options
+parsoid
+!! input
+[[en:Foo]]
+!! result
+
+!! end
+
###
### Redirects, Parsoid-only
###
!! test
-Simple redirect to page
+1. Simple redirect to page
!! options
parsoid
!! input
@@ -5896,6 +6024,19 @@ parsoid
!! end
+# Only wt2html and html2html since "Main_Page" will serialize to "Main Page"
+!! test
+2. Other redirect variants
+!! options
+parsoid=wt2html,wt2wt
+!! input
+#REDIRECT [[Main_Page]]
+#REDIRECT [[[[Bar]]]]
+!! result
+
+
+!! end
+
!! test
Optional colon in #REDIRECT
!! options
@@ -6017,6 +6158,17 @@ language=is
!! end
+!! test
+New redirect
+!! options
+parsoid=html2wt
+!! input
+Foo
+#REDIRECT [[Foo]]
+!! result
+
Foo
+!! end
+
##
## XHTML tidiness
###
@@ -7513,6 +7665,39 @@ hi+world%3F%21
!! end
+!! test
+Magic Word: prioritize type info over data-parsoid
+!! options
+parsoid=html2wt
+!! input
+__FORCETOC__
+!! result
+
+!! end
+
+!! test
+Magic Word: serialize on separate line (parsoid)
+!! options
+parsoid=wt2wt,html2wt
+!! input
+foo
+__NOTOC__
+bar
+!! result
+foobar
+!! end
+
+!! test
+Magic Word: rt non-english wikis
+!! options
+parsoid=wt2wt
+language=de
+!! input
+__NOEDITSECTION__
+!! result
+
+!! end
+
###
### Magic links
###
@@ -7583,6 +7768,27 @@ Template with invalid target containing unclosed tag
!! end
+!! test
+Template with invalid target containing wikilink (php)
+!! options
+php
+!! input
+{{[[Main Page]]}}
+!! result
+
+!! end
+
!! article
Template:test
!! text
@@ -8874,8 +9080,8 @@ parsoid
foo
-bar
-
+|bar
+|}
!!end
!!test
@@ -9767,6 +9973,31 @@ parsoid
Caption page=stuff
!! end
+!! test
+Allow empty links in image captions (Bug 60753) (parsoid)
+!! options
+parsoid
+!!input
+[[File:Foobar.jpg|thumb|Caption [[Link1]]
+[[]]
+[[Link2]]
+]]
+!! result
+Caption Link1
+[[]]
+Link2
+
+!! end
+
+!! test
+Link with empty target
+!! input
+[[]]
+!! result
+
[[]]
+
+!! end
+
!! test
Image with empty attribute (php)
!! options
@@ -9789,7 +10020,37 @@ parsoid=wt2html
!! end
!! test
-Image with attributes from template (php)
+1. Block image with individual attributes from templates
+!! options
+parsoid
+!! input
+[[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
+!! result
+This is a caption
+!! end
+
+!! test
+2. Block Image with individual attributes from templates
+!! options
+parsoid
+!! input
+[[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
+!! result
+This is a caption
+!! end
+
+!! test
+3. Inline image with individual attributes from templates
+!! options
+parsoid
+!! input
+[[File:Foobar.jpg|{{echo|50px}}]]
+!! result
+
+!! end
+
+!! test
+Image with multiple attributes from the same template (php)
!! options
php
!! input
@@ -9799,14 +10060,16 @@ php
!! end
+## Parsoid does not provide editing support for images where templates produce multiple image attributes.
+## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
!! test
-Image with attributes from template (parsoid)
+Image with multiple attributes from the same template (parsoid)
!! options
parsoid
!! input
[[File:Foobar.jpg|{{image_attribs}}]]
!! result
-Caption text
+Caption text
!! end
!! test
@@ -9836,7 +10099,7 @@ parsoid
!! result
123456
123456
-123456
+123456
!! end
!! test
@@ -9860,6 +10123,54 @@ parsoid
Caption3 - accepted
!! end
+!! test
+Image with multiple widths -- use last (php)
+!! options
+php
+!! input
+[[File:Foobar.jpg|200px|300px|caption]]
+!! result
+
+
+!! end
+
+!! test
+Image with multiple widths -- use last (parsoid)
+!! options
+parsoid
+!! input
+[[File:Foobar.jpg|200px|300px|caption]]
+!! result
+
+!! end
+
+!! test
+Image with multiple alignments -- use first (bug 48664) (php)
+!! options
+php
+!! input
+[[File:Foobar.jpg|thumb|left|right|center|caption]]
+
+[[File:Foobar.jpg|middle|text-top|caption]]
+!! result
+
caption
+
+
+!! end
+
+!! test
+Image with multiple alignments -- use first (bug 48664) (parsoid)
+!! options
+parsoid
+!! input
+[[File:Foobar.jpg|thumb|left|right|center|caption]]
+
+[[File:Foobar.jpg|middle|text-top|caption]]
+!! result
+caption
+
+!! end
+
!! test
Image with width attribute at different positions (php)
!! options
@@ -9880,15 +10191,40 @@ 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]]
+[[File:Foobar.jpg|200x200px|right|Caption]]
+[[File:Foobar.jpg|right|200x200px|Caption]]
+[[File:Foobar.jpg|right|Caption|200x200px]]
!! result
CaptionCaptionCaption
!! end
+# a sad bit of backward-compatibility
+!! test
+Image with size specified with pxpx (bug 13500, 51628) (php)
+!! options
+php
+!! input
+[[File:Foobar.jpg|20pxpx]]
+[[File:Foobar.jpg|200x20pxpx]]
+!! result
+
+
+
+!! end
+
+!! test
+Image with size specified with pxpx (bug 13500, 51628) (parsoid)
+!! options
+parsoid=wt2html,wt2wt
+!! input
+[[File:Foobar.jpg|20pxpx]]
+[[File:Foobar.jpg|200x20pxpx]]
+!! result
+
+!! end
+
!! test
Image with link parameter, wiki target (php)
!! options
@@ -10360,6 +10696,45 @@ Parsoid: Image caption containing leading space
!!end
+!! test
+Image caption containing a table (php)
+!! options
+php
+!! input
+[[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
+{|
+! Foo !! Bar
+|-
+| Foo1 || Bar1
+|}
+and some more text.]]
+!! result
+
This is an example image thumbnail caption with a table
Foo
Bar
Foo1
Bar1
and some more text.
+
+!!end
+
+!! test
+Image caption containing a table (parsoid)
+!! options
+parsoid
+!! input
+[[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
+{|
+! Foo !! Bar
+|-
+| Foo1 || Bar1
+|}
+and some more text.]]
+!! result
+
This is an example image thumbnail caption with a table
+
+
+
Foo
Bar
+
+
Foo1
+
Bar1
and some more text.
+!! end
+
!! test
Bug 3090: External links other than http: in image captions
!! input
@@ -10447,10 +10822,9 @@ Parsoid-specific image handling - simple image with size and middle alignment
!! options
parsoid
!! input
-[[Image:Foobar.jpg|50px|middle]]
+[[File:Foobar.jpg|middle|50px]]
!! result
-
-
+
@@ -10459,30 +10833,41 @@ parsoid
!! end
!! test
-Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
+Parsoid-specific image handling - simple image with size, middle alignment,
+non-standard namespace alias
!! options
-parsoid
+parsoid=wt2wt,wt2html,html2html
!! input
-[[Image:Foobar.jpg|500x10px|baseline|caption]]
+[[Image:Foobar.jpg|middle|50px]]
!! result
-
!! end
!! test
-Parsoid-specific image handling - simple image with border and size spec
+Parsoid-specific image handling - simple image with size and middle alignment
+(existing content)
!! options
parsoid
!! input
-[[Image:Foobar.jpg|50px|border|caption]]
+[[File:Foobar.jpg|50px|middle]]
!! result
-
-
+
+!! end
+
+!! test
+Parsoid-specific image handling - simple image with size and middle alignment
+and non-standard namespace name
+!! options
+parsoid=wt2html,wt2wt,html2html
+!! input
+[[Image:Foobar.jpg|50px|middle]]
+!! result
+
@@ -10490,27 +10875,58 @@ parsoid
!! end
+!! test
+Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
+!! options
+parsoid
+!! input
+[[File:Foobar.jpg|500x10px|baseline|caption]]
+!! result
+
+!! end
+
+!! test
+Parsoid-specific image handling - simple image with border and size spec
+!! options
+parsoid
+!! input
+[[File:Foobar.jpg|50px|border|caption]]
+!! result
+
+!! end
+
!! test
Parsoid-specific image handling - thumbnail with halign, valign, and caption
!! options
parsoid
!! input
-[[Image:Foobar.jpg|thumb|left|baseline|caption content]]
+[[File:Foobar.jpg|left|baseline|thumb|caption content]]
!! result
-
+caption content
!! end
+!! test
+Parsoid-specific image handling - thumbnail with halign, valign, and caption
+(existing content)
+!! options
+parsoid
+!! input
+[[File:Foobar.jpg|thumb|left|baseline|caption content]]
+!! result
+caption content
+!! 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]]
+[[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
!! result
@@ -10520,12 +10936,23 @@ parsoid
!! end
+!! test
+Parsoid-specific image handling - thumbnail with specific size, halign,
+valign, and caption (existing content)
+!! options
+parsoid
+!! input
+[[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
+!! result
+caption
+!! end
+
!! test
Parsoid-specific image handling - framed image with specific size and caption
!! options
parsoid
!! input
-[[Image:Foobar.jpg|500x50px|frame|caption]]
+[[Image:Foobar.jpg|frame|500x50px|caption]]
!! result
@@ -10535,12 +10962,23 @@ parsoid
!! end
+!! test
+Parsoid-specific image handling - framed image with specific size and caption
+(existing content)
+!! options
+parsoid
+!! input
+[[File:Foobar.jpg|442x50px|frame|caption]]
+!! result
+caption
+!! 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]]
+[[Image:Foobar.jpg|left|baseline|frame|500x50px|caption]]
!! result
@@ -10550,43 +10988,46 @@ parsoid
!! end
+!! test
+Parsoid-specific image handling - framed image with specific size, halign,
+valign, and caption (existing content)
+!! options
+parsoid
+!! input
+[[File:Foobar.jpg|442x50px|frame|left|baseline|caption]]
+!! result
+caption
+!! end
+
!! test
Parsoid-specific image handling - frameless image with specific size, border, and caption
!! options
parsoid
!! input
-[[Image:Foobar.jpg|frameless|500x50px|border|caption]]
+[[File:Foobar.jpg|frameless|442x50px|border|caption]]
!! result
-
+!! end
!! test
Parsoid-specific image handling - caption with a template in it
!! options
parsoid
!! input
-[[File:Foobar.jpg|thumb|200x200px|This caption has a {{echo|transclusion}} in it.]]
+[[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
!! result
This caption has a transclusion in it.
!! end
@@ -10605,6 +11046,40 @@ bar
bar
!! end
+!! test
+Parsoid-specific image handling - empty caption
+!! options
+parsoid
+!! input
+[[File:Foobar.jpg|thumb|]]
+!! result
+
+!! end
+
+!! test
+Parsoid-specific image handling - whitespace caption
+!! options
+parsoid
+!! input
+[[File:Foobar.jpg|thumb| ]]
+!! result
+
+!! end
+
+!! test
+Parsoid-specific image handling - lang option
+!! options
+parsoid
+!! input
+foo
+[[File:Foobar.svg|lang=de|caption]]
+bar
+!! result
+
foo
+
+bar
+!! end
+
###
### Subpages
@@ -14442,6 +14917,15 @@ ISBN ISBN 1234567890
!! end
+!! test
+ISBN with an X
+!! input
+ISBN 3-462-04561-X
+!! result
+
!! end
+# This test is wt2html only because we're permitting the serializer to produce
+# dirty diffs, normalizing the unclosed references to the self-closed version.
+!! test
+Generate references for unclosed references tag
+!! options
+parsoid=wt2html
+!! input
+afoo
+
+
+!! result
+
+!! end
+
+!! test
+New reference serializes on its own line
+!! options
+parsoid=wt2wt,html2wt
+!! input
+foo
+
+!! result
+foo
+!! end
+
#### ----------------------------------------------------------------
#### The following section of tests are primarily to test
#### wikitext escaping capabilities of Parsoid. Given that
@@ -18111,6 +18624,21 @@ parsoid
!! end
+!! test
+Tables: Digest broken attributes on table and tr tag
+!! options
+parsoid=wt2html
+!! input
+{| || |} ++
+|- || || ++ --
+|}
+!! result
+
+
+
+
+!! end
+
#### --------------- Links ----------------
#### 1. Quote marks in link text
#### 2. Wikilinks: Escapes needed
@@ -18133,15 +18661,17 @@ Links 2. WikiLinks: Escapes needed
!! options
parsoid
!! input
-[[Foo|[Foobar]]]
+[[Foo|[Foobar]]]
[[Foo|Foobar]]]
[[Foo|x [Foobar] x]]
-[[Foo|x [http://google.com g] x]]
+[[Foo|x [http://google.com g] x]]
[[Foo|[[Bar]]]]
[[Foo|x [[Bar]] x]]
[[Foo||Bar]]
[[Foo|]]bar]]
[[Foo|[[bar]]
+[[Foo|x [[ y]]
+[[Foo|x ]] y]]
[[Foo|x ]] y [[ z]]
!! result
[Foobar]
@@ -18153,6 +18683,8 @@ parsoid
|Bar]]bar[[bar
+x [[ y
+x ]] yx ]] y [[ z
!! end
@@ -18829,7 +19361,7 @@ plain text
!!end
!!test
-Ensure fostered text content is wrapped in spans
+1. Ensure fostered text content is wrapped in spans
!!options
parsoid=wt2html
!!input
@@ -18841,6 +19373,24 @@ parsoid=wt2html
!!end
+!!test
+2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost)
+!!options
+parsoid=wt2html,wt2wt
+!!input
+