mirror of
https://github.com/doocs/md.git
synced 2024-11-28 13:36:32 +08:00
style: update wx-renderer
This commit is contained in:
parent
580fa64738
commit
88419529f8
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-md",
|
||||
"version": "1.4.4",
|
||||
"version": "1.4.5",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-md",
|
||||
"version": "1.4.4",
|
||||
"version": "1.4.5",
|
||||
"homepage": ".",
|
||||
"description": "An open-source wechat markdown editor.",
|
||||
"author": "doocs",
|
||||
|
@ -1,5 +1,6 @@
|
||||
import marked from "marked";
|
||||
const WxRenderer = function (opts) {
|
||||
class WxRenderer {
|
||||
constructor(opts) {
|
||||
this.opts = opts;
|
||||
let ENV_STRETCH_IMAGE = true;
|
||||
|
||||
@ -110,7 +111,10 @@ const WxRenderer = function (opts) {
|
||||
}
|
||||
};
|
||||
renderer.paragraph = (text) => {
|
||||
if (text.indexOf("<figure") != -1 && text.indexOf("<img") != -1) {
|
||||
if (
|
||||
text.indexOf("<figure") != -1 &&
|
||||
text.indexOf("<img") != -1
|
||||
) {
|
||||
return text;
|
||||
}
|
||||
return text.replace(/ /g, "") === ""
|
||||
@ -119,7 +123,10 @@ const WxRenderer = function (opts) {
|
||||
};
|
||||
|
||||
renderer.blockquote = (text) => {
|
||||
text = text.replace(/<p.*?>/g, `<p ${getStyles("blockquote_p")}>`);
|
||||
text = text.replace(
|
||||
/<p.*?>/g,
|
||||
`<p ${getStyles("blockquote_p")}>`
|
||||
);
|
||||
return `<blockquote ${getStyles(
|
||||
"blockquote"
|
||||
)}>${text}</blockquote>`;
|
||||
@ -178,9 +185,9 @@ const WxRenderer = function (opts) {
|
||||
};
|
||||
renderer.link = (href, title, text) => {
|
||||
if (href.indexOf("https://mp.weixin.qq.com") === 0) {
|
||||
return `<a href="${href}" title="${title || text}" ${getStyles(
|
||||
"wx_link"
|
||||
)}>${text}</a>`;
|
||||
return `<a href="${href}" title="${
|
||||
title || text
|
||||
}" ${getStyles("wx_link")}>${text}</a>`;
|
||||
}
|
||||
if (href === text || !status) {
|
||||
return text;
|
||||
@ -205,5 +212,6 @@ const WxRenderer = function (opts) {
|
||||
`<hr style="border-style: solid;border-width: 1px 0 0;border-color: rgba(0,0,0,0.1);-webkit-transform-origin: 0 0;-webkit-transform: scale(1, 0.5);transform-origin: 0 0;transform: scale(1, 0.5);">`;
|
||||
return renderer;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
export default WxRenderer;
|
||||
|
Loading…
Reference in New Issue
Block a user