Class: Paru::PandocFilter::Code

Inherits:
Inline show all
Defined in:
lib/paru/filter/code.rb

Overview

A Code node, with an attribute object and the code itself as a string.

Instance Attribute Summary collapse

Attributes inherited from Node

#children, #parent

Instance Method Summary collapse

Methods inherited from Inline

#is_inline?

Methods included from InnerMarkdown

#inner_markdown, #inner_markdown=

Methods inherited from Node

#ast_type, #can_act_as_both_block_and_inline?, #each, from_markdown, #get_replacement, #has_been_replaced?, #has_block?, #has_children?, #has_class?, #has_parent?, #is_block?, #is_inline?, #is_leaf?, #is_node?, #is_root?, #markdown=, #toMetadata, #to_ast, #to_s, #type

Methods included from ASTManipulation

#append, #delete, #each_depth_first, #find_index, #get, #insert, #prepend, #remove_at, #replace, #replace_at

Constructor Details

#initialize(contents) ⇒ Code

Create a new Code node

Parameters:

  • contents (Array)

    an array of the attribute and the code



40
41
42
43
# File 'lib/paru/filter/code.rb', line 40

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

Instance Attribute Details

#attrAttr

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/paru/filter/code.rb', line 34

class Code < Inline
  attr_accessor :attr, :string

  # Create a new Code node
  #
  # @param contents [Array] an array of the attribute and the code
  def initialize(contents)
    @attr = Attr.new contents[0]
    @string = contents[1]
  end

  # Create an AST representation of this Code node.
  def ast_contents
    [
      @attr.to_ast,
      @string
    ]
  end

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

  # Has this code node inline contents?
  #
  # @return [Boolean] false
  def has_inline?
    false
  end

  # Get the markdown representation of this Node, including the Node
  # itself.
  #
  # @return [String] the outer markdown representation of this Node
  def markdown
    super.strip
  end
end

#stringString

Returns:

  • (String)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/paru/filter/code.rb', line 34

class Code < Inline
  attr_accessor :attr, :string

  # Create a new Code node
  #
  # @param contents [Array] an array of the attribute and the code
  def initialize(contents)
    @attr = Attr.new contents[0]
    @string = contents[1]
  end

  # Create an AST representation of this Code node.
  def ast_contents
    [
      @attr.to_ast,
      @string
    ]
  end

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

  # Has this code node inline contents?
  #
  # @return [Boolean] false
  def has_inline?
    false
  end

  # Get the markdown representation of this Node, including the Node
  # itself.
  #
  # @return [String] the outer markdown representation of this Node
  def markdown
    super.strip
  end
end

Instance Method Details

#ast_contentsObject

Create an AST representation of this Code node.



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

def ast_contents
  [
    @attr.to_ast,
    @string
  ]
end

#has_inline?Boolean

Has this code node inline contents?

Returns:

  • (Boolean)

    false



63
64
65
# File 'lib/paru/filter/code.rb', line 63

def has_inline?
  false
end

#has_string?Boolean

Has this Code node a string contents?

Returns:

  • (Boolean)

    true



56
57
58
# File 'lib/paru/filter/code.rb', line 56

def has_string?
  true
end

#markdownString

Get the markdown representation of this Node, including the Node itself.

Returns:

  • (String)

    the outer markdown representation of this Node



71
72
73
# File 'lib/paru/filter/code.rb', line 71

def markdown
  super.strip
end