add more softbreak rules
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Dmitriy Pleshevskiy 2022-06-21 13:42:30 +03:00
parent 2d1fbf4be2
commit 2570793058
Signed by: pleshevskiy
GPG Key ID: 1B59187B161C0215
2 changed files with 11 additions and 1 deletions

View File

@ -39,6 +39,12 @@ Deno.test({
ren.render(E("p", [], [E("span", [], "hello"), "world"])),
"<p><span>hello</span> world</p>",
);
assertEquals(
ren.render(
E("p", [], ["Always up-to-date link to", E("a", [], "resume"), "."]),
),
"<p>Always up-to-date link to <a>resume</a>.</p>",
);
},
});

View File

@ -115,7 +115,11 @@ function encodeHtmlElement(
}
function concatEncodedNodes(encodedChildren: string[]): string {
return join(" ", encodedChildren).replace(/>\s+?</g, "><");
return join(" ", encodedChildren)
// Don't use softbreak between elements
.replace(/>\s+?</g, "><")
// Don't use softbreak after element if text starts with symbol
.replace(/> (\W)/g, ">$1");
}
function encodeAttrs(