hexojs / hexo-renderer-marked

Markdown renderer for Hexo
MIT License
179 stars 94 forks source link

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

Open Pil0tXia opened 1 year ago

Pil0tXia commented 1 year ago

Check List

Please check followings before submitting a new feature request.

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 commented 1 year ago

Relevant code https://github.com/hexojs/hexo-renderer-marked/blob/d10fd5f50694df6f27e83d2fe760bc38675a6528/lib/renderer.js#L45-L50

uiolee commented 1 year ago

related issue:

stevenjoezhang commented 7 months ago

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