1
0
mirror of https://github.com/avinal/avinal.github.io.git synced 2026-07-04 07:40:09 +05:30

cleanup and minor fixes

Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
This commit is contained in:
2023-01-24 16:43:32 +05:30
parent c2adcaec6c
commit b827a4b0f9
6 changed files with 19 additions and 47 deletions
+6 -5
View File
@@ -8,12 +8,10 @@ customElements.define(
connectedCallback() {
this.runMarked();
}
attributeChangedCallback(name, oldValue, newValue) {
this.runMarked();
}
runMarked() {
const renderer = new marked.Renderer();
const data = this.getAttribute("markdowndata");
const fragment = this.getAttribute("fragment");
var lead = 0;
renderer.heading = (text, level) => {
if (level === 1) {
@@ -51,17 +49,20 @@ customElements.define(
console.warn(`Unable to find prism highlight for '${lang}'`);
return;
}
console.info("Found", lang);
return Prism.highlight(code, grammer, lang);
},
});
this.innerHTML = marked.parse(data);
console.log("Markdown rendering complete!");
if (fragment) {
console.log("Fragment found, scrolling to: #", fragment);
window.location = "#" + fragment;
}
}
static get observedAttributes() {
return ["markdowndata"];
return ["markdowndata", "fragment"];
}
}
);