mirror of
https://github.com/wassname/template.git
synced 2026-08-13 12:40:25 +08:00
Adding initial math support
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import katex from "katex";
|
||||
|
||||
const html = `
|
||||
<style>
|
||||
dt-math[block] {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
`;
|
||||
|
||||
export default function(dom, data) {
|
||||
let equationElements = [].slice.call(dom.querySelectorAll("dt-math"));
|
||||
equationElements.forEach(el => {
|
||||
let content = el.textContent;
|
||||
console.log(content)
|
||||
let displayMode = el.hasAttribute("block") ? true : false;
|
||||
el.innerHTML = html + katex.renderToString(content, {displayMode: displayMode});
|
||||
});
|
||||
}
|
||||
@@ -26,6 +26,7 @@ dt-article > h4,
|
||||
dt-article > figure,
|
||||
dt-article > ul,
|
||||
dt-article > dt-byline,
|
||||
dt-article > dt-math,
|
||||
dt-article > dt-code,
|
||||
dt-article section > div,
|
||||
dt-article section > p,
|
||||
@@ -59,6 +60,7 @@ dt-article section > dt-code {
|
||||
dt-article > figure,
|
||||
dt-article > ul,
|
||||
dt-article > dt-byline,
|
||||
dt-article > dt-math,
|
||||
dt-article > dt-code,
|
||||
dt-article section > div,
|
||||
dt-article section > p,
|
||||
@@ -85,6 +87,7 @@ dt-article section > dt-code {
|
||||
dt-article > figure,
|
||||
dt-article > ul,
|
||||
dt-article > dt-byline,
|
||||
dt-article > dt-math,
|
||||
dt-article > dt-code,
|
||||
dt-article section > div,
|
||||
dt-article section > p,
|
||||
|
||||
Reference in New Issue
Block a user