Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-02-15 18:55:13 +08:00
commit c684787cea
2 changed files with 37 additions and 19 deletions

View file

@ -366,15 +366,7 @@ func ExportMarkdownHTML(id, savePath string, docx, merge bool) (name, dom string
return
}
var tree *parse.Tree
luteEngine := NewLute()
tree, _ = filesys.LoadTree(bt.BoxID, bt.Path, luteEngine)
if "d" != bt.Type {
node := treenode.GetNodeInTree(tree, id)
tree = parse.Parse("", []byte(""), luteEngine.ParseOptions)
tree.Root.FirstChild.InsertBefore(node)
}
tree.HPath = bt.HPath
tree := prepareExportTree(bt)
if merge {
var mergeErr error
@ -449,6 +441,7 @@ func ExportMarkdownHTML(id, savePath string, docx, merge bool) (name, dom string
}
}
luteEngine := NewLute()
luteEngine.SetFootnotes(true)
md := treenode.FormatNode(tree.Root, luteEngine)
tree = parse.Parse("", []byte(md), luteEngine.ParseOptions)
@ -485,15 +478,7 @@ func ExportHTML(id, savePath string, pdf, image, keepFold, merge bool) (name, do
return
}
var tree *parse.Tree
luteEngine := NewLute()
tree, _ = filesys.LoadTree(bt.BoxID, bt.Path, luteEngine)
if "d" != bt.Type {
node := treenode.GetNodeInTree(tree, id)
tree = parse.Parse("", []byte(""), luteEngine.ParseOptions)
tree.Root.FirstChild.InsertBefore(node)
}
tree.HPath = bt.HPath
tree := prepareExportTree(bt)
if merge {
var mergeErr error
@ -558,6 +543,7 @@ func ExportHTML(id, savePath string, pdf, image, keepFold, merge bool) (name, do
}
}
luteEngine := NewLute()
if !pdf && "" != savePath { // 导出 HTML 需要复制静态资源
srcs := []string{"stage/build/export", "stage/build/fonts", "stage/protyle"}
for _, src := range srcs {
@ -612,6 +598,29 @@ func ExportHTML(id, savePath string, pdf, image, keepFold, merge bool) (name, do
return
}
func prepareExportTree(bt *treenode.BlockTree) (ret *parse.Tree) {
luteEngine := NewLute()
ret, _ = filesys.LoadTree(bt.BoxID, bt.Path, luteEngine)
if "d" != bt.Type {
node := treenode.GetNodeInTree(ret, bt.ID)
nodes := []*ast.Node{node}
if "h" == bt.Type {
children := treenode.HeadingChildren(node)
for _, child := range children {
nodes = append(nodes, child)
}
}
ret = parse.Parse("", []byte(""), luteEngine.ParseOptions)
first := ret.Root.FirstChild
for _, node := range nodes {
first.InsertBefore(node)
}
}
ret.HPath = bt.HPath
return
}
func processIFrame(tree *parse.Tree) {
// 导出 PDF/Word 时 IFrame 块使用超链接 https://github.com/siyuan-note/siyuan/issues/4035
var unlinks []*ast.Node
@ -1501,6 +1510,11 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool,
}
}
// 导出时去掉内容块闪卡样式 https://github.com/siyuan-note/siyuan/issues/7374
if n.IsBlock() {
n.RemoveIALAttr("custom-riff-decks")
}
switch n.Type {
case ast.NodeParagraph:
if nil == n.FirstChild {

View file

@ -247,7 +247,11 @@ func queryAliases() (ret []string) {
func queryDocIDsByTitle(title string, excludeIDs []string) (ret []string) {
ret = []string{}
notIn := "('" + strings.Join(excludeIDs, "','") + "')"
sqlStmt := "SELECT id FROM blocks WHERE type = 'd' AND content = ? AND id NOT IN " + notIn + " LIMIT ?"
sqlStmt := "SELECT id FROM blocks WHERE type = 'd' AND content LIKE ? AND id NOT IN " + notIn + " LIMIT ?"
if caseSensitive {
sqlStmt = "SELECT id FROM blocks WHERE type = 'd' AND content = ? AND id NOT IN " + notIn + " LIMIT ?"
}
rows, err := query(sqlStmt, title, 32)
if nil != err {
logging.LogErrorf("sql query [%s] failed: %s", sqlStmt, err)