Class: Jekyll::Scholar::BibTeXConverter

Inherits:
Converter
  • Object
show all
Defined in:
lib/jekyll/scholar/converters/bibtex.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ BibTeXConverter

Returns a new instance of BibTeXConverter.



16
17
18
19
20
# File 'lib/jekyll/scholar/converters/bibtex.rb', line 16

def initialize(config = {})
  super
  @config['scholar'] = Scholar.defaults.merge(@config['scholar'] || {})
  @markdown = MarkdownConverter.new(config)
end

Class Attribute Details

.extensionObject (readonly)

Returns the value of attribute extension.



13
14
15
# File 'lib/jekyll/scholar/converters/bibtex.rb', line 13

def extension
  @extension
end

.patternObject (readonly)

Returns the value of attribute pattern.



13
14
15
# File 'lib/jekyll/scholar/converters/bibtex.rb', line 13

def pattern
  @pattern
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/jekyll/scholar/converters/bibtex.rb', line 7

def config
  @config
end

Instance Method Details

#convert(content) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/jekyll/scholar/converters/bibtex.rb', line 30

def convert(content)
				content = BibTeX.parse(content, :strict => true, :include => [:meta_content], :filter => [:latex]).map do |b|
    if b.respond_to?(:to_citeproc)
      CiteProc.process b.to_citeproc, :style => config['style'],
        :locale => config['locale'], :format => 'html'
    else
        b.is_a?(BibTeX::MetaContent) ? b.to_s : ''
    end
  end

  @markdown.convert(content.join("\n"))
end

#matches(extension) ⇒ Object



22
23
24
# File 'lib/jekyll/scholar/converters/bibtex.rb', line 22

def matches(extension)
	extension =~ BibTeXConverter.pattern
end

#output_ext(extension) ⇒ Object



26
27
28
# File 'lib/jekyll/scholar/converters/bibtex.rb', line 26

def output_ext(extension)
	BibTeXConverter.extension
end