Skip to content

Latest commit

 

History

History
51 lines (31 loc) · 1.98 KB

readme.md

File metadata and controls

51 lines (31 loc) · 1.98 KB

JBibtexParser

This is a project aiming to provide an extensible java library for parsing bibtex or bibtex-similar files.

The goal was to make it very easy to use, but almost all parts of the project can be replaced with your own implementations simply by passing a custom class to the parser constructor.

Getting Started

Add the provided JBibtexParser.jar to your project, and include it in your dependencies. Afterwards just instantiate the parser and call Parser.parse(). It will return a BibliograpyManager which you can use to filter entries by types, fields or simply keywords

Example use

A simple constructor for creating parser with default componenents and a file reader:

    Parser parser = new Parser("samplefile.txt");

Parse the file:

    IBibliographyManager bibliographyManager;
    try {
        bibliographyManager = parser.parse();
    } catch (ParseErrorException e) {
        System.out.print(e.getMessage());
        return;
    }

Print out all entries:

    System.out.print(bibliographyManager.getBibliography().toString());

Print out all entries containing which contain both of the words 'mathematics' and 'theories'. You can chain filters:

    System.out.print(bibliographyManager.findEntriesContainingWords("mathematics").findEntriesContainingWords("theories")
    .getBibliography().toString());

print out all entries where author matches a regex .*shelah.*:

      System.out.println(bibliographyManager.findFieldsOfValue(parser.getEntryTypesManager().getField("author"),".*shelah.*").getBibliography().toString());

Running the tests

There are some (26) Junit5 tests written for the most bug-prone components, but full test coverage is definitly on the TODO list. You can find them in the tests package and run them as normal.

Authors

License

This project is licensed under the MIT License - see the license.md file for details