-
Notifications
You must be signed in to change notification settings - Fork 90
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
Anchors in markdown #491
Comments
added note about local links |
I believe you meant to file this issue for the As of PR #270, we support HTML rendering in Markdown content in The thing is though, it's probably even more important that we have a feature for linking directly to a preview card on a package or file landing page. For example, we will eventually want to be able to link people (via And if we have that feature then we have a problem: now anchors for section titles in a Markdown render can collide with the names of previewed files. For this reason I believe that for now we should just have users populate anchors the manual way. One thing in your statement that I didn't quite understand:
|
@nl0 |
probably no, at least in its current form |
To have working anchor links in markdown we have, basically, two options: manual anchor insertion and automatic generation (based on the heading text).
Manual
Insertion
Just insert the anchor:
## Section 1 <a name="section1"></a>
, -- it's simple and explicit, we just need to enable html inremarkable
options.Usage
To use these anchors, we simply reference them by given names:
[Section 1](#section1)
.Pros
Cons
Implementation
remarkable
optionsAutomatic
Generation
We can generate the anchors with the help of something like markdown-toc (see example implementation).
This will require render customization to expose the generated names.
Usage
The usage is essentially the same as with the first option, but since the names are implicit, we should make the anchors accessible in some way, like anchor icons shown when hovering headings on github.
Pros
Cons
Implementation
Caveats
Hash routing works out-of-the-box if the contents are already rendered (so navigating using TOC is ok), but doesn't work on the cold start (navigating directly to
/page#section
is not ok), so we need some (probably hacky) workaround (our existing one won't work, because it's react-specific, and markdown rendering is happening outside of react context). Server-side rendering will fix this.Site-local links
Also, it makes sense to intercept link clicks inside markdown and use
react-router
'spush
if the link is local (relative, absolute without schema or if origin matches the current one) to avoid page reload.The text was updated successfully, but these errors were encountered: