fly6022
文章12
标签23
分类2
Hexo:表格渲染错误问题的解决

Hexo:表格渲染错误问题的解决

hexo-renderer-kramed渲染器渲染表格时错误问题的解决。

最近在将Hexo博客升级的时候,发现博客网页中的表格渲染有问题:

04

经过排查,发现与主题无关,我认为是渲染器出了问题。

在浏览器F12界面进行调试发现:

05

06

01

<table>标签外面的 <div class="table-container>"删除,表格恢复正常。

前往博客根目录,在地址栏键入:<根目录文件夹>\node_modules\hexo-renderer-kramed\lib

02

renderer.js用编辑器打开,并将其中的第 35-47行:

1
2
3
4
5
6
7
8
9
10
11
12
13
// Add table-container div to set overflow-x: auto
Renderer.prototype.table = function(header, body) {
return '<div class="table-container">\n'
+ '<table>\n'
+ '<thead>\n'
+ header
+ '</thead>\n'
+ '<tbody>\n'
+ body
+ '</tbody>\n'
+ '</table>\n'
+ '</div>\n';
};

更改为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*// Add table-container div to set overflow-x: auto
Renderer.prototype.table = function(header, body) {
return '<div class="table-container">\n'
+ '<table>\n'
+ '<thead>\n'
+ header
+ '</thead>\n'
+ '<tbody>\n'
+ body
+ '</tbody>\n'
+ '</table>\n'
+ '</div>\n';
};*/

// Add table-container div to set overflow-x: auto
Renderer.prototype.table = function(header, body) {
return '<table>\n'
+ '<thead>\n'
+ header
+ '</thead>\n'
+ '<tbody>\n'
+ body
+ '</tbody>\n'
+ '</table>\n'
};

即可。

在博客根目录打开 git bash命令行界面,键入:

1
hexo clean && hexo s

localhost:4000刷新网页,即可使渲染恢复正常。

– END

本文作者:fly6022
本文链接:https://blog.fly6022.fun/posts/Hexo%EF%BC%9A%E6%96%87%E7%AB%A0%E8%A1%A8%E6%A0%BC%E6%B8%B2%E6%9F%93%E9%94%99%E8%AF%AF%E9%97%AE%E9%A2%98%E7%9A%84%E8%A7%A3%E5%86%B3/
版权声明:除特殊说明以外,本文采用 署名-非商业性使用 4.0 国际 (CC BY-NC 4.0) 协议进行许可,转载请注明原出处。
×