public function Markdown::process in Markdown 8
Same name and namespace in other branches
- 3.0.x src/Plugin/Filter/Markdown.php \Drupal\markdown\Plugin\Filter\Markdown::process()
Performs the filter processing.
Parameters
string $text: The text string to be filtered.
string $langcode: The language code of the text to be filtered.
Return value
\Drupal\filter\FilterProcessResult The filtered text, wrapped in a FilterProcessResult object, and possibly with associated assets, cacheability metadata and placeholders.
Overrides FilterInterface::process
See also
\Drupal\filter\FilterProcessResult
File
- src/
Plugin/ Filter/ Markdown.php, line 83
Class
- Markdown
- Provides a filter for markdown.
Namespace
Drupal\markdown\Plugin\FilterCode
public function process($text, $langcode) {
if (!empty($text)) {
switch ($this->settings['markdown_library']) {
case 'commonmark':
$converter = new CommonMarkConverter();
$text = $converter
->convertToHtml($text);
break;
case 'php-markdown':
if (!class_exists('Michelf\\MarkdownExtra') && \Drupal::moduleHandler()
->moduleExists('libraries')) {
libraries_load('php-markdown', 'markdown-extra');
}
$text = MarkdownExtra::defaultTransform($text);
break;
}
}
return new FilterProcessResult($text);
}