Skip to main content

unwrap_value

Function unwrap_value 

Source
pub fn unwrap_value(raw: &str) -> &str
Expand description

Strip one matching outer {...} or "..." pair from a raw field value.

The pair must enclose the whole value: a { balances against the final } only, and a " is not closed by an interior unescaped quote outside a braced group, mirroring parse_bibtex. Bare values and anything else are returned unchanged.

ยงExamples

use mos_bib::unwrap_value;

assert_eq!(unwrap_value("{Literate Programming}"), "Literate Programming");
assert_eq!(unwrap_value(r#""Quoted""#), "Quoted");
assert_eq!(unwrap_value("1984"), "1984");
assert_eq!(unwrap_value("{a} {b}"), "{a} {b}");