What reg pattern should I use make it parse all whitespace and multiple lines?

Right now only the first paragraph of my text is included in the collapsible field. I would like it to include everything.

I'm thinking changes should be done to the following... but not sure how...

/**
* Provides a layer of encapsulation for the regex call.
*/
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;
}

Comments

pooneil’s picture

Hi webbernet,

I've recently noticed the same thing. I don't think the problem lies in the regular expression. I've looked separately at what the regular expression captures and it looks correct. It looks like something is happening during the rendering (call to drupal_render), particularly with newline characters. I will try to reinvestigate this soon and let you know what I find. If anyone else reading this has ideas, please do share.

Regards,
Anthony

pooneil’s picture

Hi,

I've just created a new beta of this under 6.x-2.0-beta1 with several updates and enhancements. When looking back at this ticket I tried a collapsible section with more than 1 paragraph and it seemed to work. Can you give it a test?

Regards,
Anthony

pooneil’s picture

Status: Active » Closed (fixed)