Class: Paru::PandocFilter::Cite

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

Overview

A Cite node, consisting of a list of Citation nodes, and a list of Inline nodes

Instance Attribute Summary collapse

Attributes inherited from Node

#children, #parent

Instance Method Summary collapse

Methods inherited from Inline

#has_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_inline?, #has_parent?, #has_string?, #is_block?, #is_inline?, #is_leaf?, #is_node?, #is_root?, #markdown, #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) ⇒ Cite

Create a new Cite node

Parameters:

  • contents (Array)

    an array containing a list of citations and a list of inline nodes



38
39
40
41
42
43
44
# File 'lib/paru/filter/cite.rb', line 38

def initialize(contents)
  super(contents[1])
  @citations = []
  contents[0].each do |citation|
    @citations.push Citation.new(citation)
  end
end

Instance Attribute Details

#citationsArray<Citation>

Returns:



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/cite.rb', line 31

class Cite < Inline
  attr_accessor :citations

  # Create a new Cite node
  #
  # @param contents [Array] an array containing a list of citations
  #   and a list of inline nodes
  def initialize(contents)
    super(contents[1])
    @citations = []
    contents[0].each do |citation|
      @citations.push Citation.new(citation)
    end
  end

  # Create an AST representation of this Cite node.
  def ast_contents
    [
      @citations.map(&:to_ast),
      super
    ]
  end

  # undef_method :inner_markdown
  # undef_method :inner_markdown=
end

Instance Method Details

#ast_contentsObject

Create an AST representation of this Cite node.



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

def ast_contents
  [
    @citations.map(&:to_ast),
    super
  ]
end