timvink/mkdocs-enumerate-headings-plugin

Section numbers not getting excluded from generated headings

Opened this issue · 0 comments

Hello @timvink ,

In continuation to this - #37 (comment) & #37

I needed to exclude section numbers from generated headings. After some investigation, I would like to propose some modifications to the plugin to allow users to control whether section numbers are included in headings.

CHANGE -->

heading.py -

def enumerate(self, add_section_number=True, add_span_element=False):
        if add_section_number:
            section_string = self.section_number_string()
            self.heading.insert(0, " ")

This new configuration option "add_section_numbers", which defaults to True. When set to False, this option excludes section numbers from generated headings.

plugin.py (CURRENT) -

image

plugin.py (NEW) -

class EnumerateHeadingsPlugin(BasePlugin):
    config_scheme = (
        ("strict", config_options.Type(bool, default=True)),
        ("toc_depth", config_options.Type(int, default=0)),
        ("increment_across_pages", config_options.Type(bool, default=True)),
        ("restart_increment_after", config_options.Type(list, default=[])),
        ("include", config_options.Type(list, default=["*"])),
        ("exclude", config_options.Type(list, default=[])),
        ("add_section_numbers", config_options.Type(bool, default=True)),  # New option
    )

Let me know what do you think about this!