mirror of
https://github.com/danog/blackfriday.git
synced 2025-01-23 05:41:27 +01:00
Limit Node.String() to print itself, no children
This commit is contained in:
parent
89653c9927
commit
a4f1e5c786
14
node.go
14
node.go
@ -128,6 +128,16 @@ func NewNode(typ NodeType) *Node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *Node) String() string {
|
||||||
|
ellipsis := ""
|
||||||
|
snippet := n.Literal
|
||||||
|
if len(snippet) > 16 {
|
||||||
|
snippet = snippet[:16]
|
||||||
|
ellipsis = "..."
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s: '%s%s'", n.Type, snippet, ellipsis)
|
||||||
|
}
|
||||||
|
|
||||||
func (n *Node) unlink() {
|
func (n *Node) unlink() {
|
||||||
if n.Prev != nil {
|
if n.Prev != nil {
|
||||||
n.Prev.Next = n.Next
|
n.Prev.Next = n.Next
|
||||||
@ -310,10 +320,6 @@ func (nw *NodeWalker) resumeAt(node *Node, entering bool) (*Node, bool) {
|
|||||||
return nw.next()
|
return nw.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ast *Node) String() string {
|
|
||||||
return dumpString(ast)
|
|
||||||
}
|
|
||||||
|
|
||||||
func dump(ast *Node) {
|
func dump(ast *Node) {
|
||||||
fmt.Println(dumpString(ast))
|
fmt.Println(dumpString(ast))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user