Skip to content

Instantly share code, notes, and snippets.

@dat-boris
Last active February 9, 2025 06:43
Show Gist options
  • Save dat-boris/cc36f2f92fb29d7cb0b00dcabf2d89b6 to your computer and use it in GitHub Desktop.
Save dat-boris/cc36f2f92fb29d7cb0b00dcabf2d89b6 to your computer and use it in GitHub Desktop.
For Label studio rendering of MathJax
/** Label Studio include for MathJax.
*
* https://docs.humansignal.com/guide/scripts
*
* Script src: https://gist.github.com/dat-boris/cc36f2f92fb29d7cb0b00dcabf2d89b6
*/
LSI.import('https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js');
function initMathJax() {
const mainContentElements = document.getElementsByClassName("lsf-main-content");
if (mainContentElements === undefined) {
throw new Error('Could not find main content element');
}
console.log('MathJax loaded');
MathJax.typesetPromise(mainContentElements).catch(err => console.log('MathJax typeset failed:', err));
}
// give it some time for the script to import
initMathJax();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment