function collapse_text_process_recurs in Collapse Text 6
Provides a layer of encapsulation for the regex call.
2 calls to collapse_text_process_recurs()
File
- ./
collapse_text.module, line 98 - collapse_text is an input filter that allows text to be collapsible
Code
function collapse_text_process_recurs($text) {
// Per #259535 and #233877, add ability to specify title
// in collapse text. Thanks rivena, Justyn
// Per #233877, add ability to have nested sections.
$text = preg_replace_callback('/
(?:<p(?:\\s[^>]*)?>)? # (remove paragraph if right before)
(?<!\\\\) # make sure the tag is not escaped with a backslash
\\[ # look for an opening bracket
collapse # followed by the word `collapse`
(\\ collapsed)? # followed by (optionally) a space and the word `collapsed` (captured)
(?:\\ style=([^\\] ]*))? # followed by (optionally) a space and a style, consisting of any
# characters except a close bracket (captured)
(?:\\ title=([^\\]]*))? # followed by (optionally) a space and a title, consisting of any
\\] # followed by a closing bracket
(?:<\\/p\\s*>)? # (remove paragraph if right after)
( (?: [^[] # followed by either a non open bracket,
| \\\\\\[ # or an escaped open bracket
| \\[(?!\\/?collapse) # or a non collapse tag
| (?R) )+ ) # or the expression recursively run.
(?:<p(?:\\s[^>]*)?>)? # (remove paragraph if right before)
(?<!\\\\) # make sure the tag is not escaped with a backslash
\\[\\/collapse\\] # a closing "tag", which is a slash followed by `collapse` in brackets
(?:<\\/p\\s*>)? # (remove paragraph if right after)
/smx', "_collapse_text_replace_callback", $text);
return $text;
}