equal
deleted
inserted
replaced
197 if sibling.Prev == nil { |
197 if sibling.Prev == nil { |
198 sibling.Parent.FirstChild = sibling |
198 sibling.Parent.FirstChild = sibling |
199 } |
199 } |
200 } |
200 } |
201 |
201 |
202 func (n *Node) isContainer() bool { |
202 // IsContainer returns true if 'n' can contain children. |
|
203 func (n *Node) IsContainer() bool { |
203 switch n.Type { |
204 switch n.Type { |
204 case Document: |
205 case Document: |
205 fallthrough |
206 fallthrough |
206 case BlockQuote: |
207 case BlockQuote: |
207 fallthrough |
208 fallthrough |
234 case TableCell: |
235 case TableCell: |
235 return true |
236 return true |
236 default: |
237 default: |
237 return false |
238 return false |
238 } |
239 } |
|
240 } |
|
241 |
|
242 // IsLeaf returns true if 'n' is a leaf node. |
|
243 func (n *Node) IsLeaf() bool { |
|
244 return !n.IsContainer() |
239 } |
245 } |
240 |
246 |
241 func (n *Node) canContain(t NodeType) bool { |
247 func (n *Node) canContain(t NodeType) bool { |
242 if n.Type == List { |
248 if n.Type == List { |
243 return t == Item |
249 return t == Item |
307 entering: true, |
313 entering: true, |
308 } |
314 } |
309 } |
315 } |
310 |
316 |
311 func (nw *nodeWalker) next() { |
317 func (nw *nodeWalker) next() { |
312 if (!nw.current.isContainer() || !nw.entering) && nw.current == nw.root { |
318 if (!nw.current.IsContainer() || !nw.entering) && nw.current == nw.root { |
313 nw.current = nil |
319 nw.current = nil |
314 return |
320 return |
315 } |
321 } |
316 if nw.entering && nw.current.isContainer() { |
322 if nw.entering && nw.current.IsContainer() { |
317 if nw.current.FirstChild != nil { |
323 if nw.current.FirstChild != nil { |
318 nw.current = nw.current.FirstChild |
324 nw.current = nw.current.FirstChild |
319 nw.entering = true |
325 nw.entering = true |
320 } else { |
326 } else { |
321 nw.entering = false |
327 nw.entering = false |