Skip to content

anchors_plugin callback #7

Open
@tylerlozano

Description

@tylerlozano

I want a list of the title, unique slug-id pairs for my generated anchors so I can create a navbar linking to the content. In MarkdownIt for JS a callback exists with this data:

"The callback option is a function that will be called at the end of rendering with the token and an info object. The info object has title and slug properties with the token content and the slug used for the identifier."

How can this be done with the current plugin?

I thought about a custom parsing function for heading_open token, but how to get inline after?

I considering passing a custom slug_func to anchors_plugin, but it doesn't have access to the slugs param so it can not retrieve the unique_slug id for the heading.

I tried parsing first, then rendering, but the plugin maintains state and so the unique_slug ids in the token stream don't match what is rendered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions