typst / biblatex

A Rust crate for parsing and writing BibTeX and BibLaTeX files.
Apache License 2.0
129 stars 17 forks source link

Missing Reserved Char Escapes #25

Closed bamonroe closed 2 years ago

bamonroe commented 2 years ago

The characters '#', '~', and '^', are missing from the escape code here:

https://github.com/typst/biblatex/blob/main/src/resolve.rs#L387

These appear to be special characters:

http://latexref.xyz/Reserved-characters.html

The following entry when parsedBibliography::parse() and then written out with bibliograph.to_bibtex_string()

let src = r#"
        @article{Monroe2022,
    author = {Monroe, Brian Albert},
    journal = {Working Paper},
    keywords = {Beliefs,Risk aversion},
    pages = {1--66},
    title = {Estimating Beliefs by Event Space Bisection \#1},
    year = {2022},
    }
"#;

results in the following bibtex string:

@article{Monroe2022,
author = {Monroe, Brian Albert},
journal = {Working Paper},
keywords = {Beliefs,Risk aversion},
pages = {1--66},
title = {Estimating Beliefs by Event Space Bisection \\#1! },
year = {2022},
}

Note the double backslash before the # character in the title field. This causes biber to fail to compile the document.

(/usr/share/texmf-dist/tex/latex/biblatex/lbx/english.lbx)) (./main.bbl
! Illegal parameter number in definition of \NewValue.
<to be read again>
                   1
l.43 ...ng Beliefs by Event Space Bisection \\#1!}