-
Notifications
You must be signed in to change notification settings - Fork 140
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
[FEATURE] Header links #186
Comments
Where are you seeing it create those as absolute links? It seems to just use it verbatim: $ echo -e "[foo](#bar)\n\n##Bar" | ./bin/markdown --flavor=gfm
<p><a href="#bar">foo</a></p>
<h2>Bar</h2> But you're probably right, it'd be good to add IDs to headers in the same way that GitHub does. |
Here's the ouput of this README, parsed using this library. Excluding the outer div, this is exeactly what was output:
Notice the links are absolute links to the README, thereby taking the user off-site. |
TBH, I think that README is actually written that way, but I think we could safely remove the github link and leave just the hash if we're using GFM |
I don't think it's possible to remove the absolute link when parsing that. How would the parser know that the document is a Github readme? And you're right, it looks like the readme you linked is intentionally adding fully qualified links. |
That's where the gfm being specified comes in 😁 |
Why not just leave the URLs out of the Markdown though? I'm not sure I really understand the use case here. :-) I do think adding anchors is a good plan though, and following GitHub's method of mapping them. (Also, note that I'm not a maintainer of this package, just an interested bystander. I'm not really sure if @cebe is around here much any more.) |
See.... it's not my package or I'd do just that 😂 My use case is the markdown is converted to HTML in a backend API, sanitized, put in a database, and requested on the website and displayed. And obviously with absolute links, that takes the user off site which is suboptimal. If nothing else, just adding anchor mapping could be enough - I'm sure I can cook up an evil enough, er I mean, good enough, regex to get the links how I want them, I just think this might be a useful feature for others. |
Hmm that does sound trickier! |
GitHub at least includes the ability to create header links. This for instance makes the #header-1 link to the first heading named Header, ie
However, this library makes those links absolute, meaning it now links to the original github repository, thereby taking them off our website.
Is there a way to make the links relative that I'm missing, or could that be made a new feature if it's not already present?
The text was updated successfully, but these errors were encountered: