Class: Paru::PandocFilter::List
- Defined in:
- lib/paru/filter/list.rb
Overview
A List node is a base node for various List node types
Direct Known Subclasses
Instance Method Summary collapse
-
#ast_contents ⇒ Object
Create an AST representation of this List node.
-
#has_block? ⇒ Boolean
Has this List node block contents?.
-
#initialize(contents, node_class = Block) ⇒ List
constructor
Create a new List node based on contents.
-
#to_array ⇒ String[]
Convert this List to an array of markdown strings.
Constructor Details
#initialize(contents, node_class = Block) ⇒ List
Create a new List node based on contents
31 32 33 34 35 36 37 38 39 |
# File 'lib/paru/filter/list.rb', line 31 def initialize(contents, node_class = Block) super [] contents.each do |item| child = node_class.new(item) child.parent = self @children.push child end end |
Instance Method Details
#ast_contents ⇒ Object
Create an AST representation of this List node
42 43 44 |
# File 'lib/paru/filter/list.rb', line 42 def ast_contents() @children.map {|child| child.ast_contents} end |
#has_block? ⇒ Boolean
Has this List node block contents?
49 50 51 |
# File 'lib/paru/filter/list.rb', line 49 def has_block?() true end |
#to_array ⇒ String[]
Convert this List to an array of markdown strings
56 57 58 59 60 |
# File 'lib/paru/filter/list.rb', line 56 def to_array() @children.map do |block| block.children.map{|c| c.markdown.strip}.join("\n") end end |