You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just wondering, is there a way to override this plugin to wrap the headings with sections, give the sections the ids, and put an anchor into each heading that points to the section id?
What I imagine is something like this:
Input:
## First section### Nested first section heading## Second section
Output:
<sectionid="first-section"><h2><ahref="#first-section">First section</a></h2><sectionid="nested-first-section-heading"><h3><ahref="#nested-first-section-heading">Nested first section heading</a></h3></section></section><sectionid="second-section"><h2><ahref="#second-section">Second section</a></h2></section>
I thought I could use the renderer and only override part of what this extension does, but not sure if this is the right approach and how I would go about it.
import{gfmHeadingId}from"marked-gfm-heading-id";constgfmExtension=gfmHeadingId(options);constoldRenderer=gfmExtension.renderer.heading;gfmExtension.renderer.heading=(token)=>{consthtml=oldRenderer(token);// do something with outputreturnhtml;};marked.use(gfmExtension)
Hey @UziTech
Just wondering, is there a way to override this plugin to wrap the headings with sections, give the sections the ids, and put an anchor into each heading that points to the section id?
What I imagine is something like this:
Input:
Output:
I thought I could use the
renderer
and only override part of what this extension does, but not sure if this is the right approach and how I would go about it.The text was updated successfully, but these errors were encountered: