Skip to content

Incorrect parsing of Setext-style headings #1604

@saf-dmitry

Description

@saf-dmitry

Python-Markdown wrongly recognizes following as H1 and H2 headings, respectively:

Some text
=-=-=-=-=

Some text
-=-=-=-=-

This is because the regex for detection of Setext-style headings handles runs of the = and - characters incorrectly. Below the improved version, which uses (?:[=]+|[-]+) group instead of [=-]+:

RE = re.compile(r'^.*?\n(?:[=]+|[-]+)[ ]*(\n|$)', re.MULTILINE)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions