Based on patch posted by Dan Collins: https://bugzilla.wikimedia.org/attachment.cgi?id=9552
with a tweak to avoid breaking a similar case in other sections. Follows up on function extraction & test cases added in r105379.
* @return Mixed|string or false
*/
public static function extractSectionTitle( $text ) {
- preg_match( "/^(=+)(.+)\\1/mi", $text, $matches );
+ preg_match( "/^(=+)(.+)\\1(\n|$)/i", $text, $matches );
if ( !empty( $matches[2] ) ) {
global $wgParser;
return $wgParser->stripSectionName(trim($matches[2]));