Skip to content

Commit 598cfac

Browse files
committed
use a negative lookbehind to not break at html entities
1 parent 56a1aa9 commit 598cfac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/render/src/shared/utils/pretty.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ const prettyNodes = (
9696
property.name === 'style' &&
9797
singleLineProperty.length > maxLineLength
9898
) {
99-
const styles = property.value.slice(1, -1).split(/;/);
99+
// This uses a negative lookbehing to ensure that the semicolon is not
100+
// part of an HTML entity (e.g., `&`, `"`, ` `, etc.).
101+
const nonHtmlEntitySemicolonRegex = /(?<!&[^;]+);/;
102+
const styles = property.value
103+
.slice(1, -1)
104+
.split(nonHtmlEntitySemicolonRegex);
100105
const wrappedStyles = styles
101106
.map((style) => ` ${style}`)
102107
.join(`;${lineBreak}`);

0 commit comments

Comments
 (0)