diff options
Diffstat (limited to 'src/util/transform-content.js')
-rw-r--r-- | src/util/transform-content.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/util/transform-content.js b/src/util/transform-content.js index 2a7d859b..d1d0f51a 100644 --- a/src/util/transform-content.js +++ b/src/util/transform-content.js @@ -377,8 +377,14 @@ function unbound_transformMultiline(text, { } // for sticky headings! - if (elementMatch) { - lineContent = lineContent.replace(/<h2/, `<h2 class="content-heading"`) + if (elementMatch && elementMatch[1] === 'h2') { + lineContent = lineContent.replace(/<h2(.*?)>/g, (match, attributes) => { + const parsedAttributes = parseAttributes(attributes, {to}); + return `<h2 ${html.attributes({ + ...parsedAttributes, + class: [...parsedAttributes.class?.split(' ') ?? [], 'content-heading'], + })}>`; + }); } } |