Anomie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/88750
Change subject: Handle raw <h#> when calculating $rawtoc
......................................................................
Handle raw <h#> when calculating $rawtoc
When the parser is constructing $rawtoc, it needs the sectionIndex
number to be able to calculate the byteoffset. This number is only
available for wikitext headings ("== foo =="), HTML headings
("<h2>foo</h2>") do not have it and the lack makes byteoffset be wrong
for all subsequent headings in the page.
To fix this, we just omit output of byteoffset in this situation.
Bug: 25203
Change-Id: I39e5faa4ac22d915f06125aac36ced11607b94a3
---
M includes/parser/Parser.php
1 file changed, 3 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/50/88750/1
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index eac2202..0603a9b 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -4447,7 +4447,8 @@
# Add the section to the section tree
# Find the DOM node for this header
- while ( $node && !$isTemplate ) {
+ $noOffset = ( $isTemplate || $sectionIndex === false );
+ while ( $node && !$noOffset ) {
if ( $node->getName() === 'h' ) {
$bits = $node->splitHeading();
if ( $bits['i'] == $sectionIndex ) {
@@ -4465,7 +4466,7 @@
'number' => $numbering,
'index' => ( $isTemplate ? 'T-' : '' ) .
$sectionIndex,
'fromtitle' => $titleText,
- 'byteoffset' => ( $isTemplate ? null :
$byteOffset ),
+ 'byteoffset' => ( $noOffset ? null :
$byteOffset ),
'anchor' => $anchor,
);
--
To view, visit https://gerrit.wikimedia.org/r/88750
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I39e5faa4ac22d915f06125aac36ced11607b94a3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits