Skip to content

Do not duplicate the closing tag when a file ends in inline content - #2561

Open
benjaminkincses wants to merge 1 commit into
prettier:mainfrom
benjaminkincses:fix/1689-duplicate-close-tag
Open

benjaminkincses wants to merge 1 commit into
prettier:mainfrom
benjaminkincses:fix/1689-duplicate-close-tag

Conversation

@benjaminkincses

Copy link
Copy Markdown
Contributor

Fixes #1689.

When a file ends with an inline node and the original text ends with ?>, the printer appended a second ?> at the end of the program, so every format added another one. This happens when the close tag is part of the inline node's raw text, for example a file that uses a short open tag, or trailing HTML that contains a ?>.

The program printer now skips the extra close tag when the last child is an inline node whose raw text already ends with ?>.

Verified: the input from #1689 now formats to itself and stays stable on repeated formats. New snapshot test in tests/short-open-tag. Full suite passes (601 tests, 585 snapshots).

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.

problem with prettier auto add double "php close tag" end of file

1 participant