mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Merge "Update documentation of ReferenceStack::$refs data structure"
This commit is contained in:
commit
ef65edf6e9
|
@ -15,48 +15,38 @@ use StripState;
|
||||||
class ReferenceStack {
|
class ReferenceStack {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Datastructure representing <ref> input, in the format of:
|
* Data structure representing all <ref> tags parsed so far, indexed by group name (an empty
|
||||||
* <code>
|
* string for the default group) and reference name.
|
||||||
* [
|
|
||||||
* 'user supplied' => [
|
|
||||||
* 'text' => 'user supplied reference & key',
|
|
||||||
* 'count' => 1, // occurs twice
|
|
||||||
* 'number' => 1, // The first reference, we want
|
|
||||||
* // all occourances of it to
|
|
||||||
* // use the same number
|
|
||||||
* ],
|
|
||||||
* 0 => [
|
|
||||||
* 'text' => 'Anonymous reference',
|
|
||||||
* 'count' => -1,
|
|
||||||
* ],
|
|
||||||
* 1 => [
|
|
||||||
* 'text' => 'Another anonymous reference',
|
|
||||||
* 'count' => -1,
|
|
||||||
* ],
|
|
||||||
* 'some key' => [
|
|
||||||
* 'text' => 'this one occurs once'
|
|
||||||
* 'count' => 0,
|
|
||||||
* 'number' => 4
|
|
||||||
* ],
|
|
||||||
* 3 => 'more stuff'
|
|
||||||
* ];
|
|
||||||
* </code>
|
|
||||||
*
|
*
|
||||||
* This works because:
|
* References without a name get a numeric index, starting from 0. Conflicts are avoided by
|
||||||
* * PHP's datastructures are guaranteed to be returned in the
|
* disallowing numeric names (e.g. <ref name="1">) in {@see Cite::validateRef}.
|
||||||
* order that things are inserted into them (unless you mess
|
|
||||||
* with that)
|
|
||||||
* * User supplied keys can't be integers, therefore avoiding
|
|
||||||
* conflict with anonymous keys
|
|
||||||
*
|
*
|
||||||
* In this structure, 'key' will either be an autoincrementing integer.
|
* Elements (almost all are optional):
|
||||||
|
* - 'name': The original name="…" of a reference (also used as the array key), or null for
|
||||||
|
* anonymous references.
|
||||||
|
* - 'key': Sequence number for all references, no matter which group, starting from 1. Used to
|
||||||
|
* generate IDs and anchors.
|
||||||
|
* - 'number': Sequence number per group, starting from 1. To be used in the [1] footnote
|
||||||
|
* marker.
|
||||||
|
* - 'extendsIndex': Sequence number for sub-references with the same extends="…", starting
|
||||||
|
* from 1. Used in addition to the 'number' in [1.1] footnote markers.
|
||||||
|
* - 'count': How often a reference is reused. 0 means not reused, i.e. the reference appears
|
||||||
|
* only one time. -1 for anonymous references that cannot be reused.
|
||||||
|
* - 'extends': Marks a sub-reference. Points to the parent reference by name.
|
||||||
|
* - 'follow': Marks a broken follow="…" that appears before it's parent. This is not allowed.
|
||||||
|
* A valid follow is immediatelly resolved and not marked in any way.
|
||||||
|
* - '__placeholder__': Temporarily marks an incomplete parent reference that was referenced via
|
||||||
|
* extends="…" before it exists.
|
||||||
|
* - 'text': The content inside the <ref>…</ref> tag. Null for <ref /> without content. Also
|
||||||
|
* null for <ref></ref> without any non-whitespace content.
|
||||||
|
* - 'dir': Direction of the text. Should either be "ltr" or "rtl".
|
||||||
*
|
*
|
||||||
* @var array[][]
|
* @var array[][]
|
||||||
*/
|
*/
|
||||||
private $refs = [];
|
private $refs = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count for user displayed output (ref[1], ref[2], ...)
|
* Auto-incrementing sequence number for all <ref>, no matter which group
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue