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

[Improvment] Definition of the order of the anchors within the page is not consistent with Typora #239

Open
2 tasks done
Pil0tXia opened this issue Dec 15, 2022 · 3 comments

Comments

@Pil0tXia
Copy link

Check List

Please check followings before submitting a new feature request.

  • I have already read Docs page
  • I have already searched existing issues

Feature Request

When there are multiple duplicate titles on the page, such as three "Original", Hexo references each anchor as "#Original", "#Original-1", and "Original-2".

Whereas Typora references them as "#Original-1", "Original-2", and "#Original-3".

This causes the locally written anchor link [jump to original image](#Original-2) jumps to a different title on the web side which do not match the local one. It will jump to the second title in Typora, and to the third on the web side.

If there is no "#Original-2" on the web side, the link will not respond.

I hope you can find a way to unify it.

Thank you very much!

Others

@stevenjoezhang stevenjoezhang transferred this issue from hexojs/hexo Dec 15, 2022
@stevenjoezhang
Copy link
Member

Relevant code

// Add a number after id if repeated
if (headingId[id]) {
id += `-${headingId[id]++}`;
} else {
headingId[id] = 1;
}

@stevenjoezhang
Copy link
Member

This issue is not easy to solve because we don't know if there will be duplicates when generating first header.

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

No branches or pull requests

3 participants