mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-02 19:00:15 +01:00
♻️ 移除旧版中的行级元素实现代码 https://github.com/siyuan-note/siyuan/issues/6819
This commit is contained in:
parent
bc850b331a
commit
c69983c56c
8 changed files with 20 additions and 51 deletions
|
|
@ -943,7 +943,7 @@ func exportMarkdownContent(id string) (hPath, exportedMd string) {
|
|||
}
|
||||
|
||||
func processKaTexMacros(n *ast.Node) {
|
||||
if ast.NodeInlineMathContent != n.Type && ast.NodeMathBlockContent != n.Type && ast.NodeTextMark != n.Type {
|
||||
if ast.NodeMathBlockContent != n.Type && ast.NodeTextMark != n.Type {
|
||||
return
|
||||
}
|
||||
if ast.NodeTextMark == n.Type && !n.IsTextMarkType("inline-math") {
|
||||
|
|
@ -1081,7 +1081,7 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool) (re
|
|||
case ast.NodeHeading:
|
||||
n.HeadingNormalizedID = n.IALAttr("id")
|
||||
n.ID = n.HeadingNormalizedID
|
||||
case ast.NodeInlineMathContent, ast.NodeMathBlockContent:
|
||||
case ast.NodeMathBlockContent:
|
||||
n.Tokens = bytes.TrimSpace(n.Tokens) // 导出 Markdown 时去除公式内容中的首尾空格 https://github.com/siyuan-note/siyuan/issues/4666
|
||||
return ast.WalkContinue
|
||||
case ast.NodeTextMark:
|
||||
|
|
@ -1216,7 +1216,7 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool) (re
|
|||
// 空的段落块需要补全文本展位,否则后续格式化后再解析树会语义不一致 https://github.com/siyuan-note/siyuan/issues/5806
|
||||
emptyParagraphs = append(emptyParagraphs, n)
|
||||
}
|
||||
case ast.NodeInlineMathContent, ast.NodeMathBlockContent:
|
||||
case ast.NodeMathBlockContent:
|
||||
if expandKaTexMacros {
|
||||
processKaTexMacros(n)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,8 +46,6 @@ func AutoSpace(rootID string) (err error) {
|
|||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if entering {
|
||||
switch n.Type {
|
||||
case ast.NodeStrong, ast.NodeEmphasis, ast.NodeStrikethrough, ast.NodeUnderline:
|
||||
luteEngine.MergeSameSpan(n)
|
||||
case ast.NodeTextMark:
|
||||
luteEngine.MergeSameTextMark(n)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ func renderOutline(node *ast.Node, luteEngine *lute.Lute) (ret string) {
|
|||
buf.Write(tokens)
|
||||
case ast.NodeBackslashContent:
|
||||
buf.Write(n.Tokens)
|
||||
case ast.NodeInlineMath, ast.NodeStrong, ast.NodeEmphasis, ast.NodeCodeSpan, ast.NodeTextMark, ast.NodeMark:
|
||||
case ast.NodeTextMark:
|
||||
dom := lute.RenderNodeBlockDOM(n, luteEngine.ParseOptions, luteEngine.RenderOptions)
|
||||
buf.WriteString(dom)
|
||||
return ast.WalkSkipChildren
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ func FindReplace(keyword, replacement string, ids []string, method int) (err err
|
|||
renameRoots = append(renameRoots, n)
|
||||
}
|
||||
}
|
||||
case ast.NodeText, ast.NodeLinkDest, ast.NodeLinkText, ast.NodeLinkTitle, ast.NodeCodeSpanContent, ast.NodeCodeBlockCode, ast.NodeInlineMathContent, ast.NodeMathBlockContent:
|
||||
case ast.NodeText, ast.NodeLinkDest, ast.NodeLinkText, ast.NodeLinkTitle, ast.NodeCodeBlockCode, ast.NodeMathBlockContent:
|
||||
if 0 == method {
|
||||
if bytes.Contains(n.Tokens, []byte(keyword)) {
|
||||
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte(keyword), []byte(replacement))
|
||||
|
|
|
|||
|
|
@ -892,15 +892,10 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
if ast.NodeInlineMath == n.Type {
|
||||
content := n.ChildByType(ast.NodeInlineMathContent)
|
||||
if nil == content || 1 > len(content.Tokens) {
|
||||
// 剔除空白的行级公式
|
||||
unlinks = append(unlinks, n)
|
||||
}
|
||||
} else if ast.NodeTextMark == n.Type {
|
||||
if ast.NodeTextMark == n.Type {
|
||||
if n.IsTextMarkType("inline-math") {
|
||||
if "" == strings.TrimSpace(n.TextMarkInlineMathContent) {
|
||||
// 剔除空白的行级公式
|
||||
unlinks = append(unlinks, n)
|
||||
}
|
||||
} else if n.IsTextMarkType("block-ref") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue