Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve HTML clipping https://github.com/siyuan-note/siyuan/issues/13885

Daniel4f3f8275837e
diff --git a/kernel/api/extension.go b/kernel/api/extension.go
index 48f8da5a83..f9ca9c72d0 100644
--- a/kernel/api/extension.go
+++ b/kernel/api/extension.go
@@ -23,6 +23,7 @@ import (
"os"
"path"
"path/filepath"
+ "regexp"
"strconv"
"strings"
@@ -177,6 +178,14 @@ func extensionCopy(c *gin.Context) {
var tree *parse.Tree
if "" == md {
+ // 通过正则将 <iframe>.*</iframe> 标签中间包含的换行去掉
+ regx, _ := regexp.Compile(`(?i)<iframe[^>]*>([\s\S]*?)<\/iframe>`)
+ dom = regx.ReplaceAllStringFunc(dom, func(s string) string {
+ s = strings.ReplaceAll(s, "\n", "")
+ s = strings.ReplaceAll(s, "\r", "")
+ return s
+ })
+
tree, withMath = model.HTML2Tree(dom, luteEngine)
if nil == tree {
md, withMath, _ = model.HTML2Markdown(dom, luteEngine)