First post of blogs
Recently I am gonna migrate my blog to hexo, and I am gonna explore hexo with more intersting things, from the start, I may just use the default hexo theme – landscape.
Still, the first things I should do is to make Mathjax work compatibly with Hexo. Let’s take the equations below for an example.
The following steps are based on hexo-markdown-rendered render and mind I have changed it to hexo-renderer-markdown-it-plus, So it would be out of date.
Tips for using Mathjax in Hexo
Use hexo-math plugins for convenience.
Several Steps:
-
npm install hexo-math --saveto download it. -
No need
hexo math installforhexo-mathnewer than 1.0.6. -
Specify the configuration in
_config.ymlusingMathjax:
1 | # MathJax Support |
- Make sure that every post that you want to use
Mathjaxwith the header:
1 | mathjax: true |
And the whole things will be down! But we would discuss later about how to deal with
compatability between Mathjax and Markdown parser. Because you have to use \ to
convert _ or * to avoid parse the equation errorly.
Discuss Later
We will modify the marked.js file to escape from parsing some codes in equations, such as:
- two
_in equations would be parsed as<em></em> \{,\\,\}would not be parsed.
Let’s take the equations below as an example.
Most ways on web I searched have already out of date because hexo-render-marked has updated its regluar expression to parse em and escape. And I simply updated the ways below:
- modify
escapeininlineto:
1 | escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]^_`|~])/, // \{ \} \\ |
- modify
emininlineto:
1 | em: /^\*([^\s*<\[])\*(?!\*)|^\*([^\s<"][\s\S]*[?^\s\*])\*(?!\*|[^\spunctuation])|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/, |
- modify
brininlineto:
1 | br: /^( {2,})\n(?!\s*$)/, |
Use hexo clean to clean the cache and restart the server, things will be fine! 😃
Note:
- the version of
markedI tested is0.7.0. - After the modification, some of the features may not be used:
\\for a new line- double
_for italic (use double*instead).
Other Modification
With The clear theme landscape, I feel much better. Further modification would be adapted.
A bunch of features that I would need further:
- [ ] Content index of each post.
- [ ] Much fluently compatible with original
LaTeXcodes, so I can transfer between them easily. - [ ] Self-introduction item in the side bars.