You are here

function collapse_text_process in Collapse Text 6

Same name and namespace in other branches
  1. 5 collapse_text.module \collapse_text_process()
  2. 6.2 collapse_text.module \collapse_text_process()
1 call to collapse_text_process()
collapse_text_filter in ./collapse_text.module
Implementation of hook_filter().

File

./collapse_text.module, line 65
collapse_text is an input filter that allows text to be collapsible

Code

function collapse_text_process($text) {
  $text = collapse_text_process_recurs($text);

  // remove non-escaped collapse open tags
  $text = preg_replace('/(?<!\\\\)
                 \\[
                    collapse
                    (\\ collapsed)?
                    (?:\\ style=([^\\] ]*))?
                    (?:\\ title=([^\\]]*))?
                 \\]/smx', "", $text);

  // remove non-escaped collapse close tags
  $text = preg_replace('/(?<!\\\\)\\[\\/collapse\\]/smx', "", $text);

  // remove backslash on escaped open tags
  $text = preg_replace('/\\\\
                 (\\[
                    collapse
                    (?:\\ collapsed)?
                    (?:\\ style=([^\\] ]*))?
                    (?:\\ title=[^\\]]*)?
                 \\])/smx', '$1', $text);

  // remove backslash on escaped close tags
  $text = preg_replace('/\\\\(\\[\\/collapse\\])/smx', "\$1", $text);
  return $text;
}