Index: trunk/extensions/ActiveAbstract/AbstractFilter.php |
— | — | @@ -107,6 +107,11 @@ |
108 | 108 | * @access private |
109 | 109 | */ |
110 | 110 | function _stripMarkup( $text ) { |
| 111 | + global $wgContLang; |
| 112 | + |
| 113 | + $text = substr( $text, 0, 4096 ); // don't bother with long text... |
| 114 | + |
| 115 | + $image = preg_quote( $wgContLang->getNsText( NS_IMAGE ), '#' ); |
111 | 116 | $text = str_replace( "'''", "", $text ); |
112 | 117 | $text = str_replace( "''", "", $text ); |
113 | 118 | $text = preg_replace( '#<!--.*?-->#s', '', $text ); // HTML-style comments |
— | — | @@ -114,7 +119,20 @@ |
115 | 120 | $text = preg_replace( '#\\[[a-z]+:.*? (.*?)\\]#s', '$1', $text ); // URL links |
116 | 121 | $text = preg_replace( '#\\{\\{\\{.*?\\}\\}\\}#s', '', $text ); // template parameters |
117 | 122 | $text = preg_replace( '#\\{\\{.*?\\}\\}#s', '', $text ); // template calls |
| 123 | + $text = preg_replace( '#\\{\\|.*?\\|\\}#s', '', $text ); // tables |
| 124 | + $text = preg_replace( "# |
| 125 | + \\[\\[ |
| 126 | + :?$image\\s*: |
| 127 | + ( |
| 128 | + [^][]* |
| 129 | + \[\[ |
| 130 | + [^][]* |
| 131 | + \]\] |
| 132 | + )* |
| 133 | + [^][]* |
| 134 | + \\]\\]#six", '', $text ); // images |
118 | 135 | $text = preg_replace( '#\\[\\[([^|\\]]*\\|)?(.*?)\\]\\]#s', '$2', $text ); // links |
| 136 | + $text = preg_replace( '#^:.*$#m', '', $text ); // indented lines near start are usually disambigs or notices |
119 | 137 | $text = Sanitizer::decodeCharReferences( $text ); |
120 | 138 | return trim( $text ); |
121 | 139 | } |
— | — | @@ -136,12 +154,14 @@ |
137 | 155 | $endgroup = implode( '', array_map( 'preg_quote', $endchars ) ); |
138 | 156 | $end = "[$endgroup]"; |
139 | 157 | $sentence = ".*?$end+"; |
140 | | - $firsttwo = "/^($sentence$sentence)/"; |
| 158 | + $firsttwo = "/^($sentence$sentence)/u"; |
141 | 159 | |
142 | 160 | if( preg_match( $firsttwo, $text, $matches ) ) { |
143 | 161 | return $matches[1]; |
144 | 162 | } else { |
145 | | - return $text; |
| 163 | + // Just return the first line |
| 164 | + $lines = explode( "\n", $text ); |
| 165 | + return trim( $lines[0] ); |
146 | 166 | } |
147 | 167 | } |
148 | 168 | |