archome / jekyll-citation

Jekyll plugin to parse/render BibTeX-encoded citations included in posts/pages
MIT License
52 stars 5 forks source link

Bibtex in citation tag not rendering #2

Open futureneer opened 10 years ago

futureneer commented 10 years ago

Hello,

I followed the instructions in the readme.md file, and successfully installed all the dependencies, as well as making changes to my files and adding the liquid tag in my .md file. However, after building with Jekyll and serving, I don't see any rendered text from the bibtex item. I have copied the citation.rb to my _plugins folder. Do I need to do anything else?

Thanks!

PJK commented 10 years ago

It's not your fault. It didn't work for me either, so I looked into it. Basically, the

CiteProc.process b.to_citeproc, :style => @config['citation_style'], :locale => @config['citation_locale'], :format => 'html'

part doesn't work. I presume there were some breaking changes in the CiteProc gem.

I will probably try to fix it tomorrow.

Update:

So just in case you wanted to dig deeper into this, the following works

    def render(context)

      # get the content of the {% bibtex %} block
      content = super
      cp = CiteProc::Processor.new style: 'apa', format: 'html'
      bibtex = BibTeX.parse(content, :include => [:meta_content]).to_citeproc
      cp.import bibtex

      # so apparently we need to render them one by one
      bibtex.map {|item| cp.render(:bibliography, id: item['id']).pop}.join
    end

but it obviously doesn't forward the settings and the output is not very pretty... The citeproc gem could use some docs. I'm afraid I currently don't have time to make this really work, so I can only wish you the best of luck.

Sciss commented 9 years ago

Thanks, your update works but additional one must add require 'csl/styles' to the top of the file.