Fix dependence on hardcoded UNIQ_PREFIX.
authorZheng Zhu <zhengzhu@users.mediawiki.org>
Tue, 24 Jan 2006 18:36:45 +0000 (18:36 +0000)
committerZheng Zhu <zhengzhu@users.mediawiki.org>
Tue, 24 Jan 2006 18:36:45 +0000 (18:36 +0000)
includes/Parser.php
languages/LanguageConverter.php

index 97b18c6..00d2d4e 100644 (file)
@@ -157,6 +157,15 @@ class Parser
                wfRunHooks( 'ParserClearState', array( &$this ) );
        }
 
+       /**
+        * Accessor for mUniqPrefix.
+        *
+        * @access public
+        */
+       function UniqPrefix() {
+               return $this->mUniqPrefix;
+       }
+
        /**
         * Convert wikitext to HTML
         * Do not call this function recursively.
index 7484af7..1992d7e 100644 (file)
@@ -135,8 +135,17 @@ class LanguageConverter {
                if(!in_array($toVariant, $this->mVariants))
                        return $text;
 
-
-               $reg = '/<[^>]+>|&[a-z#][a-z0-9]+;|'.UNIQ_PREFIX.'-[a-zA-Z0-9]+/';
+               /* we convert everything except:
+                  1. html markups (anything between < and >)
+                  2. html entities
+                  3. place holders created by the parser
+               */
+               global $wgParser;
+               if (isset($wgParser))
+                       $marker = '|' . $wgParser->UniqPrefix() . '[\-a-zA-Z0-9]+';
+               else
+                       $marker = "";
+               $reg = '/<[^>]+>|&[a-z#][a-z0-9]+;' . $marker . '/';
                $matches = preg_split($reg, $text, -1, PREG_SPLIT_OFFSET_CAPTURE);