Debian Codegraph @

tests/parser/redirects.txt

raw
1 # The parsoid-compatible option below is only relevant when we are running
2 # parser tests in integrated mode with Parsoid. This option is ignored
3 # when this test file is run with Parsoid in standalone mode.
4 !! options
5 parsoid-compatible=wt2html,wt2wt
6 version=2
7 !! end
8
9 !! article
10 Main Page
11 !! text
12 blah blah
13 !! endarticle
14
15 !! article
16 Template:1x
17 !! text
18 {{{1}}}
19 !! endarticle
20
21 ### Redirects, Parsoid-only
22
23 !! test
24 1. Simple redirect to page
25 !! wikitext
26 #REDIRECT [[Main Page]]
27 !! html/parsoid
28 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
29 !! end
30
31 !! test
32 2. Other redirect variants
33 !! wikitext
34 #REDIRECT [[Main_Page]]
35 !! html/parsoid
36 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
37 !! end
38
39 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
40 # This tests the Parsoid bail-out code.
41 !! test
42 3. Other redirect variants
43 !! options
44 parsoid=wt2html
45 !! wikitext
46 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
47 !! html/parsoid
48 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
49 !! end
50
51 !! test
52 4. Redirect to a templated destination
53 !! wikitext
54 #REDIRECT [[{{1x|Foo}}bar]]
55 !! html/parsoid
56 <link about="#mwt2" typeof="mw:ExpandedAttrs" rel="mw:PageProp/redirect" href="./Foobar" data-parsoid='{"a":{"href":"./Foobar"},"sa":{"href":"{{1x|Foo}}bar"}}' data-mw='{"attribs":[[{"txt":"href"},{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"Foo\"}},\"i\":0}}]}&#39;>Foo&lt;/span>bar"}]]}'/>
57 !! end
58
59 !! test
60 Empty redirect
61 !! options
62 parsoid=wt2html,wt2wt
63 !! wikitext
64 #REDIRECT [[]]
65 !! html/parsoid
66 <ol>
67 <li>REDIRECT [[]]</li></ol>
68 !! end
69
70 !! test
71 Optional colon in #REDIRECT
72 !! options
73 # the colon is archaic syntax. we support it for wt2html, but we
74 # don't care that it roundtrips back to the modern syntax.
75 parsoid=wt2html,html2html
76 !! wikitext
77 #REDIRECT:[[Main Page]]
78 !! html/parsoid
79 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
80 !! end
81
82 !! test
83 Whitespace in #REDIRECT with optional colon
84 !! options
85 # the colon and gratuitous whitespace is archaic syntax. we support
86 # it for wt2html, but we don't care that it roundtrips back to the
87 # modern syntax (without extra whitespace)
88 parsoid=wt2html,html2html
89 !! wikitext
90
91 #REDIRECT
92 :
93 [[Main Page]]
94 !! html/parsoid
95 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
96 !! end
97
98 !! test
99 Piped link in #REDIRECT
100 !! options
101 # content after piped link is ignored. we support this syntax,
102 # but don't care that the piped link is lost when we roundtrip this.
103 parsoid=wt2html
104 !! wikitext
105 #REDIRECT [[Main Page|bar]]
106 !! html/parsoid
107 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
108 !! end
109
110 !! test
111 Redirect to category (T104502)
112 !! options
113 parsoid=wt2html,wt2wt
114 !! wikitext
115 #REDIRECT [[Category:Foo]]
116 !! html/parsoid
117 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
118 !! end
119
120 !! test
121 Redirect to category with URL encoding (T104502)
122 !! options
123 parsoid=wt2html
124 !! wikitext
125 #REDIRECT [[Category%3AFoo]]
126 !! html/parsoid
127 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
128 !! end
129
130 !! test
131 Redirect to category page
132 !! wikitext
133 #REDIRECT [[:Category:Foo]]
134 !! html/parsoid
135 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
136 !! end
137
138 !! test
139 Redirect to image page (1)
140 !! wikitext
141 #REDIRECT [[File:Wiki.png]]
142 !! html/parsoid
143 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
144 !! end
145
146 !! test
147 Redirect to image page (2)
148 !! wikitext
149 #REDIRECT [[Image:Wiki.png]]
150 !! html/parsoid
151 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
152 !! end
153
154 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
155 # Next test confirms this.
156 !! test
157 Redirect to language (1) (T104918)
158 !! options
159 parsoid=wt2html,wt2wt,html2html
160 !! wikitext
161 #REDIRECT [[en:File:Wiki.png]]
162 !! html/parsoid
163 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
164 !! end
165
166 !! test
167 Redirect to language (2) (T104918)
168 !! wikitext
169 #REDIRECT [[:en:File:Wiki.png]]
170 !! html/parsoid
171 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
172 !! end
173
174 !! test
175 Redirect to interwiki (T104918)
176 !! wikitext
177 #REDIRECT [[meatball:File:Wiki.png]]
178 !! html/parsoid
179 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
180 !! end
181
182 !! test
183 Non-English #REDIRECT
184 !! options
185 language=is
186 !! wikitext
187 #TILVÍSUN [[Main Page]]
188 !! html/parsoid
189 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
190 !! end
191
192 !! test
193 Redirect syntax under text isn't considered a redirect
194 !! wikitext
195 some text
196
197 #redirect [[Main Page]]
198 !! html/parsoid
199 <p>some text</p>
200
201 <ol data-parsoid='{}'><li data-parsoid='{}'>redirect <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'>Main Page</a></li></ol>
202 !! end
203
204 !! test
205 New redirect
206 !! options
207 parsoid=html2wt
208 !! html/parsoid
209 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
210 !! wikitext
211 #REDIRECT [[Foo]]
212 Foo
213 !! end
214
215 ## WikiContent::getRedirectTargetAndText() strips the redirect from text so,
216 ## in practice, the legacy parse never sees it from the source. Hence, the
217 ## the differnce in output.
218 !! test
219 Redirect followed by block on the same line
220 !! options
221 parsoid=wt2html
222 !! wikitext
223 #REDIRECT [[Main Page]]<!-- haha -->==hi==
224 !! html/php
225 <ol><li>REDIRECT <a href="/wiki/Main_Page" title="Main Page">Main Page</a>==hi==</li></ol>
226 !! html/parsoid
227 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi">hi</h2>
228 !! end
229
230 ## WikiContent::getRedirectTargetAndText() strips the redirect from text so,
231 ## in practice, the legacy parse never sees it from the source. Hence, the
232 ## the differnce in output.
233 !! test
234 Redirect followed by horizontal rule on the same line
235 !! options
236 parsoid=wt2html
237 !! wikitext
238 #REDIRECT [[Main Page]]----
239 !! html/php
240 <ol><li>REDIRECT <a href="/wiki/Main_Page" title="Main Page">Main Page</a>----</li></ol>
241 !! html/parsoid
242 <link rel="mw:PageProp/redirect" href="./Main_Page"/><hr/>
243 !! end
244
245 !! test
246 Redirect followed by a newline
247 !! wikitext
248 #REDIRECT [[Main Page]]
249 A newline
250 !! html/parsoid
251 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
252 <p>A newline</p>
253 !! end
254
255 !! test
256 Redirect followed by multiple newlines
257 !! wikitext
258 #REDIRECT [[Main Page]]
259
260
261 A newline
262 !! html/parsoid
263 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
264
265 <p><br/>
266 A newline</p>
267 !! end
268
269 !! test
270 Drop duplicate redirects
271 !! options
272 parsoid=html2wt
273 !! html/parsoid
274 <link rel="mw:PageProp/redirect" href="./Foo"/>
275 <link rel="mw:PageProp/redirect" href="./Bar"/>
276 <link rel="mw:PageProp/redirect" href="./Baz"/>
277 !! wikitext
278 #REDIRECT [[Foo]]
279 !! end
280
281 !! test
282 Redirect containing double quotes and spaces
283 !! wikitext
284 #REDIRECT [[Cool "Gator"]]
285 !! html/parsoid
286 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
287 !! end
288
289 !! test
290 Broken redirect shouldn't crash parsoid (T332242)
291 !! wikitext
292 <!-- Not a valid redirect nor a valid parser function -->
293 {{#REDIRECT [[]]}}
294 !! html/php
295 <p>{{#REDIRECT [[]]}}
296 </p>
297 !! html/parsoid+integrated
298 <!-- Not a valid redirect nor a valid parser function -->
299 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#REDIRECT [[]]","function":"REDIRECT [[]]"},"params":{},"i":0}}]}'>{{#REDIRECT [[]]}}</span></p>
300 !! html/parsoid+standalone
301 <!-- Not a valid redirect nor a valid parser function -->
302 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#REDIRECT [[]]","function":"REDIRECT [[]]"},"params":{},"i":0}}]}'>Parser function implementation for pf_REDIRECT [[]] missing in Parsoid.</span></p>
303 !! end