Mendeley allows you to emphasise Latin names in article or report titles using HTML notation like so:
A treatise on the ecology of <I>Rattus rattus</I>
Using biblatex
, the tags are passed on "verbatim" and of course LaTeX doesn't understand them. I would like to replace all <I>
with \emph{
and all </I>
with }
.
I have tried using \DeclareSourceMap
as follows:
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=title, match={<I>}, replace={\emph{}]
\step[fieldsource=title,match={</I>},replace={}}]
}
}
}
But of course LaTeX chokes as the extra {
and }
confuse it.
How should I escape the braces for this to work?
Best Answer
I found that the problem was more with getting Biber to accept what look like XML tags than it was with dealing with the
\emph
, which can be done by wrapping them in a\regexp
, with escapes. In the end I resorted to specifying the < and > by character number.Anyway, this seems to work.
Of course, as any fule kno, parsing HTML with regular expressions is not guaranteed to be robust.
Full MWE