Skip to content

Commit

Permalink
🎨 Improve web page clip content conversion siyuan-note/siyuan#9980
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 26, 2023
1 parent 2f011d3 commit 9a7f82e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
7 changes: 6 additions & 1 deletion h2m.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,9 @@ func (lute *Lute) genASTByDOM(n *html.Node, tree *parse.Tree) {
tree.Context.Tip = node
defer tree.Context.ParentTip()
case atom.Thead:
if nil == n.FirstChild {
break
}
node.Type = ast.NodeTableHead
tree.Context.Tip.AppendChild(node)
tree.Context.Tip = node
Expand All @@ -507,13 +510,15 @@ func (lute *Lute) genASTByDOM(n *html.Node, tree *parse.Tree) {
}
table := n.Parent.Parent
node.Type = ast.NodeTableRow
if atom.Thead != table.FirstChild.DataAtom && n == n.Parent.FirstChild {

if nil == tree.Context.Tip.ChildByType(ast.NodeTableHead) && nil == util.DomChildByType(table, atom.Thead) {
// 补全 thread 节点
thead := &ast.Node{Type: ast.NodeTableHead}
tree.Context.Tip.AppendChild(thead)
tree.Context.Tip = thead
defer tree.Context.ParentTip()
}

tree.Context.Tip.AppendChild(node)
tree.Context.Tip = node
defer tree.Context.ParentTip()
Expand Down
Loading

0 comments on commit 9a7f82e

Please sign in to comment.