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

does not add anchors to headings using GitHub’s algorithm #11

Closed
endiliey opened this issue Nov 20, 2019 · 4 comments
Closed

does not add anchors to headings using GitHub’s algorithm #11

endiliey opened this issue Nov 20, 2019 · 4 comments
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 🐛 type/bug This is a problem

Comments

@endiliey
Copy link

Subject of the issue

remark-slug does not add anchors to headings using GitHub’s algorithm.

This probably got to do with toString from https://github.com/syntax-tree/mdast-util-to-string

Your environment

N/A. Does not matter.

Steps to reproduce

Example you have markdown

## <a name="foo"></a> Foo

## <a name="foo"></a> _Foo_

Use runkit for easy reproduction

https://runkit.com/endiliey/5dd56d8045205a0013aec93d

image

Expected behaviour

Slug should be like GitHub https://gist.github.com/endiliey/4516bbf630b0f34eeabe8900733cfbf6#-foo

-foo and -foo-1

Actual behaviour

Slug is a-namefooa-foo and a-namefooa-foo-1

@endiliey endiliey added 🐛 type/bug This is a problem 🙉 open/needs-info This needs some more info labels Nov 20, 2019
@wooorm
Copy link
Member

wooorm commented Nov 20, 2019

We can’t do that easily, unfortunately, to solve it we’d need to include a whole HTML parser. That is a very intensive task.

If you’re going to HTML, instead, you can use rehype-slug.

Alternatively, you can set node.data.hProperties.id yourself, and bring that parser in if you want!

And lastly, you could also not use HTML in headings ;) HTML in Markdown has many downsides.

@wooorm wooorm closed this as completed Nov 20, 2019
@wooorm wooorm added 🐛 type/bug This is a problem 🙅 no/wontfix This is not (enough of) an issue for this project and removed 🐛 type/bug This is a problem 🙉 open/needs-info This needs some more info labels Nov 20, 2019
@wooorm
Copy link
Member

wooorm commented Nov 20, 2019

Btw, thanks for distilling the problem down so much! That makes me able to answer quickly.

But on the other hand, maybe there is a bigger question you have, that I can also answer?

@endiliey
Copy link
Author

endiliey commented Nov 20, 2019

Actually i don't mind with current behavior. Just opening up this issue just in case someone will open up an issue in our repo saying this.

When they do it, I will tell them to see this issue 😆

Thanks for the great work

@wooorm
Copy link
Member

wooorm commented Nov 20, 2019

Ahh alright, good! Yeah, it’s good that this is documented 👍
If you have thoughts on how and where to add this to the docs, that’s also welcome!

Thanks Endi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 🐛 type/bug This is a problem
Development

No branches or pull requests

2 participants