🐛 复制含链接的块为引用块异常 Fix https://github.com/siyuan-note/siyuan/issues/7426
This commit is contained in:
parent
740761fcc8
commit
6faff1109c
5 changed files with 11 additions and 15 deletions
|
@ -63,7 +63,7 @@ func SetBlockReminder(id string, timed string) (err error) {
|
|||
if ast.NodeDocument != node.Type && node.IsContainerBlock() {
|
||||
node = treenode.FirstLeafBlock(node)
|
||||
}
|
||||
content := treenode.NodeStaticContent(node, nil)
|
||||
content := treenode.NodeStaticContent(node, nil, false)
|
||||
content = gulu.Str.SubStr(content, 128)
|
||||
err = SetCloudBlockReminder(id, content, timedMills)
|
||||
if nil != err {
|
||||
|
|
|
@ -78,7 +78,7 @@ func renderOutline(node *ast.Node, luteEngine *lute.Lute) (ret string) {
|
|||
}
|
||||
|
||||
func renderBlockText(node *ast.Node, excludeTypes []string) (ret string) {
|
||||
ret = treenode.NodeStaticContent(node, excludeTypes)
|
||||
ret = treenode.NodeStaticContent(node, excludeTypes, false)
|
||||
ret = strings.TrimSpace(ret)
|
||||
ret = strings.ReplaceAll(ret, "\n", "")
|
||||
ret = util.EscapeHTML(ret)
|
||||
|
@ -141,7 +141,7 @@ func renderBlockContentByNodes(nodes []*ast.Node) string {
|
|||
|
||||
buf := bytes.Buffer{}
|
||||
for _, n := range subNodes {
|
||||
buf.WriteString(treenode.NodeStaticContent(n, nil))
|
||||
buf.WriteString(treenode.NodeStaticContent(n, nil, false))
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ func getBlockVirtualRefKeywords(root *ast.Node) (ret []string) {
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
content := treenode.NodeStaticContent(n, nil)
|
||||
content := treenode.NodeStaticContent(n, nil, false)
|
||||
buf.WriteString(content)
|
||||
return ast.WalkContinue
|
||||
})
|
||||
|
|
|
@ -699,9 +699,10 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
|
|||
fcontent = content
|
||||
length = utf8.RuneCountInString(fcontent)
|
||||
} else if n.IsContainerBlock() {
|
||||
markdown, content = treenode.NodeStaticMdContent(n, luteEngine)
|
||||
markdown = treenode.ExportNodeStdMd(n, luteEngine)
|
||||
content = treenode.NodeStaticContent(n, nil, true)
|
||||
fc := treenode.FirstLeafBlock(n)
|
||||
fcontent = treenode.NodeStaticContent(fc, nil)
|
||||
fcontent = treenode.NodeStaticContent(fc, nil, false)
|
||||
parentID = n.Parent.ID
|
||||
// 将标题块作为父节点
|
||||
if h := heading(n); nil != h {
|
||||
|
@ -709,7 +710,8 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
|
|||
}
|
||||
length = utf8.RuneCountInString(fcontent)
|
||||
} else {
|
||||
markdown, content = treenode.NodeStaticMdContent(n, luteEngine)
|
||||
markdown = treenode.ExportNodeStdMd(n, luteEngine)
|
||||
content = treenode.NodeStaticContent(n, nil, true)
|
||||
parentID = n.Parent.ID
|
||||
// 将标题块作为父节点
|
||||
if h := heading(n); nil != h {
|
||||
|
|
|
@ -114,12 +114,6 @@ func IsEmbedBlockRef(n *ast.Node) bool {
|
|||
return "" != GetEmbedBlockRef(n)
|
||||
}
|
||||
|
||||
func NodeStaticMdContent(node *ast.Node, luteEngine *lute.Lute) (md, content string) {
|
||||
md = ExportNodeStdMd(node, luteEngine)
|
||||
content = NodeStaticContent(node, nil)
|
||||
return
|
||||
}
|
||||
|
||||
func FormatNode(node *ast.Node, luteEngine *lute.Lute) string {
|
||||
markdown, err := lute.FormatNodeSync(node, luteEngine.ParseOptions, luteEngine.RenderOptions)
|
||||
if nil != err {
|
||||
|
@ -138,7 +132,7 @@ func ExportNodeStdMd(node *ast.Node, luteEngine *lute.Lute) string {
|
|||
return markdown
|
||||
}
|
||||
|
||||
func NodeStaticContent(node *ast.Node, excludeTypes []string) string {
|
||||
func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATitleURL bool) string {
|
||||
if nil == node {
|
||||
return ""
|
||||
}
|
||||
|
@ -225,7 +219,7 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string) string {
|
|||
if n.IsTextMarkType("tag") {
|
||||
buf.WriteByte('#')
|
||||
}
|
||||
if n.IsTextMarkType("a") {
|
||||
if n.IsTextMarkType("a") && includeTextMarkATitleURL {
|
||||
// 搜索不到超链接元素的 URL 和标题 https://github.com/siyuan-note/siyuan/issues/7352
|
||||
if "" != n.TextMarkATitle {
|
||||
buf.WriteString(" " + n.TextMarkATitle)
|
||||
|
|
Loading…
Add table
Reference in a new issue