typst / biblatex

A Rust crate for parsing and writing BibTeX and BibLaTeX files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Certain LaTeX text accents are incorrectly displayed

pjhuxford opened this issue · comments

Consider the following code

use biblatex::Bibliography;

fn main() {
    let src = r"@article {test, author = {L\^{e} D\~{u}ng Tr\'{a}ng}}";
    let bibliography = Bibliography::parse(src).unwrap();
    let entry = bibliography.get("test").unwrap();
    let author = entry.author().unwrap();
    println!("{}", author[0]);
}

When run, this code prints

L^e D~ung Tráng

The correct output should be

Lê Dũng Tráng

The problem is that if a backslash \ proceeds any of LaTeX's reserved characters, then the reserved character is printed literally. This is always correct behavior for many reserved characters, however if either ^ or ~ are preceded by a backslash and given a non-empty argument, then they should be viewed as commands which can modify their argument by adding a circumflex or combining tilde.

I've submitted a pull request here that fixes this, in a rather hacky way.