Fixed incorrect treatment of <nowiki>.
authorDan
Fri, 29 May 2009 19:53:19 -0400
changeset 4 97d85c22ced7
parent 3 f3e2bbbd2155
child 5 bfe00fc686f2
Fixed incorrect treatment of <nowiki>.
plugins/GeSHi.php
--- a/plugins/GeSHi.php	Fri May 29 19:40:15 2009 -0400
+++ b/plugins/GeSHi.php	Fri May 29 19:53:19 2009 -0400
@@ -47,6 +47,14 @@
 
 function geshi_strip_code(&$text, &$codeblocks, $random_id)
 {
+  // remove nowiki
+  $nw = preg_match_all('#<nowiki>(.*?)<\/nowiki>#is', $text, $nowiki);
+    
+  for ( $i = 0; $i < $nw; $i++ )
+  {
+    $text = str_replace('<nowiki>'.$nowiki[1][$i].'</nowiki>', '{NOWIKI:'.$random_id.':'.$i.'}', $text);
+  }
+  
   global $geshi_supported_formats;
   $codeblocks = array();
   $sf = '(' . implode('|', $geshi_supported_formats) . ')';
@@ -68,6 +76,12 @@
       );
     $text = str_replace_once($match, "{GESHI_BLOCK:$i:$random_id}", $text);
   }
+  
+  // Reinsert <nowiki> sections
+  for ( $i = 0; $i < $nw; $i++ )
+  {
+    $text = str_replace('{NOWIKI:'.$random_id.':'.$i.'}', $nowiki[1][$i], $text);
+  }
 }
 
 function geshi_restore_code(&$text, &$codeblocks, $random_id)