function hook_toc_filter_alter in TOC filter 8.2
Alter the options used to be a table of contents.
This hook is called by the TOC filter before a table of contents is initialized.
A module could add addition options based on custom attributes/options
Setting $options to FALSE will stop a table of contents from being generated.
Parameters
array &$options: An associative array containing the [toc] token's options merged with the the TOC filter setting's options.
string &$content: The content about to be converted to a table of contents.
1 function implements hook_toc_filter_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- toc_filter_toc_filter_alter in tests/
modules/ toc_filter_test/ toc_filter_test.module - Implements hook_toc_filter_alter().
1 invocation of hook_toc_filter_alter()
- TocFilter::process in src/
Plugin/ Filter/ TocFilter.php - Performs the filter processing.
File
- ./
toc_filter.api.php, line 31 - Hooks provided by the TOC filter module.
Code
function hook_toc_filter_alter(&$options, &$content) {
// If there is less than five <h2> tags don't generate a table of contents.
if (substr_count($content, '<h2') < 5) {
$options = FALSE;
}
}