本文基於 asciidoctor 1.5.7.13,其通過 mathjax 實現 LaTex
字體的顯示,方法和 markdown 差不多,區別是
markdown(不同差距實現方法不同)使用 $$
或者 $``$
包圍 LaTex
語法,而 asciidoctor 使用 stem:[]
包圍 LaTex 語法。
渲染後 | 源碼 |
stem:[\cdot] |
|
stem:[\times] |
|
stem:[a^{prime} a] |
|
stem:[a’’] |
|
stem:[a’’’] |
|
stem:[\pm] |
|
stem:[\mp] |
|
stem:[!] |
|
stem:[\dots] |
|
stem:[\ldots] |
|
stem:[\cdots] |
|
stem:[\vdots] |
|
stem:[\ddots] |
|
渲染後 | 源碼 |
15\\ 7 \end{array}right) |
|
| |
|
hexo中集成asciidoctor後渲染latex的bug
hexo, asciidoctor, latex 三者在一起組成了一個很小衆的東西。實際上使用
ruby 安裝的 asciidoctor 在使用起來完全沒有問題,但是 hexo 中因爲使用的是
nodejs 中的一個
hexo-renderer-asciidoc
插件對 hexo 增強了 asciidoctor 的功能,並且該插件會對 {
}
進行
轉義,因此會導致莫名其妙的
問題出現。
另外 hexo 的 theme\next 主題中有 mathjax 的配置,將其設置爲 true 後所有的頁面都會引用 mathjax 的 js。
themes/next/_config.yml.
mathjax:
enable: true
per_page: false
cdn: //cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML
因此開啓此項配置後,結合插件,頁面上的 LaTex 公式就可以正常顯示了。