mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Improve HTML svg clipping https://github.com/siyuan-note/siyuan/issues/16413
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
a45c7de02f
commit
c8033c44b0
1 changed files with 21 additions and 0 deletions
|
|
@ -78,6 +78,27 @@ func HTML2Tree(htmlStr string, luteEngine *lute.Lute) (tree *parse.Tree, withMat
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
if ast.NodeHTMLBlock == n.Type {
|
||||
if bytes.HasPrefix(n.Tokens, []byte("<pre ")) && bytes.HasSuffix(n.Tokens, []byte("</pre>")) && bytes.Contains(n.Tokens, []byte("data:image/svg+xml;base64")) {
|
||||
matches := regexp.MustCompile(`(?sU)<pre [^>]*>(.*)</pre>`).FindSubmatch(n.Tokens)
|
||||
if len(matches) >= 2 {
|
||||
n.Tokens = matches[1]
|
||||
}
|
||||
subTree := parse.Inline("", n.Tokens, luteEngine.ParseOptions)
|
||||
if nil != subTree && nil != subTree.Root && nil != subTree.Root.FirstChild {
|
||||
n.Type = ast.NodeParagraph
|
||||
var children []*ast.Node
|
||||
for c := subTree.Root.FirstChild.FirstChild; nil != c; c = c.Next {
|
||||
children = append(children, c)
|
||||
}
|
||||
for _, c := range children {
|
||||
n.AppendChild(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
if ast.NodeText == n.Type {
|
||||
if n.ParentIs(ast.NodeTableCell) {
|
||||
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("\\|"), []byte("|"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue