mirror of
https://github.com/doocs/md.git
synced 2024-11-25 03:18:36 +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",
|
"name": "vue-md",
|
||||||
"version": "1.4.4",
|
"version": "1.4.5",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-md",
|
"name": "vue-md",
|
||||||
"version": "1.4.4",
|
"version": "1.4.5",
|
||||||
"homepage": ".",
|
"homepage": ".",
|
||||||
"description": "An open-source wechat markdown editor.",
|
"description": "An open-source wechat markdown editor.",
|
||||||
"author": "doocs",
|
"author": "doocs",
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import marked from "marked";
|
import marked from "marked";
|
||||||
const WxRenderer = function (opts) {
|
class WxRenderer {
|
||||||
|
constructor(opts) {
|
||||||
this.opts = opts;
|
this.opts = opts;
|
||||||
let ENV_STRETCH_IMAGE = true;
|
let ENV_STRETCH_IMAGE = true;
|
||||||
|
|
||||||
@ -110,7 +111,10 @@ const WxRenderer = function (opts) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
renderer.paragraph = (text) => {
|
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;
|
||||||
}
|
}
|
||||||
return text.replace(/ /g, "") === ""
|
return text.replace(/ /g, "") === ""
|
||||||
@ -119,7 +123,10 @@ const WxRenderer = function (opts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
renderer.blockquote = (text) => {
|
renderer.blockquote = (text) => {
|
||||||
text = text.replace(/<p.*?>/g, `<p ${getStyles("blockquote_p")}>`);
|
text = text.replace(
|
||||||
|
/<p.*?>/g,
|
||||||
|
`<p ${getStyles("blockquote_p")}>`
|
||||||
|
);
|
||||||
return `<blockquote ${getStyles(
|
return `<blockquote ${getStyles(
|
||||||
"blockquote"
|
"blockquote"
|
||||||
)}>${text}</blockquote>`;
|
)}>${text}</blockquote>`;
|
||||||
@ -178,9 +185,9 @@ const WxRenderer = function (opts) {
|
|||||||
};
|
};
|
||||||
renderer.link = (href, title, text) => {
|
renderer.link = (href, title, text) => {
|
||||||
if (href.indexOf("https://mp.weixin.qq.com") === 0) {
|
if (href.indexOf("https://mp.weixin.qq.com") === 0) {
|
||||||
return `<a href="${href}" title="${title || text}" ${getStyles(
|
return `<a href="${href}" title="${
|
||||||
"wx_link"
|
title || text
|
||||||
)}>${text}</a>`;
|
}" ${getStyles("wx_link")}>${text}</a>`;
|
||||||
}
|
}
|
||||||
if (href === text || !status) {
|
if (href === text || !status) {
|
||||||
return text;
|
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);">`;
|
`<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;
|
return renderer;
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
}
|
||||||
export default WxRenderer;
|
export default WxRenderer;
|
||||||
|
Loading…
Reference in New Issue
Block a user