From 3b73f3aa9f23ef55a1230b6f617c00450e15e67a Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 4 Dec 2022 12:13:51 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=AF=BC=E5=87=BA=20Markdown=20?= =?UTF-8?q?=E6=97=B6=E5=BC=95=E7=94=A8=E7=9A=84=E8=B6=85=E7=BA=A7=E5=9D=97?= =?UTF-8?q?=E8=BD=AC=E8=84=9A=E6=B3=A8=E7=A7=BB=E9=99=A4=E8=B6=85=E7=BA=A7?= =?UTF-8?q?=E5=9D=97=E6=A0=87=E8=AE=B0=E7=AC=A6=20Fix=20https://github.com?= =?UTF-8?q?/siyuan-note/siyuan/issues/6777?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/export.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/kernel/model/export.go b/kernel/model/export.go index 615531d70..108b3ac1e 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -1223,18 +1223,21 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool) (re } } - if ast.NodeParagraph == n.Type { + switch n.Type { + case ast.NodeParagraph: if nil == n.FirstChild { // 空的段落块需要补全文本展位,否则后续格式化后再解析树会语义不一致 https://github.com/siyuan-note/siyuan/issues/5806 emptyParagraphs = append(emptyParagraphs, n) } - } - - if expandKaTexMacros && (ast.NodeInlineMathContent == n.Type || ast.NodeMathBlockContent == n.Type || (ast.NodeTextMark == n.Type && n.IsTextMarkType("inline-math"))) { - processKaTexMacros(n) - } - - if ast.NodeWidget == n.Type { + case ast.NodeInlineMathContent, ast.NodeMathBlockContent: + if expandKaTexMacros { + processKaTexMacros(n) + } + case ast.NodeTextMark: + if expandKaTexMacros && n.IsTextMarkType("inline-math") { + processKaTexMacros(n) + } + case ast.NodeWidget: // 挂件块导出 https://github.com/siyuan-note/siyuan/issues/3834 https://github.com/siyuan-note/siyuan/issues/6188 if wysiwyg { @@ -1262,12 +1265,16 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool) (re } unlinks = append(unlinks, n) } - return ast.WalkContinue + case ast.NodeSuperBlockOpenMarker, ast.NodeSuperBlockLayoutMarker, ast.NodeSuperBlockCloseMarker: + if !wysiwyg { + unlinks = append(unlinks, n) + } } if ast.NodeText != n.Type { return ast.WalkContinue } + // Shift+Enter 换行在导出为 Markdown 时使用硬换行 https://github.com/siyuan-note/siyuan/issues/3458 n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("\n"), []byte(" \n")) return ast.WalkContinue