You are here

public function ReadmehelpMarkdown::convertSingleAsterisk in README Help 8

Replaces pairs of "*" signs by the em tag.

Parameters

string $text: The string to be filtered.

Return value

string The HTML source with emphasized text.

1 call to ReadmehelpMarkdown::convertSingleAsterisk()
ReadmehelpMarkdown::process in src/Plugin/Filter/ReadmehelpMarkdown.php
Performs the filter processing.

File

src/Plugin/Filter/ReadmehelpMarkdown.php, line 426

Class

ReadmehelpMarkdown
Provides a filter for markdown.

Namespace

Drupal\readmehelp\Plugin\Filter

Code

public function convertSingleAsterisk($text) {
  return preg_replace_callback('/(\\*[^*]*?\\*)/', function ($matches) {
    $match = '';
    if ($match = !empty($matches[0]) ? $matches[0] : '') {
      $match = "<em>" . str_replace('*', '', $match) . "</em>";
    }
    return $match;
  }, $text);
}