Skip to content

Heading ID conversion doesn't escape most punctuation symbols #5

@akumanatt

Description

@akumanatt

I've been using your markdown-styles page generator and noticed that some entries in table of contents doesn't work. I inspected them and found out that if a heading text contains punctuation symbols, including reserved URL characters, they will also be included (confirmed by this part of the code). This breaks the link to what the Markdown converter generated where most of them are simply removed.

Heading text: !"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~
Expected:     -0123456789_
Result:       !"#$%&'()*+,-./0123456789:;<=>?@[\]^_`{|}~

Adding this right below the line I mentioned resolves this issue:

id = id.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\]^`{|}~]/g, '');

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