-
Notifications
You must be signed in to change notification settings - Fork 7
Improper Handling of Missing Trailing Newline for Nested Void Tags #30
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
An issue arises with this plugin when handling nested void tags without a trailing newline character. The following is a POC to demonstrate this bug.
Unformatted:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example Document</title>
</head>
<body>
<a title="google.com" href="https://www.google.com"><img src="https://fastly.picsum.photos/id/675/200/300.jpg?hmac=c2gHO4_1hIFBRijtOhz09icBTxsdGCsMSYSs2XIDdAk" alt="dummy image"/></a>
</body>
</html>Output of prettier-plugin-void-html:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example Document</title>
</head>
<body>
<a title="google.com" href="https://www.google.com"
><img
src="https://fastly.picsum.photos/id/675/200/300.jpg?hmac=c2gHO4_1hIFBRijtOhz09icBTxsdGCsMSYSs2XIDdAk"
alt="dummy image"
>
/></a>
</body>
</html>Note specifically the addition of the /> as raw text following the properly closed void img tag. A current workaround is to simply add a newline after the img tag in the unformatted code and prettier-plugin-void-html handles it correctly. However, this seems like a common edge case that the plugin should try and handle.
Thanks for the creation of this project! It has proven to be quite useful. 😄
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers