25 $this->tidyDriver = $tidy;
36 if ( $requestedSentenceCount <= 0 ) {
43 '\P{Lu}\.(?=[ \n]|$)',
55 $regexp =
'/(?:' . implode(
'|', $endchars ) .
')+/u';
56 $res = preg_match_all( $regexp, $text,
$matches, PREG_OFFSET_CAPTURE );
60 $lines = explode(
"\n", $text, 2 );
64 $index = min( $requestedSentenceCount,
$res ) - 1;
65 list( $tail, $length ) =
$matches[0][$index];
67 $text = substr( $text, 0, $length ) . $tail;
69 return $this->tidy( $text );
80 if ( $requestedLength <= 0 ) {
84 $length = mb_strlen( $text );
85 if ( $length <= $requestedLength ) {
90 $pattern =
'/^[\w\/]*>?/su';
91 preg_match( $pattern, mb_substr( $text, $requestedLength ), $m );
92 $text = mb_substr( $text, 0, $requestedLength ) . $m[0];
94 return $this->tidy( $text );
101 private function tidy( $text ) {
102 if ( $this->tidyDriver ) {
104 $text = $this->tidyDriver->tidy( $text );
107 return trim( $text );