%%
%% This is file `bibleref-mouth.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bibleref-mouth.dtx  (with options: `code')
%% 
%%  Copyright 2012 Chad Parry
%% 
%%  This work may be distributed and/or modified under the
%%  conditions of the LaTeX Project Public License, either version 1.3
%%  of this license of (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 `maintained'.
%% 
%%  The Current Maintainer of this work is Chad Parry.
%% 
%%  This work consists of the files bibleref-mouth.dtx and bibleref-mouth.ins
%%  and the derived file bibleref-mouth.sty.
%% 

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{bibleref-mouth}[2012/02/26 v1.0 Expandable Bible reference style]

\RequirePackage{fmtcount}
\RequirePackage{hyperref}[2008/12/26]

\newcommand*{\setbiblestyle}[1]{%
    \def\brm@currentstyle{#1}%
}
\setbiblestyle{fullname}
\newcommand*{\bibleref}[1]{%
    \brm@bibleref{\brm@currentstyle}{#1}%
}
\newcommand*{\brm@bibleref}[2]{%
    \brm@ifnameexists{\brm@style{#1}}{%
        \brm@readlist{\brm@parseall{#2}}{%
            \brm@formatall{\csname\brm@style{#1}\endcsname}%
        }{%
        }%
    }{%
        \brm@error{Unrecognized style: #1}%
    }%
}
\newcommand*{\brm@formatall}[3]{%
    \brm@unpackrange{#2}{\brm@applystyle{#1}{#3}}%
}
\newcommand*{\brm@applystyle}[4]{%
    #1{#3}{#4}{\brm@nextrange{#2}}%
}
\newcommand*{\brm@nextrange}[3]{%
    \brm@readlist{#1}{%
        \brm@formatall{#2}%
    }{%
        #3%
    }%
}
\newcommand*{\brm@packpassage}[4]{%
    #4{#1}{#2}{#3}%
}
%% Store a passage in \mypassage.
%% Later, extract the book from \mypassage into \mybook.
\newcommand*{\thebook}[1]{%
    #1{\brm@choosebook}%
}
\newcommand*{\brm@choosebook}[3]{%
    #1%
}
\newcommand*{\thechapter}[1]{%
    #1{\brm@choosechapter}%
}
\newcommand*{\brm@choosechapter}[3]{%
    #2%
}
\newcommand*{\theverse}[1]{%
    #1{\brm@chooseverse}%
}
\newcommand*{\brm@chooseverse}[3]{%
    #3%
}
\newcommand*{\brm@packrange}[3]{%
    #3{#1}{#2}%
}
\newcommand*{\brm@unpackrange}[2]{%
    #1{#2}%
}
\newcommand*{\brm@packseparators}[3]{%
    #3{#1}{#2}%
}
\newcommand*{\bookchapterseparator}[1]{%
    #1{\@firstoftwo}%
}
\newcommand*{\chapterverseseparator}[1]{%
    #1{\@secondoftwo}%
}
\newcommand*{\brm@nillist}{%
    \@secondoftwo%
}
\newcommand*{\brm@conslist}[2]{%
    \brm@conslist@choose{#1}{#2}%
}
\newcommand*{\brm@conslist@choose}[4]{%
    #3{#1}{#2}%
}
\newcommand*{\brm@readlist}[3]{%
    #1{#2}{#3}%
}
\newcommand*{\brm@recordrange}[7]{%
    \brm@conslist{%
        \brm@packrange{%
         \brm@packpassage{#1}{#2}{#3}%
        }{%
         \brm@packpassage{#4}{#5}{#6}%
        }%
    }{%
        #7%
    }%
}
\newcommand*{\brm@recordpassage}[4]{%
    \brm@recordrange{#1}{#2}{#3}{}{}{}{#4}%
}
\newcommand*{\brm@parseall}[1]{%
    \brm@parsebook{#1}{%
        \brm@checkchapter%
    }{%
        \brm@error{Unrecognized book: #1}%
    }%
}
\newcommand*{\brm@checkchapter}[2]{%
    \brm@ifempty{#2}{%
        \brm@recordpassage{#1}{}{}{\brm@nillist}%
    }{%
        \brm@ifsamehead{#2}{-}{%
            \brm@parserange{#1}{}{}{\brm@tailstr{#2}}%
        }{%
            \brm@ifsamehead{#2}{;}{%
                \brm@recordpassage{#1}{}{}{%
                    \brm@parseall{\brm@tailstr{#2}}%
                }%
            }{%
                \brm@parsechapter{#1}{#2}%
            }%
        }%
    }%
}
\newcommand*{\brm@parsechapter}[2]{%
    \brm@parsenumber{#2}{\brm@checkchapterdelim{#1}}%
}
\newcommand*{\brm@checkchapterdelim}[3]{%
    \brm@ifempty{#3}{%
        \brm@recordpassage{#1}{#2}{}{\brm@nillist}%
    }{%
        \brm@ifsamehead{#3}{:}{%
            \brm@parseverse{#1}{#2}{\brm@tailstr{#3}}%
        }{%
            \brm@ifsamehead{#3}{-}{%
                \brm@parserange{#1}{#2}{}{\brm@tailstr{#3}}%
            }{%
                \brm@ifsamehead{#3}{;}{%
                    \brm@recordpassage{#1}{#2}{}{%
                        \brm@parsechapterlist{#1}{\brm@tailstr{#3}}%
                    }%
                }{%
                    \brm@error{Unrecognized chapter trailer: #3}%
                }%
            }%
        }%
    }%
}
\newcommand*{\brm@parseverse}[3]{%
    \brm@parsenumber{#3}{\brm@checkversetrailer{#1}{#2}}%
}
\newcommand*{\brm@checkversetrailer}[4]{%
    \brm@ifempty{#4}{%
        \brm@recordpassage{#1}{#2}{#3}{\brm@nillist}%
    }{%
        \brm@ifsamehead{#4}{-}{%
            \brm@parserange{#1}{#2}{#3}{\brm@tailstr{#4}}%
        }{%
            \brm@ifsamehead{#4}{;}{%
                \brm@recordpassage{#1}{#2}{#3}{%
                    \brm@parsechapterlist{#1}{\brm@tailstr{#4}}%
                }%
            }{%
                \brm@ifsamehead{#4}{,}{%
                    \brm@recordpassage{#1}{#2}{#3}{%
                        \brm@parseverse{#1}{#2}{\brm@tailstr{#4}}%
                    }%
                }{%
                    \brm@error{Unrecognized verse trailer: #4}%
                }%
            }%
        }%
    }%
}
\newcommand*{\brm@parserange}[4]{%
    \brm@parsebook{#4}{%
        \brm@checkrangechapter{#1}{#2}{#3}%
    }{%
        \brm@ifempty{#2}{%
            \brm@error{Unrecognized range book: #4}%
        }{%
            \brm@parsenumber{#4}{%
                \brm@checkrangenumbertrailer{#1}{#2}{#3}{#1}%
            }%
        }%
    }%
}
\newcommand*{\brm@checkrangechapter}[5]{%
    \brm@ifempty{#5}{%
        \brm@recordrange{#1}{#2}{#3}{#4}{}{}{\brm@nillist}%
    }{%
        \brm@ifsamehead{#5}{;}{%
            \brm@recordrange{#1}{#2}{#3}{#4}{}{}{%
                \brm@parseall{\brm@tailstr{#5}}%
            }%
        }{%
            \brm@parsenumber{#5}{%
                \brm@checkrangechapterdelim{#1}{#2}{#3}{#4}%
            }%
        }%
    }%
}
\newcommand*{\brm@checkrangechapterdelim}[6]{%
    \brm@ifempty{#6}{%
        \brm@recordrange{#1}{#2}{#3}{#4}{#5}{}{\brm@nillist}%
    }{%
        \brm@ifsamehead{#6}{:}{%
            \brm@parsenumber{\brm@tailstr{#6}}{%
                \brm@checkrangeversetrailer{#1}{#2}{#3}{#4}{#5}%
            }%
        }{%
            \brm@error{Unrecognized range chapter trailer: #6}%
        }%
    }%
}
\newcommand*{\brm@checkrangenumbertrailer}[6]{%
    \brm@ifempty{#6}{%
        \brm@ifempty{#3}{%
            \brm@recordrange{#1}{#2}{}{#4}{#5}{}{\brm@nillist}%
        }{%
            \brm@recordrange{#1}{#2}{#3}{#4}{#2}{#5}{\brm@nillist}%
        }%
    }{%
        \brm@ifsamehead{#6}{:}{%
            \brm@parsenumber{\brm@tailstr{#6}}{%
                \brm@checkrangeversetrailer{#1}{#2}{#3}{#4}{#5}%
            }%
        }{%
            \brm@ifempty{#3}{%
                \brm@ifsamehead{#6}{;}{%
                    \brm@recordrange{#1}{#2}{}{#4}{#5}{}{%
                        \brm@parsechapterlist{#4}{\brm@tailstr{#6}}%
                    }%
                }{%
                    \brm@error{Unrecognized range number trailer: #6}%
                }%
            }{%
                \brm@ifsamehead{#6}{;}{%
                    \brm@recordrange{#1}{#2}{#3}{#4}{#2}{#5}{%
                        \brm@parsechapterlist{#4}{\brm@tailstr{#6}}%
                    }%
                }{%
                    \brm@ifsamehead{#6}{,}{%
                        \brm@recordrange{#1}{#2}{#3}{#4}{#2}{#5}{%
                            \brm@parseverse{#4}{#2}{\brm@tailstr{#6}}%
                        }%
                    }{%
                        \brm@error{Unrecognized range number trailer: #6}%
                    }%
                }%
            }%
        }%
    }%
}
\newcommand*{\brm@checkrangeversetrailer}[7]{%
    \brm@ifempty{#7}{%
        \brm@recordrange{#1}{#2}{#3}{#4}{#5}{#6}{\brm@nillist}%
    }{%
        \brm@ifsamehead{#7}{;}{%
            \brm@recordrange{#1}{#2}{#3}{#4}{#5}{#6}{%
                \brm@parsechapterlist{#4}{\brm@tailstr{#7}}%
            }%
        }{%
            \brm@ifsamehead{#7}{,}{%
                \brm@recordrange{#1}{#2}{#3}{#4}{#5}{#6}{%
                    \brm@parseverse{#4}{#5}{\brm@tailstr{#7}}%
                }%
            }{%
                \brm@error{Unrecognized verse trailer: #7}%
            }%
        }%
    }%
}
\newcommand*{\brm@parsechapterlist}[2]{%
    \brm@parsebook{#2}{%
        \brm@checkchapter%
    }{%
        \brm@parsechapter{#1}{#2}%
    }%
}
\newcommand*{\brm@parsebook}[3]{%
    \expandafter\brm@parsebook@accumulate\expandafter%
        {\romannumeral-`0#1}{}{#2}{#3}%
}
\newcommand*{\brm@parsebook@accumulate}[4]{%
    \brm@ifempty{#1}{%
        #4%
    }{%
        \expandafter\brm@parsebook@expand\expandafter%
            {\romannumeral-`0\brm@headstr{#1}}%
            {#2}%
            {\brm@tailstr{#1}}%
            {#3}%
            {%
                \brm@ifnameexists{\brm@bookalias{#2\brm@headstr{#1}}}{%
                    \expandafter\brm@parsebook@success\expandafter%
                        {\romannumeral-`0\brm@tailstr{#1}}%
                        {\csname\brm@bookalias%
                            {#2\brm@headstr{#1}}\endcsname}%
                        {#3}%
                }{%
                    #4%
                }%
            }%
    }%
}
\newcommand*{\brm@parsebook@expand}[5]{%
    \expandafter\brm@parsebook@accumulate\expandafter%
        {\romannumeral-`0#3}{#2#1}{#4}{#5}%
}
\newcommand*{\brm@parsebook@success}[3]{%
    #3{#2}{#1}%
}
\newcommand*{\brm@parsenumber}[2]{%
    \expandafter\brm@parsenumber@accumulate\expandafter%
        {\romannumeral-`0#1}{}{#2}%
}
\newcommand*{\brm@parsenumber@accumulate}[3]{%
    \brm@ifempty{#1}{%
        \brm@parsenumber@end{#1}{#2}{#3}%
    }{%
        \expandafter\brm@ifdigit\expandafter%
            {\romannumeral-`0\brm@headstr{#1}}{%
            \expandafter\brm@parsenumber@expand\expandafter%
                {\romannumeral-`0\brm@headstr{#1}}{\brm@tailstr{#1}}{#3}{#2}%
        }{%
            \brm@parsenumber@end{#1}{#2}{#3}%
        }%
    }%
}
\newcommand*{\brm@parsenumber@expand}[4]{%
    \expandafter\brm@parsenumber@accumulate\expandafter%
        {\romannumeral-`0#2}{#4#1}{#3}%
}
\newcommand*{\brm@parsenumber@end}[3]{%
    \brm@ifempty{#2}{%
        \brm@error{Invalid number: #1}%
    }{%
        #3{#2}{#1}%
    }%
}
\newcommand*{\brm@ifsamehead}[4]{%
    \brm@ifsamechar{\brm@headstr{#1}}{\brm@headstr{#2}}{#3}{#4}%
}
\newcommand*{\brm@ifsamechar}[4]{%
    \if#1#2%
        \expandafter\@firstoftwo%
    \else%
        \expandafter\@secondoftwo%
    \fi%
    {#3}{#4}%
}
\newcommand*{\brm@ifsamestr}[4]{%
    \expandafter\brm@ifsamestr@expandsecond\expandafter%
        {\romannumeral-`0#2}{#1}{#3}{#4}%
}
\newcommand*{\brm@ifsamestr@expandsecond}[4]{%
    \expandafter\brm@ifsamestr@expanded\expandafter%
        {\romannumeral-`0#2}{#1}{#3}{#4}%
}
\newcommand*{\brm@ifsamestr@expanded}[4]{%
    \brm@ifempty{#1}{%
        \brm@ifempty{#2}{%
            #3%
        }{%
            #4%
        }%
    }{%
        \brm@ifempty{#2}{%
            #4%
        }{%
            \brm@ifsamehead{#1}{#2}{%
                \brm@ifsamestr{\brm@tailstr{#1}}{\brm@tailstr{#2}}{%
                    #3%
                }{%
                    #4%
                }%
            }{%
                #4%
            }%
        }%
    }%
}
\newcommand*{\ifsamebook}[4]{%
    \brm@ifsamestr{\thebook{#1}}{\thebook{#2}}{#3}{#4}%
}
\newcommand*{\ifsamechapter}[4]{%
    \brm@ifsamestr{\thechapter{#1}}{\thechapter{#2}}{#3}{#4}%
}
\newcommand*{\ifsameverse}[4]{%
    \brm@ifsamestr{\theverse{#1}}{\theverse{#2}}{#3}{#4}%
}
\newcommand*{\ifhasbook}[3]{%
    \expandafter\brm@ifempty\expandafter%
        {\romannumeral-`0\thebook{#1}}{#3}{#2}%
}
\newcommand*{\ifhaschapter}[3]{%
    \expandafter\brm@ifempty\expandafter%
        {\romannumeral-`0\thechapter{#1}}{#3}{#2}%
}
\newcommand*{\ifhasverse}[3]{%
    \expandafter\brm@ifempty\expandafter%
        {\romannumeral-`0\theverse{#1}}{#3}{#2}%
}
\newcommand*{\brm@ifempty}[3]{%
    \expandafter\ifx\expandafter\brm@nevermatch#1\brm@nevermatch%
        \expandafter\@firstoftwo%
    \else%
        \expandafter\@secondoftwo%
    \fi%
    {#2}{#3}%
}
\def\brm@nevermatch{\brm@nevermatch}
\newcommand*{\brm@ifnameexists}[3]{%
    \ifcsname#1\endcsname%
        \expandafter\@firstoftwo%
    \else%
        \expandafter\@secondoftwo%
    \fi%
    {#2}{#3}%
}
\newcommand*{\brm@ifdigit}[3]{%
    \ifnum 9<1\string#1 %
        \expandafter\@firstoftwo%
    \else%
        \expandafter\@secondoftwo%
    \fi%
    {#2}{#3}%
}
\newcommand*{\brm@ifspace}[3]{%
    \ifcat #1 %
        \expandafter\@firstoftwo%
    \else%
        \expandafter\@secondoftwo%
    \fi%
    {#2}{#3}%
}
\newcommand*{\brm@uppercaseascii}[1]{%
    \brm@ifempty{#1}{}{%
        \expandafter\brm@uppercaseascii@char\expandafter%
            {\romannumeral-`0\brm@headstr{#1}}%
        \expandafter\brm@uppercaseascii\expandafter%
            {\romannumeral-`0\brm@tailstr{#1}}%
    }%
}
\newcommand*{\brm@uppercaseascii@char}[1]{%
    \ifcase`#1%
        #1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or%
        #1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or%
        #1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or%
        #1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or%
        #1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or%
        #1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or%
        #1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or%
        #1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or%
        #1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or#1\or%
        A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or K\or L\or M\or%
        N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or X\or Y\or Z%
    \else#1%
    \fi%
}
\def\brm@headstr#1{\brm@headstr@helper#1\@nil}
\def\brm@headstr@helper#1#2\@nil{#1}
\def\brm@tailstr#1{\brm@tailstr@helper#1\@nil}
\def\brm@tailstr@helper#1#2\@nil{#2}
\begingroup
\catcode`\:=11\relax
\gdef\brm@error#1{%
    \protect\expandafter\brm@error@aux\csname#1\endcsname%
}
\gdef\brm@error@aux#1{%
    \romannumeral-`0\@firstofone{\brm@error: #1}%
}
\endgroup
\newcommand*{\brm@bookref}[2]{brm@bookref@#1@#2}
\newcommand*{\brm@bookalias}[1]{brm@bookalias@#1}
\newcommand*{\brm@style}[1]{brm@style@#1}
\newcommand*{\thebookname}[2]{%
    \brm@bookname{#1}{\thebook{#2}}%
}
\newcommand*{\brm@bookname}[2]{%
    \brm@ifnameexists{\brm@bookref{#1}{#2}}{%
        \csname\brm@bookref{#1}{#2}\endcsname%
    }{%
        \brm@error{Style missing book: #2}%
    }%
}
\newcommand*{\providebiblestyle}[2]{%
    \expandafter\def\csname\brm@style{#1}\endcsname##1##2##3{%
        #2%
    }%
}
\newcommand*{\providebiblebookalias}[2]{%
    \expandafter\brm@providebiblebookalias\expandafter%
        {\romannumeral-`0#2}{#1}%
}
\newcommand*{\brm@providebiblebookalias}[2]{%
    \expandafter\def\csname\brm@bookalias{#1}\endcsname{#2}%
}
\newcommand*{\providebiblebook}[3]{%
    \expandafter\def\csname\brm@bookref{#1}{#2}\endcsname{#3}%
}
\newcommand*{\brm@formatchapter}[2]{%
    #1{\thechapter{#2}}%
}
\newcommand*{\brm@formatverse}[2]{%
    #1{\theverse{#2}}%
}
\newcommand*{\brm@identity@filter}[6]{%
    #6{#1}{#2}{#3}{#4}{#5}%
}
\newcommand*{\standardbiblestyle}[9]{%
    \brm@standard@filtered%
        {\brm@packseparators{#2}{#3}}%
        {\brm@packpassage{#4}{#5}{#6}}%
        {\brm@packpassage{#7}{#7}{#7}}%
        {\brm@packpassage%
            {\thebookname{#1}}%
            {\brm@formatchapter{#8}}%
            {\brm@formatverse{#9}}}%
        {\brm@identity@filter}%
}
\newcommand*{\brm@standard@filtered}[8]{%
    #5%
        {\brm@packpassage{}{}{}}%
        {#6}%
        {#1}%
        {\brm@packpassage{}{}{}}%
        {#4}%
        {\brm@standard@passage}%
    #5{#6}{#7}{#1}{#3}{#4}{\brm@standard@passage}%
    #8{%
        \brm@standard@list{#1}{#2}{#3}{#4}{#5}%
            {\ifhasbook{#7}{#7}{#6}}%
    }{%
    }%
}
\newcommand*{\brm@standard@list}[9]{%
    #5{#6}{#7}{#1}{#2}{#4}{\brm@standard@passage}%
    #5{#7}{#8}{#1}{#3}{#4}{\brm@standard@passage}%
    #9{%
        \brm@standard@list{#1}{#2}{#3}{#4}{#5}%
            {\ifhasbook{#8}{#8}{#7}}%
    }{%
    }%
}
\newcommand*{\brm@standard@passage}[5]{%
    \ifhasbook{#2}{%
        \ifhaschapter{#2}{%
            \ifhasverse{#2}{%
                \ifsamebook{#1}{#2}{%
                    \ifsamechapter{#1}{#2}{%
                        \ifsameverse{#1}{#2}{%
                        }{%
                            \ifhasverse{#1}{%
                                \theverse{#4}%
                                \theverse{#5}{#2}%
                            }{%
                                \thechapter{#4}%
                                \thechapter{#5}{#2}%
                                \chapterverseseparator{#3}%
                                \theverse{#5}{#2}%
                            }%
                        }%
                    }{%
                        \ifhaschapter{#1}{%
                            \thechapter{#4}%
                            \thechapter{#5}{#2}%
                            \chapterverseseparator{#3}%
                            \theverse{#5}{#2}%
                        }{%
                            \thebook{#4}%
                            \thebook{#5}{#2}%
                            \bookchapterseparator{#3}%
                            \thechapter{#5}{#2}%
                            \chapterverseseparator{#3}%
                            \theverse{#5}{#2}%
                        }%
                    }%
                }{%
                    \thebook{#4}%
                    \thebook{#5}{#2}%
                    \bookchapterseparator{#3}%
                    \thechapter{#5}{#2}%
                    \chapterverseseparator{#3}%
                    \theverse{#5}{#2}%
                }%
            }{%
                \ifsamebook{#1}{#2}{%
                    \ifsamechapter{#1}{#2}{%
                        \ifhasverse{#1}{%
                            \brm@ifsamestr
                                {\thechapter{#4}}{\theverse{#4}}{%
                                \thebook{#4}%
                                \thebook{#5}{#2}%
                                \bookchapterseparator{#3}%
                                \thechapter{#5}{#2}%
                            }{%
                                \thechapter{#4}%
                                \thechapter{#5}{#2}%
                            }%
                        }{%
                        }%
                    }{%
                        \ifhaschapter{#1}{%
                            \ifhasverse{#1}{%
                                \brm@ifsamestr
                                    {\thechapter{#4}}{\theverse{#4}}{%
                                    \thebook{#4}%
                                    \thebook{#5}{#2}%
                                    \bookchapterseparator{#3}%
                                    \thechapter{#5}{#2}%
                                }{%
                                    \thechapter{#4}%
                                    \thechapter{#5}{#2}%
                                }%
                            }{%
                                \thechapter{#4}%
                                \thechapter{#5}{#2}%
                            }%
                        }{%
                            \thebook{#4}%
                            \thebook{#5}{#2}%
                            \bookchapterseparator{#3}%
                            \thechapter{#5}{#2}%
                        }%
                    }%
                }{%
                    \thebook{#4}%
                    \thebook{#5}{#2}%
                    \bookchapterseparator{#3}%
                    \thechapter{#5}{#2}%
                }%
            }%
        }{%
            \ifsamebook{#1}{#2}{%
                \ifhaschapter{#1}{%
                    \thebook{#4}%
                    \thebook{#5}{#2}%
                }{%
                }%
            }{%
                \thebook{#4}%
                \thebook{#5}{#2}%
            }%
        }%
    }{%
    }%
}
\newcommand*{\brm@delegatestyle}[4]{%
    \brm@ifnameexists{\brm@style{#1}}{%
        \csname\brm@style{#1}\endcsname{#2}{#3}{#4}%
    }{%
        \brm@error{Unrecognized style: #1}%
    }%
}
\newcommand*{\brm@foreachbook@full}[9]{%
    #1{Genesis}{#3Genesis}%
    #1{Exodus}{#3Exodus}%
    #1{Leviticus}{#3Leviticus}%
    #1{Numbers}{#3Numbers}%
    #1{Deuteronomy}{#3Deuteronomy}%
    #1{Joshua}{#3Joshua}%
    #1{Judges}{#3Judges}%
    #1{Ruth}{#3Ruth}%
    #1{ISamuel}{#8{1}#3Samuel}%
    #1{IISamuel}{#8{2}#3Samuel}%
    #1{IKings}{#8{1}#3Kings}%
    #1{IIKings}{#8{2}#3Kings}%
    #1{IChronicles}{#8{1}#3Chronicles}%
    #1{IIChronicles}{#8{2}#3Chronicles}%
    #1{Ezra}{#3Ezra}%
    #1{Nehemiah}{#3Nehemiah}%
    #1{Tobit}{#3Tobit}%
    #1{Judith}{#3Judith}%
    #1{Esther}{#3Esther}%
    #1{IMaccabees}{#8{1}#3Maccabees}%
    #1{IIMaccabees}{#8{2}#3Maccabees}%
    #1{Job}{#3Job}%
    #1{Psalms}{#3Psalms}%
    #1{Proverbs}{#3Proverbs}%
    #1{Ecclesiastes}{#3Ecclesiastes}%
    #1{SongofSongs}{#3Song#2of#2Songs}%
    #1{Wisdom}{#3Wisdom}%
    #1{Ecclesiasticus}{#3Ecclesiasticus}%
    #1{Isaiah}{#3Isaiah}%
    #1{Jeremiah}{#3Jeremiah}%
    #1{Lamentations}{#3Lamentations}%
    #1{Baruch}{#3Baruch}%
    #1{Ezekiel}{#3Ezekiel}%
    #1{Daniel}{#3Daniel}%
    #1{Hosea}{#3Hosea}%
    #1{Joel}{#3Joel}%
    #1{Amos}{#3Amos}%
    #1{Obadiah}{#3Obadiah}%
    #1{Jonah}{#3Jonah}%
    #1{Micah}{#3Micah}%
    #1{Nahum}{#3Nahum}%
    #1{Habakkuk}{#3Habakkuk}%
    #1{Zephaniah}{#3Zephaniah}%
    #1{Haggai}{#3Haggai}%
    #1{Zechariah}{#3Zechariah}%
    #1{Malachi}{#3Malachi}%
    #1{Matthew}{#4Matthew}%
    #1{Mark}{#4Mark}%
    #1{Luke}{#4Luke}%
    #1{John}{#4John}%
    #1{Acts}{Acts}%
    #1{Romans}{#6Romans}%
    #1{ICorinthians}{#9{1}#6Corinthians}%
    #1{IICorinthians}{#9{2}#6Corinthians}%
    #1{Galatians}{#6Galatians}%
    #1{Ephesians}{#6Ephesians}%
    #1{Philippians}{#6Philippians}%
    #1{Colossians}{#6Colossians}%
    #1{IThessalonians}{#9{1}#6Thessalonians}%
    #1{IIThessalonians}{#9{2}#6Thessalonians}%
    #1{ITimothy}{#9{1}#5Timothy}%
    #1{IITimothy}{#9{2}#5Timothy}%
    #1{Titus}{#5Titus}%
    #1{Philemon}{#5Philemon}%
    #1{Hebrews}{#6Hebrews}%
    #1{James}{#7James}%
    #1{IPeter}{#9{1}#7Peter}%
    #1{IIPeter}{#9{2}#7Peter}%
    #1{IJohn}{#9{1}#7John}%
    #1{IIJohn}{#9{2}#7John}%
    #1{IIIJohn}{#9{3}#7John}%
    #1{Jude}{#7Jude}%
    #1{Revelation}{#3Revelation}%
}
\newcommand*{\brm@foreachbook@abbrv}[4]{%
    #1{Genesis}{Gn#2}%
    #1{Exodus}{Ex#2}%
    #1{Leviticus}{Lv#2}%
    #1{Numbers}{Nb#2}%
    #1{Deuteronomy}{Dt#2}%
    #1{Joshua}{Jos#2}%
    #1{Judges}{Jg#2}%
    #1{Ruth}{Rt#2}%
    #1{ISamuel}{#3{1}S#2}%
    #1{IISamuel}{#3{2}S#2}%
    #1{IKings}{#3{1}K#2}%
    #1{IIKings}{#3{2}K#2}%
    #1{IChronicles}{#3{1}Ch#2}%
    #1{IIChronicles}{#3{2}Ch#2}%
    #1{Ezra}{Ezr#2}%
    #1{Nehemiah}{Ne#2}%
    #1{Tobit}{Tb#2}%
    #1{Judith}{Jdt#2}%
    #1{Esther}{Est#2}%
    #1{IMaccabees}{#3{1}M#2}%
    #1{IIMaccabees}{#3{2}M#2}%
    #1{Job}{Jb#2}%
    #1{Psalms}{Ps#2}%
    #1{Proverbs}{Pr#2}%
    #1{Ecclesiastes}{Qo#2}%
    #1{SongofSongs}{Sg#2}%
    #1{Wisdom}{Ws#2}%
    #1{Ecclesiasticus}{Si#2}%
    #1{Isaiah}{Is#2}%
    #1{Jeremiah}{Jr#2}%
    #1{Lamentations}{Lm#2}%
    #1{Baruch}{Ba#2}%
    #1{Ezekiel}{Ezk#2}%
    #1{Daniel}{Dn#2}%
    #1{Hosea}{Ho#2}%
    #1{Joel}{Jl#2}%
    #1{Amos}{Am#2}%
    #1{Obadiah}{Ob#2}%
    #1{Jonah}{Jon#2}%
    #1{Micah}{Mi#2}%
    #1{Nahum}{Na#2}%
    #1{Habakkuk}{Hab#2}%
    #1{Zephaniah}{Zp#2}%
    #1{Haggai}{Hg#2}%
    #1{Zechariah}{Zc#2}%
    #1{Malachi}{Ml#2}%
    #1{Matthew}{Mt#2}%
    #1{Mark}{Mk#2}%
    #1{Luke}{Lk#2}%
    #1{John}{Jn#2}%
    #1{Acts}{Ac#2}%
    #1{Romans}{Rm#2}%
    #1{ICorinthians}{#4{1}Co#2}%
    #1{IICorinthians}{#4{2}Co#2}%
    #1{Galatians}{Ga#2}%
    #1{Ephesians}{Ep#2}%
    #1{Philippians}{Ph#2}%
    #1{Colossians}{Col#2}%
    #1{IThessalonians}{#4{1}Th#2}%
    #1{IIThessalonians}{#4{2}Th#2}%
    #1{ITimothy}{#4{1}Tm#2}%
    #1{IITimothy}{#4{2}Tm#2}%
    #1{Titus}{Tt#2}%
    #1{Philemon}{Phm#2}%
    #1{Hebrews}{Heb#2}%
    #1{James}{Jm#2}%
    #1{IPeter}{#4{1}P#2}%
    #1{IIPeter}{#4{2}P#2}%
    #1{IJohn}{#4{1}Jn#2}%
    #1{IIJohn}{#4{2}Jn#2}%
    #1{IIIJohn}{#4{3}Jn#2}%
    #1{Jude}{Jude}%
    #1{Revelation}{Rv#2}%
}
\newcommand*{\brm@foreachbook@altabbrv}[5]{%
    #1{Genesis}{Gen#2}%
    #1{Exodus}{Exod#2}%
    #1{Leviticus}{Lev#2}%
    #1{Numbers}{Num#2}%
    #1{Deuteronomy}{Deut#2}%
    #1{Joshua}{Josh#2}%
    #1{Judges}{Judg#2}%
    #1{Ruth}{Ruth}%
    #1{ISamuel}{#4{1}Sam#2}%
    #1{IISamuel}{#4{2}Sam#2}%
    #1{IKings}{#4{1}Kgs#2}%
    #1{IIKings}{#4{2}Kgs#2}%
    #1{IChronicles}{#4{1}Chr#2}%
    #1{IIChronicles}{#4{2}Chr#2}%
    #1{Ezra}{Ezra}%
    #1{Nehemiah}{Neh#2}%
    #1{Tobit}{Tobit}%
    #1{Judith}{Judith}%
    #1{Esther}{Esther}%
    #1{IMaccabees}{#4{1}M#2}%
    #1{IIMaccabees}{#4{2}M#2}%
    #1{Job}{Job}%
    #1{Psalms}{Ps#2}%
    #1{Proverbs}{Prov#2}%
    #1{Ecclesiastes}{Eccles#2}%
    #1{SongofSongs}{S#2#3of#3S#2}%
    #1{Wisdom}{Wisd#2}%
    #1{Ecclesiasticus}{Ecclus#2}%
    #1{Isaiah}{Isa#2}%
    #1{Jeremiah}{Jer#2}%
    #1{Lamentations}{Lam#2}%
    #1{Baruch}{Baruch}%
    #1{Ezekiel}{Ezek#2}%
    #1{Daniel}{Dan#2}%
    #1{Hosea}{Hos#2}%
    #1{Joel}{Joel}%
    #1{Amos}{Amos}%
    #1{Obadiah}{Obad#2}%
    #1{Jonah}{Jonah}%
    #1{Micah}{Mic#2}%
    #1{Nahum}{Nah#2}%
    #1{Habakkuk}{Hab#2}%
    #1{Zephaniah}{Zeph#2}%
    #1{Haggai}{Hag#2}%
    #1{Zechariah}{Zech#2}%
    #1{Malachi}{Mal#2}%
    #1{Matthew}{Matt#2}%
    #1{Mark}{Mark}%
    #1{Luke}{Luke}%
    #1{John}{John}%
    #1{Acts}{Acts}%
    #1{Romans}{Rom#2}%
    #1{ICorinthians}{#5{1}Cor#2}%
    #1{IICorinthians}{#5{2}Cor#2}%
    #1{Galatians}{Gal#2}%
    #1{Ephesians}{Eph#2}%
    #1{Philippians}{Phil#2}%
    #1{Colossians}{Col#2}%
    #1{IThessalonians}{#5{1}Thess#2}%
    #1{IIThessalonians}{#5{2}Thess#2}%
    #1{ITimothy}{#5{1}Tim#2}%
    #1{IITimothy}{#5{2}Tim#2}%
    #1{Titus}{Tit#2}%
    #1{Philemon}{Philem#2}%
    #1{Hebrews}{Heb#2}%
    #1{James}{Jas#2}%
    #1{IPeter}{#5{1}Pet#2}%
    #1{IIPeter}{#5{2}Pet#2}%
    #1{IJohn}{#5{1}John}%
    #1{IIJohn}{#5{2}John}%
    #1{IIIJohn}{#5{3}John}%
    #1{Jude}{Jude}%
    #1{Revelation}{Rev#2}%
}
\newcommand*{\brm@number@arabic}[1]{#1}
\newcommand*{\brm@number@lowerroman}[1]{\romannumeral#1}
\newcommand*{\brm@number@upperroman}[1]{%
    \MakeUppercase{\romannumeral#1}%
}
\newcommand*{\brm@number@arabicspace}[1]{#1~}
\newcommand*{\brm@number@arabicspaceascii}[1]{#1 }
\newcommand*{\brm@number@lowerromanspace}[1]{\romannumeral#1~}
\newcommand*{\brm@number@upperromanspace}[1]{%
    \MakeUppercase{\romannumeral#1}~%
}
\newcommand*{\brm@number@scromanspace}[1]{\textsc{\romannumeral#1}~}
\newcommand*{\brm@number@upperromanascii}[1]{%
    \expandafter\brm@uppercaseascii\expandafter{\romannumeral#1}%
}
\brm@foreachbook@full{\providebiblebookalias}{}{}{}{}{}{}%
    {\brm@number@upperromanascii}{\brm@number@upperromanascii}
\brm@foreachbook@full{\providebiblebookalias}{}{}{}{}{}{}%
    {\brm@number@arabic}{\brm@number@arabic}
\brm@foreachbook@abbrv{\providebiblebookalias}{}%
    {\brm@number@upperromanascii}{\brm@number@upperromanascii}
\brm@foreachbook@abbrv{\providebiblebookalias}{}%
    {\brm@number@arabic}{\brm@number@arabic}
\brm@foreachbook@abbrv{\providebiblebookalias}{.}%
    {\brm@number@upperromanascii}{\brm@number@upperromanascii}
\brm@foreachbook@abbrv{\providebiblebookalias}{.}%
    {\brm@number@arabic}{\brm@number@arabic}
\brm@foreachbook@altabbrv{\providebiblebookalias}{}{}%
    {\brm@number@arabic}{\brm@number@arabic}
\brm@foreachbook@altabbrv{\providebiblebookalias}{}{}%
    {\brm@number@upperromanascii}{\brm@number@upperromanascii}
\brm@foreachbook@altabbrv{\providebiblebookalias}{.}{}%
    {\brm@number@arabic}{\brm@number@arabic}
\brm@foreachbook@altabbrv{\providebiblebookalias}{.}{}%
    {\brm@number@upperromanascii}{\brm@number@upperromanascii}
\brm@foreachbook@full{\providebiblebook{fullname}}{\ }{}{}{}{}{}%
    {\brm@number@arabicspace}{\brm@number@arabicspace}
\brm@foreachbook@abbrv{\providebiblebook{jerusalem}}{}%
    {\brm@number@arabicspace}{\brm@number@arabicspace}
\brm@foreachbook@altabbrv{\providebiblebook{anglosaxon}}{.}{\ }%
    {\brm@number@upperromanspace}{\brm@number@upperromanspace}
\brm@foreachbook@altabbrv{\providebiblebook{JEH}}{.}{\ }%
    {\brm@number@arabicspace}{\brm@number@arabicspace}
\brm@foreachbook@full{\providebiblebook{MHRA}}{\ }{}{}{}{}{}%
    {\brm@number@scromanspace}{\brm@number@scromanspace}
\brm@foreachbook@altabbrv{\providebiblebook{NTG}}{}{\ }%
    {\brm@number@arabicspace}{\brm@number@arabicspace}
\brm@foreachbook@altabbrv{\providebiblebook{MLA}}{.}{\ }%
    {\brm@number@arabicspace}{\brm@number@arabicspace}
\brm@foreachbook@altabbrv{\providebiblebook{chicago}}{.}{\ }%
    {\brm@number@arabicspace}{\brm@number@arabicspace}
\providebiblestyle{fullname}{\standardbiblestyle{fullname}%
    {\ }{:}{; }{;}{,}{--}%
    {\brm@number@arabic}{\brm@number@arabic}%
    {#1}{#2}{#3}}
\providebiblestyle{jerusalem}{\standardbiblestyle{jerusalem}%
    {\ }{:}{; }{; }{,}{--}%
    {\brm@number@arabic}{\brm@number@arabic}%
    {#1}{#2}{#3}}
\providebiblestyle{anglosaxon}{\standardbiblestyle{anglosaxon}%
    {\ }{.}{; }{; }{,}{--}%
    {\brm@number@upperroman}{\brm@number@arabic}%
    {#1}{#2}{#3}}
\providebiblestyle{JEH}{\standardbiblestyle{JEH}%
    {\ }{.~}{; }{; }{,}{--}%
    {\brm@number@lowerroman}{\brm@number@arabic}%
    {#1}{#2}{#3}}
\providebiblestyle{MHRA}{\standardbiblestyle{MHRA}%
    {\ }{.~}{; }{; }{,}{--}%
    {\brm@number@lowerroman}{\brm@number@arabic}%
    {#1}{#2}{#3}}
\providebiblestyle{NTG}{\standardbiblestyle{NTG}%
    {\ }{,}{; }{; }{,}{--}%
    {\brm@number@lowerroman}{\brm@number@arabic}%
    {#1}{#2}{#3}}
\providebiblestyle{MLA}{\standardbiblestyle{MLA}%
    {\ }{.}{; }{; }{,}{--}%
    {\brm@number@lowerroman}{\brm@number@arabic}%
    {#1}{#2}{#3}}
\providebiblestyle{chicago}{\standardbiblestyle{chicago}%
    {\ }{\,:\,}{; }{; }{,}{--}%
    {\brm@number@lowerroman}{\brm@number@arabic}%
    {#1}{#2}{#3}}
\newcommand*{\brm@number@stomach@text}[1]{\numberstringnum{#1}}
\newcommand*{\brm@number@stomach@ordspace}[1]{\Ordinalstringnum{#1}~}
\newcommand*{\brm@number@stomach@chapter}[1]{chapter\ %
    \brm@number@stomach@text{#1}}
\newcommand*{\brm@number@stomach@verse}[1]{verse\ %
    \brm@number@stomach@text{#1}}
\brm@foreachbook@full{\providebiblebook{text}}%
    {\ }%
    {Book of }{Gospel according to St.~}%
    {Epistle to }{Epistle to the }{Epistle of }%
    {\brm@number@stomach@ordspace}%
    {\brm@number@stomach@ordspace}
\providebiblestyle{text}{\standardbiblestyle{text}%
    {,\ }{\ }{,\ and\ }{,\ and\ }{,\ and\ }{\ to\ }%
    {\brm@number@stomach@chapter}{\brm@number@stomach@verse}%
    {#1}{#2}{#3}}
\brm@foreachbook@full{\providebiblebook{biblegateway.com}}%
    {\ }{}{}{}{}{}%
    {\brm@number@arabicspaceascii}{\brm@number@arabicspaceascii}
\newcommand*{\providebiblegatewayurl}[2]{%
    \providebiblestyle{#1}{%
        \brm@biblegatewayurl@style{#2}{##1}{##2}{##3}%
    }%
}
\newcommand*{\brm@biblegatewayurl@style}[4]{%
    http://www.biblegateway.com/passage/?search=%
    \brm@standard@filtered%
        {\brm@packseparators{ }{:}}%
        {\brm@packpassage{; }{; }{,}}%
        {\brm@packpassage{-}{-}{-}}%
        {\brm@packpassage%
            {\thebookname{biblegateway.com}}%
            {\brm@formatchapter{\brm@number@arabic}}%
            {\brm@formatverse{\brm@number@arabic}}}%
        {\brm@biblegatewayurl@filter{-}}%
        {#2}{#3}{#4}%
    \&version=#1%
}
\newcommand*{\brm@biblegatewayurl@filter}[7]{%
    \brm@ifsamestr{\theverse{#5}}{#1}{%
        % Show ranges like normal.
        #7{#2}{#3}{#4}{#5}{#6}%
    }{%
        % List the book explicitly for each list element.
        #7{\brm@packpassage{}{}{}}{#3}{#4}{#5}{#6}%
    }%
}
\providebiblegatewayurl{biblegateway.com-url}{NIV}
\newcommand*{\providebiblegatewaystyle}[3]{%
    \providebiblestyle{#1}{%
        \href{%
            \brm@delegatestyle{#2}{##1}{##2}{##3}%
        }{%
            \brm@delegatestyle{#3}{##1}{##2}{##3}%
        }%
    }%
}
\providebiblegatewaystyle{biblegateway.com}%
    {biblegateway.com-url}{fullname}
\endinput
%%
%% End of file `bibleref-mouth.sty'.