marked
marked copied to clipboard
Add documentation for Slugger
Currently the heading token looks like this
{
type: 'heading',
depth: 3,
text: 'Chapter 7',
}
I think it should also contain the heading id as it is not easy to generate from the text (https://github.com/markedjs/marked/blob/master/lib/marked.js#L1312).
{
type: 'heading',
depth: 3,
text: 'Chapter 7',
id: 'chapter-7',
}
An alternative would be to expose the slug
function via the marked module.
the slug function is exposed https://github.com/markedjs/marked/blob/5d727cb020fd9c748b228066f44f8a34828cc17b/lib/marked.js#L1685
You can get the slug function from
const slugger = new marked.Slugger();
slugger.slug(...)
Haha, what the heck. I somehow overlooked it in the code. 🙈 I guess when you don't expect to see something you don't see it even when it's there 😅.
Then the questions remains if it should be part of the token already 🤔
I don't think computed properties should be part of the AST
When you say it like this, I guess you're right. Then let's change the issue to "Add documentation for Slugger"
PRs are welcome
@UziTech The documentation already talks about the slugger. Do we need to add more info or clarify it somehow? Otherwise we can probably close this issue.
The documentation should say something about marked.Slugger
being public and show how to use it.