public function MathjaxFilter::process in MathJax: LaTeX for Drupal 8.2
Same name and namespace in other branches
- 3.0.x src/Plugin/Filter/MathjaxFilter.php \Drupal\mathjax\Plugin\Filter\MathjaxFilter::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/ MathjaxFilter.php, line 28
Class
- MathjaxFilter
- Provides a filter to format text with Mathjax.
Namespace
Drupal\mathjax\Plugin\FilterCode
public function process($text, $langcode) {
$wrapped = strip_tags($text) !== 'TEST' ? '<div class="tex2jax_process">' . $text . '</div>' : $text;
$result = new FilterProcessResult($wrapped);
$config = \Drupal::config('mathjax.settings');
$config_type = $config
->get('config_type');
if ($config_type == 0) {
$result
->setAttachments([
'library' => [
'mathjax/config',
'mathjax/source',
'mathjax/setup',
],
'drupalSettings' => [
'mathjax' => [
'config_type' => $config_type,
'config' => json_decode($config
->get('default_config_string')),
],
],
]);
}
return $result;
}