mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 06:54:00 +00:00
Gallery: shift TSRs in the DOM, rather than fibbing about srcOffset
Passing srcOffsets which don't actually correspond to actual regions of the source wikitext cause problems in the token offset conversion code. Instead, parse the wikitext as itself, then adjust the TSRs in the DOM tree. Since Gallery isn't ported to PHP (yet), update the automatically-generated Gallery/index.php. The newly-added ContentUtils::shiftDSR() was ported, however. Change-Id: I28f3d3398930733ae2bcf9759e49c45f93bc7190
This commit is contained in:
parent
c790d125de
commit
b84b71af22
|
@ -29,14 +29,16 @@ class Ref {
|
||||||
// in-memory DOM which is simply a tree data structure, we can
|
// in-memory DOM which is simply a tree data structure, we can
|
||||||
// nest flow content in a <sup> tag.
|
// nest flow content in a <sup> tag.
|
||||||
wrapperTag: 'sup',
|
wrapperTag: 'sup',
|
||||||
inTemplate: state.parseContext.inTemplate,
|
pipelineOpts: {
|
||||||
extTag: 'ref',
|
extTag: 'ref',
|
||||||
extTagOpts: {
|
extTagOpts: {
|
||||||
allowNestedRef: !!allowNestedRef,
|
allowNestedRef: !!allowNestedRef,
|
||||||
|
},
|
||||||
|
inTemplate: state.parseContext.inTemplate,
|
||||||
|
// FIXME: One-off PHP parser state leak.
|
||||||
|
// This needs a better solution.
|
||||||
|
inPHPBlock: true,
|
||||||
},
|
},
|
||||||
// FIXME: One-off PHP parser state leak.
|
|
||||||
// This needs a better solution.
|
|
||||||
inPHPBlock: true,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,10 @@ class References {
|
||||||
static toDOM(state, content, args) {
|
static toDOM(state, content, args) {
|
||||||
return ParsoidExtApi.parseTokenContentsToDOM(state, args, '', content, {
|
return ParsoidExtApi.parseTokenContentsToDOM(state, args, '', content, {
|
||||||
wrapperTag: 'div',
|
wrapperTag: 'div',
|
||||||
extTag: 'references',
|
pipelineOpts: {
|
||||||
inTemplate: state.parseContext.inTemplate,
|
extTag: 'references',
|
||||||
|
inTemplate: state.parseContext.inTemplate,
|
||||||
|
},
|
||||||
}).then(function(doc) {
|
}).then(function(doc) {
|
||||||
var refsOpts = Object.assign({
|
var refsOpts = Object.assign({
|
||||||
group: null,
|
group: null,
|
||||||
|
|
|
@ -48,12 +48,14 @@ class Ref implements ExtensionTag, SerialHandler {
|
||||||
// in-memory DOM which is simply a tree data structure, we can
|
// in-memory DOM which is simply a tree data structure, we can
|
||||||
// nest flow content in a <sup> tag.
|
// nest flow content in a <sup> tag.
|
||||||
'wrapperTag' => 'sup',
|
'wrapperTag' => 'sup',
|
||||||
'inTemplate' => $extApi->parseContext['inTemplate'] ?? null,
|
'pipelineOpts' => [
|
||||||
'extTag' => 'ref',
|
'extTag' => 'ref',
|
||||||
'extTagOpts' => [ 'allowNestedRef' => $allowNestedRef ],
|
'extTagOpts' => [ 'allowNestedRef' => $allowNestedRef ],
|
||||||
// FIXME: One-off PHP parser state leak.
|
'inTemplate' => $extApi->parseContext['inTemplate'] ?? null,
|
||||||
// This needs a better solution.
|
// FIXME: One-off PHP parser state leak.
|
||||||
'inPHPBlock' => true,
|
// This needs a better solution.
|
||||||
|
'inPHPBlock' => true,
|
||||||
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -486,8 +486,10 @@ class References implements ExtensionTag, SerialHandler {
|
||||||
$txt,
|
$txt,
|
||||||
[
|
[
|
||||||
'wrapperTag' => 'div',
|
'wrapperTag' => 'div',
|
||||||
'extTag' => 'references',
|
'pipelineOpts' => [
|
||||||
'inTemplate' => $extApi->parseContext['inTemplate'] ?? null,
|
'extTag' => 'references',
|
||||||
|
'inTemplate' => $extApi->parseContext['inTemplate'] ?? null,
|
||||||
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue