% !Mode:: "TeX:UTF-8"
%% udesoftec-biblatex.sty
%% Copyright 2015 J. Peter M. Schuler
%% 2021/02/22 v1.7.1 udesoftec

%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `author-maintained'.
% 
% The current maintainer of this work is J. Peter M. Schuler
% j.peter.m.schuler@uni-due.de
%
% This work consists of the files 
% * udesoftec.cls 
% * udesoftec.bst
% * udesoftec-bibcommon.sty
% * udesoftec-biblatex.sty
% * udesoftec-bst.sty
% * udesoftec-extra.sty
%
% As this work is based on years of mostly undocumented improvement, 
% it includes parts, for which sources can't be identified anymore. Public postings
% in the LaTeX community were used as an input and if source is known, it is
% mentioned below. If anybody identifies parts of his/her own code,
% feel free to contact the maintainer in order to get listed. 
%
% Special thanks to all contributors and for the help of the tex-live team,
% e.g. Axel K.; Norbert P.; Petra R.; Rainer S.; Reinhard K.; Robin F.
%
% For further information refer to:
% http://mirrors.ctan.org/macros/latex/contrib/udesoftec/README
% and
% http://mirrors.ctan.org/macros/latex/contrib/udesoftec/udesoftec-doc.pdf

\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{udesoftec-bibcommon}[2021/02/22 v1.7.1 udesoftec-bibcommon.sty udesoftec bibstyle configuration commons]%


\newif\ifprimaryDocumentLanguageGerman
\DeclareOption{de}          {\primaryDocumentLanguageGermantrue}
\DeclareOption{en}          {\primaryDocumentLanguageGermanfalse}

\newif\ifdocumentIsFinal
\documentIsFinalfalse
\DeclareOption{final}          {\documentIsFinaltrue}

\DeclareOption*{\PackageWarning{udesoftec-bibcommon}{Unknown option \CurrentOption}}

\ProcessOptions\relax



\RequirePackage{csquotes}  % language dependant quotes and in-quote-quotes
\RequirePackage{regexpatch}  % language dependant quotes and in-quote-quotes
\RequirePackage{hyperref} % support doi-links
\RequirePackage{hyphenat} % prevent author names and quotations from hyphenating
%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[doipre={doi:}]{uri}

\providecaptionname{ngerman}{\bbland}{und }%
\providecaptionname{english}{\bbland}{and }%
\providecaptionname{british}{\bbland}{and }%
\providecaptionname{ngerman}{\bblheading}{Bibliografie}%
\providecaptionname{english}{\bblheading}{Bibliography}%
\providecaptionname{british}{\bblheading}{Bibliography}%
\providecaptionname{ngerman}{\bblin}{In:~}%
\providecaptionname{english}{\bblin}{In:~}%
\providecaptionname{british}{\bblin}{In:~}%
\providecaptionname{ngerman}{\bbled}{~(Hrsg.)}%
\providecaptionname{english}{\bbled}{~(Ed.)}%
\providecaptionname{british}{\bbled}{~(Ed.)}%
\providecaptionname{ngerman}{\bblEdPrefix}{}%
\providecaptionname{english}{\bblEdPrefix}{}%
\providecaptionname{british}{\bblEdPrefix}{}%
\providecaptionname{ngerman}{\bbleds}{~(Hrsg.)}%
\providecaptionname{english}{\bbleds}{~(Eds.)}%
\providecaptionname{british}{\bbleds}{~(Eds.)}%
\providecaptionname{ngerman}{\bbledn}{Aufl.}%
\providecaptionname{english}{\bbledn}{edn}%
\providecaptionname{british}{\bbledn}{edn}%
\providecaptionname{ngerman}{\bbletal}{et~al.}%
\providecaptionname{english}{\bbletal}{et~al.}%
\providecaptionname{british}{\bbletal}{et~al.}%
\providecaptionname{ngerman}{\bblpp}{S.~}%
\providecaptionname{english}{\bblpp}{pp.}%
\providecaptionname{british}{\bblpp}{pp.}%
\providecaptionname{ngerman}{\bblp}{S.~}%
\providecaptionname{english}{\bblp}{p.~}%
\providecaptionname{british}{\bblp}{p.~}%
\providecaptionname{ngerman}{\bblvol}{Nr.}%
\providecaptionname{english}{\bblvol}{No}%
\providecaptionname{british}{\bblvol}{No}%
\providecaptionname{ngerman}{\bblof}{von}%
\providecaptionname{english}{\bblof}{of}%
\providecaptionname{british}{\bblof}{of}%
\providecaptionname{ngerman}{\bblnoyear}{oJ}%
\providecaptionname{english}{\bblnoyear}{n.d.}%
\providecaptionname{british}{\bblnoyear}{n.d.}%
\providecaptionname{ngerman}{\bblnoyearlong}{ohne Jahresangabe}%
\providecaptionname{english}{\bblnoyearlong}{no date}%
\providecaptionname{british}{\bblnoyearlong}{no date}%
\providecaptionname{ngerman}{\bbllastaccesswas}{Abruf am}%
\providecaptionname{english}{\bbllastaccesswas}{Accessed}%
\providecaptionname{british}{\bbllastaccesswas}{Accessed}%
\providecaptionname{ngerman}{\bblpublishedon}{Veröffentlicht am}%
\providecaptionname{english}{\bblpublishedon}{Published on}%
\providecaptionname{british}{\bblpublishedon}{Published on}%
\providecaptionname{ngerman}{\bblstandardpublishedon}{Version vom}%
\providecaptionname{english}{\bblstandardpublishedon}{Version dated}%
\providecaptionname{british}{\bblstandardpublishedon}{Version dated}%




% normal space stretches in order to cope with align justify
% in case of initials we don't want this to allow the eyes to assign the initial
% to the surname. Else one is always irritated.
\providecommand{\bblSmallSpace}{\nobreak\hspace{.25em}} 
\providecommand{\bblisbn}[1]{ISBN:\mbox{#1}}
\providecommand{\bblissn}[1]{ISSN:\mbox{#1}}
\providecommand{\bbland}{\& }
\providecommand{\bblAuthorYearSep}{ } % possible to add \newline 
\providecommand{\bblAuthorTitleSep}{ } % possible to add \newline 
\providecommand{\bblAuthorTitleSepInEd}{ }
\providecommand{\bblFirstnameSep}{\bblSmallSpace}
\providecommand{\bblNamePrefixSep}{\bblSmallSpace}
\providecommand{\bblAuthorsSepInText}{\bbland}
\providecommand{\bblAuthorsSep}{, }
\providecommand{\bblstdseptypenum}{ }
\providecommand{\bblstdsepnumed}{-}
\providecommand{\bblnostandardrepeat}{}
%\providecommand{\bblInTextPagePrefix}[1]{}
\providecommand{\bblInTextPagePrefix}[1]{%
% test for 1...9,i,v,x
\@ifnextchar1{\bblp}{\@ifnextchar2{\bblp}{\@ifnextchar4{\bblp}{\@ifnextchar3{\bblp}{\@ifnextchar5{\bblp}{\@ifnextchar6{\bblp}{\@ifnextchar7{\bblp}{\@ifnextchar8{\bblp}{\@ifnextchar9{\bblp}{\@ifnextchar{i}{\bblp}{}\@ifnextchar{v}{\bblp}{}\@ifnextchar{x}{\bblp}{}}}}}}}}}}%
}

\providecommand{\bblstandardpublishdate}[1]{\bblstandardpublishedon\space\bblParseDate{#1}}
\providecommand{\bblpublishdate}[1]{\bblpublishedon\space\bblParseDate{#1}}
\providecommand{\bblurldate}[1]{(\bbllastaccesswas\space\bblParseDate{#1})}
\providecommand{\bblVolumeOfSeries}[2]{ (#2~#1)}
\providecommand{\bblSeries}[1]{ (#1)}
\providecommand{\bblYear}[1]{(#1)}
\providecommand{\bblFontAuthorInText}[1]{\nohyphens{\textsc{#1}}}
\providecommand{\bblFontAuthorInList}[1]{\textbf{#1}}
\providecommand{\bblFontYearInList}[1]{\textbf{#1}}
\providecommand{\bblFontBookTitle}[1]{\emph{#1}}
\providecommand{\bblFontInBookTitle}[1]{#1}
\providecommand{\bblFontJournalTitle}[1]{#1}
\providecommand{\bblFontTitle}[1]{#1}




\ifdocumentIsFinal
    \providecommand{\bblWarning}[2]{} %for production
\else
    \providecommand{\bblWarning}[2]{
        \message{LaTeX Warning: Error with citation of #2 -- #1 }%
        \textbf{\emph{BibError: #2 -- #1}}%
    }
\fi
\providecommand{\bblyear}[1]{\Ifnumber{#1}{#1}{\bblnoyear}}
\providecommand{\bbledGenerateEdition}[1]{\Ifnumber{#1}{\bbledOrdinal{#1}\bbledn}{#1}}

\providecommand{\englishordinal}[1]{\ifcase #1\or 1\textsuperscript{st}\or 2\textsuperscript{nd}\or 3\textsuperscript{rd}\else #1\textsuperscript{th}\fi}
\providecommand{\germanordinal}[1]{#1.}
\providecommand{\bbledOrdinal}[1]{
    \iflanguage{british}{%
        \englishordinal{#1}
    }{%
        \germanordinal{#1}
    }
}


% taken from pkg:uri
\providecommand{\bbldoi}[1]{%
  \doi{#1}%
}%

\RequirePackage{xstring}
\RequirePackage{babel}
\usepackage[useregional=text]{datetime2}
\DTMsetstyle{ddmmyyyy}
% http://tex.stackexchange.com/questions/225919/how-to-split-input-string-in-a-latex-command
% \def\bblParseDate #1-#2-#3\endparse{%                                                                 
%   \DTMDisplaydate{#1}{#2}{#3}{-1}%
% }
\def\bblParseDateWithDots #1.#2.#3 #4\endBblDateparse{%
   \DTMdate{#3-#2-#1}%
}
\providecommand{\bblParseDate}[1]{%
\IfSubStr{#1}{-}{\DTMdate{#1}}{%
\bblParseDateWithDots #1 x\endBblDateparse%
}%
}

% only show first city
\def\bblParseAddressWithAnd #1 and #2\endBblAddressparse{%
   \bblAddress{#1}%
}
\def\bblParseAddressWithComma #1,#2\endBblAddressparse{%
   \bblAddress{#1}%
}
\def\bblParseAddressWithSemiColon #1;#2\endBblAddressparse{%
   \bblAddress{#1}%
}
\providecommand{\bblAddress}[1]{%
\IfSubStr{#1}{ and }%
    {\bblParseAddressWithAnd #1 and x\endBblAddressparse}%
    {\IfSubStr{#1}{,}%
        {\bblParseAddressWithComma #1,x\endBblAddressparse}%
        {\IfSubStr{#1}{;}%
            {\bblParseAddressWithSemiColon #1;x\endBblAddressparse}%
            {#1}%
        }%
    }%
}


\providecommand{\citemulti}[1]{%
\citetext{%
\bibstyle@udesoftecmulticite%
#1%
\bibstyle@udesoftec%
}}


\providecommand{\inquotequote}[1]{\enquote{#1}}

\providecommand{\intextquote}[3][]{%
    \message{LaTeX Warning: \noexpand\intextquote is deprecated, use \noexpand\citequote on input line \the\inputlineno }%
    \citequote[#1]{#2}{#3}%
}
\providecommand{\inlinequote}[3][]{%
    \message{LaTeX Warning: \noexpand\intextquote is deprecated, use \noexpand\citequote on input line \the\inputlineno }%
    \citequote[#1]{#2}{#3}%
}
\providecommand{\citequote}[3][]{\enquote{#3} \citep[#1]{#2}}
\providecommand{\citequotehidden}[3][]{\citep[#1]{#2}}
\providecommand{\citetquotehidden}[3][]{\citet[#1]{#2}}
\providecommand{\citetquotepar}[3][]{
    \begin{quote}
    #3\par
    \hfill\citep[#1]{#2}
    \end{quote}
}

% from biblatex
\protected\def\bblisdot{%
\ifpunct \ifterm \nopunct \isdot \adddot \addperiod \addcomma
\appto\nocorrlist{\isdot\adddot\addperiod\addcomma}}

\endinput%