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 Attribute Summary
Attributes inherited from Node
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.
Methods inherited from Block
Methods inherited from Node
#ast_type, #can_act_as_both_block_and_inline?, #each, from_markdown, #get_replacement, #has_been_replaced?, #has_children?, #has_class?, #has_inline?, #has_parent?, #has_string?, #is_block?, #is_inline?, #is_leaf?, #is_node?, #is_root?, #markdown, #markdown=, #toMetadata, #to_ast, #to_s, #type
Methods included from ASTManipulation
#append, #delete, #each_depth_first, #find_index, #get, #insert, #prepend, #remove_at, #replace, #replace_at
Constructor Details
#initialize(contents, node_class = Block) ⇒ List
Create a new List node based on contents
32 33 34 35 36 37 38 39 40 |
# File 'lib/paru/filter/list.rb', line 32 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
43 44 45 |
# File 'lib/paru/filter/list.rb', line 43 def ast_contents @children.map(&:ast_contents) end |
#has_block? ⇒ Boolean
Has this List node block contents?
50 51 52 |
# File 'lib/paru/filter/list.rb', line 50 def has_block? true end |
#to_array ⇒ String[]
Convert this List to an array of markdown strings
57 58 59 60 61 |
# File 'lib/paru/filter/list.rb', line 57 def to_array @children.map do |block| block.children.map { |c| c.markdown.strip }.join("\n") end end |