Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for Slugger #1484

Closed
ad-si opened this issue Apr 30, 2019 · 8 comments · Fixed by #2750
Closed

Add documentation for Slugger #1484

ad-si opened this issue Apr 30, 2019 · 8 comments · Fixed by #2750
Labels
category: docs Documentation changes category: headings good first issue Something easy to get started with

Comments

@ad-si
Copy link

ad-si commented Apr 30, 2019

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.

@UziTech
Copy link
Member

UziTech commented Apr 30, 2019

the slug function is exposed

marked.Slugger = Slugger;

@UziTech
Copy link
Member

UziTech commented Apr 30, 2019

You can get the slug function from

const slugger = new marked.Slugger();
slugger.slug(...)

@ad-si
Copy link
Author

ad-si commented Apr 30, 2019

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 🤔

@UziTech
Copy link
Member

UziTech commented May 1, 2019

I don't think computed properties should be part of the AST

@ad-si
Copy link
Author

ad-si commented May 1, 2019

When you say it like this, I guess you're right.
Then let's change the issue to "Add documentation for Slugger"

@UziTech
Copy link
Member

UziTech commented May 1, 2019

PRs are welcome

@UziTech UziTech added category: docs Documentation changes and removed proposal labels May 3, 2019
@calculuschild calculuschild changed the title Add heading id to heading token Add documentation for Slugger May 30, 2021
@calculuschild
Copy link
Contributor

@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.

@UziTech
Copy link
Member

UziTech commented May 31, 2021

The documentation should say something about marked.Slugger being public and show how to use it.

@UziTech UziTech added the good first issue Something easy to get started with label Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: docs Documentation changes category: headings good first issue Something easy to get started with
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants