public function ReadmehelpMarkdown::convertSingleUnderscore 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::convertSingleUnderscore()
- ReadmehelpMarkdown::process in src/
Plugin/ Filter/ ReadmehelpMarkdown.php - Performs the filter processing.
File
- src/
Plugin/ Filter/ ReadmehelpMarkdown.php, line 464
Class
- ReadmehelpMarkdown
- Provides a filter for markdown.
Namespace
Drupal\readmehelp\Plugin\FilterCode
public function convertSingleUnderscore($text) {
return preg_replace_callback('/(\\s)(_[^_]*?_)/', function ($matches) {
$match = '';
if ($match = !empty($matches[2]) ? $matches[2] : '') {
$char = isset($matches[3]) ? $matches[3] : '';
$match = "{$matches[1]}<em>" . str_replace('_', '', $match) . "</em>{$char}";
}
return $match;
}, $text);
}