Class: Paru::PandocFilter::Div

Inherits:
Block show all
Includes:
InnerMarkdown
Defined in:
lib/paru/filter/div.rb

Overview

A Div node consisting of an attribute object and a list of Block nodes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ Div

Create a new Div node based on the contents

Parameters:

  • contents (Array)

    an array containing the attribute object and the contents of this div.



39
40
41
42
# File 'lib/paru/filter/div.rb', line 39

def initialize(contents)
    @attr = Attr.new contents[0]
    super contents[1]
end

Instance Attribute Details

#attrAttr

Returns:



33
34
35
# File 'lib/paru/filter/div.rb', line 33

def attr
  @attr
end

Instance Method Details

#ast_contentsObject

Create an AST representation of this Div node.



45
46
47
48
49
50
# File 'lib/paru/filter/div.rb', line 45

def ast_contents()
    [
        @attr.to_ast,
        super
    ]
end

#has_block?Boolean

Has this Div node Blocks as children?

Returns:

  • (Boolean)

    true



55
56
57
# File 'lib/paru/filter/div.rb', line 55

def has_block?
    true
end

#inner_markdownString Originally defined in module InnerMarkdown

Get the markdown representation of this Node's children.

Examples:

Replace all occurrences of “hello” by “world” in all paragraphs

Paru::Filter.run do
    with "Para" do |p|
        p.inner_markdown = p.inner_markdown.gsub "hello", "world"
    end
end         

Returns:

  • (String)

    the inner markdown representation of this Node

#inner_markdown=(markdown) ⇒ Object Originally defined in module InnerMarkdown

Replace this Node's children with the Nodes represented by the markdown string

Examples:

Replace all occurrences of “hello” by “world” in all paragraphs

Paru::Filter.run do
    with "Para" do |p|
        p.inner_markdown = p.inner_markdown.gsub "hello", "world"
    end
end         

Parameters:

  • markdown (String)

    the markdown string to replace this Node's children