Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 导出 Markdown 时引用的超级块转脚注移除超级块标记符 Fix https://github.com/siyuan-note/siyuan/issues/6777

Liang Ding3b73f3aa9f23
diff --git a/kernel/model/export.go b/kernel/model/export.go
index 615531d704..108b3ac1ef 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