Commit 56674158 authored by Sylvester Keil's avatar Sylvester Keil

Implemented BibTeX converter

parent c97da063
source :rubygems
gemspec
# -*- encoding: utf-8 -*-
lib = File.expand_path('../lib/', __FILE__)
$:.unshift lib unless $:.include?(lib)
require 'jekyll/scholar/version'
Gem::Specification.new do |s|
s.name = 'jekyll-scholar'
s.version = Jekyll::Scholar::VERSION.dup
s.platform = Gem::Platform::RUBY
s.authors = ['Sylvester Keil']
s.email = 'http://sylvester.keil.or.at'
s.homepage = 'http://github.com/inukshuk/jekyll-scholar'
s.summary = 'Jekyll extensions for the academic blogger.'
s.description = 'A set of jekyll extensions for academic blogging.'
s.date = Time.now
s.required_rubygems_version = '>= 1.3.6'
s.rubyforge_project = s.name
s.add_dependency('jekyll', '~> 0.10')
s.add_development_dependency('bundler', '~> 1.0')
s.add_development_dependency('rdoc', '~> 2.5')
s.add_development_dependency('rake', '>= 0.8')
s.add_development_dependency('rspec', '~> 2.5')
s.add_development_dependency('cucumber', '~> 0.3')
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = []
s.require_path = 'lib'
s.has_rdoc = false
end
# vim: syntax=ruby
\ No newline at end of file
require 'bibtex'
require 'citeproc'
module Jekyll
module Scholar
class BibTeXConverter < Converter
safe true
priority :highest
DEFAULTS = Hash[*%w{
citation_style apa
citation_locale en
}].freeze
PATTERN = (/^\.bib(tex)?$/i).freeze
EXTENSION = '.html'.freeze
def initialize (config = {})
super
@config['scholar'] = DEFAULTS.merge(@config['scholar'] || {})
@citeproc = CiteProc::Processor.new :style => @config['citation_style'],
:locale => @config['citation_locale'], :format => 'html'
@markdown = MarkdownConverter.new config
end
def matches (extension); extension =~ PATTERN; end
def output_ext (extension); EXTENSION; end
def convert(content)
content = BibTeX.parse(content, :include => [:meta_content]).map do |b|
if b.respond_to? :to_citeproc
@citeproc.bibliography(b.to_citeproc).data.join
else
b.is_a? BibTeX::MetaContent ? b.to_s : ''
end
end
@markdown.convert(content.join("\n"))
end
end
end
end
\ No newline at end of file
module Jekyll
module Scholar
VERSION = '0.0.1'.freeze
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment