TokenParser.php in Markdown 8.2
File
src/Twig/TokenParser.php
View source
<?php
namespace Drupal\markdown\Twig;
use Drupal\markdown\MarkdownInterface;
use Twig\Token;
class TokenParser extends \Twig_TokenParser {
protected $markdown;
public function __construct(MarkdownInterface $markdown) {
$this->markdown = $markdown;
}
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);
}
public function getTag() {
return 'markdown';
}
public function getMarkdown() {
return $this->markdown;
}
}