zotero / citeproc-rs

CSL processor in Rust.
https://cormacrelf.github.io/citeproc-wasm-demo/
Other
75 stars 11 forks source link

Plaintext output of citations does not handle unicode characters properly #91

Closed adomasven closed 3 years ago

adomasven commented 3 years ago

Plaintext output of citations (at least with the previewCitationCluster()) produces output like:

\uc0\u268 otar et al., 2020

where it should be

Čotar et al., 2020

The bibliography plaintext output for unicode characters is fine.

cormacrelf commented 3 years ago

Ah, that's a dumb but easy one. Good catch.

let build = built_cluster_before_output(db, cluster_id);
let string = formatter.output(build, get_piq(db));
Arc::new(string)

What's missing here? Using the overridden formatter inside built_cluster_before_output, Cormac you idiot. Hence the Unicode encoded for RTF.

cormacrelf commented 3 years ago

Turns out this code was fine. You need to pass one of "html", "rtf" or "plain", and it was not raising an error when it wasn't one of these, it just silently used the driver's default output format. I've got a PR to make it raise errors & document slightly more, but you'll have to check that you're not writing "plaintext" instead of "plain".