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

Prepend markdown anchor links with '#md:' #2413

Merged
merged 1 commit into from Oct 28, 2023

Conversation

mogelbrod
Copy link
Contributor

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.

Comment on lines +201 to +207
href
?.replace(/^#(?:md:)?(.+)/, "#md:$1")
.replace(/"/g, """) || "";
let html = `<a href="${href}"`;
if (title != null)
html += ` title="${title.replace(/"/g, "&quot;")}"`;
html += `>${text}</a>`;
Copy link
Contributor Author

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?

Copy link
Collaborator

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

Copy link
Collaborator

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...

Copy link
Collaborator

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...

Copy link
Contributor Author

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?

Copy link
Collaborator

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.

@Gerrit0 Gerrit0 merged commit 41e6b33 into TypeStrong:master Oct 28, 2023
4 checks passed
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Oct 28, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

header id conflicts
2 participants