ToC: Handle anchors with % in plaintext

TODO: Remove the fallback to {{anchor}} when all old parser cache expired.

Bug: T315222
Change-Id: I1da089cfef83131cda26859e3346cd2d840b3839
This commit is contained in:
Func 2022-08-16 12:19:37 +08:00
parent aad1c4c836
commit c6bf88520e
2 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,6 @@
<li id="toc-{{anchor}}"
class="sidebar-toc-list-item sidebar-toc-level-{{toclevel}}{{#is-top-level-section}}{{^vector-is-collapse-sections-enabled}} sidebar-toc-list-item-expanded{{/vector-is-collapse-sections-enabled}}{{/is-top-level-section}}">
<a class="sidebar-toc-link" href="#{{anchor}}">
<a class="sidebar-toc-link" href="#{{linkAnchor}}{{^linkAnchor}}{{anchor}}{{/linkAnchor}}">
<div class="sidebar-toc-text">
<span class="sidebar-toc-numb">{{number}}</span>{{{line}}}</div>
</a>

View File

@ -64,6 +64,7 @@ class SkinVectorTest extends MediaWikiIntegrationTestCase {
'fromtitle' => 'Test',
'byteoffset' => 231,
'anchor' => 'A',
'linkAnchor' => 'A',
'array-sections' => [],
'is-top-level-section' => true,
'is-parent-section' => false,
@ -77,6 +78,7 @@ class SkinVectorTest extends MediaWikiIntegrationTestCase {
'fromtitle' => 'Test',
'byteoffset' => 245,
'anchor' => 'B',
'linkAnchor' => 'B',
'array-sections' => [],
'is-top-level-section' => true,
'is-parent-section' => false,
@ -95,6 +97,7 @@ class SkinVectorTest extends MediaWikiIntegrationTestCase {
'fromtitle' => 'Test',
'byteoffset' => 231,
'anchor' => 'A',
'linkAnchor' => 'A',
'array-sections' => [
'toclevel' => 2,
'level' => '4',
@ -104,6 +107,7 @@ class SkinVectorTest extends MediaWikiIntegrationTestCase {
'fromtitle' => 'Test',
'byteoffset' => 245,
'anchor' => 'A1',
'linkAnchor' => 'A1',
'array-sections' => [],
'is-top-level-section' => false,
'is-parent-section' => false,