@@ -14,12 +14,12 @@ const root = parse(slot ?? '', { lowerCaseTagName: false });
1414const headings = [];
1515
1616// AnchorHeading component source
17- function renderAnchorHeading(level , id , text ) {
17+ function renderAnchorHeading(level , id , text , classAttr = ' ' , styleAttr = ' ' ) {
1818 const accessibleLabel = ` Section ${text } ` ;
1919
2020 return `
2121 <div class="sl-heading-wrapper level-h${level }">
22- <h${level } id="${id }">${text }</h${level }>
22+ <h${level } id="${id }" class="${ classAttr }" style="${ styleAttr }" >${text }</h${level }>
2323 <a class="sl-anchor-link" href="#${id }">
2424 <span aria-hidden="true" class="sl-anchor-icon">
2525 <svg width="16" height="16" viewBox="0 0 24 24">
@@ -49,7 +49,10 @@ root.querySelectorAll('h2, h3').forEach((el) => {
4949
5050 headings .push ({ depth: level , slug , text });
5151
52- el .replaceWith (renderAnchorHeading (level , slug , escapeHtml (text )));
52+ const classAttr = el .getAttribute (' class' ) || ' ' ;
53+ const styleAttr = el .getAttribute (' style' ) || ' ' ;
54+
55+ el .replaceWith (renderAnchorHeading (level , slug , escapeHtml (text ), classAttr , styleAttr ));
5356});
5457
5558const finalHtml = root .toString ();
0 commit comments