diff --git a/docs/social-media.md b/docs/social-media.md index d113c0d99..8bdd4078f 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -1197,7 +1197,8 @@ rule | displayVideo | 是否直接显示微博视频和 Live Photo,只在博主或个人时间线 RSS 中有效 | 0/1/true/false | true | | displayArticle | 是否直接显示微博文章,只在博主或个人时间线 RSS 中有效 | 0/1/true/false | false | | displayComments | 是否直接显示热门评论,只在博主或个人时间线 RSS 中有效 | 0/1/true/false | false | -| showEmojiInDescription | 是否展示正文中的 emoji 表情 | 0/1/true/false | true | +| showEmojiInDescription | 是否展示正文中的微博表情,关闭则替换为 `[表情名]` | 0/1/true/false | true | +| showLinkIconInDescription | 是否展示正文中的链接图标 | 0/1/true/false | true | 指定更多与默认值不同的参数选项可以改善 RSS 的可读性,如 diff --git a/lib/routes/weibo/utils.js b/lib/routes/weibo/utils.js index 23a4da45a..7870805c0 100644 --- a/lib/routes/weibo/utils.js +++ b/lib/routes/weibo/utils.js @@ -24,6 +24,7 @@ const weiboUtils = { heightOfPics: fallback(params.heightOfPics, queryToInteger(routeParams.heightOfPics), -1), sizeOfAuthorAvatar: fallback(params.sizeOfAuthorAvatar, queryToInteger(routeParams.sizeOfAuthorAvatar), 48), showEmojiInDescription: fallback(params.showEmojiInDescription, queryToInteger(routeParams.showEmojiInDescription), true), + showLinkIconInDescription: fallback(params.showLinkIconInDescription, queryToInteger(routeParams.showLinkIconInDescription), true), }; params = mergedParams; @@ -44,6 +45,7 @@ const weiboUtils = { heightOfPics, sizeOfAuthorAvatar, showEmojiInDescription, + showLinkIconInDescription, } = params; let retweeted = ''; @@ -53,10 +55,14 @@ const weiboUtils = { if (!showEmojiInDescription) { htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/]*?alt=["']?([^>]+?)["']?\s[^>]*?\/><\/span>/g, '$1'); } - // 去掉外部链接的图标,保留 a 标签链接 // 不能去掉,否则像超话这样的有意义的图标也会被去掉 - // htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/(]*>)]*><\/span>[^<>]*?([^<>]*?)<\/span><\/a>/g, '$1$2'); - // 去掉乱七八糟的图标 // 不能去掉,否则像超话这样的有意义的图标也会被去掉 + // 去掉链接的图标,保留 a 标签链接 + if (!showLinkIconInDescription) { + htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/(]*>)]*><\/span>[^<>]*?([^<>]*?)<\/span><\/a>/g, '$1$2'); + } + // 去掉乱七八糟的图标 // 不需要,上述的替换应该已经把所有的图标都替换掉了,且这条 regex 会破坏上述替换不发生时的输出 // htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/(]*?>)<\/span>/g, ''); + // 将行内图标的高度设置为一行,改善阅读体验。但有些阅读器删除了 style 属性,无法生效 // 不需要,微博已经作此设置 + // htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/(?<=)/g, '
'); htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/全文<\/a>/g, '');