mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-23 23:44:53 +00:00
Merge "Parse section titles in notifs as if they weren't at the start of line"
This commit is contained in:
commit
a8af58f362
|
@ -1239,13 +1239,14 @@ abstract class EchoDiscussionParser {
|
|||
* @param Language $lang
|
||||
* @param int $length Length in characters (not bytes); default DEFAULT_SNIPPET_LENGTH
|
||||
* @param Title|null $title Page from which the text snippet is being extracted
|
||||
* @param bool $linestart Whether or not this is at the start of a line
|
||||
* @return string
|
||||
*/
|
||||
public static function getTextSnippet(
|
||||
$text, Language $lang, $length = self::DEFAULT_SNIPPET_LENGTH, $title = null
|
||||
$text, Language $lang, $length = self::DEFAULT_SNIPPET_LENGTH, $title = null, $linestart = true
|
||||
) {
|
||||
// Parse wikitext
|
||||
$html = MediaWikiServices::getInstance()->getMessageCache()->parse( $text, $title )->getText( [
|
||||
$html = MediaWikiServices::getInstance()->getMessageCache()->parse( $text, $title, $linestart )->getText( [
|
||||
'enableSectionEditLinks' => false
|
||||
] );
|
||||
$plaintext = trim( Sanitizer::stripAllTags( $html ) );
|
||||
|
|
|
@ -83,7 +83,10 @@ class EchoPresentationModelSection {
|
|||
$rawSectionTitle,
|
||||
$this->language,
|
||||
EchoDiscussionParser::DEFAULT_SNIPPET_LENGTH,
|
||||
$this->event->getTitle()
|
||||
$this->event->getTitle(),
|
||||
// linestart=false, because this wikitext was inside a heading like `== … ==`,
|
||||
// so start-of-line markup like `*` should not be parsed (T299572)
|
||||
false
|
||||
);
|
||||
return $this->parsedSectionTitle;
|
||||
}
|
||||
|
|
|
@ -1816,5 +1816,25 @@ TEXT
|
|||
Title::newFromText( 'Page001' )
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
'Hello',
|
||||
EchoDiscussionParser::getTextSnippet(
|
||||
'* Hello',
|
||||
Language::factory( 'en' ),
|
||||
EchoDiscussionParser::DEFAULT_SNIPPET_LENGTH,
|
||||
null,
|
||||
true
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
'* Hello',
|
||||
EchoDiscussionParser::getTextSnippet(
|
||||
'* Hello',
|
||||
Language::factory( 'en' ),
|
||||
EchoDiscussionParser::DEFAULT_SNIPPET_LENGTH,
|
||||
null,
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue