mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 16:04:35 +00:00
Merge "RevertedPresentationModel: Don't double-parse summary"
This commit is contained in:
commit
6e8e68d6ba
|
@ -826,8 +826,7 @@ abstract class EchoDiscussionParser {
|
|||
}
|
||||
|
||||
/**
|
||||
* This function returns plain text snippet, it also removes html tag,
|
||||
* template from text content
|
||||
* Parse wikitext into truncated plain text.
|
||||
* @param $text string
|
||||
* @param Language $lang
|
||||
* @param $length int default 150
|
||||
|
@ -840,4 +839,19 @@ abstract class EchoDiscussionParser {
|
|||
$plaintext = trim( html_entity_decode( strip_tags( $html ), ENT_QUOTES ) );
|
||||
return $lang->truncate( $plaintext, $length );
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an edit summary into truncated plain text.
|
||||
* @param $text string
|
||||
* @param Language $lang
|
||||
* @param $length int default 150
|
||||
* @return string
|
||||
*/
|
||||
static function getTextSnippetFromSummary( $text, Language $lang, $length = 150 ) {
|
||||
// Parse wikitext with summary parser
|
||||
$html = Linker::formatLinksInComment( Sanitizer::escapeHtmlAllowEntities( $text ) );
|
||||
// Remove HTML tags and decode HTML entities
|
||||
$plaintext = trim( html_entity_decode( strip_tags( $html ), ENT_QUOTES ) );
|
||||
return $lang->truncate( $plaintext, $length );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,11 +29,7 @@ class EchoRevertedPresentationModel extends EchoEventPresentationModel {
|
|||
}
|
||||
|
||||
private function formatSummary( $wikitext ) {
|
||||
$html = Linker::formatLinksInComment( Sanitizer::escapeHtmlAllowEntities( $wikitext ) );
|
||||
return EchoDiscussionParser::getTextSnippet(
|
||||
$html,
|
||||
$this->language
|
||||
);
|
||||
return EchoDiscussionParser::getTextSnippetFromSummary( $wikitext, $this->language );
|
||||
}
|
||||
|
||||
public function getPrimaryLink() {
|
||||
|
|
Loading…
Reference in a new issue