website/js/customElements/inline-code.js

15 lines
476 B
JavaScript

class InlineCode extends HTMLElement {
constructor() {
super();
const codeElement = document.createElement("code");
if (this.hasAttribute("language")) {
codeElement.classList.add(this.getAttribute("language"));
} else {
codeElement.classList.add("language-text");
}
codeElement.innerHTML = this.innerHTML;
this.appendChild(codeElement);
}
}
customElements.define("jl-code", InlineCode);