protected function parseString() { while ($this->lexer->moveNext()) { if (in_array($this->lexer->lookahead, $this->lookaheadToSkip)) { continue; } $value = $this->lexer->lookahead['value']; switch ($this->lexer->lookahead['type']) { case Lexer::T_NONE: $this->none($value); break; case Lexer::T_ESCAPED_CHAR: $this->escapedCharacter($value); break; case Lexer::T_COLOR: $color = preg_replace('/([^0-9a-f])/iu', '0', $value); $this->currentStyle->setColor($color); $this->color(); break; case Lexer::T_NO_COLOR: if ($this->stylesStack) { $color = $this->stylesStack[count($this->stylesStack) - 1]->getColor(); } else { $color = null; } $this->currentStyle->setColor($color); $this->color(); break; case Lexer::T_SHADOWED: $this->currentStyle->setShadowed(!$this->currentStyle->isShadowed()); $this->shadowed(); break; case Lexer::T_BOLD: $this->currentStyle->setBold(!$this->currentStyle->isBold()); $this->bold(); break; case Lexer::T_ITALIC: $this->currentStyle->setItalic(!$this->currentStyle->isItalic()); $this->italic(); break; case Lexer::T_WIDE: $this->currentStyle->setWidth(2); $this->wide(); break; case Lexer::T_NARROW: $this->currentStyle->setWidth(0); $this->narrow(); break; case Lexer::T_MEDIUM: $this->currentStyle->setWidth(1); $this->medium(); break; case Lexer::T_UPPERCASE: $this->currentStyle->setUppercase(!$this->currentStyle->isUppercase()); $this->upperCase(); break; case Lexer::T_RESET_ALL: if ($this->stylesStack) { $style = $this->stylesStack[count($this->stylesStack) - 1]; } else { $style = new Style(); } $this->currentStyle = $style; $this->isInLink = false; $this->resetAll(); break; case Lexer::T_PUSH: array_push($this->stylesStack, $this->currentStyle); $this->currentStyle = clone $this->currentStyle; $this->pushStyle(); break; case Lexer::T_POP: if (count($this->stylesStack)) { $this->currentStyle = array_pop($this->stylesStack); } $this->popStyle(); break; case Lexer::T_EXTERNAL_LINK: $this->isInLink = !$this->isInLink; if ($this->isInLink) { $link = $this->getLink(); $this->openExternalLink($link); } else { $this->closeExternalLink(); } break; case Lexer::T_INTERNAL_LINK: $this->isInLink = !$this->isInLink; if ($this->isInLink) { $link = $this->getLink(); $this->openInternalLink($link); } else { $this->closeInternalLink(); } break; case Lexer::T_UNKNOWN_MARKUP: // We do nothing with unknown markup for the moment break; } } }