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:
C. Scott Ananian 2019-04-19 15:38:27 -04:00 committed by jenkins-bot
parent c790d125de
commit b84b71af22
4 changed files with 25 additions and 17 deletions

View file

@ -29,14 +29,16 @@ class Ref {
// in-memory DOM which is simply a tree data structure, we can
// nest flow content in a <sup> tag.
wrapperTag: 'sup',
inTemplate: state.parseContext.inTemplate,
extTag: 'ref',
extTagOpts: {
allowNestedRef: !!allowNestedRef,
pipelineOpts: {
extTag: 'ref',
extTagOpts: {
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,
});
}

View file

@ -26,8 +26,10 @@ class References {
static toDOM(state, content, args) {
return ParsoidExtApi.parseTokenContentsToDOM(state, args, '', content, {
wrapperTag: 'div',
extTag: 'references',
inTemplate: state.parseContext.inTemplate,
pipelineOpts: {
extTag: 'references',
inTemplate: state.parseContext.inTemplate,
},
}).then(function(doc) {
var refsOpts = Object.assign({
group: null,

View file

@ -48,12 +48,14 @@ class Ref implements ExtensionTag, SerialHandler {
// in-memory DOM which is simply a tree data structure, we can
// nest flow content in a <sup> tag.
'wrapperTag' => 'sup',
'inTemplate' => $extApi->parseContext['inTemplate'] ?? null,
'extTag' => 'ref',
'extTagOpts' => [ 'allowNestedRef' => $allowNestedRef ],
// FIXME: One-off PHP parser state leak.
// This needs a better solution.
'inPHPBlock' => true,
'pipelineOpts' => [
'extTag' => 'ref',
'extTagOpts' => [ 'allowNestedRef' => $allowNestedRef ],
'inTemplate' => $extApi->parseContext['inTemplate'] ?? null,
// FIXME: One-off PHP parser state leak.
// This needs a better solution.
'inPHPBlock' => true,
],
]
);
}

View file

@ -486,8 +486,10 @@ class References implements ExtensionTag, SerialHandler {
$txt,
[
'wrapperTag' => 'div',
'extTag' => 'references',
'inTemplate' => $extApi->parseContext['inTemplate'] ?? null,
'pipelineOpts' => [
'extTag' => 'references',
'inTemplate' => $extApi->parseContext['inTemplate'] ?? null,
],
]
);