H1 is converted into H2?
yagudaev opened this issue · comments
Michael Yagudaev commented
Hi Mozilla team, thanks so much for this amazing library!
I found it surprising to see H1 converted into an H2 like so:
Is there a way to turn this off?
Here is a live demo
Michael Yagudaev commented
Here is a quick workaround using classes:
const parser = new DOMParser();
const doc = parser.parseFromString(value, "text/html");
const readability = new Readability(doc, {
classesToPreserve: "h1",
}).parse().content;
const readabilityDoc = parser.parseFromString(readability, "text/html");
readabilityDoc.querySelectorAll(".h1").forEach((heading) => {
heading.outerHTML = heading.outerHTML.replace("h2", "h1");
});
See: Demo