mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-09-23 10:20:12 +00:00
Implement support to convert extended notes with auto names
To make sure also the parent gets a name even if it is not re-used we need to iterate the list of reference to see if there's at least one child that matches the parent. The rest will be taken care of by getUniqueListKey that makes sure that the matching temporary names will result in matching literal names. TODO: - Write a ve.dm.Convertor test which shows the auto-name being added. Bug: T367031 Change-Id: I6ef42c8ffc8a4ff9224bfb2a910682d2c44f0dd2
This commit is contained in:
parent
aa5368ad32
commit
15bcfdcc70
|
@ -124,6 +124,10 @@ ve.dm.MWReferenceNode.static.toDomElements = function ( dataElement, doc, conver
|
|||
.getNodeGroup( dataElement.attributes.listGroup )
|
||||
.keyedNodes[ dataElement.attributes.listKey ];
|
||||
|
||||
const extendsNodes = converter.internalList.getNodeGroup( dataElement.attributes.listGroup ).firstNodes.filter(
|
||||
( node ) => node.element.attributes.extendsRef === dataElement.attributes.listKey
|
||||
);
|
||||
|
||||
let contentsAlreadySet = false;
|
||||
if ( setContents ) {
|
||||
// Check if a previous node has already set the content. If so, we don't overwrite this
|
||||
|
@ -200,8 +204,13 @@ ve.dm.MWReferenceNode.static.toDomElements = function ( dataElement, doc, conver
|
|||
let extendsAttr;
|
||||
const extendsKeyParts = dataElement.attributes.extendsRef.match( this.listKeyRegex );
|
||||
if ( extendsKeyParts[ 1 ] === 'auto' ) {
|
||||
// TODO auto generated names that match the parent
|
||||
extendsAttr = ':0-FIXME-T367031';
|
||||
// Allocate a unique list key, then strip the 'literal/'' prefix
|
||||
extendsAttr = converter.internalList.getUniqueListKey(
|
||||
dataElement.attributes.listGroup,
|
||||
dataElement.attributes.extendsRef,
|
||||
// Generate a name starting with ':' to distinguish it from normal names
|
||||
'literal/:'
|
||||
).slice( 'literal/'.length );
|
||||
} else {
|
||||
extendsAttr = extendsKeyParts[ 2 ];
|
||||
}
|
||||
|
@ -213,7 +222,7 @@ ve.dm.MWReferenceNode.static.toDomElements = function ( dataElement, doc, conver
|
|||
const listKeyParts = dataElement.attributes.listKey.match( this.listKeyRegex );
|
||||
if ( listKeyParts[ 1 ] === 'auto' ) {
|
||||
// Only render a name if this key was reused
|
||||
if ( keyedNodes.length > 1 ) {
|
||||
if ( keyedNodes.length > 1 || extendsNodes.length ) {
|
||||
// Allocate a unique list key, then strip the 'literal/'' prefix
|
||||
name = converter.internalList.getUniqueListKey(
|
||||
dataElement.attributes.listGroup,
|
||||
|
|
Loading…
Reference in a new issue