add option to set language with attribute
This commit is contained in:
parent
031cccb475
commit
04e198c6d4
1 changed files with 8 additions and 1 deletions
|
@ -1,7 +1,14 @@
|
|||
class InlineCode extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
this.innerHTML = "<code class=\"language-text\">" + this.innerHTML + "</code>";
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue