Skip to content

Commit

Permalink
🔖 Release v1.1.17 Improve browser extension clipping siyuan-note/siyu…
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed May 9, 2024
1 parent 9366161 commit 4b8508f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
"name": "SiYuan",
"options_page": "options.html",
"description": "Web clipping for SiYuan. 思源笔记网页剪藏。",
"version": "1.1.17"
"version": "1.1.18"
}

0 comments on commit 4b8508f

Please sign in to comment.