|
|
@@ -0,0 +1,51 @@
|
|
|
+// mathjax 配置
|
|
|
+// 标识 mathjax 是否已配置
|
|
|
+let isMathjaxConfig = false
|
|
|
+const initMathjaxConfig = () => {
|
|
|
+ if (!window.MathJax) {
|
|
|
+ console.log('mathjax not exist')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ window.MathJax.Hub.Config({
|
|
|
+ showProcessingMessages: false, // 关闭js加载过程信息
|
|
|
+ messageStyle: 'none', // 不显示信息
|
|
|
+ jax: ['input/TeX', 'output/HTML-CSS'],
|
|
|
+ tex2jax: {
|
|
|
+ inlineMath: [['$', '$'], ['\\(', '\\)']], // 行内公式选择符
|
|
|
+ displayMath: [['$$', '$$'], ['\\[', '\\]']], // 段内公式选择符
|
|
|
+ skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code', 'a'] // 避开某些标签
|
|
|
+ },
|
|
|
+ 'HTML-CSS': {
|
|
|
+ availableFonts: ['STIX', 'TeX'], // 可选字体
|
|
|
+ showMathMenu: false // 关闭右击菜单显示
|
|
|
+ }
|
|
|
+ })
|
|
|
+ isMathjaxConfig = true // 配置完成,改为true
|
|
|
+}
|
|
|
+
|
|
|
+const MathQueue = function(elementId) {
|
|
|
+ if (!window.MathJax) {
|
|
|
+ console.log('mathjax not exist')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('render')
|
|
|
+ window.MathJax.Hub.Queue(['Typeset', window.MathJax.Hub, document.getElementById(elementId)])
|
|
|
+}
|
|
|
+
|
|
|
+const MathQueue1 = function(className) {
|
|
|
+ if (!window.MathJax) {
|
|
|
+ console.log('mathjax not exist')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ window.MathJax.Hub.Queue(['Typeset', window.MathJax.Hub, document.getElementsByClassName(className)])
|
|
|
+}
|
|
|
+
|
|
|
+export default {
|
|
|
+ isMathjaxConfig,
|
|
|
+ initMathjaxConfig,
|
|
|
+ MathQueue,
|
|
|
+ MathQueue1
|
|
|
+}
|