From 9aca165875b5339e2043948b47fefccca7a8c01d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 17 May 2023 15:37:39 +0800 Subject: [PATCH 1/3] :art: Support for embedding images when exporting EPUB, ODT and RTF Fix https://github.com/siyuan-note/siyuan/issues/8288 --- kernel/model/export.go | 30 +++++++++++++++--------------- kernel/util/pandoc.go | 1 + 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/kernel/model/export.go b/kernel/model/export.go index b6dba1430..2e529443f 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -1032,7 +1032,7 @@ func BatchExportMarkdown(boxID, folderPath string) (zipPath string) { for _, docFile := range docFiles { docPaths = append(docPaths, docFile.path) } - zipPath = exportPandocConvertZip(boxID, baseFolderName, docPaths, "", "md", ".md") + zipPath = exportPandocConvertZip(boxID, baseFolderName, docPaths, "", "", ".md") return } @@ -2030,20 +2030,6 @@ func exportPandocConvertZip(boxID, baseFolderName string, docPaths []string, continue } - // 调用 Pandoc 进行格式转换 - output, err := util.Pandoc(pandocFrom, pandocTo, writePath, md) - if nil != err { - logging.LogErrorf("pandoc failed: %s", err) - continue - } - - if "odt" != pandocTo && "epub" != pandocTo && "rtf" != pandocTo { - if err := gulu.File.WriteFileSafer(writePath, gulu.Str.ToBytes(output), 0644); nil != err { - logging.LogErrorf("write export markdown file [%s] failed: %s", writePath, err) - continue - } - } - // 解析导出后的标准 Markdown,汇总 assets tree := parse.Parse("", gulu.Str.ToBytes(md), luteEngine.ParseOptions) var assets []string @@ -2067,6 +2053,20 @@ func exportPandocConvertZip(boxID, baseFolderName string, docPaths []string, continue } } + + // 调用 Pandoc 进行格式转换 + output, err := util.Pandoc(pandocFrom, pandocTo, writePath, md) + if nil != err { + logging.LogErrorf("pandoc failed: %s", err) + continue + } + + if "odt" != pandocTo && "epub" != pandocTo && "rtf" != pandocTo { + if err := gulu.File.WriteFileSafer(writePath, gulu.Str.ToBytes(output), 0644); nil != err { + logging.LogErrorf("write export markdown file [%s] failed: %s", writePath, err) + continue + } + } } zipPath = exportFolder + ".zip" diff --git a/kernel/util/pandoc.go b/kernel/util/pandoc.go index f46d6208d..c3a13a0cf 100644 --- a/kernel/util/pandoc.go +++ b/kernel/util/pandoc.go @@ -58,6 +58,7 @@ func Pandoc(from, to, o, content string) (ret string, err error) { args := []string{ "--from", from, "--to", to, + "--resource-path", filepath.Dir(o), "-s", } From 2091be9213b7a58907f0a37ba3217bc39bc96395 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 17 May 2023 16:00:45 +0800 Subject: [PATCH 2/3] :art: Holding `Shift` to hover a block ref to show backlinks of it https://github.com/siyuan-note/siyuan/issues/7999 --- .../20200924100950-9op5xi1.sy | 116 +++++++++++++++++- .../20200813004551-gm0pbn1.sy | 116 +++++++++++++++++- .../20211226122549-jktxego.sy | 116 +++++++++++++++++- 3 files changed, 330 insertions(+), 18 deletions(-) diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy index 23ef50c9f..b0c348799 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20200924100950-9op5xi1.sy @@ -7,7 +7,7 @@ "id": "20200924100950-9op5xi1", "title": "Shortcuts", "type": "doc", - "updated": "20230503141906" + "updated": "20230517155934" }, "Children": [ { @@ -9977,13 +9977,14 @@ "ID": "20220619002135-vggu3cg", "Type": "NodeTable", "TableAligns": [ + 0, 0, 0 ], "Properties": { - "colgroup": "|", + "colgroup": "||", "id": "20220619002135-vggu3cg", - "updated": "20220619002856" + "updated": "20230517155934" }, "Children": [ { @@ -10021,6 +10022,16 @@ "Data": "br" } ] + }, + { + "Type": "NodeTableCell", + "Data": "th", + "Children": [ + { + "Type": "NodeText", + "Data": "Memo" + } + ] } ] } @@ -10044,12 +10055,24 @@ "Type": "NodeTableCell", "Data": "td", "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "Click" + }, + { + "Type": "NodeText", + "Data": "​" } ] + }, + { + "Type": "NodeTableCell", + "Data": "td" } ] }, @@ -10071,6 +10094,10 @@ "Type": "NodeTableCell", "Data": "td", "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "kbd", @@ -10078,14 +10105,22 @@ }, { "Type": "NodeText", - "Data": " / " + "Data": "​ / " }, { "Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "⌘Click" + }, + { + "Type": "NodeText", + "Data": "​" } ] + }, + { + "Type": "NodeTableCell", + "Data": "td" } ] }, @@ -10107,6 +10142,10 @@ "Type": "NodeTableCell", "Data": "td", "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "kbd", @@ -10114,14 +10153,22 @@ }, { "Type": "NodeText", - "Data": " / " + "Data": "​ / " }, { "Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "⌥Click" + }, + { + "Type": "NodeText", + "Data": "​" } ] + }, + { + "Type": "NodeTableCell", + "Data": "td" } ] }, @@ -10143,6 +10190,10 @@ "Type": "NodeTableCell", "Data": "td", "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "kbd", @@ -10150,12 +10201,65 @@ }, { "Type": "NodeText", - "Data": " / " + "Data": "​ / " }, { "Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "⇧Click" + }, + { + "Type": "NodeText", + "Data": "​" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td" + } + ] + }, + { + "Type": "NodeTableRow", + "Data": "tr", + "Children": [ + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "View all references to the definition block" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "Shift+Hover" + }, + { + "Type": "NodeText", + "Data": "​" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "Only supported on reference elements" } ] } diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy index 92e29c68f..9dbed0a6b 100644 --- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy +++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20200813004551-gm0pbn1.sy @@ -7,7 +7,7 @@ "id": "20200813004551-gm0pbn1", "title": "快捷键", "type": "doc", - "updated": "20230503141637" + "updated": "20230517155522" }, "Children": [ { @@ -9998,13 +9998,14 @@ "ID": "20220619000401-peit222", "Type": "NodeTable", "TableAligns": [ + 0, 0, 0 ], "Properties": { - "colgroup": "|", + "colgroup": "||", "id": "20220619000401-peit222", - "updated": "20220904093137" + "updated": "20230517155522" }, "Children": [ { @@ -10034,6 +10035,16 @@ "Data": "操作" } ] + }, + { + "Type": "NodeTableCell", + "Data": "th", + "Children": [ + { + "Type": "NodeText", + "Data": "备注" + } + ] } ] } @@ -10057,12 +10068,24 @@ "Type": "NodeTableCell", "Data": "td", "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "Click" + }, + { + "Type": "NodeText", + "Data": "​" } ] + }, + { + "Type": "NodeTableCell", + "Data": "td" } ] }, @@ -10084,6 +10107,10 @@ "Type": "NodeTableCell", "Data": "td", "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "kbd", @@ -10091,14 +10118,22 @@ }, { "Type": "NodeText", - "Data": " / " + "Data": "​ / " }, { "Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "⌘Click" + }, + { + "Type": "NodeText", + "Data": "​" } ] + }, + { + "Type": "NodeTableCell", + "Data": "td" } ] }, @@ -10120,6 +10155,10 @@ "Type": "NodeTableCell", "Data": "td", "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "kbd", @@ -10127,14 +10166,22 @@ }, { "Type": "NodeText", - "Data": " / " + "Data": "​ / " }, { "Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "⌥Click" + }, + { + "Type": "NodeText", + "Data": "​" } ] + }, + { + "Type": "NodeTableCell", + "Data": "td" } ] }, @@ -10156,6 +10203,10 @@ "Type": "NodeTableCell", "Data": "td", "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "kbd", @@ -10163,12 +10214,65 @@ }, { "Type": "NodeText", - "Data": " / " + "Data": "​ / " }, { "Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "⇧Click" + }, + { + "Type": "NodeText", + "Data": "​" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td" + } + ] + }, + { + "Type": "NodeTableRow", + "Data": "tr", + "Children": [ + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "查看定义块的所有引用" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "Shift+悬浮" + }, + { + "Type": "NodeText", + "Data": "​" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "仅在引用元素上支持" } ] } diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy index 898fe8533..735df8d7b 100644 --- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy +++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122549-jktxego.sy @@ -6,7 +6,7 @@ "icon": "2328", "id": "20211226122549-jktxego", "title": "快捷鍵", - "updated": "20230503141751" + "updated": "20230517155553" }, "Children": [ { @@ -10089,13 +10089,14 @@ "ID": "20220619002223-k6apxvm", "Type": "NodeTable", "TableAligns": [ + 0, 0, 0 ], "Properties": { - "colgroup": "|", + "colgroup": "||", "id": "20220619002223-k6apxvm", - "updated": "20220904093825" + "updated": "20230517155553" }, "Children": [ { @@ -10129,6 +10130,16 @@ "Data": "操作" } ] + }, + { + "Type": "NodeTableCell", + "Data": "th", + "Children": [ + { + "Type": "NodeText", + "Data": "備註" + } + ] } ] } @@ -10156,12 +10167,24 @@ "Type": "NodeTableCell", "Data": "td", "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "Click" + }, + { + "Type": "NodeText", + "Data": "​" } ] + }, + { + "Type": "NodeTableCell", + "Data": "td" } ] }, @@ -10187,6 +10210,10 @@ "Type": "NodeTableCell", "Data": "td", "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "kbd", @@ -10194,14 +10221,22 @@ }, { "Type": "NodeText", - "Data": " / " + "Data": "​ / " }, { "Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "⌘Click" + }, + { + "Type": "NodeText", + "Data": "​" } ] + }, + { + "Type": "NodeTableCell", + "Data": "td" } ] }, @@ -10227,6 +10262,10 @@ "Type": "NodeTableCell", "Data": "td", "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "kbd", @@ -10234,14 +10273,22 @@ }, { "Type": "NodeText", - "Data": " / " + "Data": "​ / " }, { "Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "⌥Click" + }, + { + "Type": "NodeText", + "Data": "​" } ] + }, + { + "Type": "NodeTableCell", + "Data": "td" } ] }, @@ -10263,6 +10310,10 @@ "Type": "NodeTableCell", "Data": "td", "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, { "Type": "NodeTextMark", "TextMarkType": "kbd", @@ -10270,12 +10321,65 @@ }, { "Type": "NodeText", - "Data": " / " + "Data": "​ / " }, { "Type": "NodeTextMark", "TextMarkType": "kbd", "TextMarkTextContent": "⇧Click" + }, + { + "Type": "NodeText", + "Data": "​" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td" + } + ] + }, + { + "Type": "NodeTableRow", + "Data": "tr", + "Children": [ + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "查看定義塊的所有引用" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "​" + }, + { + "Type": "NodeTextMark", + "TextMarkType": "kbd", + "TextMarkTextContent": "Shift+懸浮" + }, + { + "Type": "NodeText", + "Data": "​" + } + ] + }, + { + "Type": "NodeTableCell", + "Data": "td", + "Children": [ + { + "Type": "NodeText", + "Data": "僅在引用元素上支持" } ] } From 00a5d612a26af6301ee963212ac521ce9dbad70e Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 17 May 2023 18:36:06 +0800 Subject: [PATCH 3/3] :art: Update text --- app/appearance/langs/en_US.json | 2 +- app/appearance/langs/es_ES.json | 2 +- app/appearance/langs/fr_FR.json | 2 +- app/appearance/langs/zh_CHT.json | 2 +- app/appearance/langs/zh_CN.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 7678419c1..5d8fa5f89 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -951,7 +951,7 @@ "12": "Query asset failed [%s]", "13": "Cannot create a file starting with .", "14": "Export failed: %s", - "15": "Content block with id [%s] not found, please try again later", + "15": "Content block with id [%s] not found", "16": "Please enter the doc name", "17": "The initial synchronization failed at startup. Unpredictable data overwriting may occur if you continue to operate. Please perform a synchronization first", "18": "Get community user account failed", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index 50000e67b..4b80d9b8c 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -951,7 +951,7 @@ "12": "Fallo en la consulta de activos [%s]", "13": "No se puede crear un archivo que empiece por .", "14": "Exportación fallida: %s", - "15": "No se encontró el bloque de contenido con id [%s], inténtelo de nuevo más tarde", + "15": "No se encontró el bloque de contenido con id [%s]", "16": "Por favor, introduzca el nombre del documento", "17": "La sincronización inicial falló en el arranque. Puede producirse una sobreescritura de datos imprevisible si continúa operando. Por favor, realice primero una sincronización", "18": "Falló la obtención de la cuenta de usuario de la comunidad", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index d76a678ec..87f692b0f 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -951,7 +951,7 @@ "12": "Échec de la requête asset [%s]", "13": "Impossible de créer un fichier commençant par .", "14": "L'exportation a échoué : %s", - "15": "Bloc de contenu avec l'identifiant [%s] introuvable, veuillez réessayer plus tard", + "15": "Bloc de contenu avec l'identifiant [%s] introuvable", "16": "Veuillez entrer le nom du fichier", "17": "La synchronisation initiale a échoué au démarrage. Un écrasement imprévisible des données peut se produire si vous continuez à fonctionner. Veuillez d'abord effectuer une synchronisation.", "18": "Échec de la récupération du compte utilisateur communautaire", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 5fda94e17..d04bc1d88 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -951,7 +951,7 @@ "12": "查詢資料檔失敗 [%s]", "13": "無法創建 . 開頭的文件", "14": "匯出失敗:%s", - "15": "未找到 ID 為 [%s] 的內容塊,請稍後再試", + "15": "未找到 ID 為 [%s] 的內容塊", "16": "請輸入文檔名", "17": "啟動時初次同步失敗,繼續操作可能會發生無法預測的數據覆蓋,請先執行一次同步", "18": "獲取社區用戶帳號失敗", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 7451dfdb2..a71c5a452 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -953,7 +953,7 @@ "12": "查询资源文件失败 [%s]", "13": "无法创建 . 开头的文件", "14": "导出失败:%s", - "15": "未找到 ID 为 [%s] 的内容块,请稍后再试", + "15": "未找到 ID 为 [%s] 的内容块", "16": "请输入文档名", "17": "启动时初次同步失败,继续操作可能会发生无法预测的数据覆盖,请先执行一次同步", "18": "获取社区用户账号失败",