%%
%% This is file `bibleref-lds.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bibleref-lds.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 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 `maintained'.
%% 
%%  The Current Maintainer of this work is Chad Parry.
%% 
%%  This work consists of the files bibleref-lds.dtx and bibleref-lds.ins
%%  and the derived file bibleref-lds.sty.
%% 

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

\RequirePackage{bibleref-mouth}[2012/02/26]
\RequirePackage{ifthen}
\RequirePackage{hyperref}

\newcommand*{\brl@foreachbook@full}[5]{%
    #1{INephi}{#5{1}#4Nephi}%
    #1{IINephi}{#5{2}#4Nephi}%
    #1{Jacob}{#4Jacob}%
    #1{Enos}{#4Enos}%
    #1{Jarom}{#4Jarom}%
    #1{Omni}{#4Omni}%
    #1{WordsofMormon}{Words#2of#2Mormon}%
    #1{Mosiah}{#4Mosiah}%
    #1{Alma}{#4Alma}%
    #1{Helaman}{#4Helaman}%
    #1{IIINephi}{#5{3}#4Nephi}%
    #1{IVNephi}{#5{4}#4Nephi}%
    #1{Mormon}{#4Mormon}%
    #1{Ether}{#4Ether}%
    #1{Moroni}{#4Moroni}%
    #1{DoctrineandCovenants}{Doctrine#2and#2Covenants}%
    #1{OfficialDeclaration}{Official#2Declaration}%
    #1{Moses}{#4Moses}%
    #1{Abraham}{#4Abraham}%
    #1{JosephSmith-Matthew}{Joseph#2Smith#3Matthew}%
    #1{JosephSmith-History}{Joseph#2Smith#3History}%
    #1{ArticlesofFaith}{Articles#2of#2Faith}%
}
\newcommand*{\brl@foreachbook@abbrv}[6]{%
    #1{INephi}{#6{1}Ne#2}%
    #1{IINephi}{#6{2}Ne#2}%
    #1{Jacob}{Jacob}%
    #1{Enos}{Enos}%
    #1{Jarom}{Jarom}%
    #1{Omni}{Omni}%
    #1{WordsofMormon}{W#3#4of#4M#3}%
    #1{Mosiah}{Mosiah}%
    #1{Alma}{Alma}%
    #1{Helaman}{Hel#2}%
    #1{IIINephi}{#6{3}Ne#2}%
    #1{IVNephi}{#6{4}Ne#2}%
    #1{Mormon}{Morm#2}%
    #1{Ether}{Ether}%
    #1{Moroni}{Moro#2}%
    #1{DoctrineandCovenants}{D#3#5C#3}%
    #1{OfficialDeclaration}{O#3D#3}%
    #1{Moses}{Moses}%
    #1{Abraham}{Abr#2}%
    #1{JosephSmith-Matthew}{J#3S#3-M#3}%
    #1{JosephSmith-History}{J#3S#3-H#3}%
    #1{ArticlesofFaith}{A#3#4of#4F#3}%
}
\newcommand*{\brl@foreachbook@thumb}[6]{%
    #1{INephi}{#6{1}Ne#2}%
    #1{IINephi}{#6{2}Ne#2}%
    #1{Jacob}{Jac#2}%
    #1{Enos}{Eno#2}%
    #1{Jarom}{Jar#2}%
    #1{Omni}{Omn#2}%
    #1{WordsofMormon}{W#3#4Mn#3}%
    #1{Mosiah}{Msh#2}%
    #1{Alma}{Alma}%
    #1{Helaman}{Hel#2}%
    #1{IIINephi}{#6{3}Ne#2}%
    #1{IVNephi}{#6{4}Ne#2}%
    #1{Mormon}{Mor#2}%
    #1{Ether}{Eth#2}%
    #1{Moroni}{Mni#2}%
    #1{DoctrineandCovenants}{D#3#5C#3}%
    #1{OfficialDeclaration}{O#3D#3}%
    #1{Moses}{Mos#2}%
    #1{Abraham}{Abr#2}%
    #1{JosephSmith-Matthew}{J#3S#3-M#3}%
    #1{JosephSmith-History}{J#3S#3-H#3}%
    #1{ArticlesofFaith}{A#3#4of#4F#3}%
}
\newcommand*{\brl@foreachbook@bible@abbrv}[3]{%
    #1{Exodus}{Ex#2}%
    #1{Esther}{Esth#2}%
    #1{Ecclesiastes}{Eccl#2}%
    #1{SongofSongs}{Song#2}%
    #1{Hosea}{Hosea}%
    #1{Obadiah}{Obad#2}%
    #1{Micah}{Micah}%
    #1{Nahum}{Nahum}%
    #1{Philippians}{Philip#2}%
    #1{IThessalonians}{#3{1}Thes#2}%
    #1{IIThessalonians}{#3{2}Thes#2}%
    #1{Titus}{Titus}%
    #1{James}{James}%
    #1{IJohn}{#3{1}Jn#2}%
    #1{IIJohn}{#3{2}Jn#2}%
    #1{IIIJohn}{#3{3}Jn#2}%
}
\newcommand*{\brl@foreachbook@bible@thumb}[5]{%
    #1{Exodus}{Exo#2}%
    #1{Deuteronomy}{Deu#2}%
    #1{Joshua}{Jos#2}%
    #1{Judges}{Jdg#2}%
    #1{Ruth}{Rth#2}%
    #1{Ezra}{Ezr#2}%
    #1{Esther}{Est#2}%
    #1{Psalms}{Psm#2}%
    #1{Proverbs}{Pro#2}%
    #1{Ecclesiastes}{Ecl#2}%
    #1{SongofSongs}{S#2#3S#2}%
    #1{Ezekiel}{Ezk#2}%
    #1{Joel}{Jol#2}%
    #1{Amos}{Amo#2}%
    #1{Obadiah}{Oba#2}%
    #1{Jonah}{Jna#2}%
    #1{Zephaniah}{Zph#2}%
    #1{Zechariah}{Zch#2}%
    #1{Matthew}{Mat#2}%
    #1{Mark}{Mrk#2}%
    #1{Luke}{Luk#2}%
    #1{John}{Jhn#2}%
    #1{Philippians}{Phl#2}%
    #1{IThessalonians}{#5{1}Ths#2}%
    #1{IIThessalonians}{#5{2}Ths#2}%
    #1{Philemon}{Phm#2}%
    #1{IJohn}{#5{1}Jhn#2}%
    #1{IIJohn}{#5{2}Jhn#2}%
    #1{IIIJohn}{#5{3}Jhn#2}%
}
\brl@foreachbook@full{\providebiblebookalias}{}{-}{}%
    {\brm@number@upperromanascii}
\brl@foreachbook@full{\providebiblebookalias}{}{-}{}%
    {\brm@number@arabic}
\brl@foreachbook@abbrv{\providebiblebookalias}{}{}{}{&}%
    {\brm@number@upperromanascii}
\brl@foreachbook@abbrv{\providebiblebookalias}{}{}{}{&}%
    {\brm@number@arabic}
\brl@foreachbook@abbrv{\providebiblebookalias}{.}{.}{}{&}%
    {\brm@number@upperromanascii}
\brl@foreachbook@abbrv{\providebiblebookalias}{.}{.}{}{&}%
    {\brm@number@arabic}
\brl@foreachbook@abbrv{\providebiblebookalias}{}{}{}{and}%
    {\brm@number@upperromanascii}
\brl@foreachbook@thumb{\providebiblebookalias}{}{}{}{&}%
    {\brm@number@upperromanascii}
\brl@foreachbook@thumb{\providebiblebookalias}{}{}{}{&}%
    {\brm@number@arabic}
\brl@foreachbook@thumb{\providebiblebookalias}{.}{.}{}{&}%
    {\brm@number@upperromanascii}
\brl@foreachbook@thumb{\providebiblebookalias}{.}{.}{}{&}%
    {\brm@number@arabic}
\brl@foreachbook@thumb{\providebiblebookalias}{}{}{}{and}%
    {\brm@number@upperromanascii}
\brl@foreachbook@bible@abbrv{\providebiblebookalias}{}%
    {\brm@number@upperromanascii}
\brl@foreachbook@bible@abbrv{\providebiblebookalias}{}%
    {\brm@number@arabic}
\brl@foreachbook@bible@abbrv{\providebiblebookalias}{.}%
    {\brm@number@upperromanascii}
\brl@foreachbook@bible@abbrv{\providebiblebookalias}{.}%
    {\brm@number@arabic}
\brl@foreachbook@bible@thumb{\providebiblebookalias}{}{}%
    {\brm@number@upperromanascii}{\brm@number@upperromanascii}
\brl@foreachbook@bible@thumb{\providebiblebookalias}{}{}%
    {\brm@number@arabic}{\brm@number@arabic}
\brl@foreachbook@bible@thumb{\providebiblebookalias}{.}{}%
    {\brm@number@upperromanascii}{\brm@number@upperromanascii}
\brl@foreachbook@bible@thumb{\providebiblebookalias}{.}{}%
    {\brm@number@arabic}{\brm@number@arabic}
\brl@foreachbook@full{\providebiblebook{fullname}}{\ }{---}{}%
    {\brm@number@arabicspace}
\brl@foreachbook@abbrv{\providebiblebook{jerusalem}}{}{}{\ }{\&}%
    {\brm@number@arabicspace}
\brl@foreachbook@abbrv{\providebiblebook{anglosaxon}}{.}{}{\ }{\&}%
    {\brm@number@upperromanspace}
\brl@foreachbook@abbrv{\providebiblebook{JEH}}{.}{}{\ }{\&}%
    {\brm@number@arabicspace}
\brl@foreachbook@full{\providebiblebook{MHRA}}{\ }{---}{}%
    {\brm@number@scromanspace}
\brl@foreachbook@abbrv{\providebiblebook{NTG}}{}{}{\ }{\&}%
    {\brm@number@arabicspace}
\brl@foreachbook@abbrv{\providebiblebook{MLA}}{.}{}{\ }{\&}%
    {\brm@number@arabicspace}
\brl@foreachbook@abbrv{\providebiblebook{chicago}}{.}{}{\ }{\&}%
    {\brm@number@arabicspace}
\providebiblebook{fullname}{SongofSongs}{Song of Solomon}
\providebiblebook{text}{SongofSongs}{Song of Solomon}
\brl@foreachbook@abbrv{\providebiblebook{lds}}%
    {.}{}{\ }{\&}{\brm@number@arabicspace}
\brm@foreachbook@altabbrv{\providebiblebook{lds}}%
    {.}{\ }{\brm@number@arabicspace}{\brm@number@arabicspace}
\brl@foreachbook@bible@abbrv{\providebiblebook{lds}}%
    {.}{\brm@number@arabicspace}
\providebiblestyle{lds}{\standardbiblestyle{lds}%
    {\ }{:}{; }{; }{, }{--}%
    {\brm@number@arabic}{\brm@number@arabic}%
    {#1}{#2}{#3}}
\newcommand*{\brl@formatchapter}[1]{%
    \brm@ifsamestr{\thebook{#1}}{DoctrineandCovenants}{%
        section \brm@number@stomach@text{\thechapter{#1}}%
    }{%
        \brm@ifsamestr{\thebook{#1}}{OfficialDeclaration}{%
            \Numberstringnum{\thechapter{#1}}%
        }{%
            \brm@ifsamestr{\thebook{#1}}{ArticlesofFaith}{%
            }{%
                chapter \brm@number@stomach@text{\thechapter{#1}}%
            }%
        }%
    }%
}
\newcommand*{\brl@formatverse}[1]{%
    \brm@ifsamestr{\thebook{#1}}{ArticlesofFaith}{%
        article \brm@number@stomach@text{\theverse{#1}}%
    }{%
        verse \brm@number@stomach@text{\theverse{#1}}%
    }%
}
\newcommand*{\brl@bkchsep}[1]{%
    \brm@ifsamestr{\thebook{#1}}{OfficialDeclaration}{%
        ---%
    }{%
        \brm@ifsamestr{\thebook{#1}}{ArticlesofFaith}{%
        }{%
            ,\ %
        }%
    }%
}
\newcommand*{\brl@chvsep}[1]{%
    \brm@ifsamestr{\thebook{#1}}{ArticlesofFaith}{%
        ,\ %
    }{%
        \ %
    }%
}
\newcommand*{\brl@text@filter}[6]{%
    #6%
        {#1}%
        {#2}%
        {\brm@packseparators{\brl@bkchsep{#2}}{\brl@chvsep{#2}}}%
        {#4}%
        {#5}%
}
\brl@foreachbook@full{\providebiblebook{text}}{\ }{---}{Book of }%
    {\brm@number@stomach@ordspace}
\providebiblestyle{text}{%
    \brm@standard@filtered%
        {}%
        {\brm@packpassage{,\ and\ }{,\ and\ }{,\ and\ }}%
        {\brm@packpassage{\ to\ }{\ to\ }{\ to\ }}%
        {\brm@packpassage%
            {\thebookname{text}}%
            {\brl@formatchapter}%
            {\brl@formatverse}}%
        {\brl@text@filter}%
        {#1}{#2}{#3}%
}
\providebiblebook{lds.org}{Genesis}{gen}
\providebiblebook{lds.org}{Exodus}{ex}
\providebiblebook{lds.org}{Leviticus}{lev}
\providebiblebook{lds.org}{Numbers}{num}
\providebiblebook{lds.org}{Deuteronomy}{deut}
\providebiblebook{lds.org}{Joshua}{josh}
\providebiblebook{lds.org}{Judges}{judg}
\providebiblebook{lds.org}{Ruth}{ruth}
\providebiblebook{lds.org}{ISamuel}{1\_sam}
\providebiblebook{lds.org}{IISamuel}{2\_sam}
\providebiblebook{lds.org}{IKings}{1\_kgs}
\providebiblebook{lds.org}{IIKings}{2\_kgs}
\providebiblebook{lds.org}{IChronicles}{1\_chr}
\providebiblebook{lds.org}{IIChronicles}{2\_chr}
\providebiblebook{lds.org}{Ezra}{ezra}
\providebiblebook{lds.org}{Nehemiah}{neh}
\providebiblebook{lds.org}{Esther}{esth}
\providebiblebook{lds.org}{Job}{job}
\providebiblebook{lds.org}{Psalms}{ps}
\providebiblebook{lds.org}{Proverbs}{prov}
\providebiblebook{lds.org}{Ecclesiastes}{eccl}
\providebiblebook{lds.org}{SongofSongs}{song}
\providebiblebook{lds.org}{Isaiah}{isa}
\providebiblebook{lds.org}{Jeremiah}{jer}
\providebiblebook{lds.org}{Lamentations}{lam}
\providebiblebook{lds.org}{Ezekiel}{ezek}
\providebiblebook{lds.org}{Daniel}{dan}
\providebiblebook{lds.org}{Hosea}{hosea}
\providebiblebook{lds.org}{Joel}{joel}
\providebiblebook{lds.org}{Amos}{amos}
\providebiblebook{lds.org}{Obadiah}{obad}
\providebiblebook{lds.org}{Jonah}{jonah}
\providebiblebook{lds.org}{Micah}{micah}
\providebiblebook{lds.org}{Nahum}{nahum}
\providebiblebook{lds.org}{Habakkuk}{hab}
\providebiblebook{lds.org}{Zephaniah}{zeph}
\providebiblebook{lds.org}{Haggai}{hag}
\providebiblebook{lds.org}{Zechariah}{zech}
\providebiblebook{lds.org}{Malachi}{mal}
\providebiblebook{lds.org}{Matthew}{matt}
\providebiblebook{lds.org}{Mark}{mark}
\providebiblebook{lds.org}{Luke}{luke}
\providebiblebook{lds.org}{John}{john}
\providebiblebook{lds.org}{Acts}{acts}
\providebiblebook{lds.org}{Romans}{rom}
\providebiblebook{lds.org}{ICorinthians}{1\_cor}
\providebiblebook{lds.org}{IICorinthians}{2\_cor}
\providebiblebook{lds.org}{Galatians}{gal}
\providebiblebook{lds.org}{Ephesians}{eph}
\providebiblebook{lds.org}{Philippians}{philip}
\providebiblebook{lds.org}{Colossians}{col}
\providebiblebook{lds.org}{IThessalonians}{1\_thes}
\providebiblebook{lds.org}{IIThessalonians}{2\_thes}
\providebiblebook{lds.org}{ITimothy}{1\_tim}
\providebiblebook{lds.org}{IITimothy}{2\_tim}
\providebiblebook{lds.org}{Titus}{titus}
\providebiblebook{lds.org}{Philemon}{philem}
\providebiblebook{lds.org}{Hebrews}{heb}
\providebiblebook{lds.org}{James}{james}
\providebiblebook{lds.org}{IPeter}{1\_pet}
\providebiblebook{lds.org}{IIPeter}{2\_pet}
\providebiblebook{lds.org}{IJohn}{1\_jn}
\providebiblebook{lds.org}{IIJohn}{2\_jn}
\providebiblebook{lds.org}{IIIJohn}{3\_jn}
\providebiblebook{lds.org}{Jude}{jude}
\providebiblebook{lds.org}{Revelation}{rev}
\providebiblebook{lds.org}{INephi}{1\_ne}
\providebiblebook{lds.org}{IINephi}{2\_ne}
\providebiblebook{lds.org}{Jacob}{jacob}
\providebiblebook{lds.org}{Enos}{enos}
\providebiblebook{lds.org}{Jarom}{jarom}
\providebiblebook{lds.org}{Omni}{omni}
\providebiblebook{lds.org}{WordsofMormon}{w\_of\_m}
\providebiblebook{lds.org}{Mosiah}{mosiah}
\providebiblebook{lds.org}{Alma}{alma}
\providebiblebook{lds.org}{Helaman}{hel}
\providebiblebook{lds.org}{IIINephi}{3\_ne}
\providebiblebook{lds.org}{IVNephi}{4\_ne}
\providebiblebook{lds.org}{Mormon}{morm}
\providebiblebook{lds.org}{Ether}{ether}
\providebiblebook{lds.org}{Moroni}{moro}
\providebiblebook{lds.org}{DoctrineandCovenants}{dc}
\providebiblebook{lds.org}{OfficialDeclaration}{od}
\providebiblebook{lds.org}{Moses}{moses}
\providebiblebook{lds.org}{Abraham}{abr}
\providebiblebook{lds.org}{JosephSmith-Matthew}{js\_m}
\providebiblebook{lds.org}{JosephSmith-History}{js\_h}
\providebiblebook{lds.org}{ArticlesofFaith}{a\_of\_f}
\providebiblestyle{lds.org-url}{%
    http://scriptures.lds.org/%
    \thebookname{lds.org}{#1}/%
    \ifhaschapter{#1}{%
        \thechapter{#1}/%
        \ifhasverse{#1}{%
            \theverse{#1}%
        }{%
        }%
    }{%
    }%
    \brl@ldsdotorgurl@passage{#1}{#2}{-}%
    #3{
        \brl@ldsdotorgurl@list{\ifhasbook{#2}{#2}{#1}}%
    }{%
    }%
    \ifhasverse{#1}{%
        \#\theverse{#1}%
    }{%
    }%
}
\newcommand*{\brl@ldsdotorgurl@passage}[3]{%
    \ifhasbook{#2}{%
        \ifsamebook{#1}{#2}{%
            \ifsamechapter{#1}{#2}{%
                \ifsameverse{#1}{#2}{%
                }{%
                    #3\theverse{#2}%
                }%
            }{%
                \brm@error{Links cannot span chapters}%
            }%
        }{%
            \brm@error{Links cannot span books}%
        }%
    }{%
    }%
}
\newcommand*{\brl@ldsdotorgurl@list}[4]{%
    \brl@ldsdotorgurl@passage{#1}{#2}{,}%
    \brl@ldsdotorgurl@passage{#2}{#3}{-}%
    #4{
        \brl@ldsdotorgurl@list{\ifhasbook{#3}{#3}{#2}}%
    }{%
    }%
}
\newcommand*{\provideldsdotorgstyle}[8]{%
    \brl@ldsdotorg@consumeargs{#1}{#2}%
        {\brm@packseparators{#3}{#4}}%
        {\brm@packpassage{#5}{#6}{#7}}%
        {\brm@packpassage{#8}{#8}{#8}}%
}
\newcommand*{\brl@ldsdotorg@consumeargs}[7]{%
    \brl@ldsdotorg@providestyle{#1}{#3}{#4}{#5}%
        {\brm@packpassage{\thebookname{#2}}%
        {\brm@formatchapter{#6}}%
        {\brm@formatverse{#7}}}%
}
\newcommand*{\brl@ldsdotorg@providestyle}[5]{%
    \providebiblestyle{#1}{%
        \brl@ldsdotorg@style{#2}{#3}{#4}{#5}{##1}{##2}{##3}%
    }%
}
\newcommand*{\brl@ldsdotorg@style}[7]{%
    \brl@ldsdotorg@range%
        {\brm@packpassage{}{}{}}%
        {#5}{#6}{#1}%
        {\brm@packpassage{}{}{}}%
        {#3}{#4}%
    #7{%
        \brl@ldsdotorg@list{#1}{#2}{#3}{#4}{\ifhasbook{#6}{#6}{#5}}%
    }{%
    }%
}
\newcommand*{\brl@ldsdotorg@list}[8]{%
    \brl@ldsdotorg@range{#5}{#6}{#7}{#1}{#2}{#3}{#4}%
    #8{%
        \brl@ldsdotorg@list{#1}{#2}{#3}{#4}{\ifhasbook{#7}{#7}{#6}}%
    }{%
    }%
}
\newcommand*{\brl@number@empty}[1]{}
\newcommand*{\brl@ldsdotorg@range}[7]{%
    \brl@ldsdotorg@href{#2}{#3}{%
        \brm@standard@passage{#1}{#2}%
            {\brm@packpassage{}{}{}}%
            {#5}%
            {\brm@packpassage%
                {\brl@number@empty}%
                {\brl@number@empty}%
                {\brl@number@empty}}%
    }{%
        \brm@standard@passage{#1}{#2}{#4}%
            {\brm@packpassage{}{}{}}%
            {#7}%
    }{%
        \brm@standard@passage{#2}{#3}%
            {\brm@packpassage{}{}{}}%
            {#6}%
            {\brm@packpassage%
                {\brl@number@empty}%
                {\brl@number@empty}%
                {\brl@number@empty}}%
    }{%
        \brm@standard@passage{#2}{#3}{#4}{\brm@packpassage{}{}{}}{#7}%
    }%
}
\newcommand*{\brl@ldsdotorg@href}[6]{%
    \ifsamebook{#1}{#2}{%
        \ifsamechapter{#1}{#2}{%
            \brl@ldsdotorg@samechapter{#1}{#2}{#3}{#4}{#5}{#6}%
        }{%
            \brl@ldsdotorg@spanchapter{#1}{#2}{#3}{#4}{#5}{#6}%
        }%
    }{%
        \brl@ldsdotorg@spanchapter{#1}{#2}{#3}{#4}{#5}{#6}%
    }%
}
\newcommand*{\brl@ldsdotorg@samechapter}[6]{%
    #3%
    \href{%
        \brm@delegatestyle{lds.org-url}{#1}{#2}{\brm@nillist}%
    }{%
        #4#5#6%
    }%
}
\newcommand*{\brl@ldsdotorg@spanchapter}[6]{%
    #3%
    \href{%
        \brm@delegatestyle{lds.org-url}{#1}%
            {\brm@packpassage{}{}{}}%
            {\brm@nillist}%
    }{%
        #4%
    }%
    #5%
    \ifhasbook{#2}{%
        \href{%
            \brm@delegatestyle{lds.org-url}{#2}%
            {\brm@packpassage{}{}{}}%
            {\brm@nillist}%
        }{%
            #6%
        }%
    }{%
    }%
}
\provideldsdotorgstyle{lds.org}{lds}%
    {\ }{:}{; }{; }{, }{--}%
    {\brm@number@arabic}{\brm@number@arabic}
\provideldsdotorgstyle{lds.org-fullname}{fullname}%
    {\ }{:}{; }{;}{,}{--}%
    {\brm@number@arabic}{\brm@number@arabic}
\setbiblestyle{lds.org}
\endinput
%%
%% End of file `bibleref-lds.sty'.
