fix: use [图片] to replace <img> (#278)

* fix: use `[图片]` to replace <img>

closes #267

* style: fix to remove warnings

* remove unnecessary file
This commit is contained in:
Ir1dXD
2018-06-06 23:24:57 +08:00
committed by DIYgod
parent 8b7fd4abdb
commit c85e006809
3 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ module.exports = async (ctx) => {
link: `http://s.weibo.com/weibo/${encodeURIComponent(keyword)}&b=1&nodup=1`,
description: `又有人在微博提到${keyword}了`,
item: data.map((item) => {
const title = item.mblog.text.replace(/<.*?>/g, '');
const title = item.mblog.text.replace(/<img.*?>/g, '[图片]').replace(/<.*?>/g, '');
return {
title: `${item.mblog.user.screen_name}: ${title.length > 24 ? title.slice(0, 24) + '...' : title}`,
description: `${item.mblog.user.screen_name}: ${weiboUtils.format(item.mblog)}`,
+1 -1
View File
@@ -30,7 +30,7 @@ module.exports = async (ctx) => {
link: `http://weibo.com/${uid}/`,
description: `${name}的微博`,
item: response.data.data.cards.filter((item) => item.mblog && !item.mblog.isTop).map((item) => {
const title = item.mblog.text.replace(/<.*?>/g, '');
const title = item.mblog.text.replace(/<img.*?>/g, '[图片]').replace(/<.*?>/g, '');
return {
title: title.length > 24 ? title.slice(0, 24) + '...' : title,
description: weiboUtils.format(item.mblog),
+6 -1
View File
@@ -27,9 +27,14 @@ module.exports = async (ctx) => {
wb = {};
item = $(ele);
titleEle = item.find('.wgtCell_txt');
wb.title = titleEle.text().replace(/^\s+|\s+$/g, '');
wb.title = titleEle
.text()
.replace(/^\s+|\s+$/g, '')
.replace(/\u200B/g, '');
if (wb.title.length > 24) {
wb.title = wb.title.slice(0, 24) + '...';
} else if (wb.title === '') {
wb.title = '[图片]';
}
wb.description = titleEle
.html()