diff --git a/lib/commonmarker/node.rb b/lib/commonmarker/node.rb index 12508e80..d86c725d 100644 --- a/lib/commonmarker/node.rb +++ b/lib/commonmarker/node.rb @@ -6,6 +6,8 @@ class Node # # blk - A {Proc} representing the action to take for each child def walk(&block) + return enum_for(:walk) unless block_given? + yield self each do |child| child.walk(&block) @@ -23,7 +25,7 @@ def to_html(options = :default) end # Public: Iterate over the children (if any) of the current pointer. - def each + def each(&block) return enum_for(:each) unless block_given? child = first_child