Class: Paru::PandocFilter::Caption

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

Overview

A table or figure's caption, can contain an optional short caption

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ Caption

Create a new Caption based on the contents

Parameters:

  • contents (Array)


34
35
36
37
38
39
40
41
# File 'lib/paru/filter/caption.rb', line 34

def initialize(contents)
    if contents[0].nil?
      @short = nil
    else
      @short = ShortCaption.new contents[0]
    end
    super(contents[1])
end

Instance Attribute Details

#shortObject

Returns the value of attribute short.



29
30
31
# File 'lib/paru/filter/caption.rb', line 29

def short
  @short
end

Instance Method Details

#ast_contentsArray

The AST contents of this Caption node

Returns:

  • (Array)


60
61
62
63
64
65
# File 'lib/paru/filter/caption.rb', line 60

def ast_contents()
    [
      if has_short? then @short.to_ast else nil end,
      @children.map {|row| row.to_ast}
    ]
end

#has_block?Boolean

Has this node a block?

Returns:

  • (Boolean)

    true



53
54
55
# File 'lib/paru/filter/caption.rb', line 53

def has_block?
    true
end

#has_short?Boolean

Does this Caption have a short caption?

Returns:

  • (Boolean)


46
47
48
# File 'lib/paru/filter/caption.rb', line 46

def has_short?()
    not @short.nil?
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

#to_astHash

Create an AST representation of this Node

Returns:

  • (Hash)


70
71
72
# File 'lib/paru/filter/caption.rb', line 70

def to_ast()
  ast_contents()
end