This commit is contained in:
hackrobot
2024-05-19 20:36:12 +08:00
parent 606570d6d8
commit 83cbce56b9

View File

@@ -66,6 +66,7 @@ let maxWidths = null;
marked.setOptions({
breaks: true, // 是否回车换行
gfm: true, //使用经批准的 GitHub Flavored Markdown (GFM) 规范
// pedantic: true, //严格模式
// highlight(code:any, lang:any) {
// // 语法高亮
// let val = code;
@@ -84,6 +85,9 @@ marked.setOptions({
const renderer = new marked.Renderer();
// const originRenderer = _.cloneDeep(renderer);
// 图片调整300px
renderer.image = function (href, title, text) {
// console.log("href, title, text", href, title, text);
@@ -161,11 +165,21 @@ renderer.text = function (text) {
// 分隔符
renderer.hr = function () {
console.log('hr')
// return '<hr>\n';
return '';
return '<br/>';
};
// 自定义分隔线解析规则
// marked.Lexer.rules.block.gfm.hr = /^(\*{3,}|-{3,}|_{3,})(?:\s*)$/;
// 内联样式,使用直角引号「」
renderer.codespan = function (text) {
// return `「${text}」`;
@@ -247,8 +261,9 @@ renderer.html= function(html, block) {
return html;
}
// 自定义分隔线解析规则
// marked.Lexer.rules.block.gfm.hr = /^(\*{3,}|-{3,}|_{3,})(?:\s*)$/;
// 使用拓展
marked.use({ renderer });