Translate citation locator braces to \pnfmt when using --biblatex
BibLaTeX provides \pnfmt, which allows users to force treating special parts of a citation postnote as pages. This seems to be equivalent to pandoc-citeproc's locator braces, which provide the same functionality. Since locator braces are already handled by the LaTeX Writer anyway (they are stripped), it might be a good idea to simply translate them into LaTeX when possible.
But not all locators are page numbers....
I just saw that we already talked about this issue in https://github.com/jgm/pandoc/issues/5722. I completely forgot about that, to be honest.
But not all locators are page numbers....
Using \pnfmt should still work, I believe. Apparently,
it is more of a suggestion to biblatex than a strong
override (such as using \pno would be). To quote the manual
(http://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf,
p. 117):
\pnfmt{<text>}This command formats its argument
<text>in the same format aspostnote. The command can be used to format a page range while adding additional text in the postnote argument of a cite command.\autocite[\pnfmt{378-381, 383} and more]{sigfridsson}
Preliminary testing with biblatex suggests that it might work:
\documentclass{article}
\begin{filecontents}{\jobname.bib}
@article{tenen-wythoff-2014,
author = "Dennis Tenen and Grant Wythoff",
title = "Sustainable Authorship in Plain Text using Pandoc and Markdown",
year = "2014",
journal = "The Programming Historian",
volume = "3",
doi = "https://doi.org/10.46430/phen0041",
}
\end{filecontents}
\usepackage[style=authoryear]{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
Arabic number as locator
\autocite[\pnfmt{20}, additional note]{tenen-wythoff-2014}.
Roman number as locator
\autocite[\pnfmt{iv}, additional note]{tenen-wythoff-2014}.
Part as locator
\autocite[\pnfmt{pt. III}, additional note]{tenen-wythoff-2014}.
Something else as locator
\autocite[\pnfmt{(a)}, additional note]{tenen-wythoff-2014}.
\end{document}
The latex above produces the following citations:
Arabic number as locator (Tenen and Wythoff 2014, p. 20, additional note). Roman number as locator (Tenen and Wythoff 2014, p. iv, additional note). Part as locator (Tenen and Wythoff 2014, pt. III, additional note). Something else as locator (Tenen and Wythoff 2014, (a), additional note).
Adding pnfmt around an explicitly delimited citation locator with biblatex shouldn't hurt, at least.
The implementation is still lacking, of course, as it doesn't support whitespace in locators yet. It is also inconsistent with pandoc-citeproc, as my implementation allows multiple locators, while pandoc-citeproc only allows one. Maybe I could reuse (part of) the postfix parsing functionality from pandoc-citeproc directly? It has been integrated into pandoc if I understand correctly, hasn't it?
Sorry I've let this languish. Yes, the code you're talking about is in Text.Pandoc.Citeproc.Locator - parseLocator.