[Tex/LaTex] biblatex: sentence case and nested quotation marks

biblatexcapitalizationcsquotespunctuation

If a title contains formatting commands, how can we hook in \MakeSentenceCase to ensure correct casing and, say, nesting of quotation marks? The example below doesn't work; the quotes are properly nested, but "Quotation Marks" is still title case.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{test.bib}
@article{ref,
  sorttitle = {Handle Quotation Marks within Article Titles},
  author = {Lastname, Firstname},
  title = {Handle \mkbibquote{Quotation Marks} within Article Titles},
  journal = {Journalname},
  volume = {10},
  date = {1},
  pages = {5--10}}
\end{filecontents}

\bibliography{test.bib}

\DeclareFieldFormat{sentencecase}{\MakeSentenceCase*{#1}}
\renewbibmacro{title}{%
    \ifthenelse{\iffieldundef{title}\AND\iffieldundef{subtitle}}{}
        {\ifthenelse{\ifentrytype{article}\OR\ifentrytype{inbook}%
            \OR\ifentrytype{incollection}\OR\ifentrytype{inproceedings}}
            {\printtext[title]{%
                \printfield[sentencecase]{title}%
                \setunit{\subtitlepunct}%
                \printfield[sentencecase]{subtitle}}%
                \newunit}%
            {\printtext[title]{%
                \printfield[titlecase]{title}%
                \setunit{\subtitlepunct}%
                \printfield[titlecase]{subtitle}}%
                \newunit}}%
    \printfield{titleaddon}}

\begin{document}
    \textcite{ref}
    \printbibliography
\end{document}

Best Answer

As a workaround, you may use csquote's \MakeAutoQuote macro to define active characters which may be used instead of \mkbibquote. (In my example, I use « and ».)

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\MakeAutoQuote{«}{»}
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{test.bib}
@article{ref,
  sorttitle = {Handle Quotation Marks within Article Titles},
  author = {Lastname, Firstname},
  title = {Handle «Quotation Marks» within Article Titles},
  journal = {Journalname},
  volume = {10},
  date = {1},
  pages = {5--10}}
\end{filecontents}

\bibliography{test.bib}

\DeclareFieldFormat{sentencecase}{\MakeSentenceCase*{#1}}
\renewbibmacro{title}{%
    \ifthenelse{\iffieldundef{title}\AND\iffieldundef{subtitle}}{}
        {\ifthenelse{\ifentrytype{article}\OR\ifentrytype{inbook}%
            \OR\ifentrytype{incollection}\OR\ifentrytype{inproceedings}}
            {\printtext[title]{%
                \printfield[sentencecase]{title}%
                \setunit{\subtitlepunct}%
                \printfield[sentencecase]{subtitle}}%
                \newunit}%
            {\printtext[title]{%
                \printfield[titlecase]{title}%
                \setunit{\subtitlepunct}%
                \printfield[titlecase]{subtitle}}%
                \newunit}}%
    \printfield{titleaddon}}

\begin{document}
    \textcite{ref}
    \printbibliography
\end{document}