Skip to content

Doesn't work with [TOC] (instead of [toc] #20

@wasmitonline

Description

@wasmitonline

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions