-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move from MathJax to Katex (#483)
* feat: move from MathJax to Katex
- Loading branch information
1 parent
604d2e5
commit 41b2b4a
Showing
15 changed files
with
57 additions
and
218 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,43 @@ | ||
import renderMathInElement from 'katex/dist/contrib/auto-render'; | ||
|
||
import { IRenderMime } from '@jupyterlab/rendermime-interfaces'; | ||
|
||
import { DescriptionView } from '@jupyter-widgets/controls'; | ||
|
||
let latexDelimiters = [ | ||
{ left: '$$', right: '$$', display: true }, | ||
{ left: '$', right: '$', display: false }, | ||
{ left: '\\(', right: '\\)', display: false }, | ||
{ left: '\\[', right: '\\]', display: true } | ||
]; | ||
|
||
// Override DescriptionView with one that doesn't use MathJax, and instead just uses KatexTypesetter | ||
DescriptionView.prototype.typeset = function(element: HTMLElement, text?: string): void { | ||
this.displayed.then(() => { | ||
const widget_manager: any = this.model.widget_manager; | ||
const latexTypesetter = widget_manager._rendermime?.latexTypesetter; | ||
if (latexTypesetter) { | ||
if (text !== void 0) { | ||
element.textContent = text; | ||
} | ||
latexTypesetter.typeset(element); | ||
} | ||
}); | ||
} | ||
|
||
export class KatexTypesetter implements IRenderMime.ILatexTypesetter { | ||
/** | ||
* Typeset the math in a node. | ||
*/ | ||
typeset(node: HTMLElement): void { | ||
renderMathInElement(node, { | ||
delimiters: latexDelimiters | ||
}); | ||
} | ||
} | ||
|
||
export function renderKatex(): void { | ||
renderMathInElement(document, { | ||
delimiters: latexDelimiters, | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,131 +1 @@ | ||
@font-face /* 0 */ { | ||
font-family: MJXZERO; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Zero.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 1 */ { | ||
font-family: MJXTEX; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 2 */ { | ||
font-family: MJXTEX-B; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 3 */ { | ||
font-family: MJXTEX-MI; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 4 */ { | ||
font-family: MJXTEX-I; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 5 */ { | ||
font-family: MJXTEX-BI; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 6 */ { | ||
font-family: MJXTEX-S1; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 7 */ { | ||
font-family: MJXTEX-S2; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 8 */ { | ||
font-family: MJXTEX-S3; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 9 */ { | ||
font-family: MJXTEX-S4; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 10 */ { | ||
font-family: MJXTEX-A; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 11 */ { | ||
font-family: MJXTEX-C; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 12 */ { | ||
font-family: MJXTEX-C-B; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 13 */ { | ||
font-family: MJXTEX-FR; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 14 */ { | ||
font-family: MJXTEX-FR-B; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 15 */ { | ||
font-family: MJXTEX-SS; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 16 */ { | ||
font-family: MJXTEX-SS-B; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 17 */ { | ||
font-family: MJXTEX-SS-I; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 18 */ { | ||
font-family: MJXTEX-SC; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 19 */ { | ||
font-family: MJXTEX-T; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 20 */ { | ||
font-family: MJXTEX-V; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff') | ||
format('woff'); | ||
} | ||
|
||
@font-face /* 21 */ { | ||
font-family: MJXTEX-VB; | ||
src: url('~mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff') | ||
format('woff'); | ||
} | ||
@import "../node_modules/katex/dist/katex.min.css"; |
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
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
Binary file modified
BIN
+42 Bytes
(110%)
...est_widget_latex_solara-flask-chromium-linux-ipywidgets-7-changed-reference.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+80 Bytes
(110%)
...est.py/test_widget_latex_solara-flask-chromium-linux-ipywidgets-7-reference.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+44 Bytes
(110%)
...est_widget_latex_solara-flask-chromium-linux-ipywidgets-8-changed-reference.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+82 Bytes
(110%)
...est.py/test_widget_latex_solara-flask-chromium-linux-ipywidgets-8-reference.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.