Commit e930fdd
Changed files (2)
README.md
@@ -54,6 +54,24 @@ shiki:
```
See [Dual Themes](https://shiki.style/guide/dual-themes) for how to switch between multiple themes.
+## Bugs
+### mathjax
+If you are using [hexo-filter-mathjax](https://github.com/next-theme/hexo-filter-mathjax) or any other plugin that uses mathjax to render mathematical formulas locally, you may encounter an `Error: Can't find handler for document` when rendering articles that include code blocks and have mathjax rendering enabled. This is a problem with mathjax, as its LiteDOM cannot parse complex HTML fragments.
+
+#### Solution
+
+For example, if you are using the hexo-filter-mathjax plugin, modify the [this line](https://github.com/next-theme/hexo-filter-mathjax/blob/20dc61352f8cf4d19425ad1833eb72b467c212ef/index.js#L20C3-L20C40) in the source code:
+```js
+- 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`.
+
+#### Related Issues:
+- [Error in applying html the markdown file #26](https://github.com/next-theme/hexo-filter-mathjax/issues/26)
+- [Can't find handler for document #265](https://github.com/mathjax/MathJax-src/issues/265)
+
+
## Acknowledgments
This plugin is developed based on
- [ArcticLampyrid/hexo-shiki-highlighter](https://github.com/ArcticLampyrid/hexo-shiki-highlighter)
README_zh-CN.md
@@ -53,6 +53,23 @@ shiki:
```
在 [Dual Themes](https://shiki.style/guide/dual-themes) 中查看如何切换多个主题。
+## Bugs
+### mathjax
+如果你正在使用 [hexo-filter-mathjax](https://github.com/next-theme/hexo-filter-mathjax) 或其他任意在本地使用 mathjax 渲染数学公式的插件,在渲染包含代码块且开启 mathjax 渲染的文章时可能会出现 `Error: Can't find handler for document`。这是 mathjax 的问题,mathjax 的 LiteDOM 无法解析复杂的 HTML 片段。
+
+#### 解决方法
+
+以 hexo-filter-mathjax 插件为例,修改源代码中的[这一行](https://github.com/next-theme/hexo-filter-mathjax/blob/20dc61352f8cf4d19425ad1833eb72b467c212ef/index.js#L20C3-L20C40):
+```js
+- data.content = mathjax(data.content);
++ data.content = data.content.replace(/<span\s+class="math\s+[^"]*">\\[\(\[].*?\\[\)\]]<\/span>/gs, mathjax);
+```
+这可以避免对那些复杂的 HTML 片段进行渲染导致的 `Can't find handler for document` 错误。
+
+#### 相关 Issues
+- [Error in applying html the markdown file #26](https://github.com/next-theme/hexo-filter-mathjax/issues/26)
+- [ Can't find handler for document #265 ](https://github.com/mathjax/MathJax-src/issues/265)
+
## 感谢
本插件基于
- [ArcticLampyrid/hexo-shiki-highlighter](https://github.com/ArcticLampyrid/hexo-shiki-highlighter)