-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Automatically get Anchor link #395
Comments
I'm not sure what's being asked here. @RensTillmann Can you explain a little more? @jhildenbiddle @anikethsaha any ideas? |
Can you elaborate on how you would use this feature? I understand the basic idea of what you're asking for, but I'm unsure if you want this behavior in the sidebar, the main navigation, to content area, or anywhere in the site. |
Hi, @trusktr @jhildenbiddle @anikethsaha I asked about this back in February 2018 (time goes too fast), back then I had not much understanding (nor used it) of what "Markdown" really was. Now I do, this question/feature request might actually not be so much related to Docsify at all, but more to the Markdown language itself. However I do not know how Docsify works under the hood, and if it might actually be capable of solving this issue on it's own. Let's assume we got the following markdown document which in this case is a simple FAQ:
As per my understanding the part My question would be: is there an automatic way to "generate" the anchor link based on the title itself? Something like this:
where I hope this explains it better :) @jhildenbiddle I understand the basic idea of what you're asking for, but I'm unsure if you want this behavior in the sidebar, the main navigation, to content area, or anywhere in the site. Just in the content area itself. Thanks! |
Thanks for the quick feedback, @RensTillmann!
Yes, but it is unlikely that this is something we would add to docsify. One of the major selling points of markdown is portability. It's the reason why the same README.md file can be rendered in multiple places (like github.com or npmjs.com) and look completely different. In order for this to work, markdown processors have to abide by rules that determine how markdown should be rendered. There's a basic syntax that everyone supports, then a few extended syntax options that may or may not be supported by your markdown renderer. The problem with implementing new/custom rendering behaviors into docsify like the one you're describing is that they negatively impact the portability of your markdown files. Instead of writing markdown that works everywhere, you're now writing markdown that works only with docsify. For example, if you wrote the following markdown: [My Anchor Link 1]
[My Anchor Link 2](?) We could add functionality to docsify that treated this as if it were the following: [My Anchor Link 1](#my-anchor-link-1)
[My Anchor Link 2](#my-anchor-link-2) And render the following HTML in docsify: <a href="#my-anchor-link-1">My Anchor Link 1</a>
<a href="#my-anchor-link-2">My Anchor Link 2</a> But if you rendered that same markdown outside of docsify (for example, on GitHub) here's how it would render: [My Anchor Link 1]
<a href="?">My Anchor Link 2</a> To be fair, docsify has a few of these "docsify only" markdown features (like our doc helpers), but the maintainers are revisiting these to determine if we can offer docsify-specific markdown options that don't negatively affect document portability (see #413 for details). The good news is that the functionality you're asking for could be implemented using a docsify plugin. This is exactly what the plugin system was designed for: to allow others to extend docsify's functionality beyond the core docsify experience. Hope this helps explain things a bit. |
Thanks for the detailed reply. I totally agree that portability is and should be the priority. I guess I will just stick with the method I am using right (may I ever need to switch to a different processor). After reading the issue (#413) you shared, I noticed that there is a way to make a "Collapse/Accordion" section. I think that this could help me a lot in some cases where I have to put a lengthy FAQ. More details here: https://gist.github.com/pierrejoubert73/902cc94d79424356a8d20be2b382e1ab. The only downside is that you can't anchor to any of the inner content, e.g a heading. You would have to add an id attribute on either the |
I was wondering if it would be possible to automatically retrieve the correct anchor link like this:
Or maybe leave blank like so:
Instead of having to do like this:
If this is possible I couldn't find how to do it, but if it's not possible maybe it's a good suggestion to add in future? Thanks 👍
The text was updated successfully, but these errors were encountered: