Class: Paru::PandocFilter::List

Inherits:
Block show all
Defined in:
lib/paru/filter/list.rb

Overview

A List node is a base node for various List node types

Direct Known Subclasses

BulletList, LineBlock, OrderedList

Instance Method Summary collapse

Constructor Details

#initialize(contents, node_class = Block) ⇒ List

Create a new List node based on contents

Parameters:



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_contentsObject

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?

Returns:

  • (Boolean)

    true



49
50
51
# File 'lib/paru/filter/list.rb', line 49

def has_block?()
    true
end

#to_arrayString[]

Convert this List to an array of markdown strings

Returns:

  • (String[])


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