# LanguageConverter and language variants parser tests
# This file includes standalone tests of Parsoid parsing of LC
# constructs (html/parsoid) as well as tests of language converter
# behavior (html/parsoid+langconv).
!! options
version=2
parsoid-compatible=wt2html
!! end
# This is the standard article assumed to exist.
!! article
Main Page
!! text
blah blah
!! endarticle
!! article
A
!! text
Dummy article to suppress redlinks in tests
!! end
!! article
Template:1x
!! text
{{{1}}}
!! endarticle
# For Serbian; localize Template namespace
!! article
Шаблон:1x
!! text
{{{1}}}
!! endarticle
!! article
Тест
!! text
sr-el article variant
!! endarticle
## sr-ec ##
!! test
sr-ec: Simple conversion of Latin to Cyrillic
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
abvg
!! html/php
абвг
!! html/parsoid
abvg
!! html/parsoid+langconv
абвг
!! end
!! test
sr-ec: Same as above, but assert that -{}-s must be removed and not converted (1)
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
-{lj}-аб-{nj}-вг-{dž}-
!! html/php
ljабnjвгdž
!! html/parsoid
абвг
!! html/parsoid+langconv
ljабnjвгdž
!! end
!! test
sr-ec: This text has some Cyrillic, but is recognized as Latin, so it should be converted
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
абвгšđžčć
!! html/php
абвгшђжчћ
!! html/parsoid
абвгšđžčć
!! html/parsoid+langconv
абвгшђжчћ
!! end
!! test
sr-ec: Same as above, but assert that -{}-s must be removed and not converted (2)
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
-{lj}-абвг-{nj}-šđžčć-{dž}-
!! html/php
ljабвгnjшђжчћdž
!! html/parsoid
абвгšđžčć
!! html/parsoid+langconv
ljабвгnjшђжчћdž
!! end
!! test
sr-ec: Roman numerals are not converted
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
a I b II v III g IV šđžčć
!! html/php
а I б II в III г IV шђжчћ
!! html/parsoid
a I b II v III g IV šđžčć
!! html/parsoid+langconv
а I б II в III г IV шђжчћ
!! end
## sr-el ##
!! test
sr-el: A simple conversion of Latin to Latin
!! options
language=sr htmlVariantLanguage=sr-Latn
!! wikitext
abcd
!! html/php
abcd
!! html/parsoid
abcd
!! html/parsoid+langconv
abcd
!! end
!! test
sr-el: A simple conversion of Cyrillic to Latin
!! options
language=sr htmlVariantLanguage=sr-Latn
!! wikitext
абцд
!! html/php
abcd
!! html/parsoid
абцд
!! html/parsoid+langconv
abcd
!! end
!! test
sr-el: This text has some Latin, but is recognized as Cyrillic, so it should be converted
!! options
language=sr htmlVariantLanguage=sr-Latn
!! wikitext
abcdшђжчћ
!! html/php
abcdšđžčć
!! html/parsoid
abcdшђжчћ
!! html/parsoid+langconv
abcdšđžčć
!! end
!! test
External links should be converted, unless they "look like a URL".
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
[http://example.com abcd]
[http://example.com http://foo.com]
http://example.com
[http://example.com -{abcd}-]
!! html/php
!! end
!! test
Language converter: output gets cut off unexpectedly (T7757)
!! options
language=zh
!! wikitext
this bit is safe: }-
but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
then we get cut off here: }-
all additional text is vanished
!! html/php
this bit is safe: }-
but if we add a conversion instance: xxx
then we get cut off here: }-
all additional text is vanished
!! html/parsoid
this bit is safe: }-
but if we add a conversion instance:
then we get cut off here: }-
all additional text is vanished
!! end
!! test
Language converter glossary rules inside attributes (T119158)
!! options
language=sr htmlVariantLanguage=sr-Latn
!! wikitext
-{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
[[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
!! html/php
!! html/parsoid
!! end
###
### Language variants related tests
###
!! test
Self-link in language variants
!! options
title=[[Dunav]] language=sr
!! wikitext
Both [[Dunav]] and [[Дунав]] are names for this river.
!! html/php
!! 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
!! wikitext
[[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
!! html/php
Дуна is not a self-link while Duna and Dуна are still self-links.
!! html/parsoid+langconv
Дуна is not a self-link while Duna and Dуна are still self-links.
!! end
!! test
Link to a section of a variant of this title should be parsed as mw-selflink-fragment
!! options
title=[[Duna]] language=sr
!! wikitext
[[Dуна]] is a self-link while [[Duna#Foo]] and [[Dуна#Foo]] are mw-selflink-fragments.
!! html/php
!! end
!! test
Multiple links to pages in language variants
!! options
language=sr
!! wikitext
[[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
!! html/php
!! end
!! article
Template:test
!! text
This is a test template
!! endarticle
!! test
Simple template in language variants
!! options
language=sr
!! wikitext
{{тест}}
!! html/php
This is a test template
!! end
!! test
Template with explicit namespace in language variants
!! options
language=sr
!! wikitext
{{Template:тест}}
!! html/php
This is a test template
!! end
!! article
Template:paramtest
!! text
This is a test template with parameter {{{param}}}
!! endarticle
!! test
Basic test for template parameter in language variants
!! options
language=sr
!! wikitext
{{парамтест|param=foo}}
!! html/php
This is a test template with parameter foo
!! end
!! test
Simple category in language variants
!! options
language=sr cat
!! metadata
cat=МедиаWики_Усер'с_Гуиде sort=
!! wikitext
[[Category:МедиаWики Усер'с Гуиде]]
!! html/php
!! html/parsoid
!! end
!! article
Category:分类
!! text
blah
!! endarticle
!! article
Category:分類
!! text
blah
!! endarticle
## We used to, but no longer wt2wt this test since the default serializer
## will normalize all categories to serialize on their own line.
## This wikitext usage is going to be fairly uncommon in production and
## selser will take care of preserving formatting in those scenarios.
!! test
Don't convert blue categorylinks to another variant (T35210)
!! options
cat
language=zh
parsoid=wt2html
!! metadata
cat=分类 sort=
!! wikitext
[[A]][[Category:分类]]
!! html/php
!! end
!! test
Stripping -{}- tags (language variants)
!! options
language=sr
!! wikitext
Latin proverb: -{Ne nuntium necare}-
!! html/php
Latin proverb: Ne nuntium necare
!! html/parsoid
Latin proverb:
!! end
!! test
Prevent conversion with -{}- tags (language variants)
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
Latinski: -{Ne nuntium necare}-
!! html/php
Латински: Ne nuntium necare
!! html/parsoid
Latinski:
!! end
!! test
Prevent conversion of text with -{}- tags (language variants)
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
Latinski: -{Ne nuntium necare}-
!! html/php
Латински: Ne nuntium necare
!! html/parsoid
Latinski:
!! end
!! test
Prevent conversion of links with -{}- tags (language variants)
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
-{[[Main Page]]}-
!! html/php
!! end
!! test
-{}- tags within headlines (within html for parserConvert())
!! config
wgFragmentMode=[ "html5", "legacy" ]
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
==-{Naslov}-==
Note that even an unprotected headline ID is not affected by language
conversion:
==Latinski==
!! html/php
Note that even an unprotected headline ID is not affected by language
conversion:
Latinski
!! end
!! test
Explicit definition of language variant alternatives
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
!! wikitext
-{zh:China;zh-tw:Taiwan}-, not China
!! html/php
Taiwan, not China
!! html/parsoid
, not China
!! end
!! test
Explicit definition of language variant alternatives (BCP 47 codes)
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
!! wikitext
-{zh:China;zh-Hant-TW:Taiwan}-, not China
!! html/php
Taiwan, not China
!! html/parsoid
, not China
!! end
!! test
Filter rules with BCP 47 codes
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
!! wikitext
-{zh-Hant-TW;|-{zh-tw:Taiwan;zh-hk:Hong Kong;zh-cn:China}-}-
!! html/php
Taiwan
!! html/parsoid
!! html/parsoid+langconv
Taiwan
!! end
!! test
html2wt support for edited wildcard rule (strip trailing semi where needed)
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
parsoid={
"modes": ["wt2wt", "selser"],
"changes": [
["meta[typeof]", "attr", "data-mw-variant", "{\"add\":true,\"twoway\":[{\"l\":\"*\",\"t\":\"content\"}]}"]
]
}
!! wikitext
test: -{H|zh:content; }-
!! wikitext/edited
test: -{H|content}-
!! end
!! test
html2wt support for wildcard rule with whitespace around flag value
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
parsoid=wt2html,wt2wt,html2html
!! wikitext
test: -{ H |all variants}-
!! html/php
test:
!! html/parsoid
test:
!! end
!! test
Filter syntax for language variants
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
!! wikitext
foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
!! html/php
fooblog, WEBJOURNAL, WEBLOGquux
!! html/parsoid
fooquux
!! end
# Note that Parsoid post-processing for language variants needs to
# update the `title` attribute here, based on the mw:ExpandedAttrs property
!! test
Conversion around HTML tags
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
-{H|span=>sr-ec:script;title=>sr-ec:src}-
ski
!! html/php
ски
!! html/parsoid
ski
!! end
!! test
Explicit session-wise two-way language variant mapping (A flag and - flag)
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
!! wikitext
This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
Taiwan is not China.
But -{A|zh:China; zh-tw:Taiwan}- is China,
(This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
and -{China}- is China.
!! html/php
This is Taiwan, but we'll forget that now.
Taiwan is not China.
But Taiwan is Taiwan,
(This should be stripped!)
and China is China.
!! html/parsoid
This is , but we'll forget that now.
Taiwan is not China.
But is China,
(This should be stripped!)
and is China.
!! end
!! test
Explicit session-wise one-way language variant mapping (A flag and - flag)
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
!! wikitext
This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
COUNTRY is China or Taiwan.
But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
(This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
and -{COUNTRY}- is COUNTRY.
!! html/php
This is Taiwan, but we'll forget that now.
COUNTRY is China or Taiwan.
But Taiwan is Taiwan,
(This should be stripped!)
and COUNTRY is COUNTRY.
!! html/parsoid
This is , but we'll forget that now.
COUNTRY is China or Taiwan.
But is COUNTRY,
(This should be stripped!)
and is COUNTRY.
!! end
!! test
Explicit session-wise two-way language variant mapping (H flag for hide)
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
!! wikitext
(This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
Taiwan is China.
!! html/php
(This should be stripped!)
Taiwan is Taiwan.
!! html/parsoid
(This should be stripped!)
Taiwan is China.
!! end
!! test
Explicit session-wise one-way language variant mapping (H flag for hide)
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
!! wikitext
(This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
COUNTRY is Taiwan or China.
!! html/php
(This should be stripped!)
Taiwan is Taiwan or China.
!! html/parsoid
(This should be stripped!)
COUNTRY is Taiwan or China.
!! end
!! test
Adding explicit conversion rule for title (T flag)
!! options
language=zh htmlVariantLanguage=zh-Hant-TW showtitle
!! wikitext
Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
Taiwan is China.
!! metadata+langconv
Taiwan
!! html/php
Should be stripped!
Taiwan is China.
!! html/parsoid
Should be stripped!
Taiwan is China.
!! html/parsoid+langconv
Should be stripped!
Taiwan is China.
!! end
!! test
Code coverage: T combined with H flag
!! options
language=zh htmlVariantLanguage=zh-Hant-TW showtitle
!! wikitext
Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
Taiwan is China.
!! metadata+langconv
Taiwan
!! html/php
Should be stripped!
Taiwan is Taiwan.
!! html/parsoid
Should be stripped!
Taiwan is China.
!! html/parsoid+langconv
Should be stripped!
Taiwan is Taiwan.
!! end
!! test
Code coverage: T with no variants
!! options
language=zh htmlVariantLanguage=zh-Hant-TW showtitle
!! wikitext
-{H|zh:China; zh-tw:Taiwan}-
Taiwan is China.-{T|Taiwan is China}-
!! metadata+langconv
Taiwan is China
!! html/php
Taiwan is Taiwan.
!! html/parsoid
Taiwan is China.
!! html/parsoid+langconv
Taiwan is Taiwan.
!! end
!! test
Code coverage: T with no variants (default variant)
!! options
language=zh htmlVariantLanguage=zh showtitle
!! wikitext
-{H|zh:China; zh-tw:Taiwan}-
Taiwan is China.-{T|Taiwan is China}-
!! metadata+langconv
Parser test
!! html/php
Taiwan is China.
!! html/parsoid
Taiwan is China.
!! html/parsoid+langconv
Taiwan is China.
!! end
!! test
Code coverage: rules with no variants
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
!! wikitext
-{H|zh:China; zh-tw:Taiwan}-
Taiwan is China.
-{H|China}-
Taiwan is China.
!! html/php
Taiwan is Taiwan.
Taiwan is China.
!! html/parsoid
Taiwan is China.
Taiwan is China.
!! end
!! test
Code coverage: D flag for conversion rule
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
!! wikitext
-{D|zh-cn:XA; zh-tw:YA}-
-{A;D|zh-cn:XB; zh-tw:YB}-
-{D;H|zh-cn:XC; zh-tw:YC}-
-{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
-{D|0=>zh-tw:1}-
-{A;D|2=>zh-tw:3}-
-{D;H|4=>zh-tw:5}-
XA XB XC YA YB YC FOO BAR BAT 012345
!! html/php
大陆:XA;臺灣:YA;
大陆:XC;臺灣:YC;
FOO⇒臺灣:BAR;FOO⇒大陆:BAT;
0⇒臺灣:1;
4⇒臺灣:5;
XA YB YC YA YB YC BAR BAR BAT 013355
!! html/parsoid
XA XB XC YA YB YC FOO BAR BAT 012345
!! end
!! test
Code coverage: N flag for conversion rule
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
!! wikitext
-{N|zh-cn}-
-{N|zh-tw}-
-{N|sr-ec}-
!! html/php
大陆
臺灣
српски (ћирилица)
!! html/parsoid
!! end
# html2wt suppresses the bogus 'D' flag, so this is wt2html only
!! test
Code coverage: N flag for conversion rule (wt2html only)
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
parsoid=wt2html,html2html
!! wikitext
-{D;N|en}-
!! html/php
English
!! html/parsoid
!! end
!! test
Testing that changing the language variant here in the tests actually works
!! options
language=zh htmlVariantLanguage=zh showtitle
!! wikitext
Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
!! metadata+langconv
China
!! html/php
Should be stripped!
!! html/parsoid
Should be stripped!
!! html/parsoid+langconv
Should be stripped!
!! end
!! test
Title with HTML
!! options
language=zh htmlVariantLanguage=zh showtitle
!! wikitext
-{T|zh:Title with HTML&Entities}-
Should be stripped!
!! metadata/php
Title with HTML&Entities
!! metadata/parsoid+langconv
Title with HTML&Entities
!! html/php
!! end
!! test
Title with JavaScript injection
!! options
language=zh htmlVariantLanguage=zh showtitle
!! wikitext
-{T|zh:Title click me }-
Should be stripped!
!! metadata+langconv
Title click me <script>alert(43)</script>
!! html/php
Should be stripped!
!! html/parsoid+langconv
Should be stripped!
!! end
!! test
Test 1 from T298401/T67747
!! options
language=zh htmlVariantLanguage=zh showtitle
!! wikitext
-{T|zh:Title &b}-
Should be stripped!
!! metadata/php
Title <script>a</script>&b
!! metadata/parsoid+langconv
Title <script>a</script>&b
!! html/php
Should be stripped!
!! html/parsoid+langconv
Should be stripped!
!! end
!! test
Test 2 from T298401/T67747
!! options
language=zh htmlVariantLanguage=zh showtitle
!! wikitext
-{T|zh:Title }-
Should be stripped!
!! metadata+langconv
Title
!! html/php
Should be stripped!
!! html/parsoid+langconv
Should be stripped!
!! end
!! test
Test 3 from T298401/T67747
!! options
language=zh htmlVariantLanguage=zh showtitle
!! wikitext
-{T|zh:Title Foo bar}-
Should be stripped!
!! metadata+langconv
Title Foo bar
!! html/php
Should be stripped!
!! html/parsoid+langconv
Should be stripped!
!! end
!! test
Recursive conversion of alt and title attrs shouldn't clear converter state
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
showtitle
!! wikitext
-{H|zh-cn:Exclamation; zh-tw:exclamation}-
Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-!
!! metadata+langconv
China
!! html/php
Should be stripped!
!! html/parsoid
Should be stripped!
!! html/parsoid+langconv
Should be stripped!
!! end
!! test
T26072: more test on conversion rule for title
!! options
language=zh htmlVariantLanguage=zh-Hant-TW showtitle
!! wikitext
This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
!! metadata+langconv
Taiwan
!! html/php
This should be stripped!
This won't take interferes with the title rule.
!! html/parsoid
This should be stripped!
This won't take interferes with the title rule.
!! html/parsoid+langconv
This should be stripped!
This won't take interferes with the title rule.
!! end
!! test
Partly disable title conversion if variant == main language code
!! options
language=zh htmlVariantLanguage=zh title=[[ZH]] showtitle
!! wikitext
-{T|zh-cn:CN;zh-tw:TW}-
!! metadata+langconv
ZH
!! html/php
!! html/parsoid
!! html/parsoid+langconv
!! end
!! test
Partly disable title conversion if variant == main language code, more
!! options
language=zh htmlVariantLanguage=zh title=[[ZH]] showtitle
!! wikitext
-{T|TW}-
!! metadata+langconv
ZH
!! html/php
!! html/parsoid
!! html/parsoid+langconv
!! end
!! test
Raw output of variant escape tags (R flag)
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
!! wikitext
Raw: -{R|zh:China;zh-tw:Taiwan}-
!! html/php
Raw: zh:China;zh-tw:Taiwan
!! html/parsoid
Raw:
!! end
# html2wt suppresses the bogus 'D' flags, so this is wt2html only
!! test
Raw output of variant escape tags (R flag) (wt2html only)
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
parsoid=wt2html,html2html
!! wikitext
-{Variant}- -{D|syntax}- -{D;R|options}-
!! html/php
Variant syntax options
!! html/parsoid
!! end
!! test
Nested markup inside raw output of variant escape tags (R flag)
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
!! wikitext
Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
!! html/php
Nested raw: nested Taiwan nested
!! html/parsoid
Nested raw:
!! end
!! test
Nested markup and spaces inside raw output of variant escape tags (R flag)
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
!! wikitext
X-{ outer -{ inner }- outer }-X
!! html/php
X outer inner outer X
!! html/parsoid
XX
!! end
!! test
Templates inside raw output of variant escape tags (R flag)
!! options
language=zh htmlVariantLanguage=zh-Hant-TW
!! wikitext
Nested raw: -{R|nested {{1x|hi}} templates}-
!! html/php
Nested raw: nested hi templates
!! html/parsoid
Nested raw:
!! end
!! test
Strings evaluating false shouldn't be ignored by Language converter (T51072)
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
!! wikitext
-{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
!! html/php
0
!! html/parsoid
!! end
!! test
Conversion rules from [numeric-only string] to [something else] (T48634)
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
!! wikitext
-{H|0=>zh-cn:B}--{H|0=>zh-cn:C;0=>zh-cn:D}--{H|0=>zh-hans:A}-012345-{A|zh-tw:0;zh-cn:E;}-012345
!! html/php
D12345EE12345
!! html/parsoid
012345012345
!! end
!! test
Two-way converter rule entries with an empty value should be ignored (T53551)
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
!! wikitext
-{H|zh-cn:foo;zh-tw:;}-foobar
!! html/php
foobar
!! html/parsoid
foobar
!! end
!! test
One-way converter rule entries with an empty "from" string should be ignored (T53551)
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
!! wikitext
-{H|=>zh-cn:foo;}-foobar
!! html/php
foobar
!! html/parsoid
foobar
!! end
!! test
Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
!! wikitext
-{H|}-foobar
!! html/php
foobar
!! html/parsoid
foobar
!! end
!! test
Nested using of manual convert syntax
!! options
language=zh htmlVariantLanguage=zh-Hant-HK
!! wikitext
Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
!! html/php
Nested: Hello Hong Kong!
!! html/parsoid
Nested: !
!! end
!! test
HTML markups with conversion syntax in attribs, nested in other conversion blocks
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
!! wikitext
-{zh;zh-hans;zh-hant|A}-
!! html/php
A
!! html/parsoid
!! end
!! test
HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
!! wikitext
-{A}-
!! html/php+disabled
A
!! html/parsoid
!! end
# Parsoid and PHP disagree on how to parse this example: Parsoid
# insists that the content of a language converter element be a valid
# DOM fragment or attribute string
!! test
Language converter markup with block content
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
!! wikitext
a-{b
c}-d
a-{zh;zh-hans;zh-hant|b
c}-d
a-{H|0=>zh-cn:xy;0=>zh-tw:b
c}-d
!! html/php
ab
cd
ab
cd
ad
!! html/parsoid
ad
ad
ad
!! end
!! test
LanguageConverter selser (1)
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
parsoid={
"modes": ["wt2wt", "selser"],
"changes": [
["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
]
}
!! wikitext
-{raw}-
!! wikitext/edited
-{edited}-
!! end
!! test
LanguageConverter selser (2)
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
parsoid={
"modes": ["wt2wt", "selser"],
"changes": [
["span[class='x']", "contents", "text", "-{foo}-"],
["a", "contents", "text", "-{"],
["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
]
}
!! wikitext
TEXT1
[http://example.com TEXT2]
[[Foo|TEXT3]]
{{1x|TEXT4}}
!! wikitext/edited
-{foo}-
[http://example.com -{]
[[Foo|-{]]
{{1x|-{}}
!! end
# Tests LanguageVariantText in ConstrainedText
!! test
LanguageConverter selser (3)
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
parsoid={
"modes": ["wt2wt", "selser"],
"changes": [
["td > span", "attr", "typeof", "mw:LanguageVariant"],
["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
]
}
!! wikitext
{|
|-
|Foo
|}
!! wikitext/edited
{|
|-
|-{edited}-
|}
!! end
# Tests LanguageVariantText._fromSelSer
!! test
LanguageConverter selser (4)
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
parsoid={
"modes": ["wt2wt", "selser"],
"changes": [
["td > span.x", "remove"]
]
}
!! wikitext
{|
|-
|Foo-{Bar}-
||Foo-{Bar}-
|}
!! wikitext/edited
{|
|-
|-{Bar}-
||-{Bar}-
|}
!! end
# Since Parsoid is starting to emit canonical wikitext for links,
# [http://example.com http://example.com] will not RT back to that
# form anymore.
# Parsoid does not language-convert links (it is done in a
# post-processing step)
!! test
Proper conversion of text in external links
!! options
language=sr htmlVariantLanguage=sr-Cyrl
parsoid=wt2html
!! wikitext
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]
!! html/php
!! end
!! test
Do not convert roman numbers to language variants
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
Fridrih IV je car.
!! html/php
Фридрих IV је цар.
!! html/parsoid
Fridrih IV je car.
!! end
!! test
Unclosed language converter markup "-{"
!! options
language=sr
!! wikitext
-{T|hello
!! html
-{T|hello
!! end
!! test
Don't convert raw rule "-{R|=>}-" to "=>"
!! options
language=sr
!! wikitext
-{R|=>}-
!! html/php
=>
!! html/parsoid
!!end
!! test
Don't break link parsing if language converter markup is in the caption.
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
[[Main Page|-{R|main page}-]]
!! html/php
!! end
!! test
T146304: Don't break template parsing if language converter markup is in the parameter.
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
{{1x|-{R|foo}-}}
!! html/php
foo
!! html/parsoid
!! end
!! test
T153135: Don't break list handling if language converter markup is in the item.
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
!! wikitext
;-{zh-cn:AAA;zh-tw:BBB}-
;-{R|foo:bar}-
!! html/php
AAA
foo:bar
!! html/parsoid
!! end
# Note that parsoid does not protect colons unless language converter
# markup is properly nested, because it is a backtracking parser.
!! test
T153135: Unclosed markup in definition list (code coverage)
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
!! wikitext
;foo:bar
;-{zh-cn:AAA
!! html/php
foo:bar
-{zh-cn:AAA
!! html/parsoid
foo:bar
-{zh-cn
AAA
!! end
!! test
T153135: Nested language converter markup in definition list (code coverage)
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
!! wikitext
;-{zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
!! html/php
AAA foo:bar bat:baz
def
!! html/parsoid
def
!! end
# html2wt mode disabled due to insertion.
!! test
T153140: Don't break table handling if language converter markup is in the cell.
!! options
language=sr htmlVariantLanguage=sr-Cyrl
parsoid=wt2html,wt2wt,html2html
!! wikitext
{|
|-
| -{R|B}-
|}
!! html/php
B
!! html/parsoid
!! end
!! test
Language converter tricky html2wt cases (1)
!! options
language=sr
parsoid=html2wt,wt2wt
!! html/parsoid
!! wikitext
-{}-}-
!! html/php
}-
!! end
!! test
Language converter tricky html2wt cases (2)
!! options
language=sr
parsoid=html2wt,wt2wt
!! html/parsoid
-{foo}-
!! wikitext
-{foo}-
!! html/php
-{foo}-
!! end
!! test
Language converter tricky html2wt cases (3)
!! options
language=sr
parsoid=html2wt,wt2wt
!! html/parsoid
!! end
!! test
Language converter tricky html2wt cases (4)
!! options
language=sr
parsoid=html2wt,wt2wt
!! html/parsoid
!! wikitext
-{R|{{1x|hey}}}-
!! html/php
hey
!! end
# Note that the escaping added by parsoid for source text,
# destination text, and language names only works on the PHP side
# for *destination text*. (HTML entity escaping wouldn't work
# any better.) This is probably a bug, at least for source texts.
# (For language names PHP uses a precise regexp based on the languages
# it currently knows have variants, which is fragile since this set
# can grow/shrink over time.)
!! test
Language converter tricky html2wt cases (5)
!! options
language=zh htmlVariantLanguage=zh-Hans-CN
!! html/parsoid
!! end
!! test
T239806: Trailing garbage in language converter rules (1)
!! options
language=zh htmlVariantLanguage=zh-Hans
parsoid=wt2html,html2html
!! wikitext
-{H|zh-cn:约翰·塞纳; zh-hk:莊·先拿; zh-tw:約翰·希南; ;}-
-{H|zh-cn:泰瑞斯·吉布森; zh-hk:泰列斯·吉遜; zh-tw:泰瑞斯·吉布森; ;}-
-{H|zh-cn:金·米尔福特; zh-tw:金·米爾福特; 真·米爾福特;}-
!! html/php
!! html/parsoid
!! end
!! test
T239806: Trailing garbage in language converter rules (2)
!! options
language=zh htmlVariantLanguage=zh-Hans
parsoid=wt2html,html2html
!! wikitext
-{H|zh-cn:玛格特·罗比; zh-tw:瑪格·羅比; zh-hk:瑪歌·羅比; zh-sg:玛格·罗比; ;}-
!! html/php
!! html/parsoid
!! end
!! test
T179579: Nowiki and lc interaction
!! options
parsoid=wt2html
language=sr
!! wikitext
-{123}-
-{123|456}-
!! html/parsoid
!! end
!! test
Balinese language conversion
!! options
language=ban htmlVariantLanguage=ban-x-palmleaf
!! wikitext
ᬫᬦ᭄ᬢ᭄ᬭ -{ban-x-palmleaf:AAA;ban:BBB}-
!! html/php
mantra AAA
!! html/parsoid
ᬫᬦ᭄ᬢ᭄ᬭ
!! end
!! test
Langconvert tag: crh-latn to crh-cyrl
!! wikitext
test
!! html/php
тест
!! end
!! test
Langconvert tag: en to en-x-piglatin
!! config
wgUsePigLatinVariant=true
!! wikitext
test
!! html/php
esttay
!! end
!! test
Langconvert tag: gan-hans to gan-hant
!! wikitext
爱
!! html/php
愛
!! end
!! test
Langconvert tag: ku-latn to ku-arab
!! wikitext
test
!! html/php
تەست
!! end
!! test
Langconvert tag: shi-latn to shi-tfng
!! wikitext
test
!! html/php
ⵜⴻⵙⵜ
!! end
!! test
Langconvert tag: sr-latn to sr-cyrl
!! wikitext
zdravo
!! html/php
здраво
!! end
!! test
Langconvert tag: sr-el to sr-ec (should fail)
!! wikitext
zdravo
!! html/php
Error: Langconvert tag's from and to attributes must not be empty and must contain BCP 47 codes for convertible variants of the same language.
!! end
!! test
Langconvert tag: tg to tg-latn
!! wikitext
тест
!! html/php
test
!! end
!! test
Langconvert tag: uz-cyrl to uz-latn
!! wikitext
тест
!! html/php
test
!! end
!! test
Langconvert tag: zh-hans to zh-hant
!! wikitext
爱
!! html/php
愛
!! end
!! test
Langconvert tag: self-closed
!! wikitext
xx
!! html/php
xx
!! end
!! test
Langconvert tag: ensure output is not double-converted
!! options
language=zh htmlVariantLanguage=zh-hans
!! wikitext
氣
气
!! html/php
气
氣
!! end
!! test
T302678: Serialize empty twoway
!! options
language=zh
parsoid=html2wt
!! html/parsoid
!! wikitext
-{H|}-
!! end
!! test
Rewrite redlinks to point to variant title
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
[[Test]]
!! html/php
!! end
## Legacy parser inconsistency in the title attribute
!! test
Nonexistent internal link targets should be resolved using variants (T258856)
!! options
language=sr htmlVariantLanguage=sr-Cyrl
!! wikitext
[[DoesNotExist]]
!! html/php
!! end
!! test
Two-way rules with images
!! options
language=zh htmlVariantLanguage=zh-tw
!! wikitext
-{zh-tw:[[File:Foobar.jpg|thumb|tw]]; zh-hk:[[File:Foobar.jpg|thumb|hk]]; zh-cn:[[File:Foobar.jpg|thumb|cn]]}-
!! html/php
tw
!! html/parsoid
!! end
!! test
Embedded new lines
!! options
language=zh htmlVariantLanguage=zh-tw
parsoid=wt2html,wt2wt,html2html
!! wikitext
-{zh-tw:* foo;
zh-cn:* bar}-
!! html/php
* foo
!! html/parsoid
!! end
!! test
Language variant with empty flag section
!! options
language=zh htmlVariantLanguage=zh-tw
parsoid=wt2html,html2html
!! wikitext
This is -{|a test}-
!! html/php
This is a test
!! html/parsoid
This is
!! end
!! test
html2wt of language variant text that could be confused for a flag
!! options
language=zh htmlVariantLanguage=zh-tw
parsoid=html2wt
!! html/parsoid
!! wikitext
-{R|R|R}-
!! end
!! test
Don't crash if there are no possible variants of a redlink
!! options
language=zh htmlVariantLanguage=zh-tw
!! wikitext
[[This is a red link]]
!! html/parsoid+langconv
!! end
!! test
Language converter markup can contain tables (T422966)
!! options
language=zh htmlVariantLanguage=zh-tw
parsoid=wt2html
!! wikitext
-{zh-tw;|
{|
| col1
| col2
|-
| foo || bar
|}
}-
!! html/php
col1
col2
foo
bar
!! html/parsoid
!! html/parsoid+langconv
col1
col2
foo
bar
!! end
!! test
Language converter markup can contain tables containing tables (T422966)
!! options
language=zh htmlVariantLanguage=zh-tw
parsoid=wt2html,wt2wt,html2html
!! wikitext
-{zh-tw;|before table
{| border="1"
|α
|
{| bgcolor="#ABCDEF" border="2"
|nested
|-
|table
|}
|the original table again
|}
after table}-
!! html/php
before table
α
nested
table
the original table again
after table
!! html/parsoid
!! html/parsoid+langconv
before table
α
nested
table
the original table again
after table
!! end
!! test
Tables can contain language converter markup that can contain tables (T422966)
!! options
language=zh htmlVariantLanguage=zh-tw
parsoid=wt2html,wt2wt,html2html
!! wikitext
{| border="1"
|α
|
-{zh-tw;|before table
{| bgcolor="#ABCDEF" border="2"
|nested
|-
|table
|}
after table}-
|the original table again
|}
!! html/php
α
before table
nested
table
after table
the original table again
!! html/parsoid
α
the original table again
!! html/parsoid+langconv
α
before table
nested
table
after table
the original table again
!! end
!! test
Language converter markup can contain lists (T422966)
!! options
language=zh htmlVariantLanguage=zh-tw
parsoid=wt2html,wt2wt,html2html
!! wikitext
-{
#foo
#bar
}-
!! html/php
foo
bar
!! html/parsoid
!! html/parsoid+langconv
foo
bar
!! end
!! test
Nested raw markup
!! options
language=sr htmlVariantLanguage=sr-Cyrl
parsoid=wt2html,wt2wt,html2html
!! wikitext
-{raw1 -{raw2}- -{R|raw3}-}-
-{raw -{sr-Cyrl;|filter}- -{sr-Latn:foo;sr-Cyrl:bar}- -{xyz=>sr-Cyrl:bat}-}-
!! html/php
!! end
!! test
T424401: Don't convert inside
!! options
language=sr htmlVariantLanguage=sr-Cyrl
parsoid=wt2html,wt2wt,html2html
!! wikitext
This is Latin.
Even if the nowiki -{contains}- lc markup.
!! html/php