BibtexSourceBibTeX Parser and Pretty Printer
This module provides comprehensive functionality for parsing, manipulating, and formatting BibTeX bibliographic entries. It supports all standard BibTeX entry types and provides robust error handling for malformed input.
Type representing different ways field values can be formatted in BibTeX
A BibTeX field with name and value
type entry_type = | ArticleJournal article
*)| BookBook with explicit publisher
*)| BookletWork that is printed and bound, but without a named publisher
*)| ConferenceConference proceedings entry
*)| InBookPart of a book (chapter, section, etc.)
*)| InCollectionPart of a book having its own title
*)| InProceedingsArticle in conference proceedings
*)| ManualTechnical documentation
*)| MastersThesisMaster's thesis
*)| MiscMiscellaneous entry type
*)| PhdThesisPhD thesis
*)| ProceedingsConference proceedings
*)| TechReportTechnical report
*)| UnpublishedDocument having an author and title, but not formally published
*)Standard BibTeX entry types
type entry_content = | Field of fieldA field-value pair
*)| EntryComment of stringComment within an entry
*)Content within a BibTeX entry
type bibtex_entry = {entry_type : entry_type;Type of the entry
*)citekey : string;Citation key/identifier
*)contents : entry_content list;List of fields and comments
*)}Complete BibTeX entry
type bibtex_item = | Entry of bibtex_entryA bibliographic entry
*)| Comment of stringA comment line
*)Top-level BibTeX item
Parse error information
Result of parsing with potential errors
parse_bibtex input parses a BibTeX string into a list of items. This function ignores parse errors and returns only successfully parsed items.
parse_bibtex_with_errors input parses a BibTeX string and returns both successfully parsed items and any errors encountered.
has_parse_errors result checks if a parse result contains any errors.
get_parse_errors result extracts the list of parse errors.
get_parsed_items result extracts the list of successfully parsed items.
pretty_print_bibtex items formats a list of BibTeX items into a complete BibTeX string.
clean_bibtex input parses and reformats BibTeX input, effectively cleaning and normalizing the formatting.
string_of_entry_type entry_type converts an entry type to its string representation (e.g., Article becomes "article").
entry_type_of_string str converts a string to an entry type.
format_field_value value formats a field value for output.
format_field_value_with_url_unescaping field_name value formats a field value with URL unescaping and Unicode normalization applied. Special handling is applied to URL fields.
format_entry_content content formats entry content (field or comment).
format_entry entry formats a complete BibTeX entry.
format_bibtex_item item formats a BibTeX item (entry or comment).