Fix ID shared by different pages being considered duplicates#311
Open
romaricpascal wants to merge 5 commits intoalphagov:mainfrom
Open
Fix ID shared by different pages being considered duplicates#311romaricpascal wants to merge 5 commits intoalphagov:mainfrom
romaricpascal wants to merge 5 commits intoalphagov:mainfrom
Conversation
Prevents IDs to be misinterpreted as duplicated across the rendering of different pages sharing headings
It is no longer needed for resetting the generator on the before lifecycle hook as it gets reset by the Markdown renderer
It no longer needs to be as its lifecycle is now fully tied to the Redcarpet renderer
c63ea99 to
38ad278
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for #310 where pages sharing the same headings referenced in the navigation would end up with these headings treated as duplicates when their ID get generated for the navigation links. This would make the link point to the wrong ID and not fullfill their role of sending the user straight to the right section.
What’s changed
The commits should paint a step by step decription of the changes. As a broad summary, this PR changes when the
UniqueIdentifierGeneratorgets reset. It makes it happen before each Markdown render, rather than on Middleman'sbeforehook (whose timing is still very unclear to me, but led to the original situation).I did also try to tie the resets to a Rack middleware, to ensure they happen for every request made to Middleman (which surprisingly didn't match the
beforehook), but the issue remained.The PR also cleans things up now the generator's lifecycle is bound to that of Redcarpet's renderer:
Each of these two bits is done in their own separate commit so could be easily dropped if we fear this may break things for people using the gem.
I've also added a few tests around the
TechDocsHTMLRendererto validate the heading generation.Identifying a user need
This issue was discovered while adding JavaScript API documentation alongside the Sass one in the govuk-frontend docs. It may hit any documentation whose pages share the same heading structure (either written manually or automated).
Closes #310