Leave fenced code blocks alone when spacing markdown headings - #961
Open
sulimanbenhalim wants to merge 1 commit into
Open
Leave fenced code blocks alone when spacing markdown headings#961sulimanbenhalim wants to merge 1 commit into
sulimanbenhalim wants to merge 1 commit into
Conversation
…ents in guidelines and skills stop being split apart
Contributor
Author
|
ran this end to end on a fresh laravel 13 app with livewire 4.4.1 installed, what lands in # Single-file component (SFC - default in v4)
# Creates: resources/views/components/⚡create-post.blade.php
php artisan make:livewire create-post
# Page component (SFC - Full Page in v4)and on this branch: # Single-file component (SFC - default in v4)
# Creates: resources/views/components/⚡create-post.blade.php
php artisan make:livewire create-post
# Page component (SFC - Full Page in v4)2 of the 4 skills that install by default are affected, 13 stray blank lines total across |
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.
MarkdownFormatter::format()spaces out anything that looks like a heading, but it doesn't know about code fences. So a# commentline inside a bash block gets blank lines shoved around it.This ships in the box today. Real diff for
.ai/laravel/skill/laravel-best-practices/rules/config.md:The Livewire 4 skill is worse,
.ai/livewire/4/skill/livewire-development/SKILL.blade.phphas 9 comment lines in one bash block and every one gets split. User content goes through it too,SkillWriter::copyFile()andRuleComposer::composeManaged()both format everything, so a recorded rule with a code sample gets mangled the same way.Fix masks fences before the heading pass and restores them after, same trick
RendersBladeGuidelines::markScopedBlocks()already uses. Also anchored the second heading regex to line start soUse # for commentsin normal prose isn't read as a heading, the first one already is anchored.Side effect worth calling out: blank lines inside a fence now survive the
\n{3,}collapse.8 tests, 4 for the bug and 4 pinning what already worked (headings still spaced, blank lines still collapsed outside fences, CRLF still normalized). Reverting the src change fails exactly the first 4.