mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🐛 Optimize typography exception when code block contains ``` https://github.com/siyuan-note/siyuan/issues/15843
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
bcc0472ed0
commit
be6e92ad7a
1 changed files with 14 additions and 6 deletions
|
|
@ -17,7 +17,10 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
|
||||||
"github.com/88250/lute/ast"
|
"github.com/88250/lute/ast"
|
||||||
|
"github.com/88250/lute/editor"
|
||||||
"github.com/88250/lute/render"
|
"github.com/88250/lute/render"
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
|
|
@ -37,13 +40,18 @@ func AutoSpace(rootID string) (err error) {
|
||||||
|
|
||||||
generateOpTypeHistory(tree, HistoryOpFormat)
|
generateOpTypeHistory(tree, HistoryOpFormat)
|
||||||
luteEngine := NewLute()
|
luteEngine := NewLute()
|
||||||
// 合并相邻的同类行级节点
|
|
||||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||||
if entering {
|
if !entering {
|
||||||
switch n.Type {
|
return ast.WalkContinue
|
||||||
case ast.NodeTextMark:
|
}
|
||||||
luteEngine.MergeSameTextMark(n)
|
|
||||||
}
|
switch n.Type {
|
||||||
|
case ast.NodeTextMark:
|
||||||
|
luteEngine.MergeSameTextMark(n) // 合并相邻的同类行级节点
|
||||||
|
case ast.NodeCodeBlockCode:
|
||||||
|
// 代码块中包含 ``` 时 `优化排版` 异常 `Optimize typography` exception when code block contains ``` https://github.com/siyuan-note/siyuan/issues/15843
|
||||||
|
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte(editor.Zwj+"```"), []byte("```"))
|
||||||
|
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("```"), []byte(editor.Zwj+"```"))
|
||||||
}
|
}
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue