mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-18 10:00:48 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
1994998530
@ -71,7 +71,7 @@ func NewSearch() *Search {
|
|||||||
HTMLBlock: true,
|
HTMLBlock: true,
|
||||||
|
|
||||||
Limit: 64,
|
Limit: 64,
|
||||||
CaseSensitive: false,
|
CaseSensitive: true,
|
||||||
|
|
||||||
Name: true,
|
Name: true,
|
||||||
Alias: true,
|
Alias: true,
|
||||||
|
@ -926,11 +926,24 @@ func exportMarkdownContent(id string) (hPath, exportedMd string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func processKaTexMacros(n *ast.Node) {
|
func processKaTexMacros(n *ast.Node) {
|
||||||
if ast.NodeInlineMathContent != n.Type && ast.NodeMathBlockContent != n.Type {
|
if ast.NodeInlineMathContent != n.Type && ast.NodeMathBlockContent != n.Type && ast.NodeTextMark != n.Type {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if ast.NodeTextMark == n.Type && !n.IsTextMarkType("inline-math") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var mathContent string
|
||||||
|
if ast.NodeTextMark == n.Type {
|
||||||
|
mathContent = n.TextMarkInlineMathContent
|
||||||
|
} else {
|
||||||
|
mathContent = string(n.Tokens)
|
||||||
|
}
|
||||||
|
mathContent = strings.TrimSpace(mathContent)
|
||||||
|
if "" == mathContent {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mathContent := string(n.Tokens)
|
|
||||||
macros := map[string]string{}
|
macros := map[string]string{}
|
||||||
if err := gulu.JSON.UnmarshalJSON([]byte(Conf.Editor.KaTexMacros), ¯os); nil != err {
|
if err := gulu.JSON.UnmarshalJSON([]byte(Conf.Editor.KaTexMacros), ¯os); nil != err {
|
||||||
logging.LogWarnf("parse katex macros failed: %s", err)
|
logging.LogWarnf("parse katex macros failed: %s", err)
|
||||||
@ -961,7 +974,11 @@ func processKaTexMacros(n *ast.Node) {
|
|||||||
mathContent = strings.ReplaceAll(mathContent, usedMacro, expanded)
|
mathContent = strings.ReplaceAll(mathContent, usedMacro, expanded)
|
||||||
}
|
}
|
||||||
mathContent = unescapeKaTexSupportedFunctions(mathContent)
|
mathContent = unescapeKaTexSupportedFunctions(mathContent)
|
||||||
|
if ast.NodeTextMark == n.Type {
|
||||||
|
n.TextMarkInlineMathContent = mathContent
|
||||||
|
} else {
|
||||||
n.Tokens = []byte(mathContent)
|
n.Tokens = []byte(mathContent)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros bool) (ret *parse.Tree) {
|
func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros bool) (ret *parse.Tree) {
|
||||||
@ -1062,6 +1079,11 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros bool) (ret *parse.T
|
|||||||
case ast.NodeInlineMathContent, ast.NodeMathBlockContent:
|
case ast.NodeInlineMathContent, ast.NodeMathBlockContent:
|
||||||
n.Tokens = bytes.TrimSpace(n.Tokens) // 导出 Markdown 时去除公式内容中的首尾空格 https://github.com/siyuan-note/siyuan/issues/4666
|
n.Tokens = bytes.TrimSpace(n.Tokens) // 导出 Markdown 时去除公式内容中的首尾空格 https://github.com/siyuan-note/siyuan/issues/4666
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
|
case ast.NodeTextMark:
|
||||||
|
if n.IsTextMarkType("inline-math") {
|
||||||
|
n.TextMarkInlineMathContent = strings.TrimSpace(n.TextMarkInlineMathContent)
|
||||||
|
return ast.WalkContinue
|
||||||
|
}
|
||||||
case ast.NodeFileAnnotationRef:
|
case ast.NodeFileAnnotationRef:
|
||||||
refIDNode := n.ChildByType(ast.NodeFileAnnotationRefID)
|
refIDNode := n.ChildByType(ast.NodeFileAnnotationRefID)
|
||||||
if nil == refIDNode {
|
if nil == refIDNode {
|
||||||
@ -1211,7 +1233,7 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros bool) (ret *parse.T
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if expandKaTexMacros && (ast.NodeInlineMathContent == n.Type || ast.NodeMathBlockContent == n.Type) {
|
if expandKaTexMacros && (ast.NodeInlineMathContent == n.Type || ast.NodeMathBlockContent == n.Type || (ast.NodeTextMark == n.Type && n.IsTextMarkType("inline-math"))) {
|
||||||
processKaTexMacros(n)
|
processKaTexMacros(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -883,6 +883,12 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
|
|||||||
// 剔除空白的行级公式
|
// 剔除空白的行级公式
|
||||||
unlinks = append(unlinks, n)
|
unlinks = append(unlinks, n)
|
||||||
}
|
}
|
||||||
|
} else if ast.NodeTextMark == n.Type {
|
||||||
|
if n.IsTextMarkType("inline-math") {
|
||||||
|
if "" == strings.TrimSpace(n.TextMarkInlineMathContent) {
|
||||||
|
unlinks = append(unlinks, n)
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if ast.NodeBlockRef == n.Type {
|
} else if ast.NodeBlockRef == n.Type {
|
||||||
sql.CacheRef(subTree, n)
|
sql.CacheRef(subTree, n)
|
||||||
} else if ast.NodeTextMark == n.Type && n.IsTextMarkType("block-ref") {
|
} else if ast.NodeTextMark == n.Type && n.IsTextMarkType("block-ref") {
|
||||||
|
Loading…
Reference in New Issue
Block a user