Skip to main content

detect_format_from_str

Function detect_format_from_str 

Source
pub fn detect_format_from_str(src: &str) -> BibFormat
Expand description

Sniff format. Strategy: try parsing as JSON first (fast: serde_json will reject within bytes if the leading non-whitespace is @). If JSON parse fails, fall back to BibTeX. Note that an empty BibTeX file (zero entries) is legal, and an empty string parses as neither JSON nor BibTeX cleanly; we treat empty-or-whitespace-only as BibTeX so an empty .bib round-trips correctly.