68 { |
68 { |
69 return $matches[1] . |
69 return $matches[1] . |
70 $this->wiki->addToken($this->rule) . |
70 $this->wiki->addToken($this->rule) . |
71 $matches[2]; |
71 $matches[2]; |
72 } |
72 } |
|
73 |
|
74 /** |
|
75 * |
|
76 * Abstrct method to parse source text for matches. |
|
77 * |
|
78 * Applies the rule's regular expression to the source text, passes |
|
79 * every match to the process() method, and replaces the matched text |
|
80 * with the results of the processing. |
|
81 * |
|
82 * @access public |
|
83 * |
|
84 * @see Text_Wiki_Parse::process() |
|
85 * |
|
86 */ |
|
87 |
|
88 function parse() |
|
89 { |
|
90 $source =& $this->wiki->source; |
|
91 |
|
92 // This regex attempts to find HTML tags that can be safely compacted together without formatting loss |
|
93 // The idea is to make it easier for the HTML parser to find litewiki elements |
|
94 //$source = preg_replace('/<\/([a-z0-9:-]+?)>([\s]*[\n]+[\s]+|[\s]+[\n]+[\s]*|[\n]+)<([a-z0-9:-]+)(.*?)>/i', '</\\1><\\3\\4>', $source); |
|
95 $source = wikiformat_process_block($source); |
|
96 |
|
97 $rand_key = md5( str_rot13(strval(dechex(time()))) . microtime() . strval(mt_rand()) ); |
|
98 preg_match_all('/<(litewiki|pre)([^>]*?)>(.*?)<\/\\1>/is', $this->wiki->source, $matches); |
|
99 |
|
100 $poslist = array(); |
|
101 |
|
102 foreach ( $matches[0] as $i => $match ) |
|
103 { |
|
104 $source = str_replace($match, "{LITEWIKI:$i:$rand_key}", $source); |
|
105 } |
|
106 |
|
107 $this->wiki->source = preg_replace_callback( |
|
108 $this->regex, |
|
109 array(&$this, 'process'), |
|
110 $this->wiki->source |
|
111 ); |
|
112 |
|
113 foreach ( $matches[3] as $i => $match ) |
|
114 { |
|
115 $source = str_replace("{LITEWIKI:$i:$rand_key}", $match, $source); |
|
116 } |
|
117 |
|
118 // die('<pre>'.htmlspecialchars($source).'</pre>'); |
|
119 |
|
120 unset($matches, $source, $rand_key); |
|
121 } |
73 } |
122 } |
74 |
123 |
75 ?> |
124 ?> |