# Every call to the tokenizer returns a new token.
while ( $token = $tokenizer->nextToken() )
{
+echo $token["type"]."<br>";
switch ( $token["type"] )
{
case "text":
# simple text with no further markup
$txt = $token["text"];
break;
+ case "[[[":
+ # remember the tag opened with 3 [
+ $threeopen = true;
case "[[":
# link opening tag.
# FIXME : Treat orphaned open tags (stack not empty when text is over)
array_push( $tokenStack, $token );
$txt="";
break;
+
+ case "]]]":
case "]]":
# link close tag.
# get text from stack, glue it together, and call the code to handle a
# link
+
if ( count( $tokenStack ) == 0 )
{
# stack empty. Found a ]] without an opening [[
} else {
$linkText = "";
$lastToken = array_pop( $tokenStack );
- while ( $lastToken["type"] != "[[" )
+ while ( !(($lastToken["type"] == "[[[") or ($lastToken["type"] == "[[")) )
{
if( !empty( $lastToken["text"] ) ) {
$linkText = $lastToken["text"] . $linkText;
}
$lastToken = array_pop( $tokenStack );
}
+
$txt = $linkText ."]]";
+
if( isset( $lastToken["text"] ) ) {
$prefix = $lastToken["text"];
} else {
$txt .= $nextToken["text"];
}
$txt = $this->handleInternalLink( $txt, $prefix );
+
+ # did the tag start with 3 [ ?
+ if($threeopen) {
+ # show the first as text
+ $txt = "[".$txt;
+ $threeopen=false;
+ }
+
}
$tagIsOpen = (count( $tokenStack ) != 0);
break;