@@ -14,12 +14,12 @@ const root = parse(slot ?? '', { lowerCaseTagName: false });
14
14
const headings = [];
15
15
16
16
// AnchorHeading component source
17
- function renderAnchorHeading(level , id , text ) {
17
+ function renderAnchorHeading(level , id , text , classAttr = ' ' , styleAttr = ' ' ) {
18
18
const accessibleLabel = ` Section ${text } ` ;
19
19
20
20
return `
21
21
<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 }>
23
23
<a class="sl-anchor-link" href="#${id }">
24
24
<span aria-hidden="true" class="sl-anchor-icon">
25
25
<svg width="16" height="16" viewBox="0 0 24 24">
@@ -49,7 +49,10 @@ root.querySelectorAll('h2, h3').forEach((el) => {
49
49
50
50
headings .push ({ depth: level , slug , text });
51
51
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 ));
53
56
});
54
57
55
58
const finalHtml = root .toString ();
0 commit comments