Go to file
Thiemo Kreuz 60e1c5ad83 Skip <h2> in TOC when extracting first section
This piece of code is only relevant in case when:
- the intro section is requested (either in plaintext or html);
- the parse result for the full page is available in the parser cache;
- the full extract is not available in the TextExtracts WAN cache;
- the intro is also not available in the TextExtracts WAN cache.

In this case getFirstSection() is called with the parser output,
which is different from the the convertText() output it is called
with in other code paths, and still contains <h*> tags. A quick
regex is used to extract the first section. This stops at any <h2>.
A TOC also contains a <h2> (which will be removed later via
$wgExtractsRemoveClasses). This one needs to be ignored in case
the TOC is placed before the first section using e.g. the __TOC__
keyword.

The patch changes the regex so it ignores a h2 with
id="mw-toc-heading", but keeps working in plaintext mode when <h*>
tags are not present  (the code path when the intro section is
requested, and the full extract is available in the TextExtracts
WAN cache but the intro extract isn't).

Bug: T269967
Change-Id: I0a495d06cf1725744e556e81f17047fb53f53521
2023-03-20 07:40:07 +00:00
.phan Add phan 2019-04-27 21:23:26 +02:00
i18n Localisation updates from https://translatewiki.net. 2021-05-10 08:53:53 +02:00
includes Skip <h2> in TOC when extracting first section 2023-03-20 07:40:07 +00:00
tests/phpunit Skip <h2> in TOC when extracting first section 2023-03-20 07:40:07 +00:00
.eslintrc.json build: Updating mediawiki/mediawiki-codesniffer to 33.0.0 2020-11-04 14:00:01 +00:00
.gitignore build: Upgrade eslint-config-wikimedia 0.12.0, drop grunt-jsonlint 2019-05-07 10:52:31 -07:00
.gitreview Whoops, track not trace 2016-10-24 17:03:54 -07:00
.phpcs.xml Fix minor deprecations and incomplete PHPDoc tags 2021-01-08 08:36:47 +01:00
CODE_OF_CONDUCT.md build: Updating mediawiki/phan-taint-check-plugin to 1.3.0 2018-08-19 17:07:56 +00:00
composer.json build: Updating dependencies 2021-05-14 05:25:02 +00:00
COPYING Add COPYING 2014-01-22 21:33:49 +00:00
extension.json ApiQueryExtracts: remove unneeded factory method 2021-04-01 20:07:30 +00:00
Gruntfile.js build: Updating dependencies 2021-01-30 15:53:32 +00:00
package-lock.json build: Updating browserslist to 4.16.6 2021-05-26 05:14:56 +00:00
package.json build: Updating dependencies 2021-05-14 05:25:02 +00:00