예제 #1
0
 protected static function init()
 {
     if (self::$initialized) {
         return;
     }
     self::$initialized = TRUE;
     #
     # Prepare regular expressions for seraching emphasis tokens in any
     # context.
     #
     foreach (self::$em_relist as $em => $em_re) {
         foreach (self::$strong_relist as $strong => $strong_re) {
             # Construct list of allowed token expressions.
             $token_relist = array();
             if (isset(self::$em_strong_relist["{$em}{$strong}"])) {
                 $token_relist[] = self::$em_strong_relist["{$em}{$strong}"];
             }
             $token_relist[] = $em_re;
             $token_relist[] = $strong_re;
             # Construct master expression from list.
             $token_re = '{(' . implode('|', $token_relist) . ')}';
             self::$em_strong_prepared_relist["{$em}{$strong}"] = $token_re;
         }
     }
     self::$nested_brackets_re = str_repeat('(?>[^\\[\\]]+|\\[', self::nested_brackets_depth) . str_repeat('\\])*', self::nested_brackets_depth);
     self::$nested_url_parenthesis_re = str_repeat('(?>[^()\\s]+|\\(', self::nested_url_parenthesis_depth) . str_repeat('(?>\\)))*', self::nested_url_parenthesis_depth);
     self::$escape_chars_re = '[' . preg_quote(self::escape_chars) . ']';
     # Sort document, block, and span gamut in ascendent priority order.
     asort(self::$document_gamut);
     asort(self::$block_gamut);
     asort(self::$span_gamut);
 }