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 --save
to download it. -
No need
hexo math install
forhexo-math
newer than 1.0.6. -
Specify the configuration in
_config.yml
usingMathjax
:
1 | # MathJax Support |
- Make sure that every post that you want to use
Mathjax
with 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
escape
ininline
to:
1 | escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]^_`|~])/, // \{ \} \\ |
- modify
em
ininline
to:
1 | em: /^\*([^\s*<\[])\*(?!\*)|^\*([^\s<"][\s\S]*[?^\s\*])\*(?!\*|[^\spunctuation])|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/, |
- modify
br
ininline
to:
1 | br: /^( {2,})\n(?!\s*$)/, |
Use hexo clean
to clean the cache and restart the server, things will be fine! 😃
Note:
- the version of
marked
I 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
LaTeX
codes, so I can transfer between them easily. - [ ] Self-introduction item in the side bars.