207 ;sx"; |
207 ;sx"; |
208 |
208 |
209 // using preg_replace here sometimes gives us empty strings probably because we're using $0 |
209 // using preg_replace here sometimes gives us empty strings probably because we're using $0 |
210 // in the replace formatter. so we'll just take care of it explicitly here with preg_match_all |
210 // in the replace formatter. so we'll just take care of it explicitly here with preg_match_all |
211 // and good ole str_replace_once. |
211 // and good ole str_replace_once. |
|
212 |
|
213 // FIXME this regexp can cause crashes under win32 PHP due to some apache limitations... possibly |
|
214 // write a non-regexp based replacement. same bug as the comment block above, apparently |
|
215 |
|
216 // oh. and we're using this tokens thing because for identical matches, the first match will |
|
217 // get wrapped X number of times instead of all matches getting wrapped once; replacing each |
|
218 // with a unique token id remedies this |
|
219 |
|
220 $tokens = array(); |
|
221 $rand_id = sha1(microtime() . mt_rand()); |
212 if ( preg_match_all($regex, $text, $matches) ) |
222 if ( preg_match_all($regex, $text, $matches) ) |
213 { |
223 { |
214 foreach ( $matches[0] as $match ) |
224 foreach ( $matches[0] as $i => $match ) |
215 { |
225 { |
216 $text = str_replace_once($match, '<_paragraph_bypass>' . $match . '</_paragraph_bypass>', $text); |
226 $text = str_replace_once($match, "{_pb_:$rand_id:$i}", $text); |
217 } |
227 $tokens[$i] = '<_paragraph_bypass>' . $match . '</_paragraph_bypass>'; |
218 } |
228 } |
|
229 } |
|
230 |
|
231 foreach ( $tokens as $i => $match ) |
|
232 { |
|
233 $text = str_replace_once("{_pb_:$rand_id:$i}", $match, $text); |
|
234 } |
|
235 |
|
236 // die('<pre>' . htmlspecialchars($text) . '</pre>'); |
219 |
237 |
220 RenderMan::tag_unstrip('_paragraph_bypass', $text, $_nw, true); |
238 RenderMan::tag_unstrip('_paragraph_bypass', $text, $_nw, true); |
221 |
239 |
222 // This is potentially a hack. It allows the parser to stick in <_paragraph_bypass> tags |
240 // This is potentially a hack. It allows the parser to stick in <_paragraph_bypass> tags |
223 // to prevent the paragraph parser from interfering with pretty HTML generated elsewhere. |
241 // to prevent the paragraph parser from interfering with pretty HTML generated elsewhere. |