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)


44
45
46
47
48
# File 'lib/paru/filter/figure.rb', line 44

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

Instance Attribute Details

#attrAttr

Returns:



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

def attr
  @attr
end

#captionObject

Returns Caption.

Returns:

  • Caption



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

attr_accessor :attr, :caption

Instance Method Details

#ast_contentsObject

Create an AST representation of this Figure node.



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

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

#has_block?Boolean

Has this Figure node Blocks as children?

Returns:

  • (Boolean)

    true



62
63
64
# File 'lib/paru/filter/figure.rb', line 62

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