Page
Library
Module
Module type
Parameter
Class
Class type
Source
Bibtex
SourceBibTeX 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 =
| Article
Journal article
*)| Book
Book with explicit publisher
*)| Booklet
Work that is printed and bound, but without a named publisher
*)| Conference
Conference proceedings entry
*)| InBook
Part of a book (chapter, section, etc.)
*)| InCollection
Part of a book having its own title
*)| InProceedings
Article in conference proceedings
*)| Manual
Technical documentation
*)| MastersThesis
Master's thesis
*)| Misc
Miscellaneous entry type
*)| PhdThesis
PhD thesis
*)| Proceedings
Conference proceedings
*)| TechReport
Technical report
*)| Unpublished
Document having an author and title, but not formally published
*)Standard BibTeX entry types
type entry_content =
| Field of field
A field-value pair
*)| EntryComment of string
Comment 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_entry
A bibliographic entry
*)| Comment of string
A 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).