Skip to content

Section numbers not getting excluded from generated headingsΒ #42

@nihalshah-dev

Description

@nihalshah-dev

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!

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