Git Product home page Git Product logo

pelican-bibtex's Introduction

Pelican BibTeX

Organize your scientific publications with BibTeX in Pelican

Author Vlad Niculae
Author Email [email protected]
Author Homepage http://vene.ro
Github Account https://github.com/vene

Note: This code is unlicensed. It was not submitted to the pelican-plugins official repository because of the license constraint imposed there.

Requirements

pelican_bibtex requires pybtex.

pip install pybtex

How to Use

This plugin reads a user-specified BibTeX file and populates the context with a list of publications, ready to be used in your Jinja2 template.

Configuration is simply:

PUBLICATIONS_SRC = 'content/pubs.bib'

If the file is present and readable, you will be able to find the publications variable in all templates. It is a list of tuples with the following fields:

(key, year, text, bibtex, pdf, slides, poster)
  1. key is the BibTeX key (identifier) of the entry.
  2. year is the year when the entry was published. Useful for grouping by year in templates using Jinja's groupby
  3. text is the HTML formatted entry, generated by pybtex.
  4. bibtex is a string containing BibTeX code for the entry, useful to make it available to people who want to cite your work.
  5. pdf, slides, poster: in your BibTeX file, you can add these special fields, for example:
@article{
   foo13
   ...
   pdf = {/papers/foo13.pdf},
   slides = {/slides/foo13.html}
}

This plugin will take all defined fields and make them available in the template. If a field is not defined, the tuple field will be None. Furthermore, the fields are stripped from the generated BibTeX (found in the bibtex field).

Template Example

You probably want to define a 'publications.html' direct template. Don't forget to add it to the DIRECT\_TEMPLATES configuration key. Note that we are escaping the BibTeX string twice in order to properly display it. This can be achieved using forceescape.

{% extends "base.html" %}
{% block title %}Publications{% endblock %}
{% block content %}

<script type="text/javascript">
    function disp(s) {
        var win;
        var doc;
        win = window.open("", "WINDOWID");
        doc = win.document;
        doc.open("text/plain");
        doc.write("<pre>" + s + "</pre>");
        doc.close();
    }
</script>
<section id="content" class="body">
    <h1 class="entry-title">Publications</h1>
    <ul>
    {% for key, year, text, bibtex, pdf, slides, poster in publications %}
    <li id="{{ key }}">{{ text }}
    [&nbsp;<a href="javascript:disp('{{ bibtex|replace('\n', '\\n')|escape|forceescape }}');">Bibtex</a>&nbsp;]
    {% for label, target in [('PDF', pdf), ('Slides', slides), ('Poster', poster)] %}
    {{ "[&nbsp;<a href=\"%s\">%s</a>&nbsp;]" % (target, label) if target }}
    {% endfor %}
    </li>
    {% endfor %}
    </ul>
</section>
{% endblock %}

Extending this plugin

A relatively simple but possibly useful extension is to make it possible to write internal links in Pelican pages and blog posts that would point to the corresponding paper in the Publications page.

A slightly more complicated idea is to support general referencing in articles and pages, by having some BibTeX entries local to the page, and rendering the bibliography at the end of the article, with anchor links pointing to the right place.

pelican-bibtex's People

Contributors

vene avatar andreas-h avatar jvkersch avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.