0%

个人博客进化史

前言:本文记录了本博客的进化史.

将next主题更新至6.0.6

2018/03/24: 将主题升级至6.0.6, 并在主题配置文件界面开启了访问统计(不蒜子统计)及站内搜索功能, 主要参考了Next主题文档.

用mathjax引擎渲染latex公式

2018/03/24: 在主题配置文件开启了latex公式支持功能, 但没法用宏包, 主要参考了Next主题文档. 它的使用方法很简答,只需分三步:

  1. 将主题配置文件中mathjax引擎的开关打开
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    # Math Equations Render Support
    math:
    enable: true

    # Default(true) will load mathjax/katex script on demand
    # That is it only render those page who has 'mathjax: true' in Front Matter.
    # If you set it to false, it will load mathjax/katex srcipt EVERY PAGE.
    per_page: true

    engine: mathjax
    #engine: katex
  2. hexo的配置文件最后加入一行:
    1
    mathjax: true
  3. 使用前记得在front-matter中将开关打开,如:
    1
    2
    3
    4
    5
    6
    7
    ---
    title: 凸优化学习笔记
    date: 2018-02-23 15:05:49
    tags: [凸优化]
    categories: 凸优化
    mathjax: true
    ---

数学公式相关问题

2018/03/24: 输入latex公式时发现不少问题,如想输入大括号没法显示:

1
$\{x|a'x=b\}$
期望上述公式显示为:\(\{x|a'x=b\}\).

或是想输入下标却被hexo渲染为<em>标签:

1
$C_{1}$
期望上述公式显示为:\(C_{1}\).

原因是 _ , { , } 等比较特殊,它们会被渲染成其他标签. 一个有效的方案是把它们的特殊性手动去掉. 找到hexo根目录下面的node_modules\marked\lib\marked.js,查找将其中第451行escape和459行em做如下修改,修改前如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var inline = {
escape: /^\\([\\`*{}\[\]()#$+\-.!_>])/,
autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
url: noop,
tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
link: /^!?\[(inside)\]\(href\)/,
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
br: /^ {2,}\n(?!\s*$)/,
del: noop,
text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
};
修改后如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var inline = {
escape: /^\\([\\`*\[\]()#+\-.!_>])/,
autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
url: noop,
tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
link: /^!?\[(inside)\]\(href\)/,
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
em: /^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
br: /^ {2,}\n(?!\s*$)/,
del: noop,
text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
};

latex多行公式对齐

2018/06/14: 解决了latex多行公式对齐问题.

1
2
3
4
5
6
7
$$
\begin{aligned} \mathop{\mathbb{E}}_{S\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}}\left|L_{S}(h)-L_{\mathcal{D}}(h)\right|\right] & = \mathop{\mathbb{E}}_{S\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}}\left|\mathop{\mathbb{E}}_{S'\sim\mathcal{D}^{m}}L_{S'}(h)-L_{S}(h)\right|\right] \\
& \le \mathop{\mathbb{E}}_{S\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}}\mathop{\mathbb{E}}_{S'\sim\mathcal{D}^{m}}\left|L_{S'}(h)-L_{S}(h)\right|\right]\\
& \le \mathop{\mathbb{E}}_{S\sim\mathcal{D}^{m}}\left[ \mathop{\mathbb{E}}_{S'\sim\mathcal{D}^{m}}\sup_{h\in\mathcal{H}}\left|L_{S'}(h)-L_{S}(h)\right|\right]\\
& = \mathop{\mathbb{E}}_{S,S'\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}}\left|L_{S'}(h)-L_{S}(h)\right|\right]\\
& = \mathop{\mathbb{E}}_{S,S'\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}} \frac{1}{m}\left|\sum_{i=1}^{m}\left(l(h,x_{i}')-l(h,x_{i})\right)\right|\right] \end{aligned}
$$
正常latex多行公式对齐如上,但显示结果却在一行上,观察一番后发现因为转义的原因此时换行需要三个反斜杠\\\,正确的latex代码如下,特此记录
1
2
3
4
5
6
7
$$
\begin{aligned} \mathop{\mathbb{E}}_{S\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}}\left|L_{S}(h)-L_{\mathcal{D}}(h)\right|\right] & = \mathop{\mathbb{E}}_{S\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}}\left|\mathop{\mathbb{E}}_{S'\sim\mathcal{D}^{m}}L_{S'}(h)-L_{S}(h)\right|\right] \\\
& \le \mathop{\mathbb{E}}_{S\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}}\mathop{\mathbb{E}}_{S'\sim\mathcal{D}^{m}}\left|L_{S'}(h)-L_{S}(h)\right|\right]\\\
& \le \mathop{\mathbb{E}}_{S\sim\mathcal{D}^{m}}\left[ \mathop{\mathbb{E}}_{S'\sim\mathcal{D}^{m}}\sup_{h\in\mathcal{H}}\left|L_{S'}(h)-L_{S}(h)\right|\right]\\\
& = \mathop{\mathbb{E}}_{S,S'\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}}\left|L_{S'}(h)-L_{S}(h)\right|\right]\\\
& = \mathop{\mathbb{E}}_{S,S'\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}} \frac{1}{m}\left|\sum_{i=1}^{m}\left(l(h,x_{i}')-l(h,x_{i})\right)\right|\right] \end{aligned}
$$
\[ \begin{aligned} \mathop{\mathbb{E}}_{S\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}}\left|L_{S}(h)-L_{\mathcal{D}}(h)\right|\right] & = \mathop{\mathbb{E}}_{S\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}}\left|\mathop{\mathbb{E}}_{S'\sim\mathcal{D}^{m}}L_{S'}(h)-L_{S}(h)\right|\right] \\\ & \le \mathop{\mathbb{E}}_{S\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}}\mathop{\mathbb{E}}_{S'\sim\mathcal{D}^{m}}\left|L_{S'}(h)-L_{S}(h)\right|\right]\\\ & \le \mathop{\mathbb{E}}_{S\sim\mathcal{D}^{m}}\left[ \mathop{\mathbb{E}}_{S'\sim\mathcal{D}^{m}}\sup_{h\in\mathcal{H}}\left|L_{S'}(h)-L_{S}(h)\right|\right]\\\ & = \mathop{\mathbb{E}}_{S,S'\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}}\left|L_{S'}(h)-L_{S}(h)\right|\right]\\\ & = \mathop{\mathbb{E}}_{S,S'\sim\mathcal{D}^{m}}\left[ \sup_{h\in\mathcal{H}} \frac{1}{m}\left|\sum_{i=1}^{m}\left(l(h,x_{i}')-l(h,x_{i})\right)\right|\right] \end{aligned} \]

将博客部署到coding.net上及被谷歌收录

2018/09/04: 此次升级将博客部署到了coding.net上, 主要参考了这篇博文也就是说:

  • http://msgsxj.cn/
  • http://msgsxj.coding.me/
  • http://msgsxj.github.io/

这三个url均能到达本站. 另外被谷歌收录(百度已经收录过了), 也就是说能在google中搜到本站, 之前不行.

阅读统计量清零

2018/09/15: 从18年3月开始用不蒜子统计来统计每篇文章阅读量及站点访问量, 但此次一不小心把统计结果清零了, 特此记录

为自己的博客加上小锁

2018/09/22: 为了给个人博客加上小锁, 主要做了以下三件事情:

  • 按照chrome浏览器的控制台的error与warning, 在主题配置文件中关闭了一些功能, 包括自动推送url到百度
  • 在主题配置文件关闭了livere评论功能
  • 最后申请coding.net的三个月一期的免费证书(过三个月得续一次), 成功加上小锁

把图片从图床搬到本地

2018/11/08: 七牛云开始收费了, 于是手动把图片般到本地路径, 正好把小锁配齐.

博客写作平台迁移至mac

2020/01/01: 前些日子入了台mac, 这里简单记录一下将hexo从windows迁移至mac的过程.

  1. terminal下安装git,node以及hexo, 参考了这篇博客

    [install hexo]
    1
    2
    3
    brew install git
    brew install node
    npm install hexo g
    安装node过程中会在系统用户目录下生成一个node_modules文件夹并抛出warning后生成一个package-lock.json文件, 这只是警告系统用户目录下没有package.json文件.

  2. 初始化hexo,继续使用next主题

    [use next theme]
    1
    2
    3
    4
    mkdir hexo
    cd hexo
    hexo init
    git clone https://github.com/theme-next/hexo-theme-next themes/next
    接着就是source文件的覆盖,hexo配置,next主题文件的配置.

  3. 仍然在hexo目录下将hexo的markdown引擎从默认的marked更换为pandoc以更好的支持latex,参考了next主题中的一篇doc

    [pandoc]
    1
    2
    npm uninstall hexo-renderer-marked
    npm install hexo-renderer-pandoc
    markdown-itpandoc最大的区别就是需要更多的空行, 所以遇到显示不正常不妨试着加空行.