Skip to content

Commit

Permalink
fix: remove hl classes on export correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
sidvishnoi committed Jan 10, 2025
1 parent 4ffd855 commit 0aec3c1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/highlight-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ export async function run(conf) {
// remove highlights, cleanup empty class/style attributes
sub("beforesave", (/** @type {Document} */ outputDoc) => {
outputDoc.querySelectorAll("var.respec-hl").forEach(el => {
el.classList.remove("respec-hl");
const classNames = el.classList.toString().replaceAll(/respec-hl-c*/, "");
el.classList.value = classNames.trim();
for (const cls of el.classList.values()) {
if (cls.startsWith("respec-hl")) {
el.classList.remove(cls);
}
}
if (!el.classList.length) el.removeAttribute("class");
});
});
Expand Down

0 comments on commit 0aec3c1

Please sign in to comment.