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 the TOC generation with unique links #156

Merged
merged 1 commit into from
Apr 14, 2023

Conversation

javiereguiluz
Copy link
Collaborator

Still WIP. It fixes #155.

I can't find any way of getting the id attributes of headings without changing the vendor dependencies ... so this proposes to just parse the generated HTML file and extract the information from it.

@javiereguiluz javiereguiluz changed the title (WIP) Fix the TOC generation with unique links Fix the TOC generation with unique links Apr 14, 2023
@javiereguiluz
Copy link
Collaborator Author

This is now ready for review.

@wouterj, @alamirault, @OskarStark if you have some time, please help me reviewing this. Thanks a lot!

@javiereguiluz
Copy link
Collaborator Author

After the last changes, I rebuilt Symfony Docs locally and it worked as expected.

The problem was that the static variable that holds header IDs (which we need to be static for it to work) wasn't reset before parsing each document.

In practice, the code made header IDs unique across all files ... and now they are unique within each single file.

@OskarStark
Copy link
Contributor

Looks good to me

@javiereguiluz javiereguiluz merged commit f34eaab into symfony-tools:main Apr 14, 2023
@javiereguiluz javiereguiluz deleted the fix_155 branch April 14, 2023 08:18
@wouterj
Copy link
Contributor

wouterj commented Apr 14, 2023

In practice, the code made header IDs unique across all files ... and now they are unique within each single file.

Note that per spec, explicit references (the .. _some-ref: syntax) must be unique across all files whereas implicit references (the one automatically generated based on section titles) must be unique within each single file.

This is something we're tackling in the new parser, but let's keep this parser & library simple and practical.

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

Successfully merging this pull request may close these issues.

Issue with the feature that avoids links with the same ID
3 participants