diff --git a/includes/Cite.php b/includes/Cite.php index d8af7d34d..b12545203 100644 --- a/includes/Cite.php +++ b/includes/Cite.php @@ -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 input, in the format of: * @@ -391,6 +397,7 @@ class Cite { * "group" : Group to which it belongs. Needs to be passed to 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 diff --git a/tests/parser/citeParserTests.txt b/tests/parser/citeParserTests.txt index db689c4fb..d5dd509f9 100644 --- a/tests/parser/citeParserTests.txt +++ b/tests/parser/citeParserTests.txt @@ -1709,3 +1709,38 @@ wgFragmentMode=['legacy']

[1]

  1. [bar]
!! end + +!! test +Refines tag rejected by default +!! config +wgCiteBookReferencing=false +!! wikitext +[foo] +[bar] +!! html/php +

[1] +Cite error: Invalid <ref> tag; +

+invalid names, e.g. too many
    +
  1. [foo] +
  2. +
+!! end + +!! test +Refines tag allowed with feature flag set +!! config +wgCiteBookReferencing=true +!! wikitext +[foo] +[bar] +!! html/php +

[1] +

+[2]
    +
  1. [foo] +
  2. +
  3. [bar] +
  4. +
+!! end