From 3739177f97eecfe751f763a101c8178162e36985 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 15 Feb 2023 17:59:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?:art:=20=E6=94=AF=E6=8C=81=E8=81=9A?= =?UTF-8?q?=E7=84=A6=E5=AF=BC=E5=87=BA=20=E5=9B=BE=E7=89=87/PDF/HTML/Word?= =?UTF-8?q?=20https://github.com/siyuan-note/siyuan/issues/6607=20?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=97=B6=E5=8E=BB=E6=8E=89=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E5=9D=97=E9=97=AA=E5=8D=A1=E6=A0=B7=E5=BC=8F=20https://github.?= =?UTF-8?q?com/siyuan-note/siyuan/issues/7374?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/export.go | 50 +++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/kernel/model/export.go b/kernel/model/export.go index a7d6c2dab..dfe1ddb36 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -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 { From 411a99fb0eb89995dec06c5689d51e83e1f5bf8b Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 15 Feb 2023 18:40:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?:art:=20=E6=96=87=E6=A1=A3=E5=90=8D?= =?UTF-8?q?=E8=99=9A=E6=8B=9F=E5=BC=95=E7=94=A8=E9=81=B5=E5=BE=AA=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=A4=A7=E5=B0=8F=E5=86=99=E8=AE=BE=E7=BD=AE=20Fix=20?= =?UTF-8?q?https://github.com/siyuan-note/siyuan/issues/7372?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/sql/block_query.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/sql/block_query.go b/kernel/sql/block_query.go index 484752073..a52c5d41f 100644 --- a/kernel/sql/block_query.go +++ b/kernel/sql/block_query.go @@ -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)