Escape indented table delimiter rows - #19929
Open
fahadhewad wants to merge 1 commit into
Open
Conversation
A table delimiter row indented by four spaces or more is part of a paragraph rather than of a table. Its indentation was dropped without escaping the row, so the paragraph was parsed as a table the next time the file was formatted, which made formatting not idempotent. Escape such a row instead, the way an indented pseudo setext header is already escaped.
✅ Deploy Preview for prettier ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Description
Fixes #19847.
A table delimiter row that is indented by four spaces or more is a lazy continuation line of the paragraph above it, not part of a table. Prettier dropped that indentation without escaping the row, so the paragraph was parsed as a table on the next run, and formatting was not idempotent.
Such a row is now escaped, the same way an indented pseudo setext header is already escaped in
printWord. The escape applies only withproseWrapset topreserve, because the other modes join the line with the previous one, and it is skipped when the line starts with a marker that already makes the two lines join. Delimiter rows written without outer pipes, such as--- | ---, drift in the same way and are covered as well.The leading marker pattern that decides whether two lines are joined now lives in
utilities.js, so both call sites share it.The full test suite passes, the existing markdown and mdx snapshots are unchanged, and
--debug-checkreports no AST change for the affected inputs.This change was written with AI assistance, so the box about not using AI is left unchecked.
Checklist
docs/directory).changelog_unreleased/*/XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.