File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ class Snippet {
1212 * @return String: processed text
1313 */
1414 static function parseText ( $ text ) {
15+ global $ wgSnippetMaxLength ;
16+
1517 $ parts = explode ( '== ' , $ text );
1618 $ text = $ parts [0 ]; // remove anything after the first heading
1719
@@ -27,6 +29,12 @@ static function parseText( $text ) {
2729 $ text = preg_replace ( '/{{[^{]+?}}/ ' , '' , $ text ); // remove 2nd layer templates
2830 $ text = preg_replace ( '/{{[^{]+?}}/ ' , '' , $ text ); // remove 1st layer templates
2931
32+ $ text = substr ( $ text , 0 , $ wgSnippetMaxLength ); // limit to $wgSnippetMaxLength chars
33+
34+ $ parts = explode ( '. ' , $ text );
35+ array_pop ( $ parts ); // remove anything after the last full stop
36+ $ text = implode ( '. ' , $ parts ) . '. ' ;
37+
3038 $ text = trim ( $ text );
3139
3240 return $ text ;
Original file line number Diff line number Diff line change 1414
1515$ wgAPIModules ['snippet ' ] = 'SnippetAPI ' ;
1616
17- $ wgExtensionMessagesFiles ['Snippet ' ] = __DIR__ . '/Snippet.i18n.php ' ;
17+ $ wgExtensionMessagesFiles ['Snippet ' ] = __DIR__ . '/Snippet.i18n.php ' ;
18+
19+ $ wgSnippetMaxLength = 600 ;
You can’t perform that action at this time.
0 commit comments