Method: MarkdownLint::Doc#find_type_elements
- Defined in:
- lib/mdl/doc.rb
#find_type_elements(type, nested = true, elements = @elements) ⇒ Object
Find all elements of a given type, returning a list of the element objects themselves.
Instead of a single type, a list of types can be provided instead to find all types.
If nested is set to false, this returns only top level elements of a given type.
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/mdl/doc.rb', line 86 def find_type_elements(type, nested=true, elements=@elements) results = [] if type.class == Symbol type = [type] end elements.each do |e| results.push(e) if type.include?(e.type) if nested and not e.children.empty? results.concat(find_type_elements(type, nested, e.children)) end end results end |