-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
My Markdown editor of choice creates Tables of Content with the tag [TOC] (in caps) instead of [toc]. So this plugin didn't work right out of the box until I found this issue. I tried to edit my markdown files and then everything worked as expected. But as I didn't want to edit my markdown files twice, I tweaked TableOfContents.phpa little bit and inserted a little elseif structure in the block that looks for the tag (following line 160).
The whole block looks like this now:
// Replace [toc] in document
$nodes = $domXPath->query('//p');
foreach ($nodes as $node) {
if (trim($node->nodeValue) === "[toc]") {
$node->parentNode->replaceChild($div_element, $node);
break;
}
elseif (trim($node->nodeValue) === "[TOC]") {
$node->parentNode->replaceChild($div_element, $node);
break;
}
}
As I am an absolute PHP noob, I'm sure this can be solved in a much more elegant way. But it works for me and might do so for others, so I'm suggesting to integrate this feature into the plugin.
Metadata
Metadata
Assignees
Labels
No labels