Skip to content

Fix broken legacy rdoc-ref labels and duplicate heading IDs - #1602

Merged
tompng merged 1 commit into
masterfrom
fix-1590
Feb 9, 2026
Merged

Fix broken legacy rdoc-ref labels and duplicate heading IDs#1602
tompng merged 1 commit into
masterfrom
fix-1590

Conversation

@st0012

@st0012 st0012 commented Feb 7, 2026

Copy link
Copy Markdown
Member

Decode legacy CGI-encoded labels (e.g., What-27s+Here) in rdoc-ref links so they resolve to the correct GitHub-style anchors. Also deduplicate heading IDs by appending -1, -2, etc. when multiple headings produce the same anchor (e.g., "Method match" and "Method match?" both becoming method-match).

Fixes #1590

@st0012 st0012 self-assigned this Feb 7, 2026
@st0012 st0012 added the bug label Feb 7, 2026
@matzbot

matzbot commented Feb 7, 2026

Copy link
Copy Markdown
Collaborator

🚀 Preview deployment available at: https://f19c52b3.rdoc-6cd.pages.dev (commit: 9aa01f2)

Comment thread test/rdoc/markup/to_label_test.rb Outdated

def test_decode_legacy_label_alphanumeric_hex_unchanged
# -4F decodes to 'O' (alphanumeric), so leave as literal
assert_equal "class-4Fther", RDoc::Text.decode_legacy_label("class-4Fther")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding test case of something like "class-Feather" not to be converted to "class\xFEather" may help prevent regression.
This will detect a bug changing /-([0-9A-F]{2})/ to /-([0-9A-Fa-f]{2})/ in the future

Comment thread lib/rdoc/text.rb Outdated

module_function def decode_legacy_label(label)
label = label.tr('+', ' ')
label.gsub!(/-([0-9A-F]{2})/) do

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's OK to assume encoded parts to be ascii, /-([0-7][0-9A-F])/ might be better

Decode legacy CGI-encoded labels (e.g., `What-27s+Here`) in rdoc-ref
links so they resolve to the correct GitHub-style anchors. Also
deduplicate heading IDs by appending -1, -2, etc. when multiple
headings produce the same anchor (e.g., "Method match" and
"Method match?" both becoming `method-match`).

Fixes #1590
@tompng
tompng merged commit 344cff2 into master Feb 9, 2026
60 checks passed
@tompng
tompng deleted the fix-1590 branch February 9, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate id attributes

3 participants