You are here

function collapse_text_process in Collapse Text 5

Same name and namespace in other branches
  1. 6.2 collapse_text.module \collapse_text_process()
  2. 6 collapse_text.module \collapse_text_process()

Provides a layer of encapsulation for the regex call.

1 call to collapse_text_process()
collapse_text_filter in ./collapse_text.module
Implementation of hook_filter().

File

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

Code

function collapse_text_process($text) {

  // Per #259535 and #233877, add ability to specify title
  // in collapse text. Thanks rivena, Justyn
  $text = preg_replace_callback('/
      \\[                         # look for an opening bracket
         collapse                # followed by the word `collapse`
         (\\ collapsed)?          # followed by (optionally) a space and the word `collapsed` (captured)
         (?:\\ title=([^\\]]*))?   # followed by (optionally) a space and a title, consisting of any
                                 # characters except a close bracket (captured)
      \\]                         # followed by a closing bracket
      (.+?)                      # then capture as few characters as possible until
      \\[\\/collapse\\]             # a closing "tag", which is a slash followed by `collapse` in brackets
    /smx', "_collapse_text_replace_callback", $text);
  return $text;
}