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

Instance Method Summary collapse

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