Build: simplify tagname check

This commit is contained in:
Ben Edgington
2025-06-23 10:07:23 +01:00
parent 824efadcee
commit b5b7f71f3e

View File

@@ -11,16 +11,13 @@ function cleanupHtml() {
return CONTINUE;
}
// Remove whitespace at the end of headings. This can be left by section marker comments.
if (node.type === 'text') {
if (
parent.type === 'element' &&
(parent.tagName === 'h1' ||
parent.tagName === 'h2' ||
parent.tagName === 'h3')
) {
node.value = node.value.trim();
}
// Remove whitespace at the end of headings. This can be left behind by section markers.
if (
node.type === 'text' &&
parent.type === 'element' &&
['h1', 'h2', 'h3'].includes(parent.tagName)
) {
node.value = node.value.trim();
return CONTINUE;
}