Fix indentation not being preserved on first line in code fences#1672
Merged
st0012 merged 1 commit intoruby:masterfrom Apr 9, 2026
Conversation
055ac38 to
b1f58b5
Compare
Collaborator
|
🚀 Preview deployment available at: https://5ba05e5b.rdoc-6cd.pages.dev (commit: b1f58b5) |
There was a problem hiding this comment.
Pull request overview
This PR fixes a GitHub-flavored Markdown parsing bug in RDoc where leading spaces on the first line of a fenced code block were being consumed, causing inconsistent indentation compared to subsequent lines (as reported in #1633).
Changes:
- Adjust the
CodeFencegrammar to stop consuming post-newline indentation whitespace at the start of the fenced block content. - Regenerate/update the corresponding parser implementation in
lib/rdoc/markdown.rb. - Add a regression test to ensure indentation is preserved on the first line of fenced code blocks.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/rdoc/rdoc_markdown_test.rb | Adds a regression test asserting first-line indentation inside code fences is preserved. |
| lib/rdoc/markdown.kpeg | Updates the CodeFence rule to avoid eating indentation after the opening fence newline. |
| lib/rdoc/markdown.rb | Updates the generated parser code and rule metadata to reflect the new CodeFence grammar. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Fix indentation not being preserved on first line in code fences (see issue #1633).