/** * Parse wiki tags * @param string $body Markup to de-tag * @return string XHTML markup equivalent * @private */ static function _parse_tags($body) { // Possible tags here. Lets get cracking $prev = 0; $offset = 0; $start = 0; while (($start = strpos($body, "[[")) !== false) { $stop = strpos($body, "]]", $start + 2); $next = strpos($body, "[[", $start + 2); if ($next !== false && $next < $stop) { // Nexted tags - perhaps not the most efficient but most nestings will // be simple ones anyway so shouldn't make that much a difference while ($next !== false && $next < $stop) { // Grab most inner one $prev = $next; $next = strpos($body, "[[", $next + 2); } $start = $prev; } $diff = $stop - $start; $tag = substr($body, $start + 2, $diff - 2); $tag = sscText::_convert_tag($tag); $body = substr_replace($body, $tag, $start, $diff + 2); } return $body; }