public function ReadmehelpMarkdown::convertLeadingDashSpace in README Help 8
Wraps leading "- " text lines into unordered list tag.
Parameters
string $text: The string to be filtered.
Return value
string The HTML source with unordered list(s).
1 call to ReadmehelpMarkdown::convertLeadingDashSpace()
- ReadmehelpMarkdown::process in src/
Plugin/ Filter/ ReadmehelpMarkdown.php - Performs the filter processing.
File
- src/
Plugin/ Filter/ ReadmehelpMarkdown.php, line 226
Class
- ReadmehelpMarkdown
- Provides a filter for markdown.
Namespace
Drupal\readmehelp\Plugin\FilterCode
public function convertLeadingDashSpace($text) {
return preg_replace_callback('/(?(DEFINE)(?<emptyline>(\\n\\n)))((\\n- )(.*?))(?&emptyline)/s', function ($matches) {
$match = '';
if ($match = !empty($matches[0]) ? $matches[0] : '') {
$items = '';
foreach (explode('- ', $match) as $item) {
if ($item = trim($item)) {
$items .= "<li>{$item}</li>";
}
}
$match = $items ? "\n<ul class=\"ul\">{$items}</ul>\n" : $match;
}
return $match;
}, $text);
}