-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch
GovukTechDocs::TechDocsHTMLRenderer
Add a new `preprocess` hook to the Redcarpet renderer to reset the ID generator. This ensures headings that may appear on multiple pages are not treated as duplicate when rendering one of these pages. See: alphagov/tech-docs-gem#310
- Loading branch information
1 parent
69d439a
commit 78f40d4
Showing
3 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
25 changes: 25 additions & 0 deletions
25
...t/govuk_tech_docs/tech_docs_html_renderer/reset_unique_identifier_generator_preprocess.rb
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Ext | ||
module GovukTechDocs | ||
module TechDocsHTMLRenderer | ||
module ResetUniqueIndentifierGeneratorPreprocess | ||
## | ||
# Fix for the unique ID generation not being reset for each document | ||
# leading to IDs being considered duplicates when on different pages | ||
# while they shouldn't be | ||
# | ||
# @see https://github.com/alphagov/tech-docs-gem/issues/310 | ||
|
||
def preprocess(document) | ||
## | ||
# Resets the UniqueIdentifierGenerator before the document gets processed | ||
# | ||
# @see https://github.com/vmg/redcarpet#prepost-process | ||
|
||
::GovukTechDocs::UniqueIdentifierGenerator.instance.reset | ||
|
||
document | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains 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