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.



41
42
43
44
# File 'lib/paru/filter/div.rb', line 41

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

Instance Attribute Details

#attrAttr

Returns:



35
36
37
# File 'lib/paru/filter/div.rb', line 35

def attr
  @attr
end

Instance Method Details

#ast_contentsObject

Create an AST representation of this Div node.



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

def ast_contents
  [
    @attr.to_ast,
    super
  ]
end

#has_block?Boolean

Has this Div node Blocks as children?

Returns:

  • (Boolean)

    true



57
58
59
# File 'lib/paru/filter/div.rb', line 57

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