You are here

function codefilter_fix_spaces in Code Filter 7

Same name and namespace in other branches
  1. 5 codefilter.module \codefilter_fix_spaces()
  2. 6 codefilter.module \codefilter_fix_spaces()

Replace html space elements with literal space characters.

Parameters

string $text: A string to fix spaces for.

Return value

string A formatted string.

4 calls to codefilter_fix_spaces()
codefilter_prism_process_code in modules/codefilter_prism/codefilter_prism.module
Processes chunks of escaped code into HTML.
codefilter_prism_process_php in modules/codefilter_prism/codefilter_prism.module
Processes chunks of escaped PHP code into HTML.
codefilter_process_code in ./codefilter.module
Processes chunks of escaped code into HTML.
codefilter_process_php in ./codefilter.module
Processes chunks of escaped PHP code into HTML.

File

./codefilter.module, line 91
Text filter for highlighting PHP source code.

Code

function codefilter_fix_spaces($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 />&nbsp;$1', $text);
  return $text;
}