Page
Library
Module
Module type
Parameter
Class
Class type
Source
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.
Options for parsing and formatting BibTeX entries:
capitalize_names: If true, the field names are made upper capital.strict: If true, parsing will be stricter and reject bibtex files with duplicate fields.align_entries: If true, entries name and equal signs will be aligned for better readability.Default formatting options for BibTeX entries: capitalize_names: true, strict: false, align_entries: true
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_field field formats a complete field (name = value).
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).
Type representing a field conflict between duplicate entries. Each value is paired with the index of the entry it came from.
type duplicate_group = {entries : bibtex_entry list;The group of duplicate entries
*)matching_keys : (string * string) list;Key-value pairs that match
*)conflicts : field_conflict list;Fields that differ between entries
*)}Type representing a group of duplicate entries identified by matching key fields
find_duplicate_groups ~keys entries identifies groups of duplicate entries without resolving them.
This is useful for inspecting duplicates before deciding how to handle them. Each group contains at least 2 entries that match on the specified keys.
string_of_field_value fv converts a field value to its string representation.
make_field name value creates a BibTeX field with the given name and value. The value is wrapped in braces.