Skip to content

Commit

Permalink
🎨 Improve HTML details-summary clipping siyuan-note/siyuan#12106
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Aug 10, 2024
1 parent a09d4a0 commit cbc3743
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
17 changes: 11 additions & 6 deletions h2m.go
Original file line number Diff line number Diff line change
Expand Up @@ -1073,12 +1073,19 @@ func (lute *Lute) genASTByDOM(n *html.Node, tree *parse.Tree) {
tree.Context.Tip.AppendChild(node)
return
case atom.Details:
node.Type = ast.NodeHTMLBlock
node.Tokens = util.DomHTML(n)
node.Tokens = bytes.SplitAfter(node.Tokens, []byte("</summary>"))[0]
node.Type = ast.NodeList
node.ListData = &ast.ListData{}
node.ListData.Tight = true
tree.Context.Tip.AppendChild(node)
tree.Context.Tip = node
defer tree.Context.ParentTip()
case atom.Summary:
return
li := &ast.Node{Type: ast.NodeListItem}
li.ListData = &ast.ListData{Marker: []byte("*"), BulletChar: '*'}
node.Type = ast.NodeParagraph
li.AppendChild(node)
tree.Context.Tip.AppendChild(li)
tree.Context.Tip = node
case atom.Iframe, atom.Audio, atom.Video:
node.Type = ast.NodeHTMLBlock
node.Tokens = util.DomHTML(n)
Expand Down Expand Up @@ -1152,8 +1159,6 @@ func (lute *Lute) genASTByDOM(n *html.Node, tree *parse.Tree) {
case atom.Sub:
node.AppendChild(&ast.Node{Type: ast.NodeSubCloseMarker})
appendSpace(n, tree, lute)
case atom.Details:
tree.Context.Tip.AppendChild(&ast.Node{Type: ast.NodeHTMLBlock, Tokens: []byte("</details>")})
}
}

Expand Down
Loading

0 comments on commit cbc3743

Please sign in to comment.