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,
|
* Parse wikitext into truncated plain text.
|
||||||
* template from text content
|
|
||||||
* @param $text string
|
* @param $text string
|
||||||
* @param Language $lang
|
* @param Language $lang
|
||||||
* @param $length int default 150
|
* @param $length int default 150
|
||||||
|
@ -840,4 +839,19 @@ abstract class EchoDiscussionParser {
|
||||||
$plaintext = trim( html_entity_decode( strip_tags( $html ), ENT_QUOTES ) );
|
$plaintext = trim( html_entity_decode( strip_tags( $html ), ENT_QUOTES ) );
|
||||||
return $lang->truncate( $plaintext, $length );
|
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 ) {
|
private function formatSummary( $wikitext ) {
|
||||||
$html = Linker::formatLinksInComment( Sanitizer::escapeHtmlAllowEntities( $wikitext ) );
|
return EchoDiscussionParser::getTextSnippetFromSummary( $wikitext, $this->language );
|
||||||
return EchoDiscussionParser::getTextSnippet(
|
|
||||||
$html,
|
|
||||||
$this->language
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPrimaryLink() {
|
public function getPrimaryLink() {
|
||||||
|
|
Loading…
Reference in a new issue