diff --git a/background.js b/background.js index b71000f..053e490 100644 --- a/background.js +++ b/background.js @@ -78,14 +78,26 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => { let title = requestData.title ? ('/' + requestData.title) : 'Untitled' title = title.replaceAll("/", "") const siteName = requestData.siteName - const excerpt = requestData.excerpt + let excerpt = requestData.excerpt.trim() const href = requestData.href let linkText = href + try { + linkText = decodeURIComponent(linkText) + } catch (e) { + console.warn(e) + } + let markdown = "---\n\n* " + title if ("" !== siteName) { - linkText += " - " + siteName + markdown += " - " + siteName } - let markdown = "---\n\n* " + "[" + linkText + "](" + href + ")\n" + markdown += "\n" + markdown += "* " + "[" + linkText + "](" + href + ")\n" if ("" !== excerpt) { + // 将连续的三个换行符替换为两个换行符 + excerpt = excerpt.replace(/\n{3,}/g, "\n\n") + // 从第二行开始,每行前面加两个空格 https://github.com/siyuan-note/siyuan/issues/11315 + excerpt = excerpt.replace(/\n/g, "\n ") + excerpt = excerpt.trim() markdown += "* " + excerpt + "\n" } else { markdown += "\n" diff --git a/manifest.json b/manifest.json index 1520b9f..1e74ffe 100644 --- a/manifest.json +++ b/manifest.json @@ -37,5 +37,5 @@ "name": "SiYuan", "options_page": "options.html", "description": "Web clipping for SiYuan. 思源笔记网页剪藏。", - "version": "1.1.17" + "version": "1.1.18" }