diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 3a800d921..0a9646456 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -612,6 +612,7 @@ "md38": "The maximum length of the anchor text that is automatically rendered when the block ref anchor text is not customized, the default is 96 characters", "md39": "PlantUML Serve Address", "md40": "Leave blank to restore default https://www.plantuml.com/plantuml/svg/~1", + "md41": "Support using / to wrap regular expressions, for example foo,/[0-9]+/ means to exclude foo and numbers", "fileTree2": "The doc tree will automatically select the current document when the editor tab is switched", "fileTree3": "No confirmation required when deleting documents", "fileTree4": "If not enabled, a confirmation box will pop up every time you delete a document", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index d4410c291..9b1ceb85c 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -612,6 +612,7 @@ "md38": "La longitud máxima del texto de anclaje que se renderiza automáticamente cuando el texto de anclaje del bloque ref no está personalizado, el valor por defecto es 96 caracteres", "md39": "Dirección de PlantUML Serve", "md40": "Dejar en blanco para restablecer el valor por defecto https://www.plantuml.com/plantuml/svg/~1", + "md41": "Se admite el uso de / para ajustar expresiones regulares, por ejemplo foo,/[0-9]+/ significa excluir foo y números", "fileTree2": "El árbol de documentos seleccionará automáticamente el documento actual cuando se cambie la pestaña del editor", "fileTree3": "No se requiere confirmación al borrar documentos", "fileTree4": "Si no se activa, aparecerá un cuadro de confirmación cada vez que se elimine un documento", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 70050d492..ab69cbd86 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -612,6 +612,7 @@ "md38": "La longueur maximale du texte d'ancrage qui est automatiquement rendu lorsque le texte d'ancrage de la référence de bloc n'est pas personnalisé, la valeur par défaut est de 96 caractères", "md39": "Adresse Servo PlantUML", "md40": "Laissez vide pour restaurer https://www.plantuml.com/plantuml/svg/~1/ par défaut", + "md41": "Prend en charge l'utilisation de / pour envelopper les expressions régulières, par exemple foo,/[0-9]+/ signifie exclure foo et les nombres", "fileTree2": "L'arbre des Docs sélectionne automatiquement le document en cours lorsque l'on change d'onglet d'édition", "fileTree3": "Aucune confirmation requise lors de la suppression de documents", "fileTree4": "Si non activé, une boîte de confirmation apparaîtra à chaque fois que vous supprimerez un document", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 76eed1250..a18000638 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -612,6 +612,7 @@ "md38": "不自訂塊引錨文本時自動渲染錨文本的最大長度,預設為 96 個字元", "md39": "PlantUML 伺服地址", "md40": "留空將恢復默認值 https://www.plantuml.com/plantuml/svg/~1", + "md41": "支持使用 / 包裹正則表達式,例如 foo,/[0-9]+/ 表示排除 foo 和數字", "fileTree2": "在編輯器切換分頁時文檔樹會自動選中當前的文檔", "fileTree3": "刪除文檔時不需要確認", "fileTree4": "不啟用時每次刪除文檔都會彈出確認框", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index e157d7ac2..6bf7404d2 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -612,6 +612,7 @@ "md38": "不自定义块引锚文本时自动渲染锚文本的最大长度,默认为 96 个字符", "md39": "PlantUML 伺服地址", "md40": "留空将恢复默认值 https://www.plantuml.com/plantuml/svg/~1", + "md41": "支持使用 / 包裹正则表达式,例如 foo,/[0-9]+/ 表示排除 foo 和数字", "fileTree2": "在编辑器页签切换时文档树会自动选中当前的文档", "fileTree3": "删除文档时不需要确认", "fileTree4": "不启用时每次删除文档都会弹出确认框", diff --git a/app/src/config/editor.ts b/app/src/config/editor.ts index 6b73d46ed..854457ad1 100644 --- a/app/src/config/editor.ts +++ b/app/src/config/editor.ts @@ -177,6 +177,7 @@ export const editor = {
${window.siyuan.languages.md35}
${window.siyuan.languages.md36}
+
${window.siyuan.languages.md41}
diff --git a/kernel/model/virutalref.go b/kernel/model/virutalref.go index cc5950e01..0e69a7273 100644 --- a/kernel/model/virutalref.go +++ b/kernel/model/virutalref.go @@ -17,6 +17,7 @@ package model import ( + "regexp" "sort" "strings" @@ -97,13 +98,29 @@ func getVirtualRefKeywords(docName string) (ret []string) { if "" != strings.TrimSpace(Conf.Editor.VirtualBlockRefExclude) { exclude := strings.ReplaceAll(Conf.Editor.VirtualBlockRefExclude, "\\,", "__comma@sep__") excludes := strings.Split(exclude, ",") - var tmp []string + var tmp, regexps []string for _, e := range excludes { e = strings.ReplaceAll(e, "__comma@sep__", ",") - tmp = append(tmp, e) + if strings.HasPrefix(e, "/") && strings.HasSuffix(e, "/") { + regexps = append(regexps, e[1:len(e)-1]) + } else { + tmp = append(tmp, e) + } } excludes = tmp ret = gulu.Str.ExcludeElem(ret, excludes) + if 0 < len(regexps) { + tmp = nil + for _, re := range regexps { + for _, str := range ret { + if ok, regErr := regexp.MatchString(re, str); !ok && nil == regErr { + tmp = append(tmp, str) + break + } + } + } + ret = tmp + } } // 虚拟引用排除当前文档名 https://github.com/siyuan-note/siyuan/issues/4537