-
Notifications
You must be signed in to change notification settings - Fork 709
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
Prepend markdown anchor links with '#md:' #2413
Conversation
href | ||
?.replace(/^#(?:md:)?(.+)/, "#md:$1") | ||
.replace(/"/g, """) || ""; | ||
let html = `<a href="${href}"`; | ||
if (title != null) | ||
html += ` title="${title.replace(/"/g, """)}"`; | ||
html += `>${text}</a>`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awkward to have to construct the HTML tag manually - not sure if marked or typedoc provides an API for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
marked doesn't, typedoc does via the jsx templating engine, I'll make that change after merging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually... I think we can revert this annoying prefixing now! The minimal theme was removed a while ago, so I'm not sure there's a reason for it anymore...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... sadly not. I'd like to rework the renderer at some point to make this possible, but headings in comments still get linked. It feels like there ought to be some other non-terrible way to do this, that doesn't make us write different headings than npm/github does when rendering...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps going the other direction would work; adding prefixes to the headings which typedoc "owns" (generates) and leaving the regular markdown ids unprefixed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered that when first adding the prefix, but typedoc generates a lot of anchors, there are generally far, far fewer markdown header links.
Thanks! |
Typedoc prepends
md:
to heading anchor ids generated by marked (added to fix #1135), but currently doesn't update any existing anchor links that points to them. This PR should address that.