Skip to content

Unable to override header anchors #350

Open
@majutsushi

Description

@majutsushi

Describe the bug

I'm not sure if this is a bug, enhancement, or just insufficient documentation, but I would expect this to work especially since it works fine in the original markdown-it.

context
I'm trying to override the heading anchor ID generated by the "anchors" plugin in some cases just like it is documented for the "markdown-it-anchor" plugin here. However, I've tried various combinations of the "attrs" and "attrs_block" plugins with various values for the after and spans parameters and I haven't been able to get it to work. I also tried different orders of .use() calls when specifying the plugins.

expectation
I expected this to override the ID generated by the "anchors" plugin:

# Your title {#your-custom-id}

bug
The attrs specification gets treated as normal text in the header instead of an attrs instruction.

problem
This makes it impossible to override the header anchor, which is important in cases where you need a stable anchor that does not depend on the actual text of the header.

Reproduce the bug

See above.

List your environment

markdown-it-py version: 3.0.0
mdit-py-plugins version: 0.4.2
Python version: 3.13
OS: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions