!! Version 2
!! article
Main Page
!! text
blah blah
!! endarticle
!! article
Foo''s bar''s
!! text
Article titles can contain single quotes!
!! endarticle
!! article
Template:1x
!! text
{{{1}}}
!! endarticle
!! article
Template:image_attribs
!! text
[[File:foobar.jpg|right|Caption text]]
!! endarticle
!! article
Template:paramtest
!! text
This is a test template with parameter {{{param}}}
!! endarticle
!! article
Template:test
!! text
This is a test template
!! endarticle
###
### Images
###
### For Parsoid-specific tests, see
### https://www.mediawiki.org/wiki/Specs/HTML#Images
!! test
Simple image
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:foobar.jpg]]
!! html/php
!! html/parsoid
!! end
!! test
Serialize simple image with figure-inline wrapper
!! options
parsoid=html2wt
!! html/parsoid
!! wikitext
[[File:Foobar.jpg]]
!! end
!! test
Simple image (using File: namespace, now canonical)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg]]
!! html/php
!! html/parsoid
!! end
!! test
Right-aligned image
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|right]]
!! html/php
!! html/parsoid
!! end
!! test
Image with caption
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|right|Caption text]]
!! html/php
Caption text
!! html/parsoid
Caption text
!! end
!! test
Image with caption, T55312 #1
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|right|Caption page stuff]]
!! html/php
Caption page stuff
!! html/parsoid
Caption page stuff
!! end
!! test
Image with caption, T55312 #2
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|right|Caption page=]]
!! html/php
Caption page=
!! html/parsoid
Caption page=
!! end
!! test
Image with caption, T55312 #3
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|right|Caption page=stuff]]
!! html/php
Caption page=stuff
!! html/parsoid
Caption page=stuff
!! end
!! test
Image caption with pipe entity
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|one | two]]
[[File:Foobar.jpg|thumb|one ''two'' | three]]
!! html/php
one | twoone two | three
!! html/parsoid
one | twoone two| three
!! end
!! test
Allow empty links in image captions (T62753)
!! options
thumbsize=220
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|Caption [[Link1]]
[[]]
[[Link2]]
]]
!! html/php
Caption Link1 [[]] Link2
!! html/parsoid
Caption Link1
[[]]
Link2
!! end
!! test
Titles in unlinked images (T23454)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=|stuff]]
!! html/php
!! html/parsoid
!! end
!! test
Link with empty target
!! wikitext
[[]]
!! html
[[]]
!! end
!! test
Image with link trail
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
Linktrails should not work for images: [[File:Foobar.jpg]]s
!! html/php
Linktrails should not work for images: s
!! html/parsoid
Linktrails should not work for images: s
!! end
!! test
Image with empty attribute
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|right||Caption text]]
!! html/php
Caption text
!! html/parsoid
Caption text
!! end
!! test
1. Block image with individual attributes from templates
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|{{1x|137px}}|This is a caption]]
!! html/php
This is a caption
!! html/parsoid
This is a caption
!! end
!! test
2. Block Image with individual attributes from templates
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|{{1x|thumb}}|{{1x|137px}}|This is a caption]]
!! html/php
This is a caption
!! html/parsoid
This is a caption
!! end
!! test
3. Inline image with individual attributes from templates
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|{{1x|50px}}]]
!! html/php
!! html/parsoid
!! end
## Parsoid does not provide editing support for images where templates produce multiple image attributes.
## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
!! test
Image with multiple attributes from the same template
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|{{image_attribs}}]]
!! html/php
Caption text
!! html/parsoid
Caption text
!! end
!! test
Image with link tails
!! options
thumbsize=220
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
123[[File:Foobar.jpg]]456
123[[File:Foobar.jpg|right]]456
123[[File:Foobar.jpg|thumb]]456
!! html/php
123456
123
456
123
456
!! html/parsoid
123456
123
456
123
456
!! end
!! test
Image with multiple captions -- only last one is accepted
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
!! html/php
Caption3 - accepted
!! html/parsoid
Caption3 - accepted
!! end
!! test
Image with multiple widths -- use last
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|200px|300px|caption]]
!! html/php
!! html/parsoid
!! end
!! test
Image with multiple alignments -- use first (T50664)
!! options
thumbsize=220
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|left|right|center|caption]]
[[File:Foobar.jpg|middle|text-top|caption]]
!! html/php
caption
!! html/parsoid
caption
!! end
!! test
Image with width attribute at different positions
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|200px|right|Caption]]
[[File:Foobar.jpg|right|200px|Caption]]
[[File:Foobar.jpg|right|Caption|200px]]
!! html/php
CaptionCaptionCaption
!! html/parsoid
CaptionCaptionCaption
!! end
# a sad bit of backward-compatibility
!! test
Image with size specified with pxpx (T15500, T53628)
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|20pxpx]]
[[File:Foobar.jpg|200x20pxpx]]
!! html/php
!! html/parsoid
!! end
!! test
Image with link parameter, wiki target
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=Main Page]]
!! html/php
!! html/parsoid
!! end
# parsoid T51293 (part 1)
!! test
Image with link parameter, URL target
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=http://example.com/]]
!! html/php
!! html/parsoid
!! end
# parsoid T51293 (part 2)
!! test
Image with link parameter, protocol-less URL target
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=//example.com/]]
!! html/php
!! html/parsoid
!! end
!! test
Escaping non-block captions (T107435)
!! options
parsoid={
"modes": ["wt2wt"],
"changes": [
["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
]
}
!! wikitext
[[Image:Foobar.jpg|caption]]
!! wikitext/edited
[[Image:Foobar.jpg||]]
!! end
# wgExternalLinkTarget not supported by Parsoid
!! test
Image with link parameter, wgExternalLinkTarget
!! wikitext
[[Image:foobar.jpg|link=http://example.com/]]
!! config
wgExternalLinkTarget='foobar'
wgParserEnableLegacyMediaDOM=false
!! html/php
!! end
# wgExternalLinkTarget not supported by Parsoid
!! test
Thumb with link parameter, wgExternalLinkTarget
!! wikitext
[[Image:foobar.jpg|thumb|link=http://example.com/]]
!! config
wgExternalLinkTarget='foobar'
wgParserEnableLegacyMediaDOM=false
!! html/php
!! end
!! test
Image with link parameter, wgNoFollowLinks set to false
!! wikitext
[[Image:foobar.jpg|link=http://example.com/]]
!! config
wgNoFollowLinks=false
wgParserEnableLegacyMediaDOM=false
!! html/php
!! end
!! test
Image with link parameter, wgNoFollowDomainExceptions
!! wikitext
[[Image:foobar.jpg|link=http://example.com/]]
!! config
wgNoFollowDomainExceptions='example.com'
wgParserEnableLegacyMediaDOM=false
!! html/php
!! end
# wgExternalLinkTarget not supported by Parsoid
!! test
Image with link parameter, wgExternalLinkTarget, unnamed parameter
!! wikitext
[[Image:foobar.jpg|link=http://example.com/|Title]]
!! config
wgExternalLinkTarget='foobar'
wgParserEnableLegacyMediaDOM=false
!! html/php
!! end
!! test
Image with empty link parameter
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=]]
!! html/php
!! html/parsoid
!! end
!! test
Image with link parameter (wiki target) and unnamed parameter
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=Main_Page|Title]]
!! html/php
!! html/parsoid
!! end
!! test
Image with link parameter (URL target) and unnamed parameter
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=http://example.com/|Title]]
!! html/php
!! html/parsoid
!! end
!! test
Thumbnail image with link parameter
!! options
thumbsize=220
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
!! html/php
Title
!! html/parsoid
Title
!! end
!! test
Manually-specified thumbnail image
!! options
thumbsize=220
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
!! html/php
Title
!! html/parsoid
Title
!! end
!! test
Manually-specified thumbnail image (backwards compat)
!! options
thumbsize=220
parsoid=html2wt
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
!! html/php
Title
!! html/parsoid
Title
!! end
!! test
Manually-specified thumbnail image with explicit link to wiki page
!! options
thumbsize=220
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
!! html/php
Title
!! html/parsoid
Title
!! end
!! test
Manually-specified thumbnail image with explicit link to url
!! options
thumbsize=220
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
!! html/php
Title
!! html/parsoid
Title
!! end
!! test
Manually-specified thumbnail image with explicit no link
!! options
thumbsize=220
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
!! html/php
Title
!! html/parsoid
Title
!! end
!! test
Manually-specified thumbnail image with explicit link and alt text
!! options
thumbsize=220
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
!! html/php
Title
!! html/parsoid
Title
!! end
!! test
Image with frame and link
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
!! html/php
This is a test image Main Page
!! html/parsoid
This is a test image Main Page
!! end
!! test
Image with frame and link and explicit alt
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
!! html/php
This is a test image Main Page
!! html/parsoid
This is a test image Main Page
!! end
!! test
Image with wiki markup in implicit alt
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:Foobar.jpg|testing '''bold''' in alt]]
[[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
!! html/php
!! html/parsoid
!! end
!! test
Alt image option should handle most kinds of wikitext without barfing
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{1x|''bold template''}}.]]
!! html/php
This is the image caption
!! html/parsoid
This is the image caption
!! end
!! test
Ampersand in alt attribute (T206940)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|alt=&]]
File:Foobar.jpg|alt=&
!! html/php
!! html/parsoid
!! end
## FIXME: The inconsistency in the gallery extension on the php side is T49646
# Parsoid test is only wt2html because it inserts around the
# alt text when serializing (which is fine).
!! test
Link with encoded pipe in alt option
!! config
wgParserEnableLegacyMediaDOM=false
!! options
parsoid=wt2html
!! wikitext
[[File:Foobar.jpg|alt=http://testing.123?4=5|6|caption]]
[[File:Foobar.jpg|alt=http://testing.123?4=5|6|caption]]
File:Foobar.jpg|alt=http://testing.123?4=5|6|caption
File:Foobar.jpg|alt=http://testing.123?4=5|6|caption
!! html/php
!! html/parsoid
caption
caption
!! end
!! test
Italics markup in alt attribute (T206940)
!! options
parsoid=wt2html,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|alt=''x''|caption]]
File:Foobar.jpg|alt=''x''|caption
!! html/php
caption
!! html/parsoid
caption
!! end
## FIXME: This test can be dropped when Parsoid content versions 2.0.0 / 1.8.0
## are no longer in storage.
!! test
Nowiki markup in alt attribute (T206940)
!! options
parsoid=html2wt
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|alt=''x''|caption]]
File:Foobar.jpg|alt=''x''|caption
!! html/php
caption
!! html/parsoid
caption
!! end
!! test
Nowiki markup in alt attribute (edited html, no data-parsoid) (T206940)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|alt=''x''|caption]]
File:Foobar.jpg|alt=''x''|caption
!! html/php
caption
!! html/parsoid
caption
!! end
## FIXME: This test can be dropped when Parsoid content versions 2.0.0 / 1.8.0
## are no longer in storage.
!! test
Ampersand in link attribute (T206940)
!! options
parsoid=html2wt
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=Foo & bar]]
File:Foobar.jpg|link=Foo & bar
!! html/php
!! html/parsoid
!! end
!! test
Ampersand in link attribute (edited html, no data-parsoid) (T206940)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=Foo_&_bar]]
File:Foobar.jpg|link=Foo_&_bar
!! html/php
!! html/parsoid
!! end
!! test
Italics markup in link attribute (T206940)
!! options
parsoid=wt2html,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Foo''s bar''s]]
[[File:Foobar.jpg|link=Foo''s bar''s|caption1]]
[[File:Foobar.jpg|link=''Main Page''|caption2]]
File:Foobar.jpg|link=Foo''s bar''s|caption1
File:Foobar.jpg|link=''Main Page''|caption2
!! html/php
!! end
## FIXME: This test can be dropped when Parsoid content versions 2.0.0 / 1.8.0
## are no longer in storage.
!! test
Nowiki markup in link attribute (T206940)
!! options
parsoid=html2wt
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=Foo''s_bar''s|caption]]
File:Foobar.jpg|link=Foo''s_bar''s|caption
!! html/php
caption
!! html/parsoid
caption
!! end
!! test
Nowiki markup in link attribute (edited html, no data-parsoid) (T206940)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=Foo''s_bar''s|caption]]
File:Foobar.jpg|link=Foo''s_bar''s|caption
!! html/php
caption
!! html/parsoid
caption
!! end
!! test
HTML entity prefix in link markup (T209236)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=https://example.com?foo¶ms=bar]]
File:Foobar.jpg|link=https://example.com?foo¶ms=bar
!! html/php
!! html/parsoid
!! end
!! test
Image link markup is not generated when redundant (T108504) - encoded href
!! options
parsoid=html2wt,wt2wt
language=sr
!! wikitext
[[Датотека:Foobar.jpg]]
!! html/parsoid
!! end
!! test
Image with table with attributes in caption
!! options
parsoid=wt2html,html2html
!! wikitext
[[File:Foobar.jpg|thumb|
{| class="123" |
|- class="456" |
| ha
|}
]]
!! html/parsoid
ha
!! end
!! test
Image with table with rows from templates in caption
!! wikitext
[[File:Foobar.jpg|thumb|
{|
{{1x|{{!}} hi}}
|}
]]
!! html/parsoid
hi
!! end
!! test
Image with nested tables in caption
!! wikitext
[[File:Foobar.jpg|thumb|Foo
{|
|
{|
|z
|}
|}
]]
!! html/parsoid
Foo
z
!! end
!! test
Image with heading and horizontal rule in caption
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|
===Testing===
123
--------------
]]
!! html/php
123
!! end
###################
# Conflicting image format options.
# First option specified should 'win'.
# All three cases in each test should be identical.
!! test
Image with 'frameless' first.
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|frameless|caption]]
[[File:Foobar.jpg|frameless|frame|caption]]
[[File:Foobar.jpg|frameless|thumb|caption]]
!! html/php
!! html/parsoid
!! end
!! test
Image with 'frame' first.
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|frame|caption]]
[[File:Foobar.jpg|frame|frameless|caption]]
[[File:Foobar.jpg|frame|thumb|caption]]
!! html/php
captioncaptioncaption
!! html/parsoid
captioncaptioncaption
!! end
!! test
Image with 'thumb' first.
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|caption]]
[[File:Foobar.jpg|thumb|frameless|caption]]
[[File:Foobar.jpg|thumb|frame|caption]]
!! html/php
captioncaptioncaption
!! html/parsoid
captioncaptioncaption
!! end
###################
# Image sizing.
# See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
# and https://phabricator.wikimedia.org/T64258
# Foobar has actual size of 1941x220
# 1. Thumbs & frameless always reduce, can't be enlarged unless it's
# a scalable format.
# 2. Framed images always ignore size options; always render at default size.
# 3. "Unspecified format" and border are the only types which can be
# enlarged.
# 4. The srcset attribute doesn't occur if image is being enlarged
!! test
Image: unspecified format and border enlarge
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|2000px]]
[[File:Foobar.jpg|border|2000px]]
!! html/php
!! html/parsoid
!! end
!! test
Image: "unspecified format" and border reduce
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|1000px]]
[[File:Foobar.jpg|border|1000px]]
!! html/php
!! html/parsoid
!! end
!! test
Image: thumbs reduce
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|50px]]
!! html/php
!! html/parsoid
!! end
!! test
Image: bitmap thumbs can't be enlarged past original size, but vector can.
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|2000px]]
[[File:Foobar.svg|thumb|2000px]]
!! html/php
!! html/parsoid
!! end
!! test
Image: frameless can reduce in size
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|frameless|50px]]
!! html/php
!! html/parsoid
!! end
!! test
Image: bitmap frameless can't be enlarged past original size, but vector can
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|frameless|2000px]]
[[File:Foobar.svg|frameless|2000px]]
!! html/php
!! html/parsoid
!! end
!! test
Image: framed images are always unscaled.
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|frame]]
[[File:Foobar.jpg|frame|50px]]
[[File:Foobar.jpg|frame|50x50px]]
[[File:Foobar.jpg|frame|2000px]]
!! html/php
!! html/parsoid
!! end
!! test
Bogus sizes during html2wt
!! options
parsoid=html2wt
!! html/parsoid
!! wikitext
[[File:Foobar.jpg]]
[[File:Foobar.jpg|10x10px]]
!! end
###################
!! test
Link to image page- image page normally doesn't exist, hence edit link
Add test with existing image page
#
!! end
!! test
Frameless image caption with a free URL
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|http://example.com]]
!! html/php
!! html/parsoid
!! end
!! test
Thumbnail image caption with a free URL
!! options
thumbsize=220
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|http://example.com]]
!! html/php
http://example.com
!! html/parsoid
http://example.com
!! end
!! test
Thumbnail image caption with a free URL and explicit alt
!! options
thumbsize=220
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
!! html/php
http://example.com
!! html/parsoid
http://example.com
!! end
!! test
SVG thumbnails with no language set
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.svg|thumb|caption]]
!! html/php
caption
!! html/parsoid
caption
!! end
!! test
SVG thumbnails with language de
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.svg|lang=de|thumb|caption]]
!! html/php
caption
!! html/parsoid
caption
!! end
!! test
SVG thumbnails with invalid language code
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
!! html/php
lang=invalid:language:code
!! html/parsoid
caption
!! end
!! test
SVG thumbnails in page language
!! options
language=ru
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.svg]] [[File:Foobar.svg|lang=en]]
!! html/php
!! end
!! test
SVG thumbnails in page language not present in the file
!! options
language=de
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.svg]] [[File:Foobar.svg|lang=ru]]
!! html/php
!! end
!! test
T3887: A ISBN with a thumbnail
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|ISBN 1235467890]]
!! html/php
ISBN 1235467890
!! html/parsoid
ISBN 1235467890
!! end
!! test
T3887: A RFC with a thumbnail
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|This is RFC 12354]]
!! html/php
This is RFC 12354
!! html/parsoid
This is RFC 12354
!! end
!! test
T3887: A mailto link with a thumbnail
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
!! html/php
Please mailto:nobody@example.com
!! html/parsoid
Please mailto:nobody@example.com
!! end
# Pending resolution to T2368
!! test
T2648: Frameless image caption with a link
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|text with a [[link]] in it]]
!! html/php
!! html/parsoid
!! end
!! test
T2648: Frameless image caption with a link (suffix)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|text with a [[link]]foo in it]]
!! html/php
!! html/parsoid
!! end
!! test
T2648: Frameless image caption with an interwiki link
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
!! html/php
!! html/parsoid
!! end
!! test
T2648: Frameless image caption with a piped interwiki link
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
!! html/php
!! html/parsoid
!! end
!! test
T107474: Frameless image caption with
!! wikitext
[[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
!! html/parsoid
!! end
!! test
Escape HTML special chars in image alt text
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|& < > "]]
!! html/php
!! html/parsoid
!! end
!! test
Escape HTML special chars in image alt text with LanguageConverter
!! options
language=zh
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|& < > "]]
!! html/php
!! html/parsoid
!! end
!! test
Entities in file name and attributes
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
!! html/php
!! end
!! test
T2499: Alt text should have Ӓ, not &1234;
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|♀]]
!! html/php
!! html/parsoid
!! end
!! test
Broken image caption with link
!! options
parsoid=wt2html,wt2wt,html2html
!! wikitext
[[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
!! html/php
[[Image:Foobar.jpg|thumb|This is a broken caption. But this is just an ordinary link.
!! html/parsoid
[[Image:Foobar.jpg|thumb|This is a broken caption. But this is just an ordinary link.
!! end
!! test
Image caption containing another image
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
!! html/php
This is a caption with another inside it!
!! html/parsoid
This is a caption with another inside it!
!! end
!! test
Image: caption containing a newline
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|This
*is some text]]
!! html/php
!! html/parsoid
!!end
## The leading space should not trigger nowiki escaping in wt2wt mode
!! test
Image: caption containing leading space
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb| bar]]
!! html/php
bar
!! html/parsoid
bar
!!end
# html/php output not have newlines after table, td, th, etc. because
# Linker::makeThumbLink2() replaces the newlines with spaces since
# the table is inside a caption.
# FIXME: Verify if that circa 2004 fix is still required.
!! test
Image: caption containing a table
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
{|
!Foo!!Bar
|-
|Foo1||Bar1
|}
and some more text.]]
!! html/php
This is an example image thumbnail caption with a table
Foo
Bar
Foo1
Bar1
and some more text.
!! html/parsoid
This is an example image thumbnail caption with a table
Foo
Bar
Foo1
Bar1
and some more text.
!! end
!! test
T5090: External links other than http: in image captions
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
!! html/php
This caption has irc and Secure ext links in it.
!! html/parsoid
This caption has irc and Secure ext links in it.
!! end
!! test
Custom class
!! options
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:foobar.jpg|a|class=b]]
!! html/php
!! html/parsoid
!! end
!! test
Localized image handling (1).
!! options
parsoid=wt2html,wt2wt,html2html
language=es
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
!! html/php
caption
!! html/parsoid
caption
!! end
!! test
Localized image handling (2).
!! options
thumbsize=220
parsoid=wt2html,wt2wt,html2html
language=es
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
!! html/php
caption
!! html/parsoid
caption
!! end
!! test
Localized image handling (3).
!! options
language=fa
parsoid=html2wt
!! html/parsoid
!! wikitext
[[File:Foobar.jpg|بندانگشتی]]
!! end
!! test
"border", "frameless" and "class" attributes on an image.
!! options
thumbsize=220
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|frameless|border|class=extra|caption]]
!! html/php
!! html/parsoid
!! end
# Note that 'right' is the default alignment, despite the misspelled 'righ' below
!! test
Invalid image attributes (T64500)
!! options
thumbsize=220
parsoid=wt2html,wt2wt,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|float|left|caption]]
[[File:Foobar.jpg|thumb|righ|caption]]
[[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
!! html/php
captioncaptioncaption
!! html/parsoid
captioncaptioncaption
!! end
!! article
File:Barfoo.jpg
!! text
#REDIRECT [[File:Barfoo.jpg]]
!! endarticle
# FIXME: Parsoid should run this test -- but we'd need to teach the
# mockAPI about the redirected Barfoo.jpg image.
!! test
Redirected image
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:Barfoo.jpg]]
!! html/php
!! end
## FIXME: Parsoid needs to learn about this flag.
!! test
Missing image with uploads disabled
!! options
wgEnableUploads=0
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobaz.jpg]]
!! html/php
!! end
# Parsoid-specific testing for images
# https://www.mediawiki.org/wiki/Specs/HTML#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
!! wikitext
[[File:Foobar.jpg|middle|50px]]
!! html/parsoid
!! end
!! test
Parsoid-specific image handling - simple image with size, middle alignment, non-standard namespace alias
!! options
parsoid=wt2wt,wt2html,html2html
!! wikitext
[[Image:Foobar.jpg|middle|50px]]
!! html/parsoid
!! end
!! test
Parsoid-specific image handling - simple image with size and middle alignment (existing content)
!! wikitext
[[File:Foobar.jpg|50px|middle]]
!! html/parsoid
!! end
!! test
Parsoid-specific image handling - simple image with size and middle alignment and non-standard namespace name
!! options
parsoid=wt2html,wt2wt,html2html
!! wikitext
[[Image:Foobar.jpg|50px|middle]]
!! html/parsoid
!! end
!! test
Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
!! wikitext
[[File:Foobar.jpg|500x10px|baseline|caption]]
!! html/parsoid
!! end
!! test
Parsoid-specific image handling - simple image with border and size spec
!! wikitext
[[File:Foobar.jpg|50px|border|caption]]
!! html/parsoid
!! end
!! test
Parsoid-specific image handling - thumbnail with halign, valign, and caption
!! options
parsoid=wt2html,html2html
!! wikitext
[[File:Foobar.jpg|left|baseline|thumb|caption content]]
!! html/parsoid
caption content
!! end
!! test
Parsoid-specific image handling - thumbnail with halign, valign, and caption (existing content)
!! options
parsoid=wt2html,html2html
!! wikitext
[[File:Foobar.jpg|thumb|left|baseline|caption content]]
!! html/parsoid
caption content
!! end
!! test
Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
!! options
parsoid=wt2html,html2html
!! wikitext
[[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
!! html/parsoid
caption
!! end
!! test
Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption (existing content)
!! options
parsoid=wt2html,html2html
!! wikitext
[[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
!! html/parsoid
caption
!! end
!! test
Parsoid-specific image handling - framed image with specific size and caption (size is ignored)
!! options
parsoid=wt2html,wt2wt,html2html
!! wikitext
[[File:Foobar.jpg|frame|500x50px|caption]]
!! html/parsoid
caption
!! end
!! test
Parsoid-specific image handling - framed image with specific size, halign, valign, and caption (size is ignored)
!! options
parsoid=wt2html,html2html
!! wikitext
[[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
!! html/parsoid
caption
!! end
!! test
Parsoid-specific image handling - frameless image with specific size, border, and caption
!! wikitext
[[File:Foobar.jpg|frameless|442x50px|border|caption]]
!! html/parsoid
!! end
!! test
Parsoid-specific image handling - simple image with a formatted caption
!! wikitext
[[File:Foobar.jpg|
a
b
c
]]
!! html/parsoid
!! end
!! test
Parsoid-specific image handling - caption with a template in it
!! wikitext
[[File:Foobar.jpg|thumb|200x23px|This caption has a {{1x|transclusion}} in it.]]
!! html/parsoid
This caption has a transclusion in it.
!! end
!! test
Parsoid-specific image handling - caption with unbalanced tags in it
!! options
parsoid=wt2html,wt2wt,html2html
!! wikitext
foo
[[File:Foobar.jpg|thumb|200x200px|This caption has a
unbalanced tag in it.]]
bar
!! html/parsoid
foo
This caption has a
unbalanced tag in it.
bar
!! end
!! test
Parsoid-specific image handling - empty caption (1)
!! options
parsoid=wt2html,wt2wt
!! wikitext
[[File:Foobar.jpg|thumb|]]
!! html/parsoid
!! end
# empty captions don't get serialized unless we're in the "round trip" case
!! test
Parsoid-specific image handling - empty caption (2)
!! options
parsoid=html2wt
!! html/parsoid
!! wikitext
[[File:Foobar.jpg|thumb]]
!! end
!! test
Parsoid-specific image handling - whitespace caption
!! wikitext
[[File:Foobar.jpg|thumb| ]]
!! html/parsoid
!! end
!! test
Parsoid-specific image handling - lang option
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
foo
[[File:Foobar.svg|lang=de|caption]]
bar
!! html/php
foo
bar
!! html/parsoid
foo
bar
!! end
!! test
File containing double quotes and spaces
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Cool "Gator".png]]
!! html/php
!! end
!! test
Media in wikilink
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Test|[[File:Foobar.jpg]]]]
!! html/php
[[Test|]]
!! html/parsoid
[[Test|]]
!! end
!! test
Template with thumb image (with link in description)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
{{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
!! html/php
File:Noimage.pnglinkcaption
!! end
!! test
T3219 URL next to image (good)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
http://example.com [[File:Foobar.jpg]]
!! html/php
!! end
## Parsoid thinks the "centre" here is a property, not a caption.
!! test
Gallery
!! options
parsoid={
"modes": ["wt2html"]
}
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
image1.png |
image2.gif|||||
image3|
image4 |300px| centre
image5.svg| http://///////
[[x|xx]]]]
* image6
!! html/php
!! end
## FIXME: This test can be dropped when Parsoid content versions 2.0.0 / 1.8.0
## are no longer in storage.
!! test
Gallery (with options, extsrc)
!! options
parsoid=html2wt
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Nonexistent.jpg|caption
File:Nonexistent.jpg
image:foobar.jpg|some '''caption''' [[Main Page]]
image:foobar.jpg
image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
!! html/php
!! end
!! test
Gallery (without px units)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg
!! html/php
!! html/parsoid
!! end
!! test
Gallery (with invalid units)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg
!! html/php
!! html/parsoid
!! end
!! test
Gallery with link that has fragment
!! options
parsoid={
"modes": ["wt2html", "html2html"]
}
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
image:foobar.jpg|link=Main_Page
image:foobar.jpg|link=Main_Page#section
image:foobar.jpg|link=Main Page#section|caption
!! html/php
caption
!! html/parsoid
caption
!! end
!! test
Gallery with template inside caption
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg|{{1x|ho}}
!! html/php
hi
ho
!! html/parsoid
hi
ho
!! end
!! test
Gallery with wikitext inside gallery caption
!! options
parsoid={
"modes": ["wt2html", "html2html"]
}
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg|Image caption
!! html/php
# This should not be a list item Text boldlink Special File in gallery caption
Image caption
!! html/parsoid
# This should not be a list item Text boldlink-1File in gallery caption
Image caption
!! end
!! test
Gallery with wikitext inside caption
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
!! html/php
This is a test template
!! html/parsoid
This is a test template
!! end
!! test
Gallery with wikitext incl bogus HTML tag (T237318)
!! options
parsoid=wt2html,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg|
!! html/php
!! end
!! test
Gallery override link with wikilink (T36852)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg|alt=galleryalt|link=Wikilink
!! html/php
!! html/parsoid
!! end
!! test
Gallery override link with absolute external link (T36852)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
!! html/php
!! html/parsoid
!! end
## Putting the caption at the end here runs into T49646 on the php side
## so reducing the modes this runs in Parsoid
!! test
Gallery override link with absolute external link with LanguageConverter
!! options
language=zh
parsoid=wt2html,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
!! html/php
caption
!! html/parsoid
caption
!! end
!! test
Gallery override link with malicious javascript (T36852)
!! options
parsoid={
"modes": ["wt2html", "html2html"]
}
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
!! html/php
!! html/parsoid
!! end
!! test
Gallery with invalid title as link (T45964)
!! options
parsoid={
"modes": ["wt2html", "html2html"]
}
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg|link=<
!! html/php
!! html/parsoid
!! end
!! test
Serialize gallery without attrs in data-mw
!! options
parsoid={
"modes": ["html2wt"]
}
!! html/parsoid
!! wikitext
File:Test.png
!! end
!! test
Gallery with class and style attributes
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg
!! html/php
!! html/parsoid
!! end
!! test
Gallery in nolines mode
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg|foo
!! html/php
No Lines!
foo
!! html/parsoid
No Lines!
foo
!! end
!! test
Gallery in slideshow mode
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg
!! html/php
!! html/parsoid
!! end
!! test
Gallery in packed mode
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg
!! html/php
!! html/parsoid
!! end
!! test
Gallery in packed-overlay mode
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg|foo
!! html/php
Packed Overlay!
foo
!! html/parsoid
Packed Overlay!
foo
!! end
!! test
Gallery in packed-hover mode
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg|foo
!! html/php
Packed Hover!
foo
!! html/parsoid
Packed Hover!
foo
!! end
!! test
Serialize gallery image captions on a line
!! options
parsoid={
"modes": ["html2wt"]
}
!! html/parsoid
hi
ho
hi ho
!! wikitext
File:Foobar.jpg| hi ho
File:Foobar.jpg|hi ho
!! end
!! test
Centre-aligned image
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:foobar.jpg|centre]]
!! html/php
!! html/parsoid
!! end
!! test
None-aligned image
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:foobar.jpg|none]]
!! html/php
!! html/parsoid
!! end
!! test
Width + Height sized image (using px) (height is ignored)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:foobar.jpg|640x480px]]
!! html/php
!! html/parsoid
!! end
!! test
Width-sized image (using px, no following whitespace)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:foobar.jpg|640px]]
!! html/php
!! html/parsoid
!! end
!! test
Width-sized image (using px, with following whitespace - test regression from r39467)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:foobar.jpg|640px ]]
!! html/php
!! html/parsoid
!! end
!! test
Width-sized image (using px, with preceding whitespace - test regression from r39467)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Image:foobar.jpg| 640px]]
!! html/php
!! html/parsoid
!! end
!! test
Image with page parameter
!! options
djvu
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:LoremIpsum.djvu]]
[[File:LoremIpsum.djvu|page=2]]
!! html/php
!! html/parsoid
!! end
!! test
Image with page parameter and manualthumb
!! options
djvu
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:LoremIpsum.djvu|page=2|thumbnail=Thumb.png]]
!! html/php
!! html/parsoid
!! end
!! test
Image with page parameter generated by a template
!! options
djvu
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:LoremIpsum.djvu|page={{1x|2}}]]
!! html/php
!! html/parsoid
!! end
!! test
Image with modified page parameter; serialize href query not data-mw
!! options
djvu
parsoid={
"modes": ["wt2wt", "selser"],
"changes": [
["a[href]", "attr", "href", "./File:LoremIpsum.djvu?page=3"]
]
}
!! wikitext
[[File:LoremIpsum.djvu|page 2]]
[[File:LoremIpsum.djvu|page {{1x|2}}]]
!! wikitext/edited
[[File:LoremIpsum.djvu|page 3]]
[[File:LoremIpsum.djvu|page 3]]
!! end
# This tests for RESTBase content backward-compatibility;
# the output should change when T259931 has been resolved (the page
# parameter should be removed in the wikitext/edited section)
!! test
Image with modified page parameter; serialize href query not data-mw (2)
!! options
djvu
parsoid={
"modes": ["wt2wt", "selser"],
"changes": [
["a[href]", "attr", "href", "./File:LoremIpsum.djvu"]
]
}
!! wikitext
[[File:LoremIpsum.djvu|page 2]]
[[File:LoremIpsum.djvu|page {{1x|2}}]]
!! wikitext/edited
[[File:LoremIpsum.djvu|page 2]]
[[File:LoremIpsum.djvu|page {{1x|2}}]]
!! end
# Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "" tag.
!! test
Images with the "|" character in the comment
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|An [http://test/?param1=|left|¶m2=|x external] URL]]
!! html/php
An external URL
!! html/parsoid
An external URL
!! end
!! test
T146305: Don't break image parsing if language converter markup is in the caption.
!! options
language=sr
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
!! html/php
caption:
!! html/parsoid
!! end
!! test
T146305: Don't break image parsing if nested language converter markup is in the caption.
!! options
language=zh variant=zh-cn
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
!! html/php
blog (hk: WEBJOURNAL, tw: WEBLOG)
!! html/parsoid
!! end
# XXX html2wt disabled because rich markup in alt is not preserved.
!! test
Don't break gallery if language converter markup is inside.
!! options
language=zh
parsoid=wt2html,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
File:Foobar.jpg|alt=-{R|bat}-|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]
File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=-{R|param}-}}
!! html/php
This is a test template
!! html/parsoid
This is a test template
!! end
!! test
Free external link invading image caption
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|http://x|hello]]
!! html/php
hello
!! html/parsoid
hello
!! end
!! test
Special characters in embedded file links (T29679)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Contains & ampersand.jpg]]
[[File:Does not exist.jpg|Title with & ampersand]]
!! html/php
!! end
# T65642/T68749: Formatting elt fixup around images.
# We know wt2wt will fail, but we expect selser to pass.
# Due to the nature of our testing, wt2wt and selser tests will enter the
# banned list and we'll catch selser regressions based on changes to the
# banned list entries for selser tests.
!! test
1. Treebuilder fixup of formatting elt
!! options
parsoid=wt2html,wt2wt
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
{|
|
[[Image:Foobar.jpg|right|Test]]
|}
!! html/php
Test
!! html/parsoid
Test
!! end
!! test
2. Treebuilder fixup of formatting elt
!! options
parsoid=wt2html,wt2wt
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
'''foo[[File:Foobar.jpg|thumb|caption]]bar'''
[[Image:Foobar.jpg|right|300px]]
!! html/php
foo
caption
bar
!! html/parsoid
foo
caption
bar
!! end
!! test
3. Treebuilder fixup of formatting elt
!! options
parsoid=wt2html,wt2wt
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
'''foo[[File:Foobar.jpg|thumb|caption]]bar'''
!! html/php
foo
caption
bar
!! html/parsoid
foo
caption
bar
!! end
!! test
4. Treebuilder fixup of formatting elt: formatting tags around captionless images
!! options
parsoid=wt2html,wt2wt
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
'''[[Image:Foobar.jpg|right|300px]]'''
!! html/php
!! html/parsoid
!! end
!! test
Image: Modifying size of an image (1)
!! options
parsoid={
"modes": ["wt2wt"],
"changes": [
["img[height]", "attr", "height", "22"],
["img[width]", "attr", "width", "200"]
]
}
!! wikitext
[[Image:Foobar.jpg|230x230px]]
!! wikitext/edited
[[Image:Foobar.jpg|200x200px]]
!!end
!! test
Image: Modifying size of an image (2)
!! options
parsoid={
"modes": ["wt2wt"],
"changes": [
["img[height]", "attr", "height", "100"],
["img[width]", "attr", "width", "500"]
]
}
!! wikitext
[[Image:Foobar.jpg|230x230px]]
!! wikitext/edited
[[Image:Foobar.jpg|500x500px]]
!!end
# Change in size is ignored so long as class='mw-default-size'
!! test
Image: Modifying size of an image (3)
!! options
parsoid={
"modes": ["wt2wt"],
"changes": [
["figure[class]", "removeClass", "mw-default-size"],
["figure img", "attr", "height", "19"],
["figure img", "attr", "width", "170"]
]
}
!! wikitext
[[Image:Foobar.jpg|thumb]]
!! wikitext/edited
[[Image:Foobar.jpg|thumb|170x170px]]
!!end
!! test
Image: Modifying alignment of an image (T50665)
!! options
parsoid={
"modes": ["wt2wt"],
"changes": [
["figure[class]", "removeClass", "mw-halign-right"],
["figure[class]", "addClass", "mw-halign-left"]
]
}
!! wikitext
[[Image:Foobar.jpg|thumb|caption|right]]
!! wikitext/edited
[[Image:Foobar.jpg|thumb|caption|left]]
!! end
!! test
Image: Modifying mw-default-size of an frameless image (T64805)
!! options
parsoid={
"modes": ["wt2wt"],
"changes": [
["figure.mw-default-size", "removeClass", "mw-default-size"]
]
}
!! wikitext
[[Image:Foobar.jpg|frameless|right]]
!! wikitext/edited
[[Image:Foobar.jpg|frameless|right|180x180px]]
!! end
!! test
Image: Modifying valign of an image (T51221)
!! options
parsoid={
"modes": ["wt2wt"],
"changes": [
["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
]
}
!! wikitext
[[File:Foobar.jpg|20px|middle]]
!! wikitext/edited
[[File:Foobar.jpg|20px|text-top]]
!! end
!! test
Image: Modifying alt attribute of an image (T58400)
!! options
disabled
parsoid={
"modes": ["wt2wt"],
"changes": [
["img[alt]", "attr", "alt", "some alternate edited text"]
]
}
!! wikitext
[[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
!! wikitext/edited
[[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
!!end
!! test
Image: Modifying caption of an image
!! options
parsoid={
"modes": ["wt2wt"],
"changes": [
["figcaption", "text", "new caption"]
]
}
!! wikitext
[[Image:Foobar.jpg|thumb|original caption]]
!! wikitext/edited
[[Image:Foobar.jpg|thumb|new caption]]
!!end
!! test
Image: empty alt attribute (T50924)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|alt=|thumb|bar]]
!! html/php
bar
!! html/parsoid
bar
!! end
!! test
Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
!! options
parsoid=html2wt
language=ar
disabled
!! html/parsoid
!! wikitext
[[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
!! end
!! test
Image: Block level image should have \n before and after
!! wikitext
123
[[File:Foobar.jpg|right|thumb|150x150px]]
456
!! html/parsoid
123
456
!! end
!! test
Image: New block level image should have \n before and after (existing content)
!! wikitext
123
[[File:Foobar.jpg|right|thumb|150x150px]]
456
!! html/parsoid
123
456
!! end
!! test
Image: upright option (parsoid)
!! wikitext
[[File:Foobar.jpg|thumb|upright|caption]]
[[File:Foobar.jpg|thumb|upright=0.5|caption]]
[[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
!! html/parsoid
captioncaptioncaption
!! end
!! test
Image: upright option is ignored on inline and frame images (parsoid)
!! wikitext
[[File:Foobar.jpg|500x500px|upright=0.5|caption]]
!! html/parsoid
!! end
!! test
Image: in template parameter with empty parameter
!! wikitext
{{1x|[[File:Foobar.jpg|link=]]}}
!! html/parsoid
!! end
!! test
Image: from basic HTML (1)
!! options
parsoid=html2wt
!! html/parsoid
!! wikitext
[[File:Foobar.jpg|link=|alt=Alt|100x100px]]
!! end
!! test
Image: from basic HTML (2)
!! options
parsoid=html2wt
!! html/parsoid
!! wikitext
[[File:Foobar.jpg|link=|alt=Alt|100x100px]]
!! end
!! test
Image: from basic HTML (3)
!! options
parsoid=html2wt
!! html/parsoid
!! wikitext
[[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
!! end
!! test
Image: from basic HTML (4)
!! options
parsoid=html2wt
!! html/parsoid
!! wikitext
[[File:Foobar.jpg|link=]]
!! end
!! test
Image: Invalid title as link
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=<]]
[[File:Foobar.jpg|link=<|thumb]]
!! html/php
link=<
!! html/parsoid
!! end
!! test
Image with page parameter and invalid link
!! options
djvu
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:LoremIpsum.djvu|link=<|page=2]]
!! html/php
!! html/parsoid
!! end
!! test
Various link types in alt and link options
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|link=[[Main Page]]|alt=[[Main Page]]|caption]]
[[File:Foobar.jpg|link=[[Media:Thumb.png]]|alt=[[Media:Thumb.png]]|caption]]
[[File:Foobar.jpg|link=[[wikipedia:Foo]]|alt=[[wikipedia:Foo]]|caption]]
!! html/php
!! html/parsoid
!! end
!! test
Magic links inside image captions (autolinked)
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|http://example.com]]
[[File:Foobar.jpg|thumb|RFC 1234]]
[[File:Foobar.jpg|thumb|PMID 1234]]
[[File:Foobar.jpg|thumb|ISBN 123456789x]]
!! html/php
http://example.comRFC 1234PMID 1234ISBN 123456789x
!! html/parsoid
http://example.comRFC 1234PMID 1234ISBN 123456789x
!! end
## FIXME: Parsoid isn't recognizing an Interwiki here
!! test
Interwiki links inside image captions
!! options
language=de
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|right|[[:Wikipedia:Foo]] bar]]
!! html/php
Wikipedia:Foo bar
!! html/parsoid
Wikipedia:Foo bar
!! end
## Don't necessarily expect this to roundtrip, but run serialization to catch crashers
!! test
File in link scenarios
!! options
parsoid={
"modes": ["wt2html","html2wt"],
"suppressErrors": true
}
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[http://www.google.com [[File:Foobar.jpg|123]]]
[http://www.google.com [[File:Foobar.jpg|thumb|123]]]
!! html/php
123
!! html/parsoid
123
!! end
!! test
Thumbnail output
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Thumb.png|thumb]]
!! html/php
!! html/parsoid
!! end
## The bogus option here isn't going to roundtrip
!! test
File with caption with pipe in extension tag attribute
!! options
parsoid=wt2html,html2html
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|Test 123]]
!! html/php
Test 123
!! html/parsoid
Test 123
!! end
!! test
File with table in caption with extra table attribute spaces
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|
{|
|-
|hi
|}
]]
!! html/php
hi
!! html/parsoid
hi
!! end
## Expect the media structure to account for cases like this since it's common enough
!! test
File in formatting element violating content model
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
''[[File:Foobar.jpg|thumb]]''
!! html/php
!! html/parsoid
!! end
!! test
Table in figcaption nested in table
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
{|
|foo
|[[File:Foobar.jpg|thumb|
{|
|bar
|}
]]
|}
!! html/php
foo
bar
!! html/parsoid
foo
bar
!! end
!! test
Files with case sensitive media options
!! config
wgParserEnableLegacyMediaDOM=false
!! wikitext
[[File:Foobar.jpg|thumb|left]]
[[File:Foobar.jpg|thumb|Left]]
!! html/php
Left
!! html/parsoid
Left
!! end
!! test
Exercise selser on native galleries
!! options
parsoid= {
"modes": ["selser"],
"changes": [
["div.gallerytext", "contents", "text", "456"]
]
}
!! wikitext
File:Foobar.jpg|123
!! wikitext/edited
File:Foobar.jpg|456
!! end