mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-09-24 02:38:57 +00:00
Minimal support for bookreferencing tag
Allows the "refines" attribute when the feature flag is set, but doesn't render. This is part of our rollback strategy, so that we aren't left with invalid wikitext in case of undeployment. Bug: T236257 Change-Id: I936be0e62dccb46caeb84162d2c5166956fd9916
This commit is contained in:
parent
4373cb27af
commit
5e8d48b331
|
@ -61,6 +61,12 @@ class Cite {
|
|||
*/
|
||||
private const CACHE_DURATION_ONFETCH = 18000;
|
||||
|
||||
/**
|
||||
* Wikitext attribute name for Book Referencing.
|
||||
* TODO: Still under discussion.
|
||||
*/
|
||||
public const REFINES_ATTRIBUTE = 'refines';
|
||||
|
||||
/**
|
||||
* Datastructure representing <ref> input, in the format of:
|
||||
* <code>
|
||||
|
@ -391,6 +397,7 @@ class Cite {
|
|||
* "group" : Group to which it belongs. Needs to be passed to <references /> too.
|
||||
* "follow" : If the current reference is the continuation of another, key of that reference.
|
||||
* "dir" : set direction of text (ltr/rtl)
|
||||
* "refines": Points to a named reference which serves as the context for this reference.
|
||||
*
|
||||
* @param string[] $argv The argument vector
|
||||
* @return (string|false|null)[] An array with exactly four elements, where each is a string on
|
||||
|
@ -398,6 +405,8 @@ class Cite {
|
|||
* @return-taint tainted
|
||||
*/
|
||||
private function refArg( array $argv ) {
|
||||
global $wgCiteBookReferencing;
|
||||
|
||||
$group = null;
|
||||
$key = null;
|
||||
$follow = null;
|
||||
|
@ -438,6 +447,11 @@ class Cite {
|
|||
$group = $argv['group'];
|
||||
unset( $argv['group'] );
|
||||
}
|
||||
if ( $wgCiteBookReferencing && isset( $argv[self::REFINES_ATTRIBUTE] ) ) {
|
||||
// TODO: Extract the name and return it.
|
||||
// $refines = trim( $argv[self::REFINES_ATTRIBUTE] );
|
||||
unset( $argv[self::REFINES_ATTRIBUTE] );
|
||||
}
|
||||
|
||||
if ( $argv !== [] ) {
|
||||
// Invalid key
|
||||
|
|
|
@ -1709,3 +1709,38 @@ wgFragmentMode=['legacy']
|
|||
<p><sup about="#mwt2" class="mw-ref" id="cite_ref-füllen_1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{"name":"füllen"},"body":{"id":"mw-reference-text-cite_note-füllen-1"}}'><a href="./Parser_test#cite_note-füllen_1-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></p>
|
||||
<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt3" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-füllen-1" id="cite_note-füllen-1"><a href="./Parser_test#cite_ref-füllen-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-füllen-1" class="mw-reference-text" data-parsoid="{}">[bar]</span></li></ol>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
Refines tag rejected by default
|
||||
!! config
|
||||
wgCiteBookReferencing=false
|
||||
!! wikitext
|
||||
<ref name="parent">[foo]</ref>
|
||||
<ref refines="parent">[bar]</ref>
|
||||
!! html/php
|
||||
<p><sup id="cite_ref-parent_1-0" class="reference"><a href="#cite_note-parent-1">[1]</a></sup>
|
||||
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code><ref></code> tag;
|
||||
</p>
|
||||
invalid names, e.g. too many</span><div class="mw-references-wrap"><ol class="references">
|
||||
<li id="cite_note-parent-1"><span class="mw-cite-backlink"><a href="#cite_ref-parent_1-0">↑</a></span> <span class="reference-text">[foo]</span>
|
||||
</li>
|
||||
</ol></div>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
Refines tag allowed with feature flag set
|
||||
!! config
|
||||
wgCiteBookReferencing=true
|
||||
!! wikitext
|
||||
<ref name="parent">[foo]</ref>
|
||||
<ref refines="parent">[bar]</ref>
|
||||
!! html/php
|
||||
<p><sup id="cite_ref-parent_1-0" class="reference"><a href="#cite_note-parent-1">[1]</a></sup>
|
||||
</p>
|
||||
<sup id="cite_ref-2" class="reference"><a href="#cite_note-2">[2]</a></sup><div class="mw-references-wrap"><ol class="references">
|
||||
<li id="cite_note-parent-1"><span class="mw-cite-backlink"><a href="#cite_ref-parent_1-0">↑</a></span> <span class="reference-text">[foo]</span>
|
||||
</li>
|
||||
<li id="cite_note-2"><span class="mw-cite-backlink"><a href="#cite_ref-2">↑</a></span> <span class="reference-text">[bar]</span>
|
||||
</li>
|
||||
</ol></div>
|
||||
!! end
|
||||
|
|
Loading…
Reference in a new issue