Skip to content

Commit

Permalink
Add a basic KaTex node for Latex math typesetting in the default dist…
Browse files Browse the repository at this point in the history
…ribution. Closes #102
  • Loading branch information
breck7 committed Apr 26, 2023
1 parent f1a8916 commit 0f1badc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
24 changes: 24 additions & 0 deletions grammar/katex.grammar
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>`
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scroll-cli",
"version": "69.2.0",
"version": "69.3.0",
"description": "Tools for thoughts.",
"main": "scroll.js",
"engines": {
Expand Down
4 changes: 4 additions & 0 deletions releaseNotes.scroll
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ startColumns

* Here's a list of the notable changes in Scroll.

# 69.3.0 4/26/2023
- 🎉 Add `katex` keyword. KaTeX: "The fastest math typesetting library for the web."
https://katex.org/ KaTeX

# 69.2.0 4/18/2023
- 🎉 added the `tag` keyword to thought nodes so you can change the compiled html tag (needed in rare circumstances)
- 🎉 added the `thought` keyword and standardized vocab to calling the thought node the main node that most nodes extend.
Expand Down

1 comment on commit 0f1badc

@hassamalhajaji
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautifully Done! Thanks @breck7

Please sign in to comment.