From d432982f15dd0b70810b99373baf720e6b51cb57 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 24 Apr 2024 21:18:15 +0800 Subject: [PATCH] :art: The heading block convert doc block to preserve symbols as much as possible https://github.com/siyuan-note/siyuan/issues/11126 --- app/appearance/langs/en_US.json | 3 ++- app/appearance/langs/es_ES.json | 3 ++- app/appearance/langs/fr_FR.json | 3 ++- app/appearance/langs/zh_CHT.json | 3 ++- app/appearance/langs/zh_CN.json | 3 ++- kernel/model/heading.go | 5 ++++- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index d83dee49f..18cdde9ef 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -1479,6 +1479,7 @@ "242": "The binding block already exists in the current database", "243": "Only list the first [%d] tags (including subtags), if you need to adjust, please modify [Settings - Doc Tree - Maximum number to list]", "244": "It did not exit normally after the last use. It is recommended to execute [Doc Tree - Rebuild Index]", - "245": "It did not exit normally after the last use. It is recommended to execute [Doc Tree - Rebuild Index]. To exit normally, you need to use [Exit Application] in the right panel" + "245": "It did not exit normally after the last use. It is recommended to execute [Doc Tree - Rebuild Index]. To exit normally, you need to use [Exit Application] in the right panel", + "246": "The document title cannot contain / and has been replaced with _" } } diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index b567a6158..03c35fa34 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -1479,6 +1479,7 @@ "242": "El bloque de enlace ya existe en la base de datos actual", "243": "Enumere solo las primeras [%d] etiquetas (incluidas las subetiquetas), modifique [Configuración - Árbol de documentos - Número máximo a listar]", "244": "No salió normalmente después del último uso. Se recomienda ejecutar [Árbol de documentos - Reconstruir índice]", - "245": "No salió normalmente después del último uso. Se recomienda ejecutar [Árbol de documentos - Reconstruir índice]. Para salir normalmente, necesita usar [Salir de la aplicación] en el panel derecho" + "245": "No salió normalmente después del último uso. Se recomienda ejecutar [Árbol de documentos - Reconstruir índice]. Para salir normalmente, necesita usar [Salir de la aplicación] en el panel derecho", + "246": "El título del documento no puede contener / y ha sido reemplazado por _" } } diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 1a55a4bb6..3f618327d 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -1479,6 +1479,7 @@ "242": "Le bloc de liaison existe déjà dans la base de données actuelle", "243": "Répertorier uniquement les [%d] premières balises (y compris les sous-balises). veuillez modifier [Paramètres - Arbre des documents - Nombre maximum de documents à lister].", "244": "Il ne s'est pas terminé normalement après la dernière utilisation. Il est recommandé d'exécuter [Doc Tree - Rebuild Index]", - "245": "Il ne s'est pas terminé normalement après la dernière utilisation. Il est recommandé d'exécuter [Doc Tree - Rebuild Index]. Pour quitter normalement, vous devez utiliser [Quitter l'application] dans le panneau de droite" + "245": "Il ne s'est pas terminé normalement après la dernière utilisation. Il est recommandé d'exécuter [Doc Tree - Rebuild Index]. Pour quitter normalement, vous devez utiliser [Quitter l'application] dans le panneau de droite", + "246": "Le titre du document ne peut pas contenir / et a été remplacé par _" } } diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 8b02b66a7..7495471f6 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -1479,6 +1479,7 @@ "242": "目前資料庫中已經存在該綁定區塊", "243": "僅列出前 [%d] 個標籤(含子標籤),如需調整請修改 [設置 - 文檔樹 - 最大列出數量]", "244": "上次使用後未正常退出,建議執行一次 [文檔樹 - 重建索引]", - "245": "上次使用後未正常退出,建議執行一次 [文件樹 - 重建索引],正常退出需使用右側欄面板中的 [退出應用]" + "245": "上次使用後未正常退出,建議執行一次 [文件樹 - 重建索引],正常退出需使用右側欄面板中的 [退出應用]", + "246": "文件標題不能包含 /,已經使用 _ 替換" } } diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index c2f94a27f..2d32ebd93 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -1479,6 +1479,7 @@ "242": "当前数据库中已经存在该绑定块", "243": "仅列出前 [%d] 个标签(含子标签),如需调整请修改 [设置 - 文档树 - 最大列出数量]", "244": "上次使用后未正常退出,建议执行一次 [文档树 - 重建索引]", - "245": "上次使用后未正常退出,建议执行一次 [文档树 - 重建索引],正常退出需使用右侧栏面板中的 [退出应用]" + "245": "上次使用后未正常退出,建议执行一次 [文档树 - 重建索引],正常退出需使用右侧栏面板中的 [退出应用]", + "246": "文档标题不能包含 /,已经使用 _ 替换" } } diff --git a/kernel/model/heading.go b/kernel/model/heading.go index bfdf401f7..365d97dfc 100644 --- a/kernel/model/heading.go +++ b/kernel/model/heading.go @@ -287,7 +287,10 @@ func Heading2Doc(srcHeadingID, targetBoxID, targetPath string) (srcRootBlockID, box := Conf.Box(targetBoxID) headingText := getNodeRefText0(headingNode) - headingText = util.FilterFileName(headingText) + if strings.Contains(headingText, "/") { + headingText = strings.ReplaceAll(headingText, "/", "_") + util.PushMsg(Conf.language(246), 7000) + } moveToRoot := "/" == targetPath toHP := path.Join("/", headingText)