mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-04 15:58:49 +01:00
🎨 Improve markdown importing https://github.com/siyuan-note/siyuan/issues/13097 https://github.com/siyuan-note/siyuan/issues/13080
This commit is contained in:
parent
14f5570558
commit
a0491cd4ff
13 changed files with 21 additions and 18 deletions
|
|
@ -395,7 +395,7 @@ func SwapBlockRef(refID, defID string, includeChildren bool) (err error) {
|
|||
refreshUpdated(defNode)
|
||||
refreshUpdated(refNode)
|
||||
|
||||
refPivot := treenode.NewParagraph()
|
||||
refPivot := treenode.NewParagraph("")
|
||||
refNode.InsertBefore(refPivot)
|
||||
|
||||
if ast.NodeListItem == defNode.Type {
|
||||
|
|
|
|||
|
|
@ -496,7 +496,7 @@ func parseKTree(kramdown []byte) (ret *parse.Tree) {
|
|||
|
||||
func normalizeTree(tree *parse.Tree) (yfmRootID, yfmTitle, yfmUpdated string) {
|
||||
if nil == tree.Root.FirstChild {
|
||||
tree.Root.AppendChild(treenode.NewParagraph())
|
||||
tree.Root.AppendChild(treenode.NewParagraph(""))
|
||||
}
|
||||
|
||||
var unlinks []*ast.Node
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ func mergeSubDocs(rootTree *parse.Tree) (ret *parse.Tree, err error) {
|
|||
insertPoint = rootTree.Root.FirstChild
|
||||
if nil == insertPoint {
|
||||
// 如果文档为空,则创建一个空段落作为插入点
|
||||
insertPoint = treenode.NewParagraph()
|
||||
insertPoint = treenode.NewParagraph("")
|
||||
rootTree.Root.AppendChild(insertPoint)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1870,7 +1870,7 @@ func createDoc(boxID, p, title, dom string) (tree *parse.Tree, err error) {
|
|||
updated := util.TimeFromID(id)
|
||||
tree.Root.KramdownIAL = [][]string{{"id", id}, {"title", html.EscapeAttrVal(title)}, {"updated", updated}}
|
||||
if nil == tree.Root.FirstChild {
|
||||
tree.Root.AppendChild(treenode.NewParagraph())
|
||||
tree.Root.AppendChild(treenode.NewParagraph(""))
|
||||
}
|
||||
|
||||
// 如果段落块中仅包含一个 mp3/mp4 超链接,则将其转换为音视频块
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st
|
|||
if "" != tagIAL && 0 < len(tags) {
|
||||
// 带标签的文档块转换为标题块时将标签移动到标题块下方 https://github.com/siyuan-note/siyuan/issues/6550
|
||||
|
||||
tagPara := treenode.NewParagraph()
|
||||
tagPara := treenode.NewParagraph("")
|
||||
for i, tag := range tags {
|
||||
if "" == tag {
|
||||
continue
|
||||
|
|
@ -365,7 +365,7 @@ func Heading2Doc(srcHeadingID, targetBoxID, targetPath string) (srcRootBlockID,
|
|||
headingNode.Unlink()
|
||||
srcTree.Root.SetIALAttr("updated", util.CurrentTimeSecondsStr())
|
||||
if nil == srcTree.Root.FirstChild {
|
||||
srcTree.Root.AppendChild(treenode.NewParagraph())
|
||||
srcTree.Root.AppendChild(treenode.NewParagraph(""))
|
||||
}
|
||||
treenode.RemoveBlockTreesByRootID(srcTree.ID)
|
||||
if err = indexWriteTreeUpsertQueue(srcTree); err != nil {
|
||||
|
|
|
|||
|
|
@ -1137,7 +1137,7 @@ func imgHtmlBlock2InlineImg(tree *parse.Tree) {
|
|||
alt := domAttrValue(htmlImg, "alt")
|
||||
title := domAttrValue(htmlImg, "title")
|
||||
|
||||
p := &ast.Node{Type: ast.NodeParagraph, ID: n.ID}
|
||||
p := treenode.NewParagraph(n.ID)
|
||||
img := &ast.Node{Type: ast.NodeImage}
|
||||
p.AppendChild(img)
|
||||
img.AppendChild(&ast.Node{Type: ast.NodeBang})
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ func ListItem2Doc(srcListItemID, targetBoxID, targetPath string) (srcRootBlockID
|
|||
children = append(children, c)
|
||||
}
|
||||
if 1 > len(children) {
|
||||
newNode := treenode.NewParagraph()
|
||||
newNode := treenode.NewParagraph("")
|
||||
children = append(children, newNode)
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ func ListItem2Doc(srcListItemID, targetBoxID, targetPath string) (srcRootBlockID
|
|||
}
|
||||
srcTree.Root.SetIALAttr("updated", util.CurrentTimeSecondsStr())
|
||||
if nil == srcTree.Root.FirstChild {
|
||||
srcTree.Root.AppendChild(treenode.NewParagraph())
|
||||
srcTree.Root.AppendChild(treenode.NewParagraph(""))
|
||||
}
|
||||
treenode.RemoveBlockTreesByRootID(srcTree.ID)
|
||||
if err = indexWriteTreeUpsertQueue(srcTree); err != nil {
|
||||
|
|
|
|||
|
|
@ -341,9 +341,9 @@ func RenderTemplate(p, id string, preview bool) (tree *parse.Tree, dom string, e
|
|||
})
|
||||
for _, n := range nodesNeedAppendChild {
|
||||
if ast.NodeBlockquote == n.Type {
|
||||
n.FirstChild.InsertAfter(treenode.NewParagraph())
|
||||
n.FirstChild.InsertAfter(treenode.NewParagraph(""))
|
||||
} else {
|
||||
n.AppendChild(treenode.NewParagraph())
|
||||
n.AppendChild(treenode.NewParagraph(""))
|
||||
}
|
||||
}
|
||||
for _, n := range unlinks {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue