-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a basic KaTex node for Latex math typesetting in the default dist…
…ribution. Closes #102
- Loading branch information
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
katexParser | ||
cruxFromId | ||
extends abstractScrollWithRequirementsParser | ||
catchAllCellType codeCell | ||
catchAllParser lineOfCodeParser | ||
description Use the KaTex library to typeset math. | ||
string requireOnce | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.6/dist/katex.min.css" integrity="sha384-mXD7x5S50Ko38scHSnD4egvoExgMPbrseZorkbE49evAfv9nNcbrXJ8LLNsDgh9d" crossorigin="anonymous"> | ||
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.6/dist/katex.min.js" integrity="sha384-j/ZricySXBnNMJy9meJCtyXTKMhIJ42heyr7oAdxTDBy/CYA9hzpMo+YTNV5C+1X" crossorigin="anonymous"></script> | ||
<script> | ||
document.addEventListener("DOMContentLoaded", () => document.querySelectorAll(".scrollKatex").forEach(el => | ||
{ | ||
katex.render(el.innerText, el, { | ||
throwOnError: false | ||
}); | ||
} | ||
)) | ||
</script> | ||
javascript | ||
compileInstance() { | ||
const id = this._getUid() | ||
const content = this.content === undefined ? "" : this.content | ||
return `<div class="scrollKatex" id="${id}">${content + this.childrenToString()}</div>` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0f1badc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautifully Done! Thanks @breck7