HTML output for rendered citations and bibliography
Hey, I'm trying to use hayagriva as a library to parse and render citations and bibliography on a HTML website. Generally it works quite well, but when rendering the data the library includes ANSI escape codes in the output by default. This isn't a major problem, because I can for example do something like .replace("\u{1b}[0m", "") to strip them, but this is less than ideal.
For example given this bibliography
@book{dojg-advanced,
title = {A dictionary of advanced Japanese grammar},
author = {Makino, Seiichi and Tsutsui, Michio},
isbn = {9784789012959},
lccn = {2017414531},
year = {2008},
publisher = {Japan Times}
}
When rendering this entry as a String I get:
[\u{1b}[0m1\u{1b}[0m]\u{1b}[0m\u{1b}[0mMakino S\u{1b}[0m and \u{1b}[0mTsutsui M\u{1b}[0m \u{1b}[0m2008\u{1b}[0m \u{1b}[0m\u{1b}[3mA dictionary of advanced Japanese grammar\u{1b}[0m (\u{1b}[0mJapan Times\u{1b}[0m)\u{1b}[0m
Ideally (HTML) these would be something along the lines of:
[1]Makino S and Tsutsui M 2008 <i>A dictionary of advanced Japanese grammar</i> (Japan Times)
If this currently can't be accomplished, it could potentially be added as an alternative API to the default ToString, if it can then it would be useful to add the way to accomplish this to the documentation.
This is how I am currently processing the bibliography:
let bib = match res.bibliography {
Some(ref bib) => {
let test = bib.items.iter()
.map(|x| x.content.to_string().replace("\u{1b}[0m", ""))
.collect::<Vec<_>>();
Some(test)
},
None => None,
};