Class: MarkdownExtension::Citations

Inherits:
Object
  • Object
show all
Defined in:
lib/markdown_extension/citations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, type) ⇒ Citations

Returns a new instance of Citations.



4
5
6
7
8
9
10
11
# File 'lib/markdown_extension/citations.rb', line 4

def initialize(config, type)
    @config = config
    @type = type
    @inner_citations = {}            
    if config.citation
        init_citation()
    end
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



3
4
5
# File 'lib/markdown_extension/citations.rb', line 3

def config
  @config
end

#inner_citationsObject

Returns the value of attribute inner_citations.



3
4
5
# File 'lib/markdown_extension/citations.rb', line 3

def inner_citations
  @inner_citations
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/markdown_extension/citations.rb', line 3

def type
  @type
end

Instance Method Details

#add_inner_citation(file) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/markdown_extension/citations.rb', line 16

def add_inner_citation(file)
    text = File.read(file)
    lines = text.split("\n")[4..-1]
    if lines
        i = 0
        while(i < lines.size) do
            content = lines[i][2..-1]
            page_no = lines[i+2].split("hl-page:: ")[1]
            id = lines[i+3].split("id:: ")[1]
            @inner_citations[id] = "P#{page_no} #{content}"
            i = i + 4
        end
    end            
end

#get_inner_citation(id) ⇒ Object



31
32
33
# File 'lib/markdown_extension/citations.rb', line 31

def get_inner_citation(id)
    return @inner_citations[id]
end

#init_citationObject



13
14
# File 'lib/markdown_extension/citations.rb', line 13

def init_citation()
end