| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- /**
- * DEPRECATED
- * replaced by markdown-it-mathjax and rendering by PageEditor/Preview component -- 2018.01.30 Yuki Takei
- *
- export default class Mathjax {
- constructor(crowi) {
- this.crowi = crowi;
- this.defaultUrl = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?skipStartupTypeset=true';
- this.mathJaxConfigured = false;
- const config = crowi.getConfig();
- if (config.env.MATHJAX) {
- this.mathJaxConfigured = true;
- if (crowi.window.MathJax) {
- return ;
- }
- const document = crowi.document;
- const head = document.getElementsByTagName('head')[0];
- const mathJaxConfig= document.createElement('script');
- mathJaxConfig.type = 'text/x-mathjax-config';
- mathJaxConfig.text = `MathJax.Hub.Config({
- extensions: ["tex2jax.js"],
- jax: ["input/TeX", "output/SVG"],
- tex2jax: {
- inlineMath: [ ['$','$'] ],
- displayMath: [ ['$$','$$'] ],
- processEscapes: true
- },
- showMathMenu: false,
- showMathMenuMSIE: false,
- showProcessingMessages: false,
- messageStyle: "none",
- skipStartupTypeset: true
- });`;
- head.appendChild(mathJaxConfig);
- const script = document.createElement('script');
- script.type = 'text/javascript';
- script.src = this.defaultUrl;
- head.appendChild(script);
- }
- this.process = this.process.bind(this);
- }
- process(html, dom) {
- if (!this.mathJaxConfigured) {
- return html;
- }
- const intervalId = setInterval(() => {
- if (this.crowi.window.MathJax) {
- const MathJax = this.crowi.window.MathJax;
- MathJax.Hub.Queue(["Typeset", MathJax.Hub, dom.id]);
- clearInterval(intervalId);
- }
- }, 100);
- return html;
- }
- }
- */
|