From 0dd56b2dfed8441673169664f2b301b91324ef3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=9D=A8?= <1711467488@qq.com> Date: Sat, 24 Feb 2018 16:33:55 +0800 Subject: [PATCH] no message Former-commit-id: be4bcff5868360666f7a47e41b8d4e1617e1c423 Former-commit-id: 5ebaaf3f748587d8bdec8f4e5a2ea097dce03d53 Former-commit-id: 630061d1df579a2a4ae2456d5de8c35dec98b863 --- src/components/core/Markdown/index.vue | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/core/Markdown/index.vue b/src/components/core/Markdown/index.vue index c36510f9..b35534cb 100644 --- a/src/components/core/Markdown/index.vue +++ b/src/components/core/Markdown/index.vue @@ -64,8 +64,25 @@ export default { return this.marked(data) }, marked (data) { + const renderer = new marked.Renderer() + renderer.blockquote = (quote) => { + const _quote = quote.replace(/<[^<>]+>/g, '').trim() + const bdShareUrl = /^https:\/\/pan\.baidu\.com\/s\/[a-z0-9]+$/i + const bdShareUrlPwd = /^链接: https:\/\/pan\.baidu\.com\/s\/[a-z0-9]+ 密码: [a-z0-9]{4}$/i + if (bdShareUrl.test(_quote)) { + return `
${_quote}
` + } + if (bdShareUrlPwd.test(_quote)) { + const url = _quote.match(/https:\/\/pan\.baidu\.com\/s\/[a-z0-9]+/i) + const pwd = _quote.match(/[a-z0-9]{4}$/i) + return `
${url[0]} - ${pwd[0]}
` + } + // 一般的 + return `
${quote}
` + } return marked(data, { - ...this.highlight ? {highlight: (code) => highlight.highlightAuto(code).value} : {} + ...this.highlight ? {highlight: (code) => highlight.highlightAuto(code).value} : {}, + renderer }) } }