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

fix: same link header-anchors #254

Closed
wants to merge 1 commit into from
Closed

Conversation

HyTekCoop
Copy link
Member

@HyTekCoop HyTekCoop commented Sep 12, 2022

Resolves #203

If headers had the same names, they couldn't have different links (anchors). And the second header with the same name or the third or ... etc open anchors for the first header with that name. So counter was created to the headers. Thanks to it, the anchors have an ordinal number of the link, which allows the links to be individual.

First anchors "Итого"
image

Second anchors "Итого"
image

Third anchors "Итого"
image

At the same time, if you add a new heading or delete an old heading, then the link identification numbers of the heading will be updated. It will not work such that the numbers of the links will increase all the time.

@HyTekCoop HyTekCoop changed the title fix/same-link-header-anchors fix: same-link-header-anchors Sep 12, 2022
@HyTekCoop HyTekCoop changed the title fix: same-link-header-anchors fix: same link header-anchors Sep 12, 2022
@talyguryn
Copy link
Member

it is not okay at all.

view

design of these links is not good for user. why some anchor may start with strange numbers?

#2-what-does-it-mean-block-styled
#3-what-is-clean-data

it will be better to use numbers at the end of line:

#what-does-it-mean-block-styled-2
#what-is-clean-data-3

code

anchors should not be changed cause they could be used in links. that's why it should be static. your code adds count numbers before each header then if i'll change the order of headers for some reasons saved anchors may die.

example of changing the order:

#what-does-it-mean-block-styled-2 -> #what-does-it-mean-block-styled-3
#what-is-clean-data-3 -> #what-is-clean-data-2

also it will be good to upgrade the function for generating anchors or create another one as wrapper because we may need to use in on the backend side such for a search results.

idea

and the most valuable reason why we should not solve the problem this way. it's a bad approach in article editing to use same headers in the single page. then all pages with duplicated headers should be edited according the writing rules. this way we will have no reason to add any kind on additional identifiers such a numbers.

if you really need to add two identical headers to the page then you need to start adding counters from the second one. for the most cases headers will stay without any postfix:

#example
#example-1
#example-2

@HyTekCoop HyTekCoop closed this Sep 13, 2022
@nikmel2803 nikmel2803 deleted the fix/same-header-link-anchors branch December 1, 2022 18:28
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.

Headers with the same content have identical anchors
3 participants