Class: Jekyll::Scholar::BibTeXConverter

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

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes included from Utilities

#context, #max, #prefix, #site, #text

Instance Method Summary collapse

Methods included from Utilities

#base_url, #bibliography, #bibliography_tag, #bibliography_template, #bibtex_file, #bibtex_files, #bibtex_filters, #bibtex_options, #bibtex_path, #bibtex_paths, #citation_item_for, #citation_number, #cite, #cite_details, #cited_keys, #cited_only?, #cited_references, #content_tag, #details_file_for, #details_link_for, #details_path, #entries, #extend_path, #generate_details?, #interpolate, #join_strings?, #keys, #limit_entries?, #link_to, #liquid_template, #liquidify, #load_repository, #locators, #missing_reference, #optparse, #query, #reference_tag, #reference_tagname, #render_bibliography, #render_citation, #renderer, #replace_strings?, #repository, #repository?, #repository_link_for, #repository_links_for, #repository_path, #set_context_to, #skip_sort?, #sort, #split_arguments, #style, #suppress_author?

Constructor Details

#initialize(config = {}) ⇒ BibTeXConverter

Returns a new instance of BibTeXConverter.



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

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

Class Attribute Details

.extensionObject (readonly)

Returns the value of attribute extension.



15
16
17
# File 'lib/jekyll/scholar/converters/bibtex.rb', line 15

def extension
  @extension
end

.patternObject (readonly)

Returns the value of attribute pattern.



15
16
17
# File 'lib/jekyll/scholar/converters/bibtex.rb', line 15

def pattern
  @pattern
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/jekyll/scholar/converters/bibtex.rb', line 9

def config
  @config
end

Instance Method Details

#convert(content) ⇒ Object



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

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

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

#matches(extension) ⇒ Object



24
25
26
# File 'lib/jekyll/scholar/converters/bibtex.rb', line 24

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

#output_ext(extension) ⇒ Object



28
29
30
# File 'lib/jekyll/scholar/converters/bibtex.rb', line 28

def output_ext(extension)
  BibTeXConverter.extension
end