valeriangalliat / markdown-it-anchor

A markdown-it plugin that adds an `id` attribute to headings and optionally permalinks.
The Unlicense
291 stars 72 forks source link

TypeError: c.attrGet is not a function #122

Open NigelvanDuijvendijk opened 1 year ago

NigelvanDuijvendijk commented 1 year ago

Im trying to use markdown-it-anchor in a typescript react application but im getting the following error: TypeError: c.attrGet is not a function

Im using it as followed:

const mdParser = MarkdownIt().use(markdownItAnchor, {
        permalink: true,
        permalinkBefore: true,
        permalinkSymbol: "", // §
    });

This error only pops up when there is a heading in the markdown. image

valeriangalliat commented 1 year ago

Hey! If you still have this issue, it would help me to debug if you could come up with a runnable example that reproduces the problem :)

Here's what I tried so far:

const mdit = require('markdown-it')
const anchor = require('markdown-it-anchor')

const md = mdit().use(anchor, {
  permalink: true,
  permalinkBefore: true,
  permalinkSymbol: "",
})

console.log(md.render('# foo'))
{
  "dependencies": {
    "markdown-it": "^13.0.1",
    "markdown-it-anchor": "^8.6.6"
  }
}

But this code returns the HTML without exception