next-theme / hexo-filter-mathjax

💯 Server side MathJax renderer plugin for Hexo.
https://www.npmjs.com/package/hexo-filter-mathjax
MIT License
109 stars 6 forks source link

Error in applying html the markdown file #26

Closed yuxuanwu17 closed 3 years ago

yuxuanwu17 commented 3 years ago

Dear

Sorry to interrupt you. I am really new to hexo and html. I would like to publish my own markdown file into my own personal blogs, which was built on hexo. The transformation from jupyter notebook to markdown file would include some HTML format code, which maybe incompatible with the mathjax. Since when I create a new file and type the math equation, it would successfully shown, but when I followed the instruction and "hexo s" the markdown file with HTML code, it would return the error like this:

err: Error: Can't find handler for document at HandlerList.handlesDocument (/Users/yuxuan/Desktop/blog/blog/node_modules/mathjax-full/js/core/HandlerList.js:58:15) at HandlerList.document (/Users/yuxuan/Desktop/blog/blog/node_modules/mathjax-full/js/core/HandlerList.js:62:21) at Object.document (/Users/yuxuan/Desktop/blog/blog/node_modules/mathjax-full/js/mathjax.js:10:41) at /Users/yuxuan/Desktop/blog/blog/node_modules/hexo-filter-mathjax/lib/filter.js:59:26 at Hexo. (/Users/yuxuan/Desktop/blog/blog/node_modules/hexo-filter-mathjax/index.js:19:18) at Hexo.tryCatcher (/Users/yuxuan/Desktop/blog/blog/node_modules/bluebird/js/release/util.js:16:23) at Hexo. (/Users/yuxuan/Desktop/blog/blog/node_modules/bluebird/js/release/method.js:15:34) at /Users/yuxuan/Desktop/blog/blog/node_modules/hexo/lib/extend/filter.js:67:52 at tryCatcher (/Users/yuxuan/Desktop/blog/blog/node_modules/bluebird/js/release/util.js:16:23) at Object.gotValue (/Users/yuxuan/Desktop/blog/blog/node_modules/bluebird/js/release/reduce.js:166:18) at Object.gotAccum (/Users/yuxuan/Desktop/blog/blog/node_modules/bluebird/js/release/reduce.js:155:25) at Object.tryCatcher (/Users/yuxuan/Desktop/blog/blog/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/Users/yuxuan/Desktop/blog/blog/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/Users/yuxuan/Desktop/blog/blog/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/Users/yuxuan/Desktop/blog/blog/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/Users/yuxuan/Desktop/blog/blog/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/Users/yuxuan/Desktop/blog/blog/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/Users/yuxuan/Desktop/blog/blog/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/Users/yuxuan/Desktop/blog/blog/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/Users/yuxuan/Desktop/blog/blog/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (internal/timers.js:461:21) } Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.htm

hope to hear your response. thank you

stevenjoezhang commented 3 years ago

I followed the instruction and "hexo s" the markdown file with HTML code, it would return the error like this:

I found a similar issue here: https://github.com/mathjax/MathJax-src/issues/265 It seems that this is a limitation of mathjax itself, I would suggest you to avoid inserting html content not supported by mathjax in markdown document

yuxuanwu17 commented 3 years ago

Thank you for your suggestions. I really appreciate that

qiyueliuhuo commented 2 years ago

I meet the same issue.

And I don't find where I inserting html content in mathjax document.

HPCesia commented 1 month ago

If you are using hexo-renderer-pandoc, you can modify this line:

- data.content = mathjax(data.content);
+ data.content = data.content.replace(/<span\s+class="math\s+[^"]*">\\[\(\[].*?\\[\)\]]<\/span>/gs, mathjax);

This will prevent rendering errors for complex HTML fragments that result in "Can't find handler for document".