Ignore inline notes during Markdown reference parsing#1713
Open
skatkov wants to merge 2 commits into
Open
Conversation
Inline notes inside reference labels can run during the reference-gathering pass. Reset note state for each parse and reject inline notes before note ordering starts so reused parser instances do not accept stale footnote data.
Contributor
There was a problem hiding this comment.
Pull request overview
Resets @footnotes and @note_order to nil at the start of each parse call, and makes the InlineNote rule raise a ParseError when invoked before notes are initialized (e.g., during the references-gathering pass on a reused parser instance).
Changes:
- Reset
@footnotesand@note_orderto nil at the start ofparseto prevent leakage across reused parser instances. - Update the
InlineNotePEG rule action to raiseParseError, 'invalid inline note'when@note_orderis nil. - Add a regression test exercising an inline note inside a reference label after a prior parse.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/rdoc/markdown.kpeg | Source grammar: clear note state on parse and guard InlineNote action. |
| lib/rdoc/markdown.rb | Generated parser mirroring the kpeg changes (state reset + guard + Rules entry). |
| test/rdoc/rdoc_markdown_test.rb | New test validating the ParseError is raised on inline notes within reference labels after reuse. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tompng
reviewed
May 14, 2026
tompng
reviewed
May 14, 2026
Inline notes can be parsed while Markdown references are being collected, before footnote ordering has been initialized. Treat that early pass as a no-op so malformed reference labels do not crash the parser.
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.
Inline notes inside reference labels can be parsed during the reference-gathering pass, before footnote ordering is initialized.
RDoc::Markdown.parse("[foo ^[note]]: /url\n")This will crash a Markdown parser with a
NoMethodError.This change treats inline-note creation as a no-op until note ordering exists.