diff --git a/includes/ApiQueryExtracts.php b/includes/ApiQueryExtracts.php index 1d23980..3b070a7 100644 --- a/includes/ApiQueryExtracts.php +++ b/includes/ApiQueryExtracts.php @@ -231,9 +231,10 @@ class ApiQueryExtracts extends ApiQueryBase { */ private function getFirstSection( $text, $plainText ) { if ( $plainText ) { - $regexp = '/^(.*?)(?=' . ExtractFormatter::SECTION_MARKER_START . ')/s'; + $regexp = '/^.*?(?=' . ExtractFormatter::SECTION_MARKER_START . + '(?!.' . ExtractFormatter::SECTION_MARKER_END . '

...', ], + '__TOC__ before intro (HTML)' => [ + '

Contents

Intro

Actual heading

...', + false, + '

Contents

Intro', + ], + '__TOC__ before intro (plaintext)' => [ + "\1\2_\2\1

Contents

Intro\1\2_\2\1

Actual heading

...", + true, + "\1\2_\2\1

Contents

Intro", + ], ]; }