ruigomeseu / bibtex-to-html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BibTeX to HTML

Authors

  • Luís Gonçalves
  • João Bajouco
  • Rui Gomes

G60 - BibTeX2HTML

How to compile

jjtree parser.jjt && javacc parser.jj && javac *.java

How to configure

All the project configuration is done by editing the config.json file.

Available parameters

  • strict - Boolean value which indicates if invalid BibTeX files should be accepted.
  • style - This changes the style of the references. Available styles: "chicago", "apa".
  • template_path - Full/relative path of the templates folder.
  • master_template - Name of the master template.
  • output_file - Full/relative path of the output HTML file.
  • bibtex_file - Full/relative path of the input BibTeX file to parse.

How to run

java Bibtex2Html

This will run the project and load the config from the config.json file, parse the input BibTeX and use the provided templates to generate the output HTML file.

Examples

We provide several BibTeX input files to efficiently test the BibTeX parser. You can change the input file by editing the config.json file.

Use the strict parameter as true if you want fatal exceptions to be thrown.

Available examples

  • examples/lexical-error.txt - An example of a lexical error. The "invalid" type does not exist.
  • examples/syntactic-error.txt - An example of a syntatic error. The "title" property can't be an integer.
  • examples/semantic-error.txt - An example of a semantic error. The "author" property is duplicated and there are missing required properties.
  • examples/valid-bibtex.txt - A valid BibTeX file.

Lexical Analysis

The lexical analysis is performed in the parser.jjt file. If the parser finds any lexical error it will stop parsing the tree and print an error to the console.

Syntatic Analysis

The syntatic analysis is also performed in the parser.jjt file. If the parser finds any syntatical error it will stop parsing the tree and print an error to the console.

Sematic Analysis

The nodes tree is evaluated twice in the parser.jjt file which then passes the properties of each BibTeX entry to the Validator.java class. In this class the following semantic errors are detected:

  • Invalid pages order
  • Nonexistent cross reference
  • Duplicate properties within the same entry
  • Properties which aren't part of the entry type
  • Missing required properties

Intermediate language

The intermediate language is generated by removing the " and {,} from the BibTeX entry and storing all the entries with their properties in an array of Entry.java objects.

HTML Generation

The Entry.java class has a convertToHtml method which is responsible for converting each property into valid HTML:

  • Convert the month integer into a month string.
  • Replace the double hyphen into a HTML dash.
  • Replace LaTeX accents into HTML accents.
  • Convert BibTeX authors into the appropriate author string, according the the reference style in use.

Each entry will be inserted into the appropriate place in the style template (e.g. chicago.html) in use and then all HTML entries will be included in the master HTML template (e.g. template.html).

Feature Set

Fully functional HTML templates generation. The default template was fully W3C validated and loads Bootstrap from a CDN to style the BibTeX entries.

Easily configurable using a JSON file.

Implementation of a strict mode which gives the user the ability to ignore some exceptions and still compile the invalid BibTeX input file.

Two different reference styles available: Chicago and APA.

Future Improvements

The time constraints made it impossible to implement everything we envisioned:

  • Automated tests.
  • External data sources - e.g. use the Amazon API to fetch a books cover.
  • Additional reference styles.

About

License:MIT License


Languages

Language:Java 84.1%Language:HTML 15.7%Language:Makefile 0.2%