mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
Merge "Try to extract an excerpt from a revision"
This commit is contained in:
commit
15dc477e04
|
@ -885,4 +885,18 @@ abstract class EchoDiscussionParser {
|
|||
public static function htmlToText( $html ) {
|
||||
return trim( html_entity_decode( strip_tags( $html ), ENT_QUOTES ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract an edit excerpt from a revision
|
||||
*
|
||||
* @param Revision $revision
|
||||
* @param Language $lang
|
||||
* @param int $length
|
||||
* @return string
|
||||
*/
|
||||
public static function getEditExcerpt( Revision $revision, Language $lang, $length = 150 ) {
|
||||
$interpretation = self::getChangeInterpretationForRevision( $revision );
|
||||
$section = self::detectSectionTitleAndText( $interpretation );
|
||||
return $lang->truncate( $section['section-title'] . ' ' . $section['section-text'], $length );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue