Skip to content

Match Markdown link reference labels case-insensitively - #1856

Open
afurm wants to merge 1 commit into
ruby:masterfrom
afurm:markdown-reference-case-insensitive
Open

afurm wants to merge 1 commit into
ruby:masterfrom
afurm:markdown-reference-case-insensitive

Conversation

@afurm

@afurm afurm commented Oct 19, 2026

Copy link
Copy Markdown
Member

Markdown link reference labels are matched case-insensitively (both in the original Markdown syntax and in CommonMark), but RDoc::Markdown stored and looked up references by their exact text. So with

See [the Docs][] and [Ruby].

[the docs]: https://docs.ruby-lang.org
[ruby]: https://www.ruby-lang.org

both links were left as literal [the Docs][] and [Ruby] in the output.

The label text is already normalized for whitespace in the Label rule, so I added a small reference_key helper that downcases the label, and used it both where a reference is stored and where a link looks it up. The link text keeps its original case.

I changed markdown.kpeg and regenerated markdown.rb with rake generate; rake verify_generated, rake normal_test and rubocop pass locally.

Markdown link reference labels are case-insensitive, but the parser
stored and looked up references by their exact text, so [Foo][] or
[ID] did not resolve against a [foo]: or [id]: definition and were
left as literal brackets in the output.
@github-actions

Copy link
Copy Markdown

Documentation preview

View the preview

Commit: b987fd7

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant