You are here

function _tableofcontents_filter_prepare in Table of Contents 7.2

Prepare the text for the table of content.

Simply sorts out any pre-marked

1 call to _tableofcontents_filter_prepare()
tableofcontents_filter_prepare in ./tableofcontents.module
Implements hook_filter_FILTER_prepare(). (sort of)

File

./tableofcontents.filters.inc, line 28
Table of Contents - Versatile system for generating Tables of Contents for fields - filters.

Code

function _tableofcontents_filter_prepare($text, $filter, $format, $langcode, $cache, $cache_id) {
  if (!$text) {
    return $text;
  }

  // support for PEAR wiki (http://drupal.org/node/150067#comment-937519)
  $text = str_replace('[[TOC]]', '[toc]', $text);

  // And replace pre-set versions with our version
  return preg_replace_callback(array(
    '%<!--\\s*tableofcontents([^>]*?)-->%',
    '%\\[\\[TOC(.*?)\\]\\]%',
  ), '_tableofcontents_replace_comments', $text);
}