Class: Paru::PandocFilter::Figure

Inherits:
Block
  • Object
show all
Includes:
InnerMarkdown
Defined in:
lib/paru/filter/figure.rb

Overview

A Figure node consisting of an attribute object, a caption, and a list of Block nodes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ Figure

Create a new Figure node based on the contents

Parameters:

  • contents (Array)


42
43
44
45
46
# File 'lib/paru/filter/figure.rb', line 42

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

Instance Attribute Details

#attrAttr

Returns:



37
38
39
# File 'lib/paru/filter/figure.rb', line 37

def attr
  @attr
end

#captionObject

Returns Caption.

Returns:

  • Caption



37
# File 'lib/paru/filter/figure.rb', line 37

attr_accessor :attr, :caption

Instance Method Details

#ast_contentsObject

Create an AST representation of this Figure node.



49
50
51
52
53
54
55
# File 'lib/paru/filter/figure.rb', line 49

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

#has_block?Boolean

Has this Figure node Blocks as children?

Returns:

  • (Boolean)

    true



60
61
62
# File 'lib/paru/filter/figure.rb', line 60

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