You are here

function _collapse_text_filter_prepare in Collapse Text 7.2

Implements hook_filter_FILTER_prepare().

Convert any html style tags into bracket style. @todo create a better delimiter... Attempt to add quotes where needed for title= and style=

1 call to _collapse_text_filter_prepare()
CollapseTextTestCase::prepareWrapper in ./collapse_text.test
1 string reference to '_collapse_text_filter_prepare'
collapse_text_filter_info in ./collapse_text.module
Implements hook_filter_info().

File

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

Code

function _collapse_text_filter_prepare($text, $filter, $format, $langcode, $cache, $cache_id) {

  // fix any html style (ie, '<>' delimited) tags into our '[]' style delimited tags
  $text = preg_replace('/(?<!\\\\)     # not preceded by a backslash
      <             # an open bracket
      (             # start capture
        \\/?         # optional backslash
        collapse    # the string collapse
        [^>]*       # everything up to the closing angle bracket; note that you cannot use one inside the tag!
      )             # stop capture
      >             # close bracket
    /ix', '[$1]', $text);
  $text = preg_replace_callback('/(?<!\\\\)     # not preceded by a backslash
      \\[            # open bracket
      collapse      # the string collapse
      [^\\]]*        # everything up to a closing straight bracket; note that you cannot use one inside a tag!
      \\]            # closing bracket
    /ix', '_collapse_text_filter_prepare_regex_callback', $text);
  return $text;
}