mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PageImages
synced 2024-11-23 16:06:44 +00:00
Strip comments from toc section lines
Change-Id: Ide4462b9df5d02b088bf2f1c83a3c5f119366a95
This commit is contained in:
parent
87e257dd27
commit
abf45611d7
|
@ -170,6 +170,11 @@ class ParserFileProcessingHookHandlers implements
|
|||
$parserOutput->setIndicator( $id, $stripped );
|
||||
}
|
||||
}
|
||||
// Strip comments from TOC data
|
||||
$tocData = $parserOutput->getTOCData();
|
||||
foreach ( ( $tocData ? $tocData->getSections() : [] ) as $section ) {
|
||||
$section->line = trim( preg_replace( self::CANDIDATE_REGEX, '', $section->line ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,6 +37,8 @@ PageImages with best excluded by wgPageImagesLeadSectionOnly
|
|||
!! options
|
||||
property=page_image_free
|
||||
disabled
|
||||
!! config
|
||||
wgParserEnableLegacyMediaDOM=false
|
||||
!! metadata
|
||||
property[page_image_free]=Thumb.png
|
||||
!! wikitext
|
||||
|
@ -52,3 +54,24 @@ property[page_image_free]=Thumb.png
|
|||
<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
|
||||
</p>
|
||||
!! end
|
||||
|
||||
!! test
|
||||
PageImages with toc and image in heading
|
||||
!! options
|
||||
property=page_image_free
|
||||
!! config
|
||||
wgParserEnableLegacyMediaDOM=false
|
||||
!! wikitext
|
||||
__TOC__
|
||||
== Hello [[File:Foobar.jpg]] ==
|
||||
!! metadata
|
||||
property[page_image_free]=Foobar.jpg
|
||||
!! html
|
||||
<div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
|
||||
<ul>
|
||||
<li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext">Hello</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h2><span class="mw-headline" id="Hello">Hello <span class="mw-default-size" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Hello">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
|
||||
!! end
|
||||
|
|
Loading…
Reference in a new issue