一、注意是 marked.umd.js 。
二、在marked.umd.js 中找到
_proto.table = function table(header, body)
大约在2222行
三、大致如下:
修改前:
_proto.table = function table(header, body) {
if (body) body = "<tbody>" + body + "</tbody>";
return (
"<table>\n" +
"<thead>\n" +
header +
"</thead>\n" +
body +
"</table>\n"
);
};
修改后:
_proto.table = function table(header, body) {
if (body) body = "<tbody>" + body + "</tbody>";
return (
"<div class='div-table'>\n" +
"<table>\n" +
"<thead>\n" +
header +
"</thead>\n" +
body +
"</table>\n" +
"</div>\n"
);
};
就是首尾添加了个带有自定义class的div始末标签。
四、随后
就给div设置
.div-table {
overflow: auto;
width: 100%;
padding: 8px;
}
给table的th、td设置
td,
th {
white-space: nowrap;
}