markdown-pp icon indicating copy to clipboard operation
markdown-pp copied to clipboard

How to disable features (in particular auto-numbering of sections in TOC) ?

Open sylvaticus opened this issue 5 years ago • 2 comments

Hello, I just learned how to disable the latex plugin, but I would like now to also disable automatic numbering of paragraphs in the TOC, as they are already manually numbered.

More in general it would be nice to have a way to disable each feature individually and to document it.

sylvaticus avatar Apr 09 '20 15:04 sylvaticus

I can see there in an option -h (I was looking for the manpage) that list the modules that can be disabled, including tableofcontent.

It would be nice to have an option to disable individual features for each module, e.g. -e tableofcontent numbers,links -e latexplugin equations

sylvaticus avatar Apr 09 '20 15:04 sylvaticus

Solved my own user case with a bit of hacking of /usr/local/lib/python3.6/dist-packages/MarkdownPP/MarkdownPP.py

Now I have the sections with identation rather than numbering:

            if depth == 1:
                section = "%d\\. " % headernum
                sectionintoc = "- "
                sectioninbody = ""
                
            else:
                section = (".".join([str(x) for x in stack]) +
                           ".%d\\. " % headernum)
                sectionintoc = "".join("   " for x in stack)+"- "
                sectioninbody = ""

            #tocdata += ("%s [%s](#%s)  \n" %
            #            (section, TableOfContents.clean_title(title), short))
            tocdata += ("%s [%s](#%s)  \n" %
                        (sectionintoc, TableOfContents.clean_title(title), short))

            #transforms.append(Transform(linenum, "swap",
            #                  data[linenum].replace(title, section + title)))
            transforms.append(Transform(linenum, "swap",
                              data[linenum].replace(title, sectioninbody + title)))
            transforms.append(Transform(linenum, "prepend",
                              "<a name=\"%s\"></a>\n\n" % short))

Of course, the general idea to have feature disabled in the command line is still interesting..

sylvaticus avatar Apr 09 '20 16:04 sylvaticus