public static function CodeFilter::fixSpaces in Code Filter 8
Replace html space elements with literal space characters.
Parameters
string $text: A string to fix spaces for.
Return value
string A formatted string.
2 calls to CodeFilter::fixSpaces()
- CodeFilter::processCode in src/
Plugin/ Filter/ CodeFilter.php - Processes chunks of escaped code into HTML.
- CodeFilter::processPHP in src/
Plugin/ Filter/ CodeFilter.php - Processes chunks of escaped PHP code into HTML.
File
- src/
Plugin/ Filter/ CodeFilter.php, line 212
Class
- CodeFilter
- Text filter for highlighting PHP source code.
Namespace
Drupal\codefilter\Plugin\FilterCode
public static function fixSpaces($text) {
$text = preg_replace('@ (?! )@', ' ', $text);
// A single space before text is ignored by browsers. If a single space
// follows a break tag, replace it with a non-breaking space.
$text = preg_replace('@<br /> ([^ ])@', '<br /> $1', $text);
return $text;
}