Skip to content

Commit

Permalink
🎨 Vditor 支持
Browse files Browse the repository at this point in the history
heading anchor when copy & paste
Fix Vanessa219/vditor#359
  • Loading branch information
88250 committed May 5, 2020
1 parent 958320f commit df7e7eb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions h2m.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ func (lute *Lute) genASTByDOM(n *html.Node, tree *parse.Tree) {
defer tree.Context.ParentTip()
case atom.A:
node.Type = ast.NodeLink
if nil == n.FirstChild && (atom.H1 == n.Parent.DataAtom || atom.H2 == n.Parent.DataAtom || atom.H3 == n.Parent.DataAtom || atom.H4 == n.Parent.DataAtom || atom.H5 == n.Parent.DataAtom || atom.H6 == n.Parent.DataAtom) {
// 丢弃标题中文本为空的链接,这样的链接可能是锚点
return
}
node.AppendChild(&ast.Node{Type: ast.NodeOpenBracket})
tree.Context.Tip.AppendChild(node)
tree.Context.Tip = node
Expand Down
Loading

0 comments on commit df7e7eb

Please sign in to comment.