Add Mathjax Script To Pages In Office 365 Sharepoint
I'm trying to add the Mathjax library to a SharePoint library so that we can use LaTex syntax to add equations. I've seen several methods while searching on the web, but none seems
Solution 1:
My solution of editing the master page was actually working, it was just that I was using the unsecured CDN.
Changing the script to
<scripttype="text/javascript"src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
Which is the URL for the https version of the CDN makes it work correctly.
I'm keeping this until I have found a better solution.
Edit:
There was the issue that the script was triggering even if in "Design" mode and made it nearly impossible to change the equation once written.
To fix the issue, I replaced the simple line above by the following:
<scripttype="text/javascript">ExecuteOrDelayUntilScriptLoaded(function(){
var inEditMode = SP.Ribbon.PageState.Handlers.isInEditMode();
if(!inEditMode)
{
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
}
}, 'SP.Ribbon.js');
</script>
Post a Comment for "Add Mathjax Script To Pages In Office 365 Sharepoint"