Class: Paru::PandocFilter::RawBlock

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

Overview

A RawBlock node has a format and a string contents

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(contents) ⇒ RawBlock

Create a new RawBlock node based on the contents

Parameters:

  • contents (Array)


38
39
40
# File 'lib/paru/filter/raw_block.rb', line 38

def initialize(contents)
    @format, @string = contents
end

Instance Attribute Details

#formatString

Returns:

  • (String)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/paru/filter/raw_block.rb', line 31

class RawBlock < Block
    include InnerMarkdown
    attr_accessor :format, :string

    # Create a new RawBlock node based on the contents
    #
    # @param contents [Array]
    def initialize(contents)
        @format, @string = contents
    end

    # Create an AST representation of this RawBlock node
    def ast_contents()
        [
            @format,
            @string
        ]
    end

    # Has this RawBlock node a string value?
    #
    # @return [Boolean] true
    def has_string?
        true
    end
end

#stringString

Returns:

  • (String)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/paru/filter/raw_block.rb', line 31

class RawBlock < Block
    include InnerMarkdown
    attr_accessor :format, :string

    # Create a new RawBlock node based on the contents
    #
    # @param contents [Array]
    def initialize(contents)
        @format, @string = contents
    end

    # Create an AST representation of this RawBlock node
    def ast_contents()
        [
            @format,
            @string
        ]
    end

    # Has this RawBlock node a string value?
    #
    # @return [Boolean] true
    def has_string?
        true
    end
end

Instance Method Details

#ast_contentsObject

Create an AST representation of this RawBlock node



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

def ast_contents()
    [
        @format,
        @string
    ]
end

#has_string?Boolean

Has this RawBlock node a string value?

Returns:

  • (Boolean)

    true



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

def has_string?
    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