Debian Codegraph @

extensions/Cite/tests/parser/subReferencing.txt

raw
1 !! version 2
2
3 !! test
4 Sub-referencing attribute rejected by default
5 !! config
6 wgCiteBookReferencing=false
7 !! wikitext
8 <ref name="parent">[foo]</ref>
9 <ref extends="parent">[bar]</ref>
10 !! html/php
11 <p><sup id="cite&#95;ref-parent&#95;1-0" class="reference"><a href="#cite_note-parent-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
12 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid parameter in <code>&lt;ref&gt;</code> tag</span>
13 </p>
14 <div class="mw-references-wrap"><ol class="references">
15 <li id="cite&#95;note-parent-1"><span class="mw-cite-backlink"><a href="#cite_ref-parent_1-0">↑</a></span> <span class="reference-text">[foo]</span>
16 </li>
17 </ol></div>
18 !! end
19
20 !! test
21 Sub-referencing attribute allowed with feature flag set
22 !! config
23 wgCiteBookReferencing=true
24 !! wikitext
25 <ref name="parent">[foo]</ref>
26 <ref extends="parent">[bar]</ref>
27 !! html/php
28 <p><sup id="cite&#95;ref-parent&#95;1-0" class="reference"><a href="#cite_note-parent-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
29 <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
30 </p>
31 <div class="mw-references-wrap"><ol class="references">
32 <li id="cite&#95;note-parent-1"><span class="mw-cite-backlink"><a href="#cite_ref-parent_1-0">↑</a></span> <span class="reference-text">[foo]</span>
33 <ol class="mw-extended-references"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">[bar]</span>
34 </li>
35 </ol></li>
36 </ol></div>
37 !! end
38
39 !! test
40 T236256 - Sub-referencing the same parent multiple times is fine
41 !! options
42 language=de
43 !! config
44 wgCiteBookReferencing=true
45 !! wikitext
46 <ref name="a">book</ref>
47 <ref extends="a">page 2</ref>
48 <ref extends="a">page 3</ref>
49 <references />
50 !! html/php
51 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
52 <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
53 <sup id="cite&#95;ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">&#91;</span>1.2<span class="cite-bracket">&#93;</span></a></sup>
54 </p>
55 <div class="mw-references-wrap"><ol class="references">
56 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
57 <ol class="mw-extended-references"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page 2</span>
58 </li>
59 <li id="cite&#95;note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">page 3</span>
60 </li>
61 </ol></li>
62 </ol></div>
63 !! end
64
65 !! test
66 Sub-references can be reused
67 !! options
68 language=de
69 !! config
70 wgCiteBookReferencing=true
71 !! wikitext
72 <ref name="a">book</ref>
73 <ref extends="a" name="b">page 2</ref>
74 <ref name="b" />
75 !! html
76 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
77 <sup id="cite&#95;ref-b&#95;2-0" class="reference"><a href="#cite_note-b-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
78 <sup id="cite&#95;ref-b&#95;2-1" class="reference"><a href="#cite_note-b-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
79 </p>
80 <div class="mw-references-wrap"><ol class="references">
81 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
82 <ol class="mw-extended-references"><li id="cite&#95;note-b-2"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-b_2-0">1.1,0</a></sup> <sup><a href="#cite_ref-b_2-1">1.1,1</a></sup></span> <span class="reference-text">page 2</span>
83 </li>
84 </ol></li>
85 </ol></div>
86 !! end
87
88 !! test
89 T240424 - Subreference reused as normal ref before its full definition
90 !! config
91 wgCiteBookReferencing=true
92 !! wikitext
93 <ref name="b" />
94 <ref name="b" extends="a">page 2</ref>
95 <ref name="a">book</ref>
96 !! html
97 <p><sup id="cite&#95;ref-b&#95;1-0" class="reference"><a href="#cite_note-b-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
98 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; name "b" defined multiple times with different content</span>
99 <sup id="cite&#95;ref-a&#95;2-0" class="reference"><a href="#cite_note-a-2"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup>
100 </p>
101 <div class="mw-references-wrap"><ol class="references">
102 <li id="cite&#95;note-b-1"><span class="mw-cite-backlink"><a href="#cite_ref-b_1-0">↑</a></span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; no text was provided for refs named <code>b</code></span></li>
103 <li id="cite&#95;note-a-2"><span class="mw-cite-backlink"><a href="#cite_ref-a_2-0">↑</a></span> <span class="reference-text">book</span>
104 </li>
105 </ol></div>
106 !! end
107
108 !! test
109 T240424 - Sub-reference reused before defined in the <references> section
110 !! config
111 wgCiteBookReferencing=true
112 !! wikitext
113 <ref name="a" />
114 <ref name="b" />
115 <references>
116 <ref name="b" extends="a">page 2</ref>
117 <ref name="a">book</ref>
118 </references>
119 !! html
120 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
121 <sup id="cite&#95;ref-b&#95;2-0" class="reference"><a href="#cite_note-b-2"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup>
122 </p>
123 <div class="mw-references-wrap"><ol class="references">
124 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
125 </li>
126 <li id="cite&#95;note-b-2"><span class="mw-cite-backlink"><a href="#cite_ref-b_2-0">↑</a></span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; no text was provided for refs named <code>b</code></span></li>
127 </ol></div>
128 <p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; name "b" defined multiple times with different content</span>
129 </p>
130 !! end
131
132 # TODO: T367749 - We are misusing an existing error message here that is super confusing
133 !! test
134 T367749 - Turning a top-level ref into a subref is forbidden, even if the content is the same
135 !! config
136 wgCiteBookReferencing=true
137 !! wikitext
138 <ref name=p20>page 20</ref>
139 <ref extends=book name=p20>page 20</ref>
140 <references>
141 <ref name=book>book</ref>
142 </references>
143 !! html
144 <p><sup id="cite&#95;ref-p20&#95;1-0" class="reference"><a href="#cite_note-p20-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
145 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; name "p20" defined multiple times with different content</span>
146 </p>
147 <div class="mw-references-wrap"><ol class="references">
148 <li id="cite&#95;note-p20-1"><span class="mw-cite-backlink"><a href="#cite_ref-p20_1-0">↑</a></span> <span class="reference-text">page 20</span>
149 </li>
150 </ol></div>
151 <p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag with name "book" defined in <code>&lt;references&gt;</code> is not used in prior text.</span>
152 </p>
153 !! end
154
155 !! test
156 T367749 - Turning a top-level ref into a subref is forbidden, especially when the content conflicts
157 !! config
158 wgCiteBookReferencing=true
159 !! wikitext
160 <ref name=p20>page 20</ref>
161 <ref extends=book name=p20>different content</ref>
162 <references>
163 <ref name=book>book</ref>
164 </references>
165 !! html
166 <p><sup id="cite&#95;ref-p20&#95;1-0" class="reference"><a href="#cite_note-p20-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
167 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; name "p20" defined multiple times with different content</span>
168 </p>
169 <div class="mw-references-wrap"><ol class="references">
170 <li id="cite&#95;note-p20-1"><span class="mw-cite-backlink"><a href="#cite_ref-p20_1-0">↑</a></span> <span class="reference-text">page 20</span>
171 </li>
172 </ol></div>
173 <p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag with name "book" defined in <code>&lt;references&gt;</code> is not used in prior text.</span>
174 </p>
175 !! end
176
177 # TODO: T367749 - We want this to render successfully
178 !! test
179 T367749 - Turning a top-level ref into a subref is fine when the content is an empty string
180 !! config
181 wgCiteBookReferencing=true
182 !! wikitext
183 <ref name=p20></ref>
184 <ref extends=book name=p20>page 20</ref>
185 <references>
186 <ref name=book>book</ref>
187 </references>
188 !! html
189 <p><sup id="cite&#95;ref-p20&#95;1-0" class="reference"><a href="#cite_note-p20-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
190 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; name "p20" defined multiple times with different content</span>
191 </p>
192 <div class="mw-references-wrap"><ol class="references">
193 <li id="cite&#95;note-p20-1"><span class="mw-cite-backlink"><a href="#cite_ref-p20_1-0">↑</a></span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; no text was provided for refs named <code>p20</code></span></li>
194 </ol></div>
195 <p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag with name "book" defined in <code>&lt;references&gt;</code> is not used in prior text.</span>
196 </p>
197 !! end
198
199 !! test
200 T236256 - Naming sub-references is fine
201 !! config
202 wgCiteBookReferencing=true
203 !! wikitext
204 <ref name="a">book</ref>
205 <ref extends="a" name="b">page 2</ref>
206 <ref extends="a" name="c">page 3</ref>
207 <ref name="b" />
208 <ref name="c" />
209 <references />
210 !! html/php
211 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
212 <sup id="cite&#95;ref-b&#95;2-0" class="reference"><a href="#cite_note-b-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
213 <sup id="cite&#95;ref-c&#95;3-0" class="reference"><a href="#cite_note-c-3"><span class="cite-bracket">&#91;</span>1.2<span class="cite-bracket">&#93;</span></a></sup>
214 <sup id="cite&#95;ref-b&#95;2-1" class="reference"><a href="#cite_note-b-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
215 <sup id="cite&#95;ref-c&#95;3-1" class="reference"><a href="#cite_note-c-3"><span class="cite-bracket">&#91;</span>1.2<span class="cite-bracket">&#93;</span></a></sup>
216 </p>
217 <div class="mw-references-wrap"><ol class="references">
218 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
219 <ol class="mw-extended-references"><li id="cite&#95;note-b-2"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-b_2-0">1.1.0</a></sup> <sup><a href="#cite_ref-b_2-1">1.1.1</a></sup></span> <span class="reference-text">page 2</span>
220 </li>
221 <li id="cite&#95;note-c-3"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-c_3-0">1.2.0</a></sup> <sup><a href="#cite_ref-c_3-1">1.2.1</a></sup></span> <span class="reference-text">page 3</span>
222 </li>
223 </ol></li>
224 </ol></div>
225 !! end
226
227 !! test
228 T236256 - Sub-referencing a reference that doesn't exist #1
229 !! config
230 wgCiteBookReferencing=true
231 !! options
232 disabled
233 !! wikitext
234 <ref extends="a">page 1</ref>
235 !! html/php
236 <p><sup id="cite&#95;ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
237 </p>
238 <div class="mw-references-wrap"><ol class="references">
239 <li><span class="mw-cite-backlink">↑ </span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; no text was provided for refs named <code>a</code></span><ol class="mw-extended-references"><li id="cite&#95;note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">page 1</span>
240 </li>
241 </ol></li>
242 </ol></div>
243 !! end
244
245 !! test
246 T236256 - Sub-referencing a reference that doesn't exist #2
247 !! config
248 wgCiteBookReferencing=true
249 !! options
250 disabled
251 !! wikitext
252 <ref>book</ref>
253 <ref extends="a">page 1</ref>
254 !! html/php
255 <p><sup id="cite&#95;ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
256 <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>2.1<span class="cite-bracket">&#93;</span></a></sup>
257 </p>
258 <div class="mw-references-wrap"><ol class="references">
259 <li id="cite&#95;note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">book</span>
260 </li>
261 <li><span class="mw-cite-backlink">↑ </span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; no text was provided for refs named <code>a</code></span><ol class="mw-extended-references"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page 1</span>
262 </li>
263 </ol></li>
264 </ol></div>
265 !! end
266
267 !! test
268 T236256 - Reference with the same name defined twice
269 !! config
270 wgCiteBookReferencing=true
271 !! wikitext
272 <ref name="a">book</ref>
273 <ref name="a">magazine</ref>
274 <ref extends="a">page 1</ref>
275 !! html/php
276 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
277 <sup id="cite&#95;ref-a&#95;1-1" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
278 <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
279 </p>
280 <div class="mw-references-wrap"><ol class="references">
281 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-a_1-0">1.0</a></sup> <sup><a href="#cite_ref-a_1-1">1.1</a></sup></span> <span class="reference-text">book <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; name "a" defined multiple times with different content</span></span>
282 <ol class="mw-extended-references"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page 1</span>
283 </li>
284 </ol></li>
285 </ol></div>
286 !! end
287
288 !! test
289 T236256 - Cannot reuse a name for two sub-references
290 !! config
291 wgCiteBookReferencing=true
292 !! wikitext
293 <ref name="a">book</ref>
294 <ref extends="a" name="b">page 2</ref>
295 <ref extends="a" name="b">page 3</ref>
296 <references />
297 !! html/php
298 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
299 <sup id="cite&#95;ref-b&#95;2-0" class="reference"><a href="#cite_note-b-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
300 <sup id="cite&#95;ref-b&#95;2-1" class="reference"><a href="#cite_note-b-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
301 </p>
302 <div class="mw-references-wrap"><ol class="references">
303 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
304 <ol class="mw-extended-references"><li id="cite&#95;note-b-2"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-b_2-0">1.1.0</a></sup> <sup><a href="#cite_ref-b_2-1">1.1.1</a></sup></span> <span class="reference-text">page 2 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; name "b" defined multiple times with different content</span></span>
305 </li>
306 </ol></li>
307 </ol></div>
308 !! end
309
310 !! test
311 T236256 - Cannot sub-reference a sub-reference (no nesting)
312 !! config
313 wgCiteBookReferencing=true
314 !! wikitext
315 <ref name="a">book</ref>
316 <ref extends="a" name="b">page 2</ref>
317 <ref extends="b">section 3</ref>
318 <references />
319 !! html/php
320 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
321 <sup id="cite&#95;ref-b&#95;2-0" class="reference"><a href="#cite_note-b-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
322 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Extending <code>&lt;ref&gt;</code> tags more than one level deep is not allowed</span>
323 </p>
324 <div class="mw-references-wrap"><ol class="references">
325 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
326 <ol class="mw-extended-references"><li id="cite&#95;note-b-2"><span class="mw-cite-backlink"><a href="#cite_ref-b_2-0">↑</a></span> <span class="reference-text">page 2</span>
327 </li>
328 </ol></li>
329 </ol></div>
330 !! end
331
332 !! test
333 T236256 - Cannot sub-reference a sub-reference (no nesting), specified in reverse order
334 !! config
335 wgCiteBookReferencing=true
336 !! options
337 disabled
338 !! wikitext
339 <ref extends="b">section 3</ref>
340 <ref extends="a" name="b">page 2</ref>
341 <ref name="a">book</ref>
342 <references />
343 !! html/php
344 <p><sup id="cite&#95;ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
345 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; name "b" defined multiple times with different content</span>
346 <sup id="cite&#95;ref-a&#95;2-0" class="reference"><a href="#cite_note-a-2"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup>
347 </p>
348 <div class="mw-references-wrap"><ol class="references">
349 <li><span class="mw-cite-backlink">↑ </span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; no text was provided for refs named <code>b</code></span><ol class="mw-extended-references"><li id="cite&#95;note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">section 3</span>
350 </li>
351 </ol></li>
352 <li id="cite&#95;note-a-2"><span class="mw-cite-backlink"><a href="#cite_ref-a_2-0">↑</a></span> <span class="reference-text">book</span>
353 </li>
354 </ol></div>
355 !! end
356
357 !! test
358 T236256 - Named reference without text
359 !! config
360 wgCiteBookReferencing=true
361 !! wikitext
362 <ref name="a" />
363 <ref extends="a">page 1</ref>
364 !! html/php
365 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
366 <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
367 </p>
368 <div class="mw-references-wrap"><ol class="references">
369 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; no text was provided for refs named <code>a</code></span><ol class="mw-extended-references"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page 1</span>
370 </li>
371 </ol></li>
372 </ol></div>
373 !! end
374
375 !! test
376 T236256 - No text for a sub-reference
377 !! config
378 wgCiteBookReferencing=true
379 !! wikitext
380 <ref name="foo">book</ref>
381 <ref extends="foo" />
382 !! html/php
383 <p><sup id="cite&#95;ref-foo&#95;1-0" class="reference"><a href="#cite_note-foo-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
384 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: The opening <code>&lt;ref&gt;</code> tag is malformed or has a bad name</span>
385 </p>
386 <div class="mw-references-wrap"><ol class="references">
387 <li id="cite&#95;note-foo-1"><span class="mw-cite-backlink"><a href="#cite_ref-foo_1-0">↑</a></span> <span class="reference-text">book</span>
388 </li>
389 </ol></div>
390 !! end
391
392 !! test
393 T236256 - Empty text for a sub-reference
394 !! config
395 wgCiteBookReferencing=true
396 !! wikitext
397 <ref name="foo">book</ref>
398 <ref extends="foo"></ref>
399 !! html/php
400 <p><sup id="cite&#95;ref-foo&#95;1-0" class="reference"><a href="#cite_note-foo-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
401 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; refs with no name must have content</span>
402 </p>
403 <div class="mw-references-wrap"><ol class="references">
404 <li id="cite&#95;note-foo-1"><span class="mw-cite-backlink"><a href="#cite_ref-foo_1-0">↑</a></span> <span class="reference-text">book</span>
405 </li>
406 </ol></div>
407 !! end
408
409 !! test
410 T236256 - De-facto empty text for a sub-reference
411 !! config
412 wgCiteBookReferencing=true
413 !! wikitext
414 <ref name="foo">book</ref>
415 <ref extends="foo"> </ref>
416 !! html/php
417 <p><sup id="cite&#95;ref-foo&#95;1-0" class="reference"><a href="#cite_note-foo-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
418 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; refs with no name must have content</span>
419 </p>
420 <div class="mw-references-wrap"><ol class="references">
421 <li id="cite&#95;note-foo-1"><span class="mw-cite-backlink"><a href="#cite_ref-foo_1-0">↑</a></span> <span class="reference-text">book</span>
422 </li>
423 </ol></div>
424 !! end
425
426 !! test
427 T236256 - Everything in the same group
428 !! config
429 wgCiteBookReferencing=true
430 !! wikitext
431 <ref group="g1" name="a">book</ref>
432 <ref group="g1" extends="a" name="b">page</ref>
433 <ref group="g1" name="b" />
434 <references group="g1"/>
435 !! html/php
436 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>g1 1<span class="cite-bracket">&#93;</span></a></sup>
437 <sup id="cite&#95;ref-b&#95;2-0" class="reference"><a href="#cite_note-b-2"><span class="cite-bracket">&#91;</span>g1 1.1<span class="cite-bracket">&#93;</span></a></sup>
438 <sup id="cite&#95;ref-b&#95;2-1" class="reference"><a href="#cite_note-b-2"><span class="cite-bracket">&#91;</span>g1 1.1<span class="cite-bracket">&#93;</span></a></sup>
439 </p>
440 <div class="mw-references-wrap"><ol class="references">
441 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
442 <ol class="mw-extended-references"><li id="cite&#95;note-b-2"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-b_2-0">1.1.0</a></sup> <sup><a href="#cite_ref-b_2-1">1.1.1</a></sup></span> <span class="reference-text">page</span>
443 </li>
444 </ol></li>
445 </ol></div>
446 !! end
447
448 !! test
449 T236256 - Sub-reference in named group cannot access parent from another named group
450 !! config
451 wgCiteBookReferencing=true
452 !! options
453 disabled
454 !! wikitext
455 <ref group="g1" name="a">book</ref>
456 <ref group="g2" extends="a">page</ref>
457 <references group="g1"/>
458 <references group="g2"/>
459 !! html/php
460 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>g1 1<span class="cite-bracket">&#93;</span></a></sup>
461 <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>g2 1.1<span class="cite-bracket">&#93;</span></a></sup>
462 </p>
463 <div class="mw-references-wrap"><ol class="references">
464 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
465 </li>
466 </ol></div>
467 <div class="mw-references-wrap"><ol class="references">
468 <li><span class="mw-cite-backlink">↑ </span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; no text was provided for refs named <code>a</code></span><ol class="mw-extended-references"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page</span>
469 </li>
470 </ol></li>
471 </ol></div>
472 !! end
473
474 !! test
475 T236256 - Sub-reference in the unnamed default group doesn't collide with refs from other groups
476 !! config
477 wgCiteBookReferencing=true
478 !! options
479 disabled
480 !! wikitext
481 <ref group="g1" name="a">book</ref>
482 <ref extends="a">page</ref>
483 <references group="g1"/>
484 !! html/php
485 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>g1 1<span class="cite-bracket">&#93;</span></a></sup>
486 <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
487 </p>
488 <div class="mw-references-wrap"><ol class="references">
489 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
490 </li>
491 </ol></div>
492 <div class="mw-references-wrap"><ol class="references">
493 <li><span class="mw-cite-backlink">↑ </span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; no text was provided for refs named <code>a</code></span><ol class="mw-extended-references"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page</span>
494 </li>
495 </ol></li>
496 </ol></div>
497 !! end
498
499 !! test
500 T236256 - Sub-reference in named group cannot access parent from unnamed default group
501 !! config
502 wgCiteBookReferencing=true
503 !! options
504 disabled
505 !! wikitext
506 <ref name="a">book</ref>
507 <ref group="g1" extends="a">page</ref>
508 <references group="g1"/>
509 !! html/php
510 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
511 <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>g1 1.1<span class="cite-bracket">&#93;</span></a></sup>
512 </p>
513 <div class="mw-references-wrap"><ol class="references">
514 <li><span class="mw-cite-backlink">↑ </span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; no text was provided for refs named <code>a</code></span><ol class="mw-extended-references"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page</span>
515 </li>
516 </ol></li>
517 </ol></div>
518 <div class="mw-references-wrap"><ol class="references">
519 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
520 </li>
521 </ol></div>
522 !! end
523
524 !! test
525 T236256 - Sub-referencing a multi-part parent should be fine
526 !! config
527 wgCiteBookReferencing=true
528 !! wikitext
529 <ref name="a">part 1</ref>
530 <ref follow="a">part 2</ref>
531 <ref extends="a">ok</ref>
532 <references />
533 !! html/php
534 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
535 </p><p><sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
536 </p>
537 <div class="mw-references-wrap"><ol class="references">
538 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">part 1 part 2</span>
539 <ol class="mw-extended-references"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">ok</span>
540 </li>
541 </ol></li>
542 </ol></div>
543 !! end
544
545 # TODO: T242227 - Should render an error at the third reference.
546 !! test
547 T236256 - Dont allow splitting a sub-reference for now
548 !! config
549 wgCiteBookReferencing=true
550 !! wikitext
551 <ref name="a">book</ref>
552 <ref extends="a" name="b">page 2</ref>
553 <ref follow="b">and page 3 the same time?</ref>
554 <references />
555 !! html/php
556 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
557 <sup id="cite&#95;ref-b&#95;2-0" class="reference"><a href="#cite_note-b-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
558 </p>
559 <div class="mw-references-wrap"><ol class="references">
560 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
561 <ol class="mw-extended-references"><li id="cite&#95;note-b-2"><span class="mw-cite-backlink"><a href="#cite_ref-b_2-0">↑</a></span> <span class="reference-text">page 2 and page 3 the same time?</span>
562 </li>
563 </ol></li>
564 </ol></div>
565 !! end
566
567 !! test
568 T236256 - Cannot be a follow up and a sub-reference the same time
569 !! config
570 wgCiteBookReferencing=true
571 !! wikitext
572 <ref name="a">book 1</ref>
573 <ref follow="a" extends="a">huh?</ref>
574 <references />
575 !! html/php
576 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
577 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: A <code>&lt;ref follow="…"&gt;</code> tag that is the continuation of a previous one can neither be named individually nor extended</span>
578 </p>
579 <div class="mw-references-wrap"><ol class="references">
580 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book 1</span>
581 </li>
582 </ol></div>
583 !! end
584
585 !! test
586 T236256 - Cannot be a follow up and a sub-reference the same time, even when referencing different parents
587 !! config
588 wgCiteBookReferencing=true
589 !! wikitext
590 <ref name="a">book 1</ref>
591 <ref name="b">book 2</ref>
592 <ref follow="a" extends="b">huh?</ref>
593 <references />
594 !! html/php
595 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
596 <sup id="cite&#95;ref-b&#95;2-0" class="reference"><a href="#cite_note-b-2"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup>
597 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: A <code>&lt;ref follow="…"&gt;</code> tag that is the continuation of a previous one can neither be named individually nor extended</span>
598 </p>
599 <div class="mw-references-wrap"><ol class="references">
600 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book 1</span>
601 </li>
602 <li id="cite&#95;note-b-2"><span class="mw-cite-backlink"><a href="#cite_ref-b_2-0">↑</a></span> <span class="reference-text">book 2</span>
603 </li>
604 </ol></div>
605 !! end
606
607 !! test
608 Sub-referencing a list-defined parent that doesn't appear in the text, but in <references>
609 !! config
610 wgCiteBookReferencing=true
611 !! options
612 disabled
613 !! wikitext
614 <ref extends="a">Page 2</ref>
615 <references>
616 <ref name="a">Book</ref>
617 </references>
618 !! html
619 <p><sup id="cite&#95;ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
620 </p>
621 <div class="mw-references-wrap"><ol class="references">
622 <li><span class="mw-cite-backlink">↑ </span> <span class="reference-text">Book</span>
623 <ol class="mw-extended-references"><li id="cite&#95;note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">Page 2</span>
624 </li>
625 </ol></li>
626 </ol></div>
627 !! end
628
629 !! test
630 T239810: Sub-referencing a list-defined parent that doesn't appear in the text, but in {{#tag:references}}
631 !! config
632 wgCiteBookReferencing=true
633 !! options
634 disabled
635 !! wikitext
636 <ref extends="a">Page 2</ref>
637 {{#tag:references|
638 <ref name="a">Book</ref>
639 }}
640 !! html
641 <p><sup id="cite&#95;ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
642 </p>
643 <div class="mw-references-wrap"><ol class="references">
644 <li><span class="mw-cite-backlink">↑ </span> <span class="reference-text">Book</span>
645 <ol class="mw-extended-references"><li id="cite&#95;note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">Page 2</span>
646 </li>
647 </ol></li>
648 </ol></div>
649 !! end
650
651 !! test
652 A list-defined sub-reference when the <references> tag is created using #tag
653 !! config
654 wgCiteBookReferencing=true
655 !! wikitext
656 <ref name="foo">BAR</ref>
657 <ref name="footwo" />
658 {{#tag:references|
659 <ref name="footwo" extends="foo">p. 10</ref>
660 }}
661 !! html
662 <p><sup id="cite&#95;ref-foo&#95;1-0" class="reference"><a href="#cite_note-foo-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
663 <sup id="cite&#95;ref-footwo&#95;2-0" class="reference"><a href="#cite_note-footwo-2"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup>
664 </p>
665 <div class="mw-references-wrap"><ol class="references">
666 <li id="cite&#95;note-foo-1"><span class="mw-cite-backlink"><a href="#cite_ref-foo_1-0">↑</a></span> <span class="reference-text">BAR</span>
667 </li>
668 <li id="cite&#95;note-footwo-2"><span class="mw-cite-backlink"><a href="#cite_ref-footwo_2-0">↑</a></span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; no text was provided for refs named <code>footwo</code></span></li>
669 </ol></div>
670 !! end
671
672 !! test
673 Sub-referencing a list-defined parent when the <references> tag is created using #tag
674 !! config
675 wgCiteBookReferencing=true
676 !! wikitext
677 <ref>BAR</ref>
678 <ref name="footwo" extends="foo">page 7</ref>
679 <ref name="foo" />
680 {{#tag:references|
681 <ref name="foo">book name</ref>
682 }}
683 !! html
684 <p><sup id="cite&#95;ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
685 <sup id="cite&#95;ref-footwo&#95;2-0" class="reference"><a href="#cite_note-footwo-2"><span class="cite-bracket">&#91;</span>2.1<span class="cite-bracket">&#93;</span></a></sup>
686 <sup id="cite&#95;ref-foo&#95;3-0" class="reference"><a href="#cite_note-foo-3"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup>
687 </p>
688 <div class="mw-references-wrap"><ol class="references">
689 <li id="cite&#95;note-1"><span class="mw-cite-backlink"><a href="#cite_ref-1">↑</a></span> <span class="reference-text">BAR</span>
690 </li>
691 <li id="cite&#95;note-foo-3"><span class="mw-cite-backlink"><a href="#cite_ref-foo_3-0">↑</a></span> <span class="reference-text">book name</span>
692 <ol class="mw-extended-references"><li id="cite&#95;note-footwo-2"><span class="mw-cite-backlink"><a href="#cite_ref-footwo_2-0">↑</a></span> <span class="reference-text">page 7</span>
693 </li>
694 </ol></li>
695 </ol></div>
696 !! end
697
698 !! test
699 Interleaved sub-reference groups
700 !! config
701 wgCiteBookReferencing=true
702 !! wikitext
703 <ref name="a">text-a</ref>
704 <ref name="c">text-c</ref>
705
706 <ref extends="a">page b</ref>
707 <ref extends="c">page d</ref>
708 <references />
709 !! html
710 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
711 <sup id="cite&#95;ref-c&#95;2-0" class="reference"><a href="#cite_note-c-2"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup>
712 </p><p><sup id="cite&#95;ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
713 <sup id="cite&#95;ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">&#91;</span>2.1<span class="cite-bracket">&#93;</span></a></sup>
714 </p>
715 <div class="mw-references-wrap"><ol class="references">
716 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">text-a</span>
717 <ol class="mw-extended-references"><li id="cite&#95;note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">page b</span>
718 </li>
719 </ol></li>
720 <li id="cite&#95;note-c-2"><span class="mw-cite-backlink"><a href="#cite_ref-c_2-0">↑</a></span> <span class="reference-text">text-c</span>
721 <ol class="mw-extended-references"><li id="cite&#95;note-4"><span class="mw-cite-backlink"><a href="#cite_ref-4">↑</a></span> <span class="reference-text">page d</span>
722 </li>
723 </ol></li>
724 </ol></div>
725 !! end
726
727 !! test
728 Multiple groups with sub-references
729 !! config
730 wgCiteBookReferencing=true
731 !! wikitext
732 <ref name="a">text-a</ref>
733 <ref extends="a">page b</ref>
734 <references />
735
736 <ref name="c">text-c</ref>
737 <ref extends="c">page d</ref>
738 <references />
739 !! html
740 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
741 <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
742 </p>
743 <div class="mw-references-wrap"><ol class="references">
744 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">text-a</span>
745 <ol class="mw-extended-references"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page b</span>
746 </li>
747 </ol></li>
748 </ol></div>
749 <p><sup id="cite&#95;ref-c&#95;3-0" class="reference"><a href="#cite_note-c-3"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
750 <sup id="cite&#95;ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
751 </p>
752 <div class="mw-references-wrap"><ol class="references">
753 <li id="cite&#95;note-c-3"><span class="mw-cite-backlink"><a href="#cite_ref-c_3-0">↑</a></span> <span class="reference-text">text-c</span>
754 <ol class="mw-extended-references"><li id="cite&#95;note-4"><span class="mw-cite-backlink"><a href="#cite_ref-4">↑</a></span> <span class="reference-text">page d</span>
755 </li>
756 </ol></li>
757 </ol></div>
758 !! end
759
760 !! test
761 Multiple groups with sub-references, duplicated names across groups
762 !! config
763 wgCiteBookReferencing=true
764 !! wikitext
765 <ref name="a">text-a</ref>
766 <ref extends="a">page b</ref>
767 <references />
768
769 <ref name="a">text-c</ref>
770 <ref extends="a">page d</ref>
771 <references />
772 !! html
773 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
774 <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
775 </p>
776 <div class="mw-references-wrap"><ol class="references">
777 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">text-a</span>
778 <ol class="mw-extended-references"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page b</span>
779 </li>
780 </ol></li>
781 </ol></div>
782 <p><sup id="cite&#95;ref-a&#95;3-0" class="reference"><a href="#cite_note-a-3"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
783 <sup id="cite&#95;ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
784 </p>
785 <div class="mw-references-wrap"><ol class="references">
786 <li id="cite&#95;note-a-3"><span class="mw-cite-backlink"><a href="#cite_ref-a_3-0">↑</a></span> <span class="reference-text">text-c</span>
787 <ol class="mw-extended-references"><li id="cite&#95;note-4"><span class="mw-cite-backlink"><a href="#cite_ref-4">↑</a></span> <span class="reference-text">page d</span>
788 </li>
789 </ol></li>
790 </ol></div>
791 !! end
792
793 !! test
794 Intervening ref before sub-reference
795 !! config
796 wgCiteBookReferencing=true
797 !! wikitext
798 <ref name="a">book</ref>
799 <ref>another</ref>
800 <ref extends="a">page 2</ref>
801
802 <references />
803 !! html/php
804 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
805 <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup>
806 <sup id="cite&#95;ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
807 </p>
808 <div class="mw-references-wrap"><ol class="references">
809 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book</span>
810 <ol class="mw-extended-references"><li id="cite&#95;note-3"><span class="mw-cite-backlink"><a href="#cite_ref-3">↑</a></span> <span class="reference-text">page 2</span>
811 </li>
812 </ol></li>
813 <li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">another</span>
814 </li>
815 </ol></div>
816 !! end
817
818 !! test
819 Normal ref after sub-reference
820 !! config
821 wgCiteBookReferencing=true
822 !! wikitext
823 <ref name="a">text-a</ref>
824 <ref extends="a">page b</ref>
825
826 <ref name="c">text-c</ref>
827 <references />
828 !! html
829 <p><sup id="cite&#95;ref-a&#95;1-0" class="reference"><a href="#cite_note-a-1"><span class="cite-bracket">&#91;</span>1<span class="cite-bracket">&#93;</span></a></sup>
830 <sup id="cite&#95;ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
831 </p><p><sup id="cite&#95;ref-c&#95;3-0" class="reference"><a href="#cite_note-c-3"><span class="cite-bracket">&#91;</span>2<span class="cite-bracket">&#93;</span></a></sup>
832 </p>
833 <div class="mw-references-wrap"><ol class="references">
834 <li id="cite&#95;note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">text-a</span>
835 <ol class="mw-extended-references"><li id="cite&#95;note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">page b</span>
836 </li>
837 </ol></li>
838 <li id="cite&#95;note-c-3"><span class="mw-cite-backlink"><a href="#cite_ref-c_3-0">↑</a></span> <span class="reference-text">text-c</span>
839 </li>
840 </ol></div>
841 !! end
842
843 !! test
844 T242110: Copy-pasted, named sub-references should be merged and not mess with the numbering
845 !! config
846 wgCiteBookReferencing=true
847 !! options
848 disabled
849 !! wikitext
850 <ref name="a1" extends="a">a1</ref>
851 <ref name="a1" extends="a">a1</ref>
852 <references>
853 <ref name="a">a</ref>
854 </references>
855 !! html
856 <p><sup id="cite&#95;ref-a1&#95;1-0" class="reference"><a href="#cite_note-a1-1"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
857 <sup id="cite&#95;ref-a1&#95;1-1" class="reference"><a href="#cite_note-a1-1"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
858 </p>
859 <div class="mw-references-wrap"><ol class="references">
860 <li><span class="mw-cite-backlink">↑ </span> <span class="reference-text">a</span>
861 <ol class="mw-extended-references"><li id="cite&#95;note-a1-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-a1_1-0">1.1.0</a></sup> <sup><a href="#cite_ref-a1_1-1">1.1.1</a></sup></span> <span class="reference-text">a1</span>
862 </li>
863 </ol></li>
864 </ol></div>
865 !! end
866
867 !! test
868 T242110: Reused sub-references should be merged and not mess with the numbering
869 !! config
870 wgCiteBookReferencing=true
871 !! options
872 disabled
873 !! wikitext
874 <ref name="a1" extends="a">a1</ref>
875 <ref name="a1" extends="a" />
876 <references>
877 <ref name="a">a</ref>
878 </references>
879 !! html
880 <p><sup id="cite&#95;ref-a1&#95;1-0" class="reference"><a href="#cite_note-a1-1"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
881 <sup id="cite&#95;ref-a1&#95;1-1" class="reference"><a href="#cite_note-a1-1"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
882 </p>
883 <div class="mw-references-wrap"><ol class="references">
884 <li><span class="mw-cite-backlink">↑ </span> <span class="reference-text">a</span>
885 <ol class="mw-extended-references"><li id="cite&#95;note-a1-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-a1_1-0">1.1.0</a></sup> <sup><a href="#cite_ref-a1_1-1">1.1.1</a></sup></span> <span class="reference-text">a1</span>
886 </li>
887 </ol></li>
888 </ol></div>
889 !! end
890
891 !! test
892 Reused sub-references can be rolled back without messing up numbering
893 !! config
894 wgCiteBookReferencing=true
895 !! options
896 disabled
897 !! wikitext
898 <ref name="a1" extends="a" />
899 <ref group="g" name="a1" extends="a" />
900 {{#tag:references|
901 <ref name="a">a in group</ref>
902 <ref name="a1" extends="a">a1 in group</ref>
903 |group=g}}
904 <ref name="a1" extends="a">a1</ref>
905 <references>
906 <ref name="a">a</ref>
907 </references>
908 !! html
909 <p><sup id="cite&#95;ref-a1&#95;1-0" class="reference"><a href="#cite_note-a1-1"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
910 <sup id="cite&#95;ref-a1&#95;2-0" class="reference"><a href="#cite_note-a1-2"><span class="cite-bracket">&#91;</span>g 1.1<span class="cite-bracket">&#93;</span></a></sup>
911 </p>
912 <div class="mw-references-wrap"><ol class="references">
913 <li><span class="mw-cite-backlink">↑ </span> <span class="reference-text">a in group</span>
914 <ol class="mw-extended-references"><li id="cite&#95;note-a1-2"><span class="mw-cite-backlink"><a href="#cite_ref-a1_2-0">↑</a></span> <span class="reference-text">a1 in group</span>
915 </li>
916 </ol></li>
917 </ol></div>
918 <p><sup id="cite&#95;ref-a1&#95;1-1" class="reference"><a href="#cite_note-a1-1"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
919 </p>
920 <div class="mw-references-wrap"><ol class="references">
921 <li><span class="mw-cite-backlink">↑ </span> <span class="reference-text">a in group <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; name "a" defined multiple times with different content</span></span>
922 <ol class="mw-extended-references"><li id="cite&#95;note-a1-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-a1_1-0">1.1.0</a></sup> <sup><a href="#cite_ref-a1_1-1">1.1.1</a></sup></span> <span class="reference-text">a1</span>
923 </li>
924 </ol></li>
925 </ol></div>
926 !! end
927
928 !! test
929 T242110: Bad sub-referencing attributes on reused sub-references should report an error
930 !! config
931 wgCiteBookReferencing=true
932 !! options
933 disabled
934 !! wikitext
935 <ref name="a1" extends="a">a1</ref>
936 <ref name="a1" extends="unknown" />
937 <references>
938 <ref name="a">a</ref>
939 </references>
940 !! html
941 <p><sup id="cite&#95;ref-a1&#95;1-0" class="reference"><a href="#cite_note-a1-1"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
942 <sup id="cite&#95;ref-a1&#95;1-1" class="reference"><a href="#cite_note-a1-1"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
943 </p>
944 <div class="mw-references-wrap"><ol class="references">
945 <li><span class="mw-cite-backlink">↑ </span> <span class="reference-text">a</span>
946 <ol class="mw-extended-references"><li id="cite&#95;note-a1-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-a1_1-0">1.1.0</a></sup> <sup><a href="#cite_ref-a1_1-1">1.1.1</a></sup></span> <span class="reference-text">a1 <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag; name "a1" defined multiple times with different content</span></span>
947 </li>
948 </ol></li>
949 </ol></div>
950 !! end
951
952 !! test
953 T242110: Copy-pasted, named sub-references should appear in proper order
954 !! config
955 wgCiteBookReferencing=true
956 !! options
957 disabled
958 !! wikitext
959 <ref name="a1" extends="a">a1</ref>
960 <ref name="a1" extends="a">a1</ref>
961 <ref name="b1" extends="b">b1</ref>
962 <ref name="b1" extends="b" />
963 <ref name="c1" extends="c">c1</ref>
964 <ref name="c1" />
965 <references>
966 <ref name="a">a</ref>
967 <ref name="b">a</ref>
968 <ref name="c">a</ref>
969 </references>
970 !! html
971 <p><sup id="cite&#95;ref-a1&#95;1-0" class="reference"><a href="#cite_note-a1-1"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
972 <sup id="cite&#95;ref-a1&#95;1-1" class="reference"><a href="#cite_note-a1-1"><span class="cite-bracket">&#91;</span>1.1<span class="cite-bracket">&#93;</span></a></sup>
973 <sup id="cite&#95;ref-b1&#95;2-0" class="reference"><a href="#cite_note-b1-2"><span class="cite-bracket">&#91;</span>2.1<span class="cite-bracket">&#93;</span></a></sup>
974 <sup id="cite&#95;ref-b1&#95;2-1" class="reference"><a href="#cite_note-b1-2"><span class="cite-bracket">&#91;</span>2.1<span class="cite-bracket">&#93;</span></a></sup>
975 <sup id="cite&#95;ref-c1&#95;3-0" class="reference"><a href="#cite_note-c1-3"><span class="cite-bracket">&#91;</span>3.1<span class="cite-bracket">&#93;</span></a></sup>
976 <sup id="cite&#95;ref-c1&#95;3-1" class="reference"><a href="#cite_note-c1-3"><span class="cite-bracket">&#91;</span>3.1<span class="cite-bracket">&#93;</span></a></sup>
977 </p>
978 <div class="mw-references-wrap"><ol class="references">
979 <li><span class="mw-cite-backlink">↑ </span> <span class="reference-text">a</span>
980 <ol class="mw-extended-references"><li id="cite&#95;note-a1-1"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-a1_1-0">1.1.0</a></sup> <sup><a href="#cite_ref-a1_1-1">1.1.1</a></sup></span> <span class="reference-text">a1</span>
981 </li>
982 </ol></li>
983 <li><span class="mw-cite-backlink">↑ </span> <span class="reference-text">a</span>
984 <ol class="mw-extended-references"><li id="cite&#95;note-b1-2"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-b1_2-0">2.1.0</a></sup> <sup><a href="#cite_ref-b1_2-1">2.1.1</a></sup></span> <span class="reference-text">b1</span>
985 </li>
986 </ol></li>
987 <li><span class="mw-cite-backlink">↑ </span> <span class="reference-text">a</span>
988 <ol class="mw-extended-references"><li id="cite&#95;note-c1-3"><span class="mw-cite-backlink">↑ <sup><a href="#cite_ref-c1_3-0">3.1.0</a></sup> <sup><a href="#cite_ref-c1_3-1">3.1.1</a></sup></span> <span class="reference-text">c1</span>
989 </li>
990 </ol></li>
991 </ol></div>
992 !! end