How to register a custom formatting plugin from a bst file in pybtex

Issue #63 resolved
Former user created an issue

How can parse .bst in order to resgister a pybyex.style.formatting plugin?

I looked in the repository found the function parse_file from pybtex.bibtex.bst.

I think I should do something like what follows but can t seem to create a template from the output of the parse_file function.

from pybtex.style.formatting.unsrt import Style as UnsrtStyle from pybtex.style.template import toplevel # ... and anything else needed from pybtex.plugin import register_plugin

class MyStyleFromBst(UnsrtStyle):

def format_XXX(self, e):
    template = toplevel [
        # Do something with the bst file
    ]
    return template.format_data(e)

register_plugin('pybtex.style.formatting', 'mystyleFomBst', MyStyleFromBst)

The snippet is originally from sphinxcontrib-bibtex documentation. https://sphinxcontrib-bibtex.readthedocs.org/en/latest/usage.html

Comments (4)

  1. Andrey Golovizin

    Well, you you can't register .bst files as formatting plugins. The reason is that .bst styles are hard-coded to output LaTeX markup and do not other formats. Pybtex formatting plugins have to be written in Python.

  2. Former user Account Deleted

    I see. I have no other choice than registering the style manually then. Well thanks for taking the time to answer.

  3. Former user Account Deleted

    I see. I have no other choice than registering the style manually then. Well thanks for taking the time to answer.

  4. Log in to comment