class Extension in Markdown 3.0.x
Hierarchy
- class \Drupal\markdown\Twig\Markdown\Extension extends \Drupal\markdown\Twig\Markdown\Twig_Extension implements \Drupal\markdown\Twig\Markdown\Twig_Extension_GlobalsInterface
Expanded class hierarchy of Extension
1 string reference to 'Extension'
1 service uses Extension
File
- src/
Twig/ Markdown/ Extension.php, line 7
Namespace
Drupal\markdown\Twig\MarkdownView source
class Extension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface {
/**
* 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 getName() {
return 'markdown';
}
/**
* {@inheritdoc}
*/
public function getGlobals() {
return [
'markdown' => $this->markdown,
];
}
/**
* {@inheritdoc}
*/
public function getFilters() {
return [
'markdown' => new \Twig_SimpleFilter('markdown', [
$this,
'parse',
], [
'is_safe' => [
'html',
],
]),
];
}
/**
* {@inheritdoc}
*/
public function getFunctions() {
return [
'markdown' => new \Twig_SimpleFunction('markdown', [
$this,
'parse',
], [
'is_safe' => [
'html',
],
]),
];
}
/**
* {@inheritdoc}
*/
public function getTokenParsers() {
return [
new TokenParser($this->markdown),
];
}
/**
* Helper method for parsing markdown.
*
* @param string $markdown
* The markdown to render.
*
* @return string
* The rendered markdown into HTML.
*/
public function parse($markdown) {
return $this->markdown
->getParser()
->parse($markdown);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Extension:: |
protected | property | An instance of a markdown processor to use. | |
Extension:: |
public | function | ||
Extension:: |
public | function | ||
Extension:: |
public | function | ||
Extension:: |
public | function | ||
Extension:: |
public | function | ||
Extension:: |
public | function | Helper method for parsing markdown. | |
Extension:: |
public | function |