You are here

class TokenParser in Markdown 8.2

Twig Markdown Token Parser.

Hierarchy

  • class \Drupal\markdown\Twig\TokenParser extends \Drupal\markdown\Twig\Twig_TokenParser

Expanded class hierarchy of TokenParser

File

src/Twig/TokenParser.php, line 11

Namespace

Drupal\markdown\Twig
View source
class TokenParser extends \Twig_TokenParser {

  /**
   * An instance of a markdown processor to use.
   *
   * @var \Drupal\markdown\MarkdownInterface
   */
  protected $markdown;

  /**
   * {@inheritdoc}
   */
  public function __construct(MarkdownInterface $markdown) {
    $this->markdown = $markdown;
  }

  /**
   * {@inheritdoc}
   */
  public function parse(Token $token) {
    $tag = $this
      ->getTag();
    $line = $token
      ->getLine();
    $this->parser
      ->getStream()
      ->expect(\Twig_Token::BLOCK_END_TYPE);
    $body = $this->parser
      ->subparse(function (\Twig_Token $token) use ($tag) {
      return $token
        ->test("end{$tag}");
    }, TRUE);
    $this->parser
      ->getStream()
      ->expect(\Twig_Token::BLOCK_END_TYPE);
    return new Node($body, $line, $tag);
  }

  /**
   * {@inheritdoc}
   */
  public function getTag() {
    return 'markdown';
  }

  /**
   * Return the markdown instance being used.
   *
   * @return \Drupal\markdown\MarkdownInterface
   *   The Markdown instance.
   */
  public function getMarkdown() {
    return $this->markdown;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TokenParser::$markdown protected property An instance of a markdown processor to use.
TokenParser::getMarkdown public function Return the markdown instance being used.
TokenParser::getTag public function
TokenParser::parse public function
TokenParser::__construct public function