Repository navigation
Don't generate empty heading ids - #1885
Open
sourya2704 wants to merge 1 commit into
Open
sourya2704 wants to merge 1 commit into
sourya2704 wants to merge 1 commit into
Conversation
Text.to_anchor removes every character except ASCII letters, digits, spaces and hyphens, so a heading made only of symbols or non-ASCII characters, like `$=` in globals.md, got `id=""`, and later ones got `-1`, `-2` and so on. When nothing is left, fall back to the legacy label format, so `$=` becomes `label-24-3D`. The heading then has the same id as its legacy anchor, so the separate legacy anchor is skipped. Headings that already had an id are unchanged. Fixes ruby#1882
This branch has not been deployed
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.
Fixes #1882.
RDoc::Text.to_anchorkeeps only ASCII letters, digits, spaces and hyphens. A heading with none of those, like### `$=`in globals.md or a heading in Japanese, getsid="", and later ones get-1,-2and so on:When nothing is left,
to_anchornow falls back to the legacy label format, so$=becomeslabel-24-3Dand日本語becomeslabel-E6-97-A5-E6-9C-AC-E8-AA-9E. The heading id then equals its legacy anchor, soaccept_headingskips the separate legacy span. The legacy id is still registered for deduplication as before:Every heading that got a non-empty id before keeps the same id, so existing links don't change. Old
#label-24-3Dlinks now point at the heading itself. The fallback is into_anchor, so the table of contents, section anchors and@labelcross-references use the same id.bundle exec rake normal_testand RuboCop on the changed files pass.