You are here

public function FilterSyntaxHighlighter::process in Syntax Highlighter 8

Revert back to <pre> tag.

Overrides FilterInterface::process

File

src/Plugin/Filter/FilterSyntaxHighlighter.php, line 75

Class

FilterSyntaxHighlighter
Provides a filter to highlight source code.

Namespace

Drupal\syntaxhighlighter\Plugin\Filter

Code

public function process($text, $langcode) {
  $config = \Drupal::config('syntaxhighlighter.settings');
  $patterns = [
    '#{' . SYNTAXHIGHLIGHTER_TAG_STRING . ' ([^}]+)}#',
    '#{/' . SYNTAXHIGHLIGHTER_TAG_STRING . '}#',
  ];
  $tag_name = $config
    ->get('tagname');
  $replacements = [
    "<{$tag_name} \$1>",
    "</{$tag_name}>",
  ];
  $output = preg_replace($patterns, $replacements, $text);
  return new FilterProcessResult($output);
}