% \iffalse meta-comment
%
% Copyright (c) 2022-2023 David Purton <dcpurton@marshwiggle.net>
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, either version 1.3c 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.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
%<*driver>
\DocumentMetadata{}
\documentclass[a4paper]{l3doc}
\usepackage[parindent=1em]{scripture}
\usepackage[skins]{tcolorbox}
\newtcolorbox{scriptureexample}[1][]{%
  bicolor, colframe=cyan, colback=cyan!10, colbacklower=white, left=2mm,
  fonttitle=\normalsize\sffamily\bfseries,
  subtitle style={before skip=3mm, after skip=3mm},
  right=2mm, fontupper=\footnotesize, fontlower=\footnotesize, sidebyside,
  sidebyside gap=6mm, sidebyside align=top, lefthand ratio=0.6, before
  skip=\bigskipamount, after skip=\bigskipamount, #1
}
\tcbset{%
  sidebysidecompare/.style={%
    enhanced, colback=white, lefthand ratio=0.5, segmentation empty},
  compare/.style={%
    standard, colback=white, sidebyside=false}
}
\ExplSyntaxOn
\makeatletter
\cs_new_protected:Npn \__dcp_codedoc_environment_index:n #1
  {
    \@bsphack
    \begingroup
      \__codedoc_target:
      \index
        {
          #1\actualchar{\protect\ttfamily#1}~(environment)
          \encapchar hdclindex{\the\c@HD@hypercount}{usage}
        }
      \index
        {
          environments:\levelchar#1\actualchar{\protect\ttfamily#1}
          \encapchar hdclindex{\the\c@HD@hypercount}{usage}
        }
    \endgroup
    \@esphack
  }
\cs_new_protected:Npn \__dcp_codedoc_envmacro_index:nN #1#2
  {
    \DoNotIndex {#1}
    \bool_if:NT #2
      {
        \__codedoc_if_macro_internal:nF {#1}
          { \seq_gput_right:Nn \g_doc_macros_seq {#1} }
        \hbox_set:Nw \l__codedoc_macro_index_box
          \hbox_unpack_drop:N \l__codedoc_macro_index_box
          \int_gincr:N \c@CodelineNo
          \@bsphack
          \begingroup
            \__codedoc_target:
            \index
              {
                #1\actualchar{\protect\ttfamily#1}~(environment)
                \encapchar hdclindex{\the\c@HD@hypercount}{main}
              }
            \index
              {
                environments:\levelchar#1\actualchar{\protect\ttfamily#1}
                \encapchar hdclindex{\the\c@HD@hypercount}{main}
              }
          \endgroup
          \@esphack
          \int_gdecr:N \c@CodelineNo
        \exp_args:NNNo \hbox_set_end:
          \tl_set:Nn \saved@indexname { \l__codedoc_index_key_tl }
      }
  }
\cs_new_protected:Npn \__dcp_codedoc_hook_index:n #1
  {
    \@bsphack
    \begingroup
      \__codedoc_target:
      \index
        {
          #1\actualchar{\protect\ttfamily#1}~(hook)
          \encapchar hdclindex{\the\c@HD@hypercount}{usage}
        }
      \index
        {
          hooks:\levelchar#1\actualchar{\protect\ttfamily#1}
          \encapchar hdclindex{\the\c@HD@hypercount}{usage}
        }
    \endgroup
    \@esphack
  }
\cs_new_protected:Npn \__dcp_codedoc_hookmacro_index:nN #1#2
  {
    \DoNotIndex {#1}
    \bool_if:NT #2
      {
        \__codedoc_if_macro_internal:nF {#1}
          { \seq_gput_right:Nn \g_doc_macros_seq {#1} }
        \hbox_set:Nw \l__codedoc_macro_index_box
          \hbox_unpack_drop:N \l__codedoc_macro_index_box
          \int_gincr:N \c@CodelineNo
          \@bsphack
          \begingroup
            \__codedoc_target:
            \index
              {
                #1\actualchar{\protect\ttfamily#1}~(hook)
                \encapchar hdclindex{\the\c@HD@hypercount}{main}
              }
            \index
              {
                hooks:\levelchar#1\actualchar{\protect\ttfamily#1}
                \encapchar hdclindex{\the\c@HD@hypercount}{main}
              }
          \endgroup
          \@esphack
          \int_gdecr:N \c@CodelineNo
        \exp_args:NNNo \hbox_set_end:
          \tl_set:Nn \saved@indexname { \l__codedoc_index_key_tl }
      }
  }
\DeclareDocumentEnvironment { environment } { O{} +v }
  {
    \cs_set_eq:NN \__codedoc_function_index:n \__dcp_codedoc_environment_index:n
    \__codedoc_function:nnw {#1} {#2}
  }
  { \__codedoc_function_end: }
\DeclareDocumentEnvironment { hooks } { O{} +v }
  {
    \bool_if:NTF \l__codedoc_in_implementation_bool
      {
        \cs_set_eq:NN \__codedoc_macro_index:nN \__dcp_codedoc_hookmacro_index:nN
        \__codedoc_macro:nnw { var , #1 } {#2}
      }
      {
        \cs_set_eq:NN \__codedoc_function_index:n \__dcp_codedoc_hook_index:n
        \__codedoc_function:nnw {#1} {#2}
      }
  }
  {
    \bool_if:NTF \l__codedoc_in_implementation_bool
      { \__codedoc_macro_end: }
      { \__codedoc_function_end: }
  }
\DeclareDocumentEnvironment { option } { O{} +v }
  {
    \cs_set_eq:NN \__codedoc_function_index:n \SpecialOptionIndex
    \__codedoc_function:nnw {#1} {#2}
  }
  { \__codedoc_function_end: }
\DeclareDocumentEnvironment { envmacro } { O{} +v }
  {
    \cs_set_eq:NN \__codedoc_macro_index:nN \__dcp_codedoc_envmacro_index:nN
    \__codedoc_macro:nnw {#1} {#2}
  }
  { \__codedoc_macro_end: }
\DeclareDocumentCommand \opt { m }
  {
    \SpecialOptionIndex {#1}
    \texttt{#1}
  }
\DeclareDocumentCommand \hook { m }
  {
    \__dcp_codedoc_hook_index:n {#1}
    \texttt {#1}
  }
\DeclareRobustCommand \val {\texttt}
\makeatother
\ExplSyntaxOff
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \changes{v1.0}{2022/07/27}{First public release}
% \changes{v1.1}{2022/08/27}{Bug fixes}
% \changes{v1.2}{2022/11/02}{Bug fixes}
% \changes{v1.3}{2023/01/08}{Bug fixes}
% \changes{v2.0}{2023/12/26}{Switch \env{scripture} to a \LaTeX{} \env{list}
%   based environment}
% \changes{v2.0}{2023/12/27}{Bug fixes}
%
% \title{The \pkg{scripture} package}
% \author{David Purton\thanks{Email: \url{dcpurton@marshwiggle.net}}}
% \date{2023/12/27 v2.0}
%
% \maketitle
%
% \begin{abstract}
%   The \pkg{scripture} package provides a set of macros for typesetting
%   quotations from the Bible. It provides many features commonly seen in
%   Bibles such as dropped text for chapter numbers, superscripts for verse
%   numbers, indented lines for poetry sections, narrow sections and hanging
%   paragraphs. A reference for the quotation can optionally be added.
% \end{abstract}
%
% \tableofcontents
%
% \begin{documentation}
%
% \section{Introduction}
%
% Bibles tend to use a number of standard features when laying out chapters
% and verses. The main goal for the \pkg{scripture} package is to be able to
% quickly and easily input text and have it output nicely with minimal manual
% adjustment.
%
% The package supports dropped text for chapter numbers, superscripts for
% verse numbers, appropriately indented lines for the first and second halves
% of poetry, flush right sections, centred sections, narrow sections and
% hanging sections.
%
% The package could be used for typesetting an entire Bible, but it is mainly
% envisioned that it will be used for producing Scripture quotations. The
% passage reference can be included on the last line if there is space or
% failing that on the following line.
%
% \subsection{Bug reports and feature requests}
%
% Bug reports and feature requests can be made at the \pkg{scripture} package
% GitHub repository. See \url{https://github.com/dcpurton/scripture}.
%
% \subsection{Limitations}
%
% The \pkg{scripture} package makes extensive use of \LaTeX{} \env{list}
% environments and the \cs{parshape} command. This means there are some
% limitations. In particular, you should not:
% \begin{itemize}
%   \item Nest the \env{scripture} environment or any of its internal
%     environments.
%   \item Modify the \cs{parshape} within a \env{scripture} environment.
%   \item Include any other \env{list} based environment within a
%     \env{scripture} environment.
% \end{itemize}
%
% The \env{poetry} environment uses \cs{obeylines}. This means that it can not
% be placed in the argument of a macro.
%
% Some attempt is made to encourage appropriate page breaks, especially just
% before a reference is added to a quotation, but this can still sometimes
% fail and a reference will end up on the following page. Usually a little
% more stretchable space on the page before the incorrect break is enough to
% obtain acceptable output.
%
% At least version 2022-11-01 of the \LaTeX\ format is required.
%  
% \section{Documentation}
%
% \subsection{Basic usage}
%
% Scripture quotations must be set within a \env{scripture} environment. A
% simple quotation might be produced as follows:
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Isaiah 56:1--2][version=NIVUK]
%   \ch{56}This is what the \name{Lord} says:
%   \begin{poetry}
%     `Maintain justice
%     and do what is right,
% 
%     for my salvation is close at hand
%     and my righteousness will soon be revealed.
% 
%     \vs{2}Blessed is the one who does this---
%     the person who holds it fast,
% 
%     who keeps the Sabbath without desecrating it,
%     and keeps their hands from doing any evil.'
%   \end{poetry}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
% 
% \begin{scripture}[Isaiah 56:1--2][version=NIVUK]
%   \ch{56}This is what the \name{Lord} says:
%   \begin{poetry}
%     `Maintain justice
%     and do what is right,
% 
%     for my salvation is close at hand
%     and my righteousness will soon be revealed.
% 
%     \vs{2}Blessed is the one who does this---
%     the person who holds it fast,
% 
%     who keeps the Sabbath without desecrating it,
%     and keeps their hands from doing any evil.'
%   \end{poetry}
% \end{scripture}
% \end{scriptureexample}
%
% \subsection{Macros for typesetting scripture quotations}
%
% \subsubsection{Functions}
%
% \changes{v1.3}{2022/11/15}{Add feature to highlight translator added words}
% \begin{function}[added=2022-11-15]{\added}
%   \begin{syntax}
%     |\added|\marg{words}
%   \end{syntax}
%   Some Bible translations mark out words added for clarity not found in the
%   original language (e.g., in italics). This can be done using the \cs{added}
%   function. The font and format can be set using the \opt{added/font} and
%   \opt{added/format} options.
% \end{function}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[John 1:18][verse/font=\bfseries,
%     verse/format=#1, verse/sep=0.5em, version=KJV]
%   \vs{18}No man hath seen God at any time, the
%   only begotten Son, which is in the bosom of the
%   Father, he hath declared \added{him}.
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[John 1:18][verse/font=\bfseries,
%     verse/format=#1, verse/sep=0.5em, version=KJV]
%   \vs{18}No man hath seen God at any time, the
%   only begotten Son, which is in the bosom of the
%   Father, he hath declared \added{him}.
% \end{scripture}
% \end{scriptureexample}
%
% \begin{function}{\ch, \ch*}
%   \begin{syntax}
%     |\ch|\marg{chapter number}
%     |\ch*|\marg{chapter number}
%   \end{syntax}
%   Format a chapter number. By default these are formatted using drop text
%   taking up two lines and the text is separated from the chapter number by a
%   horizontal space of 0.5\,em.
%
%   If the \opt{dropchap} option is \val{true} (default), then this function
%   attempts to add sufficient space for the dropped chapter when its
%   paragraph contains only one line. The starred version suppresses this
%   behaviour.
% \end{function}
%
% \begin{scriptureexample}[lefthand ratio=0.55]
% \textbf{\sffamily|\cs{ch}| example}
%
% \begin{verbatim}
% \begin{scripture}[Exodus 20:1--2]
%   \ch{20}And God spoke all these words:
%   \begin{hanging}
%     \noindent\vs{2}`I am the \name{Lord}
%     your God, who brought you out of Egypt,
%     out of the land of slavery.
%   \end{hanging}
% \end{scripture}
% \end{verbatim}
%
% \medskip
%
% \textbf{\sffamily|\cs{ch*}| example}
%
% \begin{verbatim}
% \begin{scripture}[Exodus 20:1--2]
%   \ch*{20}And God spoke all these words:
%   \begin{hanging}
%     \nohang\vs{2}`I am the \name{Lord} your
%     God, who brought you out of Egypt, out of
%     the land of slavery.
%   \end{hanging}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \textbf{\sffamily|\cs{ch}| example}
%
% \medskip
%
% \begin{scripture}[Exodus 20:1--2]
%   \ch{20}And God spoke all these words:
%   \begin{hanging}
%     \noindent\vs{2}`I am the \name{Lord}
%     your God, who brought you out of Egypt,
%     out of the land of slavery.
%   \end{hanging}
% \end{scripture}
%
% \bigskip
%
% \textbf{\sffamily|\cs{ch*}| example}
%
% \medskip
%
% \begin{scripture}[Exodus 20:1--2]
%   \ch*{20}And God spoke all these words:
%   \begin{hanging}
%     \nohang\vs{2}`I am the \name{Lord} your
%     God, who brought you out of Egypt, out of
%     the land of slavery.
%   \end{hanging}
% \end{scripture}
% \end{scriptureexample}
%
% \begin{function}{\extraskip}
%   \begin{syntax}
%     |\extraskip|
%   \end{syntax}
%   Add a small vertical space of \opt{extraskip} between a paragraph. This
%   function attempts to add additional space to avoid a clash with a drop
%   chapter if required.
% \end{function}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Colossians 1:2]
%   \vs{2}To God's holy people in Colossae, the
%   faithful brothers and sisters in Christ:
%
%   \extraskip
%
%   Grace and peace to you from God our Father.
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Colossians 1:2]
%   \vs{2}To God's holy people in Colossae, the
%   faithful brothers and sisters in Christ:
%
%   \extraskip
%
%   Grace and peace to you from God our Father.
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v1.2}{2022/09/01}{Add divine name feature}
% \begin{function}[added=2022-09-01]{\name, \LORD, \GOD}
%   \begin{syntax}
%     |\name|\marg{divine name}
%     |\LORD|
%     |\GOD|
%   \end{syntax}
%   Modern Bible translations frequently represent God's personal divine name
%   using a small capitals typeface. This can be done using the \cs{name}
%   function. The font and format can be set using the \opt{name/font} and
%   \opt{name/format} options. The \cs{LORD} and \cs{GOD} macros equivalent to
%   \cs{name}|{Lord}| and \cs{name}|{God}| respectively.
%
%   \textbf{Note:} Watch out that trailing spaces are not eaten by \cs{LORD}
%   and \cs{GOD}. Using \cs{name} is safer and semantically better.
% \end{function}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Genesis 15:1--2][version=ESV]
%   \ch{15}After these things the word of the
%   \name{Lord} came to Abram in a vision: ``Fear
%   not, Abram, I am your shield; your reward shall
%   be very great.'' \vs{2}But Abram said, ``O Lord
%   \name{God}, what will you give me, for I
%   continue childless, and the heir of my house is
%   Eliezer of Damascus?''
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Genesis 15:1--2][version=ESV]
%   \ch{15}After these things the word of the
%   \name{Lord} came to Abram in a vision: ``Fear
%   not, Abram, I am your shield; your reward shall
%   be very great.'' \vs{2}But Abram said, ``O Lord
%   \name{God}, what will you give me, for I
%   continue childless, and the heir of my house is
%   Eliezer of Damascus?''
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v1.3}{2022/11/13}{Add \cs{nofirstverse} function}
% \begin{function}[added=2022-11-13]{\nofirstverse}
%   \begin{syntax}
%     |\nofirstverse|
%   \end{syntax}
%   When \opt{verse/first} is |true|, this causes the next \cs{vs} to print
%   normally, rather than using the format specified by
%   \opt{verse/firstformat}. You might do this if your quote begins half way
%   through a paragraph and the first verse should be printed normally.
% \end{function}
%
% \begin{function}{\nohang}
%   \begin{syntax}
%     |\nohang|
%   \end{syntax}
%   In a \env{hanging} environment, this function indents the first line of
%   the paragraph a length of \opt{hanging/hang} $+$ \opt{parindent}.
%   Remaining lines continue to be indented by a length of \opt{hanging/hang}.
% \end{function}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Genesis 1:10--11]
%   \begin{hanging}
%     \noindent\vs{10}God called the dry ground
%     `land', and the gathered waters he called
%     `seas'. And God saw that it was good.
%
%     \nohang\vs{11}Then God said, `Let the land
%     produce vegetation: seed-bearing plants and
%     trees on the land that bear fruit with seed
%     in it, according to their various kinds.'
%     And it was so.
%   \end{hanging}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Genesis 1:10--11]
%   \begin{hanging}
%     \noindent\vs{10}God called the dry ground
%     `land', and the gathered waters he called
%     `seas'. And God saw that it was good.
%
%     \nohang\vs{11}Then God said, `Let the land
%     produce vegetation: seed-bearing plants and
%     trees on the land that bear fruit with seed
%     in it, according to their various kinds.'
%     And it was so.
%   \end{hanging}
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v1.2}{2022/08/31}{Add red letter feature}
% \begin{function}[added=2022-08-31]{\redletteron, \redletteroff}
%   \begin{syntax}
%     |\redletteron|
%     |\redletteroff|
%   \end{syntax}
%   Use \cs{redletteron} and \cs{redletteroff} to mark the beginning and end
%   of sections of text that should be attributed to Jesus speaking. Some
%   attempt is made to ensure that the correct colour continues after an inner
%   environment if \cs{redletteron} or \cs{redletteroff} occurs inside the
%   inner environment. If you experience problems with unexpected colour, try
%   to ensure that matching \cs{redletteron} and \cs{redletteroff} marks occur
%   at the same group level. The colour of the text can be set using the
%   \opt{redletter/colour} option. These commands only have an effect when the
%   \opt{redletter} option is \val{true}.
% \end{function}
%
% \begin{scriptureexample}[lefthand ratio=0.67]
% \begin{verbatim}
% \begin{scripture}[Matthew 21:16--17][redletter]
%   \vs{16}`Do you hear what these children are saying?'
%   they asked him.
%
%   \redletteron `Yes,' \redletteroff replied Jesus,
%   \redletteron `have you
%   never read,
%   \begin{poetry}
%     `\thinspace ``From the lips of children and infants
%     you, Lord, have called forth your praise''?'
%   \end{poetry}\redletteroff
%
%   \vs{17}And he left them and went out of the city to
%   Bethany, where he spent the night.
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Matthew 21:16--17][redletter]
%   \vs{16}`Do you hear what these children are saying?'
%   they asked him.
%
%   \redletteron `Yes,' \redletteroff replied Jesus,
%   \redletteron `have you
%   never read,
%   \begin{poetry}
%     `\thinspace ``From the lips of children and infants
%     you, Lord, have called forth your praise''?'
%   \end{poetry}\redletteroff
%
%   \vs{17}And he left them and went out of the city to
%   Bethany, where he spent the night.
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v1.1}{2022/08/07}{Add \cs{scripturecurrentchapter} and
% \cs{scripturecurrentverse} variables}
% \begin{function}[added=2022-08-07]{\scripturecurrentchapter,
% \scripturecurrentverse}
%   \begin{syntax}
%     |\scripturecurrentchapter|
%     |\scripturecurrentverse|
%   \end{syntax}
%   \cs{scripturecurrentcapter} and \cs{scripturecurrentverse} globally hold
%   the most recent values parsed to \cs{ch} and \cs{vs}. They can initialised
%   with \cs{renewcommand*} if required and could be used in hooks, for
%   example.
% \end{function}
%
% \begin{function}{\scripturesetup}
%   \begin{syntax}
%     |\scripturesetup|\marg{options}
%   \end{syntax}
%   Set default format for quotations. See section \ref{options} for
%   supported formatting \meta{|options|}.
% \end{function}
%
% \changes{v2.0}{2023/12/27}{Add \cs{scripturestyle} function}
% \begin{function}[added=2023/12/27]{\scripturestyle, \scripturestyle*}
%   \begin{syntax}
%     |\scripturestyle|\marg{name}\marg{options}
%     |\scripturestyle*|\marg{name}\marg{options}
%   \end{syntax}
%   Set \meta{|options|} which are saved as style with \meta{|name|}. These
%   can later be set with the \opt{style} option. The starred version appends
%   \meta{|options|} to an existing style rather than overwriting all options.
% \end{function}
%
% \changes{v1.1}{2022/07/29}{Add \cs{selah} function}
% \begin{function}[added=2022-07-29]{\selah}
%   \begin{syntax}
%     |\selah|
%   \end{syntax}
%   In a \env{poetry} environment, this function inserts \emph{Selah} at the
%   end of the current line or the end of the following line if there is
%   insufficient room. See options \opt{selah/font}, \opt{selah/format},
%   \opt{selah/sep} and \opt{selah/text} for options controlling the output.
% \end{function}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Psalm 3:2][version=NIV84]
%   \begin{poetry}
%     \vs{2}Many are saying of me,
%     ``God will not deliver him.''\selah
%   \end{poetry}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Psalm 3:2][version=NIV84]
%   \begin{poetry}
%     \vs{2}Many are saying of me,
%     ``God will not deliver him.''\selah
%   \end{poetry}
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v1.2}{2022/08/30}{Add \cs{textright} function}
% \begin{function}[added=2022-08-30]{\textright}
%   \begin{syntax}
%     |\textright|\marg{text}
%   \end{syntax}
%   This function inserts \meta{|text|} at the end of the current line or the
%   end of the following line if there is insufficient room. The
%   \opt{textright/sep} option controls the minimum allowed space before the
%   \meta{|text|} to be right aligned.
% \end{function}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Jeremiah 2:29]
%   \begin{poetry}
%     \vs{5}`Why do you bring charges against me?
%     You have all rebelled against me,'
%     \textright{declares the \name{Lord}.}
%   \end{poetry}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Jeremiah 2:29]
%   \begin{poetry}
%     \vs{5}`Why do you bring charges against me?
%     You have all rebelled against me,'
%     \textright{declares the \name{Lord}.}
%   \end{poetry}
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v1.3}{2023/01/07}{Add \cs{textscripture} function}
% \begin{function}[added=2023-01-07]{\textscripture}
%   \begin{syntax}
%     |\textscripture|\oarg{reference}\oarg{options}\marg{quotation}
%   \end{syntax}
%   \cs{textscripture} sets an inline scripture quotation. The quotation is
%   surrounded be the values of \opt{inline/begin} and \opt{inline/end} which
%   default to |``\,| and |\,''|, respectively. This function also sets the
%   \opt{compact} option and places the \val{reference} inline. The reference
%   format can be controlled using the following options:
%   \begin{itemize}
%     \item \opt{inline/reference/format}
%     \item \opt{inline/reference/sep}
%     \item \opt{inline/version/delim}
%     \item \opt{inline/version/format}
%   \end{itemize}
%   Other \val{reference} and \val{version} options are inherited.
%
%   This function is equivalent to using the \env{scripture} environment with
%   the \opt{inline} option.
%
%   \textbf{Warning:} \cs{par} is redefined to \cs{relax} inside the
%   \cs{textscripture} function. If you have anything other than expected
%   macros and environments inside your \cs{textscripture} function \TeX{}
%   will likely get stuck in an infinite loop.
% \end{function}
%
% \begin{scriptureexample}
% \begin{verbatim}
% A famous verse in the Bible is:
% \textscripture[John 3:16][verse/hide]{\vs{16}For
% God so loved the world that he gave his one and
% only Son, that whoever believes in him shall not
% perish but have eternal life.}.
% \end{verbatim}
%
% \tcblower
%
% A famous verse in the Bible is:
% \textscripture[John 3:16][verse/hide]{\vs{16}For
% God so loved the world that he gave his one and
% only Son, that whoever believes in him shall not
% perish but have eternal life.}.
% \end{scriptureexample}
%
% \begin{function}{\vs}
%   \begin{syntax}
%     |\vs|\marg{verse number}
%   \end{syntax}
%   Format a verse number. By default these are formatted using a superscript.
% \end{function}
%
% \subsubsection{Environments}
% 
% All scripture quotations must be set within a \env{scripture} environment.
% The rest of the environments documented below are only defined with the
% \env{scripture} environment. In most cases there is a default small
% \meta{\opt{aboveskip}} and \meta{\opt{belowskip}} inserted above and below
% these internal environments, but these are ignored if the environment is at
% the start or end of a \env{scripture} environment.
%
% \begin{environment}{center}
%   \begin{syntax}
%     |\begin{center}|\oarg{options}
%       \quad\meta{centred text}
%     |\end{center}|
%   \end{syntax}
% \end{environment}
%
% \noindent Environment for typesetting centred sections of scripture
% quotations.
%
% See section \ref{centeroptions} for supported formatting \meta{|options|}.
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Daniel 5:25]
%   \vs{25}`This is the inscription that was
%   written:
%   \begin{center}
%     \textsc{mene, mene, tekel, parsin}
%   \end{center}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
% 
% \begin{scripture}[Daniel 5:25]
%   \vs{25}`This is the inscription that was
%   written:
%   \begin{center}
%     \textsc{mene, mene, tekel, parsin}
%   \end{center}
% \end{scripture}
% \end{scriptureexample}
%
% \begin{environment}{flushright}
%   \begin{syntax}
%     |\begin{flushright}|\oarg{options}
%       \quad\meta{right aligned text}
%     |\end{flushright}|
%   \end{syntax}
% \end{environment}
%
% \noindent Environment for typesetting right aligned sections of scripture
% quotations.
%
% See section \ref{flushrightoptions} for supported formatting
% \meta{|options|}.
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Isaiah 40:5]
%   \begin{poetry}[belowskip = 0pt]
%     \vs{5}And the glory of the \name{Lord}\ldots
%     and all people will see it together.
%   \end{poetry}
%
%   \begin{flushright}[aboveskip = 0pt]
%     For the mouth of the \name{Lord} \\
%     has spoken.'
%   \end{flushright}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
% 
% \begin{scripture}[Isaiah 40:5]
%   \begin{poetry}[belowskip = 0pt]
%     \vs{5}And the glory of the \name{Lord}\ldots
%     and all people will see it together.
%   \end{poetry}
%
%   \begin{flushright}[aboveskip = 0pt]
%     For the mouth of the \name{Lord} \\
%     has spoken.'
%   \end{flushright}
% \end{scripture}
% \end{scriptureexample}
%
% \begin{environment}{hanging}
%   \begin{syntax}
%     |\begin{hanging}|\oarg{options}
%       \quad\meta{hanging text}
%     |\end{hanging}|
%   \end{syntax}
% \end{environment}
%
% \noindent Environment for typesetting hanging sections of scripture
% quotations.
%
% See section \ref{hangingoptions} for supported formatting \meta{|options|}.
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Genesis 1:3--5]
%   \begin{hanging}
%     \vs{3}And God said, `Let there be light,' and
%     there was light. \vs{4}God saw that the light
%     was good, and he separated the light from the
%     darkness. \vs{5}God called the light `day',
%     and the darkness he called `night'. And there
%     was evening, and there was morn\-ing---the
%     first day.
%   \end{hanging}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
% 
% \begin{scripture}[Genesis 1:3--5]
%   \begin{hanging}
%     \vs{3}And God said, `Let there be light,' and
%     there was light. \vs{4}God saw that the light
%     was good, and he separated the light from the
%     darkness. \vs{5}God called the light `day',
%     and the darkness he called `night'. And there
%     was evening, and there was morn\-ing---the
%     first day.
%   \end{hanging}
% \end{scripture}
% \end{scriptureexample}
%
% \begin{environment}{midparachap}
%   \begin{syntax}
%     |\begin{midparachap}|\oarg{options}
%       \quad\meta{text containing a chapter break}
%     |\end{midparachap}|
%   \end{syntax}
% \end{environment}
%
% \noindent Environment for typesetting paragraph with a chapter break within
% it.
%
% See section \ref{midparachapoptions} for supported formatting
% \meta{|options|}.
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[1 Corinthians 10:31--11:1]
%   \begin{midparachap}
%     \vs{31}So whether you eat or drink or
%     whatever you do, do it all for the glory of
%     God. \vs{32}Do not cause anyone to stumble,
%     whether Jews, Greeks or the church of
%     God---\vs{33}even as I try to please everyone
%     in every way. For I am not seeking my own
%     good but the good of many, so that they may
%     be saved. \ch{11}Follow my example, as I
%     follow the example of Christ.
%   \end{midparachap}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
% 
% \begin{scripture}[1 Corinthians 10:31--11:1]
%   \begin{midparachap}
%     \vs{31}So whether you eat or drink or
%     whatever you do, do it all for the glory of
%     God. \vs{32}Do not cause anyone to stumble,
%     whether Jews, Greeks or the church of
%     God---\vs{33}even as I try to please everyone
%     in every way. For I am not seeking my own
%     good but the good of many, so that they may
%     be saved. \ch{11}Follow my example, as I
%     follow the example of Christ.
%   \end{midparachap}
% \end{scripture}
% \end{scriptureexample}
%
% \begin{environment}{narrow}
%   \begin{syntax}
%     |\begin{narrow}|\oarg{options}
%       \quad\meta{quotation}
%     |\end{narrow}|
%   \end{syntax}
% \end{environment}
%
% \noindent Environment for typesetting narrow sections of scripture
% quotations. If there is no blank line before the start of a \env{narrow}
% environment the indent will be suppressed.
%
% See section \ref{narrowoptions} for supported formatting \meta{|options|}.
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[2 Kings 18:18--19]
%   \vs{18}They called for the king; and Eliakim
%   son of Hilkiah the palace administrator, Shebna
%   the secretary, and Joah son of Asaph the
%   recorder went out to them.
%
%   \vs{19}The field commander said to them, `Tell
%   Hezekiah:
%
%   \begin{narrow}
%     `\thinspace``This is what the great king, the
%     king of Assyria, says: on what are you basing
%     this confidence of yours?
%   \end{narrow}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
% 
% \begin{scripture}[2 Kings 18:18--19]
%   \vs{18}They called for the king; and Eliakim
%   son of Hilkiah the palace administrator, Shebna
%   the secretary, and Joah son of Asaph the
%   recorder went out to them.
%
%   \vs{19}The field commander said to them, `Tell
%   Hezekiah:
%
%   \begin{narrow}
%     `\thinspace``This is what the great king, the
%     king of Assyria, says: on what are you basing
%     this confidence of yours?
%   \end{narrow}
% \end{scripture}
% \end{scriptureexample}
%
% \begin{environment}{poetry}
%   \begin{syntax}
%     |\begin{poetry}|\oarg{options}
%       \quad\meta{first half of verse}
%       \quad\meta{second half of verse}
%       \quad
%       \quad\meta{first half of verse}
%       \quad\meta{second half of verse}
%     |\end{poetry}|
%   \end{syntax}
% \end{environment}
%
% \noindent Environment for typesetting poetry sections of scripture
% quotations.
%
% Poetry sections of the Bible often have a first half and a parallel second
% half which is indented a little. These should be set on separate consecutive
% lines. Leaving a blank line indicates that the next line should return to
% the first half indent.
%
% See section \ref{poetryoptions} for supported formatting \meta{|options|}.
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Isaiah 1:2]
%   \begin{poetry}
%     \vs{2}Hear me, you heavens! Listen, earth!
%     For the \name{Lord} has spoken:
%
%     `I reared children and brought them up,
%     but they have rebelled against me.
%   \end{poetry}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
% 
% \begin{scripture}[Isaiah 1:2]
%   \begin{poetry}
%     \vs{2}Hear me, you heavens! Listen, earth!
%     For the \name{Lord} has spoken:
%
%     `I reared children and brought them up,
%     but they have rebelled against me.
%   \end{poetry}
% \end{scripture}
% \end{scriptureexample}
%
% \begin{environment}{scripture}
%   \begin{syntax}
%     |\begin{scripture}|\oarg{reference}\oarg{options}
%       \quad\meta{quotation}
%     |\end{scripture}|
%   \end{syntax}
% \end{environment}
%
% \noindent Main environment for typesetting scripture quotations.
%
% The optional \meta{|reference|} is printed at the end of the quotation. See
% section \ref{options} for supported formatting \meta{|options|}.
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[John 3:16][version=NIV]
%   \vs{16}For God so loved the world that he gave
%   his one and only Son, that whoever believes in
%   him shall not perish but have eternal life.
% \end{scripture}
% \end{verbatim}
%
% \tcblower
% 
% \begin{scripture}[John 3:16][version=NIV]
%   \vs{16}For God so loved the world that he gave
%   his one and only Son, that whoever believes in
%   him shall not perish but have eternal life.
% \end{scripture}
% \end{scriptureexample}
%
% \subsection{Provided hooks}
%
% \changes{v1.1}{2022/08/07}{Add before and after hooks for verses and
% chapters}
% \begin{hooks}[added=2022-08-07]{scripture/chap/before, scripture/chap/after,
%   scripture/verse/before, scripture/verse/after}
% The following public hooks are available:
%
% \begin{description}
%   \item[\hook{scripture/chap/before}] This hook is executed immediately
%     before the \opt{chap/font} is set for the chapter.
%   \item[\hook{scripture/chap/after}] This hook is executed immediately after
%     the \opt{chap/sep} space is inserted.
%   \item[\hook{scripture/verse/before}] This hook is executed immediately
%     before the \opt{verse/font} is set for the verse.
%   \item[\hook{scripture/chap/after}] This hook is executed immediately after
%     the \opt{verse/sep} space is inserted.
% \end{description}
% \end{hooks}
%
% The following example illustrates how these hooks could be used to place the
% first and last verse on the page into the header.
%
% \begin{scriptureexample}
% \begin{verbatim}
% \documentclass{article}
% \usepackage{scripture}
% \AddToHook{scripture/chap/after}{%
%   \markboth
%     {Mark \scripturecurrentchapter
%        :\scripturecurrentverse}
%     {Mark \scripturecurrentchapter
%        :\scripturecurrentverse}}
% \AddToHook{scripture/verse/after}{%
%   \markboth
%     {Mark \scripturecurrentchapter
%        :\scripturecurrentverse}
%     {Mark \scripturecurrentchapter
%        :\scripturecurrentverse}}
% \renewcommand*{\scripturecurrentchapter}{1}
% \usepackage{fancyhdr}
% \pagestyle{fancy}
% \fancyhf{}
% \lhead{\textbf{\rightmark}}
% \rhead{\textbf{\leftmark} \textbar\ \thepage}
% \begin{document}
% \begin{scripture}[][noindent]
%   \vs{45}Instead he went out and began to talk
%   freely, spreading the news. As a result, Jesus
%   could no longer enter a town openly but stayed
%   outside in lonely places. Yet the people still
%   came to him from everywhere.
%
%   \extraskip
%
%   \ch{2}A few days later, when Jesus again
%   entered Capernaum, the people heard that he had
%   come home.
% \end{scripture}
% \end{document}
% \end{verbatim}
%
% \tcblower
%
% \textbf{Mark 1:45\hfill Mark 2:1} \textbar\ 1
%
% \rule[2mm]{\linewidth}{0.4pt}
%
% \begin{scripture}[][noindent]
%   \vs{45}Instead he went out and began to talk
%   freely, spreading the news. As a result, Jesus
%   could no longer enter a town openly but stayed
%   outside in lonely places. Yet the people still
%   came to him from everywhere.
%
%    \extraskip
%
%   \ch{2}A few days later, when Jesus again
%   entered Capernaum, the people heard that he had
%   come home.
% \end{scripture}
% \end{scriptureexample}
%
% \subsection{Options}
% \label{options}
%
% \changes{v1.3}{2023/01/08}{Remove \opt{reference/delim} option}
%
% Default formatting \meta{|options|} can be set using
% \cs{usepackage}|[|\meta{|options|}|]{scripture}| or
% \cs{scripturesetup}|{|\meta{|options|}|}|. Local formatting \meta{|options|}
% can be set by passing them to the various environments described above.
%
% \begin{option}{aboveskip}
%   \begin{syntax}
%     aboveskip = \meta{skip} \hfill Default: 0pt
%   \end{syntax}
%   \meta{|skip|} inserted above the \env{scripture} environment.
% \end{option}
%
% \changes{v1.3}{2022/11/15}{Add \opt{added/font} option}
% \begin{option}[added=2022-11-15]{added/font}
%   \begin{syntax}
%     added/font = \meta{font} \hfill Default: \emph{Empty}
%   \end{syntax}
%   \meta{|font|} used for the \cs{added} function.
% \end{option}
%
% \changes{v1.3}{2022/11/15}{Add \opt{added/format} option}
% \begin{option}[added=2022-11-15]{added/format}
%   \begin{syntax}
%     added/format = \meta{macro} \hfill Default: \cs{emph}\{\#1\}
%   \end{syntax}
%   \meta{|macro|} used to format the words that should be highlighted as
%   added by the translators using the \cs{added} function. |#1| contains the
%   text of the argument to \cs{added}.
% \end{option}
%
% \begin{option}{belowskip}
%   \begin{syntax}
%     belowskip = \meta{skip} \hfill Default: 0pt
%   \end{syntax}
%   \meta{|skip|} inserted below the \env{scripture} environment.
% \end{option}
%
% \changes{v1.2}{2022/09/07}{Add \opt{chapter/colour} option}
% \begin{option}[added=2022-09-07]{chapter/colour, chapter/color}
%   \begin{syntax}
%     chapter/colour = \meta{colour expression} \hfill Default: .
%   \end{syntax}
%   The \pkg{l3color} \meta{|colour expression|} to be used for chapter
%   numbers. By default the current colour is inherited. \opt{chapter/color}
%   is an alias for \opt{chapter/colour}.
% \end{option}
%
% \begin{option}{chapter/drop}
%   \begin{syntax}
%     chapter/drop = \meta{boolean} \hfill Default: true
%   \end{syntax}
%   Whether the chapter should be set as a drop letter taking up two
%   lines or as a normal letter taking up one line. The value of
%   \meta{|boolean|} is optional and assumed to be \val{true} if not present.
%   This option is the opposite of \opt{chapter/nodrop}.
% \end{option}
%
% \begin{option}{chapter/font}
%   \begin{syntax}
%     chapter/font = \meta{font} \hfill Default: \cs{bfseries}
%   \end{syntax}
%   \meta{|font|} used for the \cs{ch} function.
% \end{option}
%
% \changes{v1.1}{2022/07/28}{Add \opt{chapter/format} option}
% \begin{option}[added=2022-07-28]{chapter/format}
%   \begin{syntax}
%     chapter/format = \meta{macro} \hfill Default: \#1
%   \end{syntax}
%   \meta{|macro|} used to format the \val{chapter} for a \env{scripture}
%   quotation. |#1| contains the text of the \val{chapter}.
% \end{option}
%
% \changes{v1.1}{2022/08/15}{Add \opt{chapter/hide} option}
% \begin{option}[added=2022-08-15]{chapter/hide}
%   \begin{syntax}
%     chapter/hide = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Whether chapters should be shown or hidden. The value of \meta{|boolean|}
%   is optional and assumed to be \val{true} if not present. This option is
%   the opposite of \opt{chapter/show}. Note that the \hook{scripture/chap/before}
%   and \hook{scripture/chap/after} hooks are still executed when chapters are
%   hidden.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Romans 5:1--2][chapter/hide]
%   \ch{5}Therefore, since we have been justified
%   through faith, we have peace with God through
%   our Lord Jesus Christ, \vs{2}through whom we
%   have gained access by faith into this grace in
%   which we now stand. And we boast in the hope of
%   the glory of God.
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Romans 5:1--2][chapter/hide]
%   \ch{5}Therefore, since we have been justified
%   through faith, we have peace with God through
%   our Lord Jesus Christ, \vs{2}through whom we
%   have gained access by faith into this grace in
%   which we now stand. And we boast in the hope of
%   the glory of God.
% \end{scripture}
% \end{scriptureexample}
%
% \begin{option}{chapter/nodrop}
%   \begin{syntax}
%     chapter/nodrop = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Whether the chapter should be set as a drop letter taking up two lines or
%   as a normal letter taking up one line. The value of \meta{|boolean|} is
%   optional and assumed to be \val{true} if not present. This option is the
%   opposite of \opt{chapter/drop}.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[John 1:1--3][chapter/nodrop]
%   \ch{1}In the beginning was the Word, and the
%   Word was with God, and the Word was God.
%   \vs{2}He was with God in the beginning.
%   \vs{3}Through him all things were made; without
%   him nothing was made that has been made.
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[John 1:1--3][chapter/nodrop]
%   \ch{1}In the beginning was the Word, and the
%   Word was with God, and the Word was God.
%   \vs{2}He was with God in the beginning.
%   \vs{3}Through him all things were made; without
%   him nothing was made that has been made.
% \end{scripture}
% \end{scriptureexample}
%
% \begin{option}{chapter/sep}
%   \begin{syntax}
%     chapter/sep = \meta{dimen} \hfill Default: 0.5em
%   \end{syntax}
%   \meta{|dimen|} used to separate a \cs{ch} from the following text.
% \end{option}
%
% \changes{v1.1}{2022/08/15}{Add \opt{chapter/show} option}
% \begin{option}[added=2022-08-15]{chapter/show}
%   \begin{syntax}
%     chapter/show = \meta{boolean} \hfill Default: true
%   \end{syntax}
%   Whether chapters should be shown or hidden. The value of \meta{|boolean|}
%   is optional and assumed to be \val{true} if not present. This option is
%   the opposite of \opt{chapter/hide}.
% \end{option}
%
% \changes{v1.1}{2022/11/14}{Add \opt{chapter/showverse} option}
% \begin{option}[added=2022-11-14]{chapter/showverse}
%   \begin{syntax}
%     chapter/showverse = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Whether \cs{vs}|\{1\}| should be automatically inserted after \cs{ch}. The
%   value of \meta{|boolean|} is optional and assumed to be \val{true} if not
%   present. See also \opt{midparachap/showverse} and
%   \opt{midparachap/hideverse}. Note that \opt{chapter/showverse} take
%   precedence over \opt{midparachap/hideverse}.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[John 1:1][chapter/showverse]
%   \ch{1}In the beginning was the Word, and the
%   Word was with God, and the Word was God.
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[John 1:1][chapter/showverse]
%   \ch{1}In the beginning was the Word, and the
%   Word was with God, and the Word was God.
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v1.2}{2022/08/31}{Add \opt{colour} option}
% \begin{option}[added=2022-08-31]{colour, color}
%   \begin{syntax}
%     colour = \meta{colour expression} \hfill Default: .
%   \end{syntax}
%   The \pkg{l3color} \meta{|colour expression|} to be used for the
%   \env{scripture} environment. By default the current colour is inherited.
%   \opt{color} is an alias for \opt{colour}.
% \end{option}
%
% \changes{v1.1}{2022/08/15}{Add \opt{compact} option}
% \begin{option}[added=2022-08-15]{compact}
%   \begin{syntax}
%     compact = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   This option removes all paragraph breaks along with any \cs{extraskip} in
%   the quotation so the whole quotation is a single paragraph of running
%   prose. This option implies \opt{chapter/nodrop} and all options relating
%   to inner environments are ignored.
%
%   The value of \meta{|boolean|} is optional and assumed to be \val{true} if
%   not present.
%
%   \textbf{Warning:} This option redefines \cs{par} to \cs{relax} inside the
%   \env{scripture} environment. If you have anything other than expected
%   macros and environments inside your \env{scripture} environment \TeX{}
%   will likely get stuck in an infinite loop.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Jonah 1:17--2:2a][compact]
%   \begin{midparachap}
%     \vs{17}Now the \name{Lord} provided a huge
%     fish to swallow Jonah, and Jonah was in the
%     belly of the fish three days and three
%     nights. \ch{2}From inside the fish Jonah
%     prayed to the \name{Lord} his God. \vs{2}He
%     said:
%   \end{midparachap}
%   \begin{poetry}
%     `In my distress I called to the Lord,
%     and he answered me.
%   \end{poetry}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Jonah 1:17--2:2a][compact]
%   \begin{midparachap}
%     \vs{17}Now the \name{Lord} provided a huge
%     fish to swallow Jonah, and Jonah was in the
%     belly of the fish three days and three
%     nights. \ch{2}From inside the fish Jonah
%     prayed to the \name{Lord} his God. \vs{2}He
%     said:
%   \end{midparachap}
%   \begin{poetry}
%     `In my distress I called to the Lord,
%     and he answered me.
%   \end{poetry}
% \end{scripture}
% \end{scriptureexample}
%
% \begin{option}{extraskip}
%   \begin{syntax}
%     extraskip = \meta{skip} \hfill Default: \cs{medskipamount}
%   \end{syntax}
%   \meta{|skip|} used for the \cs{extraskip} function.
% \end{option}
%
% \begin{option}{font}
%   \begin{syntax}
%     font = \meta{font} \hfill Default: \emph{Empty}
%   \end{syntax}
%   \meta{|font|} used for the \env{scripture} environment.
% \end{option}
%
% \changes{v1.3}{2023/01/07}{Add \opt{inline} option}
% \begin{option}[added=2023-01-07]{inline}
%   \begin{syntax}
%     inline = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Set the scripture quotation inline. The quotation is surrounded be the
%   values of \opt{inline/begin} and \opt{inline/end} which default to |``\,|
%   and |\,''|, respectively. This option also sets the \opt{compact} option
%   set sets the \val{reference} inline. The reference format can be
%   controlled using the following options:
%   \begin{itemize}
%     \item \opt{inline/reference/format}
%     \item \opt{inline/reference/sep}
%     \item \opt{inline/version/delim}
%     \item \opt{inline/version/format}
%   \end{itemize}
%   Other \val{reference} and \val{version} options are inherited.
%
%   \textbf{Warning:} \cs{par} is redefined to \cs{relax} when the
%   \opt{inline} option is set. If you have anything other than expected
%   macros and environments inside your quotation \TeX{} will likely get stuck
%   in an infinite loop.
% \end{option}
%
% \changes{v1.3}{2023/01/07}{Add \opt{inline/begin} option}
% \begin{option}[added=2023-01-07]{inline/begin}
%   \begin{syntax}
%     inline/begin = \meta{text} \hfill Default: |``\,|
%   \end{syntax}
%   Text inserted at the beginning of \cs{textscripture} or a \env{scripture}
%   environment with the \opt{inline} option set.
% \end{option}
%
% \changes{v1.3}{2023/01/07}{Add \opt{inline/end} option}
% \begin{option}[added=2023-01-07]{inline/end}
%   \begin{syntax}
%     inline/end = \meta{text} \hfill Default: |\,''|
%   \end{syntax}
%   Text inserted between the end of \cs{textscripture} or a \env{scripture}
%   environment with the \opt{inline} option set and the \meta{|reference|}
%   (if specified).
% \end{option}
%
% \changes{v2.0}{2023/12/27}{Add \opt{inline/reference/format} option}
% \begin{option}[added=2023-12-27]{inline/reference/format}
%   \begin{syntax}
%     inline/reference/format = \meta{macro} \hfill Default: (\#1)
%   \end{syntax}
%   \meta{|macro|} used to format the \val{reference} for an inline
%   \env{scripture} quotation. |#1| contains the text of the \val{reference}
%   and \val{version} (if specified).
% \end{option}
%
% \changes{v2.0}{2023/12/27}{Add \opt{inline/reference/sep} option}
% \begin{option}[added=2023-12-27]{inline/reference/sep}
%   \begin{syntax}
%     inline/reference/sep = \meta{dimen} \hfill Default: 0.5em
%   \end{syntax}
%   The \meta{|dimen|} between the end of an inline \env{scripture} quotation
%   and its \val{reference}.
% \end{option}
%
% \changes{v2.0}{2023/12/27}{Add \opt{inline/version/delim} option}
% \begin{option}[added=2023-12-27]{inline/version/delim}
%   \begin{syntax}
%     inline/version/delim = \meta{delim} \hfill Default: \{\ \}
%   \end{syntax}
%   \meta{|delim|} to use between the \val{reference} and the \val{version} of
%   an inline \env{scripture} quotation.
% \end{option}
%
% \changes{v2.0}{2023/12/27}{Add \opt{inline/version/format} option}
% \begin{option}[added=2023-12-27]{inline/version/format}
%   \begin{syntax}
%     inline/version/format = \meta{macro} \hfill Default: \#1
%   \end{syntax}
%   \meta{|macro|} used to format the \val{version} for an inline
%   \env{scripture} quotation. |#1| contains the text of the \val{version}.
% \end{option}
%
% \begin{option}{indent}
%   \begin{syntax}
%     indent = \meta{boolean} \hfill Default: true
%   \end{syntax}
%   Whether to indent the first line of a \env{scripture} environment or not
%   by \opt{parindent}. The value of \meta{|boolean|} is optional and assumed
%   to be \val{true} if not present. This option is the opposite of
%   \opt{noindent}.
% \end{option}
%
% \changes{v1.2}{2022/11/02}{Add \opt{language} option}
% \begin{option}[added=2022-11-02]{language}
%   \begin{syntax}
%     language = \meta{language name} \hfill Default: \emph{Empty}
%   \end{syntax}
%   \pkg{babel} or \pkg{polyglossia} \meta{|language name|} to be used for the
%   \env{scripture} environment. This calls
%   \cs{selectlanguage}|{|\meta{|language name|}|}| at the start of the
%   environment. Make sure you have \pkg{babel} or \pkg{polyglossia} loaded
%   and correctly set up for your specified language. If unset the current
%   active language is used.
% \end{option}
%
% \changes{v1.2}{2022/11/02}{Add \opt{language/variant} option}
% \begin{option}[added=2022-11-02]{language/variant}
%   \begin{syntax}
%     language/variant = \meta{language variant name} \hfill Default: \emph{Empty}
%   \end{syntax}
%   \pkg{polyglossia} \meta{|language variant name|} to be used along with the
%   specified \opt{language} for the \env{scripture} environment. This inserts
%   \cs{selectlanguage}|[|\meta{|language variant name|}|]{|\meta{language
%   name}|}| at the start of the environment. Make sure you have
%   \pkg{polyglossia} loaded and correctly set up for your specified language.
% \end{option}
%
% \begin{option}{leftmargin}
%   \begin{syntax}
%     leftmargin = \meta{dimen} \hfill Default: 0pt
%   \end{syntax}
%   \meta{|dimen|} used for the left margin of the \env{scripture}
%   environment.
% \end{option}
%
% \changes{v1.2}{2022/09/01}{Add \opt{name/font} option}
% \begin{option}[added=2022-09-01]{name/font}
%   \begin{syntax}
%     name/font = \meta{font} \hfill Default: \cs{scshape}
%   \end{syntax}
%   \meta{|font|} used for the \cs{name} function.
% \end{option}
%
% \changes{v1.2}{2022/09/01}{Add \opt{name/format} option}
% \begin{option}[added=2022-09-01]{name/format}
%   \begin{syntax}
%     name/format = \meta{macro} \hfill Default: \#1
%   \end{syntax}
%   \meta{|macro|} used to format the \val{divine name} using the \cs{name}
%   function. |#1| contains the text of the argument to \cs{name}.
% \end{option}
%
% \begin{option}{noindent}
%   \begin{syntax}
%     noindent = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Whether to indent the first line of a \env{scripture} environment or not
%   by \opt{parindent}. The value of \meta{|boolean|} is optional and assumed
%   to be \val{true} if not present. This option is the opposite of
%   \opt{indent}.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[1 Peter 3:18][noindent]
%   \vs{18}For Christ also suffered once for sins,
%   the righteous for the unrighteous, to bring you
%   to God. He was put to death in the body but
%   made alive in the Spirit.
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[1 Peter 3:18][noindent]
%   \vs{18}For Christ also suffered once for sins,
%   the righteous for the unrighteous, to bring you
%   to God. He was put to death in the body but
%   made alive in the Spirit.
% \end{scripture}
% \end{scriptureexample}
%
% \begin{option}{parindent}
%   \begin{syntax}
%     parindent = \meta{dimen} \hfill Default: \cs{parindent}
%   \end{syntax}
%   \meta{|dimen|} to use when indenting the first line of a paragraph in the
%   \env{scripture} environment.
% \end{option}
%
% \begin{option}{parskip}
%   \begin{syntax}
%     parskip = \meta{skip} \hfill Default: \cs{parskip}
%   \end{syntax}
%   \meta{|skip|} to use between paragraphs in the \env{scripture} environment.
% \end{option}
%
% \changes{v1.2}{2022/08/31}{Add \opt{redletter} option}
% \begin{option}[added=2022-08-31]{redletter}
%   \begin{syntax}
%     redletter = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Whether to enable highlighting of Jesus' words in red. The value of
%   \meta{|boolean|} is option and assumed to be \val{true} if not present.
%   The text needs to be marked up with \cs{redletteron} and \cs{redletteroff}
%   for this option to have any effect.
% \end{option}
%
% \changes{v1.2}{2022/08/31}{Add \opt{redletter/colour} option}
% \begin{option}[added=2022-08-31]{redletter/colour, redletter/color}
%   \begin{syntax}
%     redletter/colour = \meta{colour expression} \hfill Default: red!80!black
%   \end{syntax}
%   The \pkg{l3color} \meta{|colour expression|} to be used for the words of
%   Jesus when the \opt{redletter} option is \val{true}. \cs{redletteron} and
%   \cs{redletteroff} must be used to mark up the text. \opt{redletter/color}
%   is an alias for \opt{redletter/colour}.
% \end{option}
%
% \changes{v1.3}{2023/01/08}{Add \opt{reference/align} option}
% \begin{option}[added=2023-01-08]{reference/align}
%   \begin{syntax}
%     reference/align = left \textbar\ right \hfill Default: right
%   \end{syntax}
%   Set the alignment of the reference. Note that in neither case will the
%   reference break across lines.
% \end{option}
%
% \changes{v1.2}{2022/09/07}{Add \opt{reference/colour} option}
% \begin{option}[added=2022-09-07]{reference/colour, reference/color}
%   \begin{syntax}
%     reference/colour = \meta{colour expression} \hfill Default: .
%   \end{syntax}
%   The \pkg{l3color} \meta{|colour expression|} to be used for the reference
%   and version. By default the current colour is inherited.
%   \opt{reference/color} is an alias for \opt{reference/colour}.
% \end{option}
%
% \begin{option}{reference/font}
%   \begin{syntax}
%     reference/font = \meta{font} \hfill Default: \cs{bfseries}
%   \end{syntax}
%   \meta{|font|} used when printing the \val{reference} for a \env{scripture}
%   quotation.
% \end{option}
%
% \begin{option}{reference/format}
%   \begin{syntax}
%     reference/format = \meta{macro} \hfill Default: \#1
%   \end{syntax}
%   \meta{|macro|} used to format the \val{reference} for a \env{scripture}
%   quotation. |#1| contains the text of the \val{reference} and \val{version}
%   (if specified).
% \end{option}
%
% \changes{v1.3}{2023/01/08}{Add \opt{reference/newline} option}
% \begin{option}[added=2023-01-8]{reference/newline}
%   \begin{syntax}
%     reference/newline
%   \end{syntax}
%   Always push the \val{reference} to a newline even if there is space for it
%   to fit on the last line of the quotation. The option sets
%   \opt{reference/sep} to \cs{linewidth} so there is never room for the
%   reference on the final line of the quotation.
% \end{option}
%
% \begin{option}{reference/sep}
%   \begin{syntax}
%     reference/sep = \meta{dimen} \hfill Default: 2em
%   \end{syntax}
%   The minimum \meta{|dimen|} allowed between the end of a \env{scripture}
%   quotation and its \val{reference} before the \val{reference} is pushed to
%   the following line.
% \end{option}
%
% \begin{option}{rightmargin}
%   \begin{syntax}
%     rightmargin = \meta{dimen} \hfill Default: 0pt
%   \end{syntax}
%   \meta{|dimen|} used for the right margin of the \env{scripture}
%   environment.
% \end{option}
%
% \begin{option}{selah/font}
%   \begin{syntax}
%     selah/font = \meta{font} \hfill Default: \cs{itshape}
%   \end{syntax}
%   \meta{|font|} used when printing \cs{selah} in a \env{poetry} environment.
% \end{option}
%
% \begin{option}{selah/format}
%   \begin{syntax}
%     selah/format = \meta{macro} \hfill Default: \#1
%   \end{syntax}
%   \meta{|macro|} used to format the \cs{selah} in a \env{poetry}
%   environment. |#1| contains the value of \opt{selah/text}.
% \end{option}
%
% \begin{option}{selah/sep}
%   \begin{syntax}
%     selah/sep = \meta{dimen} \hfill Default: 1em
%   \end{syntax}
%   The minimum \meta{|dimen|} allowed between the end of a poetry line and
%   \emph{Selah} before the \emph{Selah} is pushed to the following line.
% \end{option}
%
% \begin{option}{selah/text}
%   \begin{syntax}
%     selah/text = \meta{text} \hfill Default: Selah
%   \end{syntax}
%   \meta{|text|} used to for \cs{selah} in a \env{poetry} environment.
% \end{option}
%
% \changes{v2.0}{2023/12/27}{Add \opt{style} option}
% \begin{option}[added=2023/12/27]{style}
%   \begin{syntax}
%     style = \meta{name}
%   \end{syntax}
%   Set options previously saved with \cs{scripturestyle}. An error occurs if
%   the style isn't defined.
% \end{option}
%
% \changes{v1.2}{2022/08/30}{Add \opt{textright/sep} option}
% \begin{option}[added=2022-08-30]{textright/sep}
%   \begin{syntax}
%     textright/sep = \meta{dimen} \hfill Default: 1em
%   \end{syntax}
%   The minimum \meta{|dimen|} allowed between the end of a line and text
%   aligned to the right with \cs{textright} before the right aligned text is
%   pushed to the following line.
% \end{option}
%
% \changes{v1.2}{2022/09/07}{Add \opt{verse/colour} option}
% \begin{option}[added=2022-09-07]{verse/colour, verse/color}
%   \begin{syntax}
%     verse/colour = \meta{colour expression} \hfill Default: .
%   \end{syntax}
%   The \pkg{l3color} \meta{|colour expression|} to be used for verse numbers.
%   By default the current colour is inherited. \opt{verse/color} is an alias
%   for \opt{verse/colour}.
% \end{option}
%
% \changes{v1.3}{2022/11/13}{Add \opt{verse/first} option}
% \begin{option}[added=2022-11-13]{verse/first}
%   \begin{syntax}
%     verse/first = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   In prose sections, print the verse number in a different format if it is
%   at the start of the paragraph. The format and separation between verse and
%   text are controlled with the \opt{verse/firstformat} and
%   \opt{verse/firstsep} options. Use \cs{noversefirst} to suppress this at
%   the next verse (e.g., if your quote starts mid-way though a paragraph and
%   a normal verse should be printed). The value of \meta{|boolean|} is optional
%   and assumed to be true if not present.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Luke 18:25--28][noindent,
%     verse/first, version=NRSV]
%   \nofirstverse\vs{25}Indeed, it is easier for a
%   camel to go through the eye of a needle than for
%   someone who is rich to enter the kingdom of
%   God.''
%
%   \vs{26}Those who heard it said, ``Then who can
%   be saved?'' \vs{27}He replied, ``What is
%   impossible for mortals is possible for God.''
%
%   \vs{28}Then Peter said, ``Look, we have left our
%   homes and followed you.''
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Luke 18:25--28][noindent,
%     verse/first, version=NRSV]
%   \nofirstverse\vs{25}Indeed, it is easier for a
%   camel to go through the eye of a needle than for
%   someone who is rich to enter the kingdom of
%   God.''
%
%   \vs{26}Those who heard it said, ``Then who can
%   be saved?'' \vs{27}He replied, ``What is
%   impossible for mortals is possible for God.''
%
%   \vs{28}Then Peter said, ``Look, we have left our
%   homes and followed you.''
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v1.3}{2022/11/13}{Add \opt{verse/firstformat} option}
% \begin{option}[added=2022-11-13]{verse/firstformat}
%   \begin{syntax}
%     verse/firstformat = \meta{macro} \hfill Default: \#1
%   \end{syntax}
%   \meta{|macro|} used to format the first \cs{vs} in a paragraph. |#1|
%   contains the argument of \cs{vs}. Only used if \opt{verse/first} is
%   |true|.
% \end{option}
%
% \changes{v1.3}{2022/11/13}{Add \opt{verse/firstsep} option}
% \begin{option}[added=2022-11-13]{verse/firstsep}
%   \begin{syntax}
%     verse/firstsep = \meta{dimen} \hfill Default: 0.5em
%   \end{syntax}
%   \meta{|dimen|} used to separate the first \cs{vs} in a paragraph from the
%   following text. Only used if \opt{verse/first} is |true|.
% \end{option}
%
% \begin{option}{verse/font}
%   \begin{syntax}
%     verse/font = \meta{font} \hfill Default: \emph{Empty}
%   \end{syntax}
%   \meta{|font|} used for the \cs{vs} function.
% \end{option}
%
% \begin{option}{verse/format}
%   \begin{syntax}
%     verse/format = \meta{macro} \hfill Default: \cs{textsuperscript}\{\#1\}
%   \end{syntax}
%   \meta{|macro|} used to format the \cs{vs} function. |#1| contains the
%   argument of \cs{vs}.
% \end{option}
%
% \changes{v1.1}{2022/08/15}{Add \opt{verse/hide} option}
% \begin{option}[added=2022-08-15]{verse/hide}
%   \begin{syntax}
%     verse/hide = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Whether verses should be shown or hidden. The value of \meta{|boolean|} is
%   optional and assumed to be \val{true} if not present. This option is the
%   opposite of \opt{verse/show}. Note that the \hook{scripture/verse/before}
%   and \hook{scripture/verse/after} hooks are still executed when verses are
%   hidden.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Colossians 1:15--16][verse/hide]
%   \vs{15}The Son is the image of the invisible
%   God, the firstborn over all creation.
%   \vs{16}For in him all things were created:
%   things in heaven and on earth, visible and
%   invisible, whether thrones or powers or rulers
%   or authorities; all things have been created
%   through him and for him.
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Colossians 1:15--16][verse/hide]
%   \vs{15}The Son is the image of the invisible
%   God, the firstborn over all creation.
%   \vs{16}For in him all things were created:
%   things in heaven and on earth, visible and
%   invisible, whether thrones or powers or rulers
%   or authorities; all things have been created
%   through him and for him.
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v1.1}{2022/07/28}{Add \opt{verse/sep} option with small default}
% \begin{option}[added=2022-07-28]{verse/sep}
%   \begin{syntax}
%     verse/sep = \meta{dimen} \hfill Default: 0.05em
%   \end{syntax}
%   \meta{|dimen|} used to separate a \cs{vs} from the following text.
% \end{option}
%
% \changes{v1.1}{2022/08/15}{Add \opt{verse/show} option}
% \begin{option}[added=2022-08-15]{verse/show}
%   \begin{syntax}
%     verse/show = \meta{boolean} \hfill Default: true
%   \end{syntax}
%   Whether verses should be shown or hidden. The value of \meta{|boolean|}
%   is optional and assumed to be \val{true} if not present. This option is
%   the opposite of \opt{verse/hide}.
% \end{option}
%
% \begin{option}{version}
%   \begin{syntax}
%     version = \meta{version} \hfill Default: \emph{Empty}
%   \end{syntax}
%   \meta{|version|} added to the \val{reference} for a \env{scripture}
%   quotation.
% \end{option}
%
% \begin{option}{version/delim}
%   \begin{syntax}
%     version/delim = \meta{delim} \hfill Default: \{\ \}
%   \end{syntax}
%   \meta{|delim|} to use between the \val{reference} and the \val{version} of a
%   \env{scripture} quotation.
% \end{option}
%
% \begin{option}{version/format}
%   \begin{syntax}
%     version/format = \meta{macro} \hfill Default: (\#1)
%   \end{syntax}
%   \meta{|macro|} used to format the \val{version} for a \env{scripture}
%   quotation. |#1| contains the text of the \val{version}.
% \end{option}
%
% \subsubsection{Options for the \env{center} environment}
% \label{centeroptions}
%
% If these options are passed directly to the \env{center} environment rather
% than to the package, \cs{scripturesetup} or the \env{scripture} environment,
% then the |center/| prefix should be dropped.
%
% \begin{option}{center/aboveskip}
%   \begin{syntax}
%     center/aboveskip = \meta{skip} \hfill Default: \cs{medskipamount}
%   \end{syntax}
%   \meta{|skip|} inserted above the \env{center} environment.
% \end{option}
%
% \begin{option}{center/belowskip}
%   \begin{syntax}
%     center/belowskip = \meta{skip} \hfill Default: \cs{medskipamount}
%   \end{syntax}
%   \meta{|skip|} inserted below the \env{center} environment.
% \end{option}
%
% \begin{option}{center/leftmargin}
%   \begin{syntax}
%     center/leftmargin = \meta{dimen} \hfill Default: 0pt
%   \end{syntax}
%   \meta{|dimen|} used for the left margin of the \env{center} environment.
% \end{option}
%
% \begin{option}{center/rightmargin}
%   \begin{syntax}
%     center/rightmargin = \meta{dimen} \hfill Default: 0pt
%   \end{syntax}
%   \meta{|dimen|} used for the right margin of the \env{center} environment.
% \end{option}
%
% \subsubsection{Options for the \env{flushright} environment}
% \label{flushrightoptions}
%
% If these options are passed directly to the \env{flushright} environment rather
% than to the package, \cs{scripturesetup} or the \env{scripture} environment,
% then the |flushright/| prefix should be dropped.
%
% \begin{option}{flushright/aboveskip}
%   \begin{syntax}
%     flushright/aboveskip = \meta{skip} \hfill Default: \cs{medskipamount}
%   \end{syntax}
%   \meta{|skip|} inserted above the \env{flushright} environment.
% \end{option}
%
% \begin{option}{flushright/belowskip}
%   \begin{syntax}
%     flushright/belowskip = \meta{skip} \hfill Default: \cs{medskipamount}
%   \end{syntax}
%   \meta{|skip|} inserted below the \env{flushright} environment.
% \end{option}
%
% \begin{option}{flushright/leftmargin}
%   \begin{syntax}
%     flushright/leftmargin = \meta{dimen} \hfill Default: 0pt
%   \end{syntax}
%   \meta{|dimen|} used for the left margin of the \env{flushright} environment.
% \end{option}
%
% \begin{option}{flushright/rightmargin}
%   \begin{syntax}
%     flushright/rightmargin = \meta{dimen} \hfill Default: 0pt
%   \end{syntax}
%   \meta{|dimen|} used for the right margin of the \env{flushright} environment.
% \end{option}
%
% \subsubsection{Options for the \env{hanging} environment}
% \label{hangingoptions}
%
% If these options are passed directly to the \env{hanging} environment rather
% than to the package, \cs{scripturesetup} or the \env{scripture} environment,
% then the |hanging/| prefix should be dropped.
%
% \begin{option}{hanging/aboveskip}
%   \begin{syntax}
%     hanging/aboveskip = \meta{skip} \hfill Default: \cs{medskipamount}
%   \end{syntax}
%   \meta{|skip|} inserted above the \env{hanging} environment.
% \end{option}
%
% \begin{option}{hanging/belowskip}
%   \begin{syntax}
%     hanging/belowskip = \meta{skip} \hfill Default: \cs{medskipamount}
%   \end{syntax}
%   \meta{|skip|} inserted below the \env{hanging} environment.
% \end{option}
%
% \begin{option}{hanging/hang}
%   \begin{syntax}
%     hanging/hang = \meta{dimen} \hfill Default: 2em
%   \end{syntax}
%   \meta{|dimen|} used for the indent of subsequent lines of the
%   \env{hanging} environment.
% \end{option}
%
% \begin{option}{hanging/leftmargin}
%   \begin{syntax}
%     hanging/leftmargin = \meta{dimen} \hfill Default: 1em
%   \end{syntax}
%   \meta{|dimen|} used for the left margin of the \env{hanging} environment.
% \end{option}
%
% \begin{option}{hanging/rightmargin}
%   \begin{syntax}
%     hanging/rightmargin = \meta{dimen} \hfill Default: 1em
%   \end{syntax}
%   \meta{|dimen|} used for the right margin of the \env{hanging} environment.
% \end{option}
%
% \subsubsection{Options for the \env{midparachap} environment}
% \label{midparachapoptions}
%
% If these options are passed directly to the \env{midparachap} environment
% rather than to the package, \cs{scripturesetup} or the \env{scripture}
% environment, then the |midparachap/| prefix should be dropped.
%
% \begin{option}{midparachap/hideverse}
%   \begin{syntax}
%     midparachap/hideverse = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Whether a \cs{vs}|{1}| should automatically be inserted after a \cs{ch}
%   when the \cs{ch} occurs mid-paragraph. This also affects \cs{ch} in
%   \env{poetry} environments. \cs{extraskip} begins a new paragraph in a
%   \env{poetry} environment. The value of \meta{|boolean|} is optional and
%   assumed to be \val{true} if not present. This option is the opposite of
%   \opt{midparachap/showverse}. See also \opt{chapter/showverse}.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Hosea 11:12--12:1]%
%     [midparachap/hideverse]
%   \begin{poetry}
%     \vs{12}Ephraim has surrounded me with lies,
%     Israel with deceit.
%
%     And Judah is unruly against God,
%     even against the faithful Holy One.
%
%     \ch{12}Ephraim feeds on the wind;
%     he pursues the east wind all day
%     and multiplies lies and violence.
%
%     He makes a treaty with Assyria
%     and sends olive oil to Egypt.
%   \end{poetry}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Hosea 11:12--12:1]%
%     [midparachap/hideverse]
%   \begin{poetry}
%     \vs{12}Ephraim has surrounded me with lies,
%     Israel with deceit.
%
%     And Judah is unruly against God,
%     even against the faithful Holy One.
%
%     \ch{12}Ephraim feeds on the wind;
%     he pursues the east wind all day
%     and multiplies lies and violence.
%
%     He makes a treaty with Assyria
%     and sends olive oil to Egypt.
%   \end{poetry}
% \end{scripture}
% \end{scriptureexample}
%
% \begin{option}{midparachap/showverse}
%   \begin{syntax}
%     midparachap/showverse = \meta{boolean} \hfill Default: true
%   \end{syntax}
%   Whether a \cs{vs}|{1}| should automatically be inserted after a \cs{ch}
%   when the \cs{ch} occurs mid-paragraph. This also affects \cs{ch} in
%   \env{poetry} environments. \cs{extraskip} begins a new paragraph in a
%   \env{poetry} environment. The value of \meta{|boolean|} is optional and
%   assumed to be \val{true} if not present. This option is the opposite of
%   \opt{midparachap/hideverse}. See also \opt{chapter/showverse}.
% \end{option}
%
% \subsubsection{Options for the \env{narrow} environment}
% \label{narrowoptions}
%
% If these options are passed directly to the \env{narrow} environment rather
% than to the package, \cs{scripturesetup} or the \env{scripture} environment,
% then the |narrow/| prefix should be dropped.
%
% \begin{option}{narrow/aboveskip}
%   \begin{syntax}
%     narrow/aboveskip = \meta{skip} \hfill Default: \cs{medskipamount}
%   \end{syntax}
%   \meta{|skip|} inserted above the \env{narrow} environment.
% \end{option}
%
% \begin{option}{narrow/belowskip}
%   \begin{syntax}
%     narrow/belowskip = \meta{skip} \hfill Default: \cs{medskipamount}
%   \end{syntax}
%   \meta{|skip|} inserted below the \env{narrow} environment.
% \end{option}
%
% \begin{option}{narrow/leftmargin}
%   \begin{syntax}
%     narrow/leftmargin = \meta{dimen} \hfill Default: 1em
%   \end{syntax}
%   \meta{|dimen|} used for the left margin of the \env{narrow} environment.
% \end{option}
%
% \begin{option}{narrow/rightmargin}
%   \begin{syntax}
%     narrow/rightmargin = \meta{dimen} \hfill Default: 1em
%   \end{syntax}
%   \meta{|dimen|} used for the right margin of the \env{narrow} environment.
% \end{option}
%
% \subsubsection{Options for the \env{poetry} environment}
% \label{poetryoptions}
%
% If these options are passed directly to the \env{poetry} environment rather
% than to the package, \cs{scripturesetup} or the \env{scripture} environment,
% then the |poetry/| prefix should be dropped.
%
% \begin{option}{poetry/aboveskip}
%   \begin{syntax}
%     poetry/aboveskip = \meta{skip} \hfill Default: \cs{medskipamount}
%   \end{syntax}
%   \meta{|skip|} inserted above the \env{poetry} environment.
% \end{option}
%
% \begin{option}{poetry/belowskip}
%   \begin{syntax}
%     poetry/belowskip = \meta{skip} \hfill Default: \cs{medskipamount}
%   \end{syntax}
%   \meta{|skip|} inserted below the \env{poetry} environment.
% \end{option}
%
% \begin{option}{poetry/bigindent}
%   \begin{syntax}
%     poetry/bigindent = \meta{dimen} \hfill Default: 4em
%   \end{syntax}
%   \meta{|dimen|} used for the indent subsequent lines of a line of poetry in
%   a \env{poetry} environment if it needs to flow on to the following line.
% \end{option}
%
% \begin{option}{poetry/indent}
%   \begin{syntax}
%     poetry/indent = \meta{dimen} \hfill Default: 1em
%   \end{syntax}
%   \meta{|dimen|} used for the second half of a line of poetry in a
%   \env{poetry} environment.
% \end{option}
%
% \begin{option}{poetry/leftmargin}
%   \begin{syntax}
%     poetry/leftmargin = \meta{dimen} \hfill Default: 1em
%   \end{syntax}
%   \meta{|dimen|} used for the left margin of the \env{poetry} environment.
% \end{option}
%
% \begin{option}{poetry/rightmargin}
%   \begin{syntax}
%     poetry/rightmargin = \meta{dimen} \hfill Default: 0pt
%   \end{syntax}
%   \meta{|dimen|} used for the right margin of the \env{poetry} environment.
% \end{option}
%
% \changes{v1.1}{2022/07/31}{Add \opt{poetry/verse/left} option}
% \begin{option}[added=2022-07-31]{poetry/verse/left}
%   \begin{syntax}
%     poetry/verse/left = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Align verse numbers in \env{poetry} environments at the left margin of the
%   \env{scripture} environment. This option is the opposite of
%   \opt{poetry/verse/right}.
% \end{option}
%
% \begin{scriptureexample}[lefthand ratio=0.65]
% \begin{verbatim}
% \begin{scripture}[Atcs 15:15--18]%
%     [poetry/leftmargin=2em, poetry/verse/left]
%   \vs{15}The words of the prophets are in
%   agreement with this, as it is written:
%   \begin{poetry}
%     \vs{16}`\thinspace``After this I will return
%     and rebuild David's fallen tent.
%
%     Its ruins I will rebuild,
%     and I will restore it,
%
%     \vs{17}that the rest of mankind may seek the Lord,
%     even all the Gentiles who bear my name,
%
%     says the Lord, who does these things''---
%     \vs{18}things known from long ago.
%   \end{poetry}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Atcs 15:15--18]%
%     [poetry/leftmargin=2em, poetry/verse/left]
%   \vs{15}The words of the prophets are in
%   agreement with this, as it is written:
%   \begin{poetry}
%     \vs{16}`\thinspace``After this I will return
%     and rebuild David's fallen tent.
%
%     Its ruins I will rebuild,
%     and I will restore it,
%
%     \vs{17}that the rest of mankind may seek the Lord,
%     even all the Gentiles who bear my name,
%
%     says the Lord, who does these things''---
%     \vs{18}things known from long ago.
%   \end{poetry}
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v1.1}{2022/07/31}{Add \opt{poetry/verse/right} option}
% \begin{option}[added=2022-07-31]{poetry/verse/right}
%   \begin{syntax}
%     poetry/verse/right = \meta{boolean} \hfill Default: true
%   \end{syntax}
%   Align verse numbers in \env{poetry} environments at the left margin of the
%   poetry environment. The verse numbers overlap to the left. This option is
%   the opposite of \opt{poetry/verse/left}.
% \end{option}
%
% \changes{v1.1}{2022/07/31}{Add \opt{poetry/verse/sep} option}
% \begin{option}[added=2022-07-31]{poetry/verse/sep}
%   \begin{syntax}
%     poetry/verse/sep = \meta{dimen} \hfill Default: 0.05 em
%   \end{syntax}
%   \meta{|dimen|} used to separate a \cs{vs} from the following text in a
%   \env{poetry} environment. This is only used for verses at the start of a
%   line.
% \end{option}
%
% \end{documentation}
%
% \begin{implementation}
% 
% \section{Implementation}
%
%    \begin{macrocode}
%<*package>
%<@@=scripture>
%    \end{macrocode}
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[2022-11-01]
\ProvidesExplPackage{scripture}{2023/12/27}{2.0}
  {Format Scripture Quotations (DCP)}
%    \end{macrocode}
%
% \subsection{Messages}
%
% \env{scripture} environments along with all internal environments can not be
% nested.
%
%    \begin{macrocode}
\msg_new:nnnn { scripture } { nested-environment }
  { Nesting~of~scripture~environments~not~supported. }
  { You~have~tried~to~nest~a~scripture~environment~or \\
    one~of~its~internal~environments,~which~is~not~supported. }
%    \end{macrocode}
%
% Make sure \pkg{polyglossia} languages and variants are set up.
%
%    \begin{macrocode}
\msg_new:nnnn { scripture } { language-error }
  { Language~`#1'~not~set~up. }
  { Language~`#1'~has~not~been~set~up.~Make~sure~you~set~up~languages~
    before~using~the~language~option~of~the~scripture~environment. }
%    \end{macrocode}
%
% Warn if a \opt{language} is requested and neither \pkg{babel} nor
% \pkg{polyglossia} is loaded.
%
%    \begin{macrocode}
\msg_new:nnnn { scripture } { language-warning }
  { Language~requested~without~support. }
  { You~have~requested~language=#1,~but~neither~babel~nor~polyglossia~
    have~been~loaded~and~set~up.~Ignoring~option~language=#1. }
%    \end{macrocode}
%
% Error if an unknown \opt{style} is requested.
%
%    \begin{macrocode}
\msg_new:nnnn { scripture } { unknown-style }
  { Style~#1~not~defined. }
  { You~have~requested~style=#1,~but~it~has~not~been~defined.~
    You~can~define~it~using~\token_to_str:N \scripturestyle.~
    Ignoring~option~style=#1. }
%    \end{macrocode}
%
% \subsection{Options}
%
% Key-value settings for the \env{scripture} environment and its inner
% environments.
%    \begin{macrocode}
\keys_define:nn { scripture }
  {
    , aboveskip                   .tl_set:N           = \l_@@_aboveskip_tl
    , aboveskip                   .value_required:n   = true
    , aboveskip                   .initial:n          = \c_zero_skip
    , added / font                .tl_set:N           = \l_@@_added_font_tl
    , added / font                .value_required:n   = true
    , added / font                .initial:n          =
    , added / format              .cs_set:Np          = \@@_added_format:n #1
    , added / format              .value_required:n   = true
    , added / format              .initial:n          = \emph { #1 }
    , belowskip                   .tl_set:N           = \l_@@_belowskip_tl
    , belowskip                   .value_required:n   = true
    , belowskip                   .initial:n          = \c_zero_skip
    , colour                      .tl_set:N           = \l_@@_colour_tl
    , colour                      .value_required:n   = true
    , colour                      .initial:n          = .
    , color                       .meta:n             = { colour = { #1 } }
    , compact                     .bool_set:N         = \l_@@_compact_bool
    , compact                     .default:n          = true
    , compact                     .initial:n          = false
    , chapter / font              .tl_set:N           = \l_@@_chap_font_tl
    , chapter / font              .value_required:n   = true
    , chapter / font              .initial:n          = \bfseries
    , chapter / colour            .tl_set:N           = \l_@@_chapter_colour_tl
    , chapter / colour            .value_required:n   = true
    , chapter / colour            .initial:n          = .
    , chapter / color             .meta:n             = { chapter / colour = { #1 } }
    , chapter / drop              .bool_set:N         = \l_@@_chap_drop_bool
    , chapter / drop              .default:n          = true
    , chapter / drop              .initial:n          = true
    , chapter / format            .cs_set:Np          = \@@_chap_format:n #1
    , chapter / format            .value_required:n   = true
    , chapter / format            .initial:n          = #1
    , chapter / hide              .bool_set_inverse:N = \l_@@_chap_show_bool
    , chapter / hide              .default:n          = true
    , chapter / nodrop            .bool_set_inverse:N = \l_@@_chap_drop_bool
    , chapter / nodrop            .default:n          = true
    , chapter / sep               .tl_set:N           = \l_@@_chap_sep_tl
    , chapter / sep               .value_required:n   = true
    , chapter / sep               .initial:n          = 0.5 em
    , chapter / show              .bool_set:N         = \l_@@_chap_show_bool
    , chapter / show              .default:n          = true
    , chapter / show              .initial:n          = true
    , chapter / showverse         .bool_set:N         = \l_@@_chap_show_verse_bool
    , chapter / showverse         .default:n          = true
    , chapter / showverse         .initial:n          = false
    , extraskip                   .tl_set:N           = \l_@@_extraskip_tl
    , extraskip                   .value_required:n   = true
    , extraskip                   .initial:n          = \medskipamount
    , font                        .tl_set:N           = \l_@@_font_tl
    , font                        .value_required:n   = true
    , font                        .initial:n          =
    , indent                      .bool_set:N         = \l_@@_indent_bool
    , indent                      .default:n          = true
    , indent                      .initial:n          = true
    , inline                      .bool_set:N         = \l_@@_inline_bool
    , inline                      .default:n          = true
    , inline                      .initial:n          = false
    , inline / begin              .tl_set:N           = \l_@@_inline_begin_tl
    , inline / begin              .value_required:n   = true
    , inline / begin              .initial:n          = ``\,
    , inline / end                .tl_set:N           = \l_@@_inline_end_tl
    , inline / end                .value_required:n   = true
    , inline / end                .initial:n          = \,''
    , inline / reference / format .cs_set:Np          = \@@_inline_ref_format:n #1
    , inline / reference / format .value_required:n   = true
    , inline / reference / format .initial:n          = (#1)
    , inline / reference / sep    .tl_set:N           = \l_@@_inline_ref_sep_tl
    , inline / reference / sep    .value_required:n   = true
    , inline / reference / sep    .initial:n          = 0.5 em
    , inline / version / delim    .tl_set:N           = \l_@@_inline_version_delim_tl
    , inline / version / delim    .value_required:n   = true
    , inline / version / delim    .initial:n          = \c_space_tl
    , inline / version / format   .cs_set:Np          = \@@_inline_version_format:n #1
    , inline / version / format   .value_required:n   = true
    , inline / version / format   .initial:n          = #1
    , language                    .tl_set:N           = \l_@@_language_tl
    , language                    .value_required:n   = true
    , language                    .initial:n          =
    , language / variant          .tl_set:N           = \l_@@_language_variant_tl
    , language / variant          .value_required:n   = true
    , language / variant          .initial:n          =
    , leftmargin                  .tl_set:N           = \l_@@_leftmargin_tl
    , leftmargin                  .value_required:n   = true
    , leftmargin                  .initial:n          = \c_zero_dim
    , name / font                 .tl_set:N           = \l_@@_name_font_tl
    , name / font                 .value_required:n   = true
    , name / font                 .initial:n          = \scshape
    , name / format               .cs_set:Np          = \@@_name_format:n #1
    , name / format               .value_required:n   = true
    , name / format               .initial:n          = #1
    , noindent                    .bool_set_inverse:N = \l_@@_indent_bool
    , noindent                    .default:n          = true
    , parindent                   .tl_set:N           = \l_@@_parindent_tl
    , parindent                   .value_required:n   = true
    , parindent                   .initial:n          = \parindent
    , parskip                     .tl_set:N           = \l_@@_parskip_tl
    , parskip                     .value_required:n   = true
    , parskip                     .initial:n          = \parskip
    , redletter                   .bool_set:N         = \l_@@_red_letter_bool
    , redletter                   .default:n          = true
    , redletter                   .initial:n          = false
    , redletter / colour          .tl_set:N           = \l_@@_red_letter_colour_tl
    , redletter / colour          .value_required:n   = true
    , redletter / colour          .initial:n          = red!80!black
    , redletter / color           .meta:n             = { redletter / colour = { #1 } }
    , reference / align           .choices:nn         = { left, right }
                                                        {
                                                          \tl_if_exist:NF \l_@@_ref_align_tl
                                                            { \tl_new:N \l_@@_ref_align_tl }
                                                          \tl_set_eq:NN \l_@@_ref_align_tl \l_keys_choice_tl
                                                        }
    , reference / align           .value_required:n   = true
    , reference / align           .initial:n          = right
    , reference / colour          .tl_set:N           = \l_@@_ref_colour_tl
    , reference / colour          .value_required:n   = true
    , reference / colour          .initial:n          = .
    , reference / color           .meta:n             = { reference / colour = { #1 } }
    , reference / font            .tl_set:N           = \l_@@_ref_font_tl
    , reference / font            .value_required:n   = true
    , reference / font            .initial:n          = \bfseries
    , reference / format          .cs_set:Np          = \@@_ref_format:n #1
    , reference / format          .value_required:n   = true
    , reference / format          .initial:n          = #1
    , reference / newline         .meta:n             = { reference / sep = \linewidth }
    , reference / newline         .value_forbidden:n  = true
    , reference / sep             .tl_set:N           = \l_@@_ref_sep_tl
    , reference / sep             .value_required:n   = true
    , reference / sep             .initial:n          = 2 em
    , rightmargin                 .tl_set:N           = \l_@@_rightmargin_tl
    , rightmargin                 .value_required:n   = true
    , rightmargin                 .initial:n          = \c_zero_dim
    , selah / text                .tl_set:N           = \l_@@_selah_text_tl
    , selah / text                .value_required:n   = true
    , selah / text                .initial:n          = Selah
    , selah / font                .tl_set:N           = \l_@@_selah_font_tl
    , selah / font                .value_required:n   = true
    , selah / font                .initial:n          = \itshape
    , selah / format              .cs_set:Np          = \@@_selah_format:n #1
    , selah / format              .value_required:n   = true
    , selah / format              .initial:n          = #1
    , selah / sep                 .tl_set:N           = \l_@@_selah_sep_tl
    , selah / sep                 .value_required:n   = true
    , selah / sep                 .initial:n          = 1 em
    , style                       .choice:
    , style / unknown             .code:n             = \msg_error:nnx
                                                          { scripture }
                                                          { unknown-style }
                                                          { \exp_not:n {#1} }
    , textright / sep             .tl_set:N           = \l_@@_text_right_sep_tl
    , textright / sep             .value_required:n   = true
    , textright / sep             .initial:n          = 1 em
    , verse / colour              .tl_set:N           = \l_@@_verse_colour_tl
    , verse / colour              .value_required:n   = true
    , verse / colour              .initial:n          = .
    , verse / color               .meta:n             = { verse / colour = { #1 } }
    , verse / first               .bool_set:N         = \l_@@_verse_first_bool
    , verse / first               .default:n          = true
    , verse / first               .initial:n          = false
    , verse / firstformat         .cs_set:Np          = \@@_verse_first_format:n #1
    , verse / firstformat         .value_required:n   = true
    , verse / firstformat         .initial:n          = #1
    , verse / firstsep            .tl_set:N           = \l_@@_verse_first_sep_tl
    , verse / firstsep            .value_required:n   = true
    , verse / firstsep            .initial:n          = 0.5em
    , verse / font                .tl_set:N           = \l_@@_verse_font_tl
    , verse / font                .value_required:n   = true
    , verse / font                .initial:n          = 
    , verse / format              .cs_set:Np          = \@@_verse_format:n #1
    , verse / format              .value_required:n   = true
    , verse / format              .initial:n          = \textsuperscript{#1}
    , verse / hide                .bool_set_inverse:N = \l_@@_verse_show_bool
    , verse / hide                .default:n          = true
    , verse / sep                 .tl_set:N           = \l_@@_verse_sep_tl
    , verse / sep                 .value_required:n   = true
    , verse / sep                 .initial:n          = 0.05 em
    , verse / show                .bool_set:N         = \l_@@_verse_show_bool
    , verse / show                .default:n          = true
    , verse / show                .initial:n          = true
    , version                     .tl_set:N           = \l_@@_version_tl
    , version                     .value_required:n   = true
    , version                     .initial:n          =
    , version / delim             .tl_set:N           = \l_@@_version_delim_tl
    , version / delim             .value_required:n   = true
    , version / delim             .initial:n          = \c_space_tl
    , version / format            .cs_set:Np          = \@@_version_format:n #1
    , version / format            .value_required:n   = true
    , version / format            .initial:n          = (#1)
%    \end{macrocode}
% Options for the \env{center} environment.
%    \begin{macrocode}
    , center / aboveskip          .tl_set:N           = \l_@@_center_aboveskip_tl
    , center / aboveskip          .value_required:n   = true
    , center / aboveskip          .initial:n          = \medskipamount
    , center / belowskip          .tl_set:N           = \l_@@_center_belowskip_tl
    , center / belowskip          .value_required:n   = true
    , center / belowskip          .initial:n          = \medskipamount
    , center / leftmargin         .tl_set:N           = \l_@@_center_leftmargin_tl
    , center / leftmargin         .value_required:n   = true
    , center / leftmargin         .initial:n          = \c_zero_dim
    , center / rightmargin        .tl_set:N           = \l_@@_center_rightmargin_tl
    , center / rightmargin        .value_required:n   = true
    , center / rightmargin        .initial:n          = \c_zero_dim
%    \end{macrocode}
% Options for the \env{flushright} environment.
%    \begin{macrocode}
    , flushright / aboveskip      .tl_set:N           = \l_@@_flushright_aboveskip_tl
    , flushright / aboveskip      .value_required:n   = true
    , flushright / aboveskip      .initial:n          = \medskipamount
    , flushright / belowskip      .tl_set:N           = \l_@@_flushright_belowskip_tl
    , flushright / belowskip      .value_required:n   = true
    , flushright / belowskip      .initial:n          = \medskipamount
    , flushright / leftmargin     .tl_set:N           = \l_@@_flushright_leftmargin_tl
    , flushright / leftmargin     .value_required:n   = true
    , flushright / leftmargin     .initial:n          = \c_zero_dim
    , flushright / rightmargin    .tl_set:N           = \l_@@_flushright_rightmargin_tl
    , flushright / rightmargin    .value_required:n   = true
    , flushright / rightmargin    .initial:n          = \c_zero_dim
%    \end{macrocode}
% Options for the \env{hanging} environment.
%    \begin{macrocode}
    , hanging / aboveskip         .tl_set:N           = \l_@@_hanging_aboveskip_tl
    , hanging / aboveskip         .value_required:n   = true
    , hanging / aboveskip         .initial:n          = \medskipamount
    , hanging / belowskip         .tl_set:N           = \l_@@_hanging_belowskip_tl
    , hanging / belowskip         .value_required:n   = true
    , hanging / belowskip         .initial:n          = \medskipamount
    , hanging / hang              .tl_set:N           = \l_@@_hanging_hang_tl
    , hanging / hang              .value_required:n   = true
    , hanging / hang              .initial:n          = 2 em
    , hanging / leftmargin        .tl_set:N           = \l_@@_hanging_leftmargin_tl
    , hanging / leftmargin        .value_required:n   = true
    , hanging / leftmargin        .initial:n          = 1 em
    , hanging / rightmargin       .tl_set:N           = \l_@@_hanging_rightmargin_tl
    , hanging / rightmargin       .value_required:n   = true
    , hanging / rightmargin       .initial:n          = \c_zero_dim
%    \end{macrocode}
% Options for the mid-paragraph chapters (including the \env{midparachap} environment).
%    \begin{macrocode}
    , midparachap / hideverse     .bool_set_inverse:N = \l_@@_midparachap_show_verse_bool
    , midparachap / hideverse     .default:n          = true
    , midparachap / showverse     .bool_set:N         = \l_@@_midparachap_show_verse_bool
    , midparachap / showverse     .default:n          = true
    , midparachap / showverse     .initial:n          = true
%    \end{macrocode}
% Options for the \env{narrow} environment.
%    \begin{macrocode}
    , narrow / aboveskip          .tl_set:N           = \l_@@_narrow_aboveskip_tl
    , narrow / aboveskip          .value_required:n   = true
    , narrow / aboveskip          .initial:n          = \medskipamount
    , narrow / belowskip          .tl_set:N           = \l_@@_narrow_belowskip_tl
    , narrow / belowskip          .value_required:n   = true
    , narrow / belowskip          .initial:n          = \medskipamount
    , narrow / leftmargin         .tl_set:N           = \l_@@_narrow_leftmargin_tl
    , narrow / leftmargin         .value_required:n   = true
    , narrow / leftmargin         .initial:n          = 1 em
    , narrow / rightmargin        .tl_set:N           = \l_@@_narrow_rightmargin_tl
    , narrow / rightmargin        .value_required:n   = true
    , narrow / rightmargin        .initial:n          = 1 em
%    \end{macrocode}
% Options for the \env{poetry} environment.
%    \begin{macrocode}
    , poetry / aboveskip          .tl_set:N           = \l_@@_poetry_aboveskip_tl
    , poetry / aboveskip          .value_required:n   = true
    , poetry / aboveskip          .initial:n          = \medskipamount
    , poetry / belowskip          .tl_set:N           = \l_@@_poetry_belowskip_tl
    , poetry / belowskip          .value_required:n   = true
    , poetry / belowskip          .initial:n          = \medskipamount
    , poetry / bigindent          .tl_set:N           = \l_@@_poetry_big_indent_tl
    , poetry / bigindent          .value_required:n   = true
    , poetry / bigindent          .initial:n          = 4 em
    , poetry / indent             .tl_set:N           = \l_@@_poetry_indent_tl
    , poetry / indent             .value_required:n   = true
    , poetry / indent             .initial:n          = 1 em
    , poetry / leftmargin         .tl_set:N           = \l_@@_poetry_leftmargin_tl
    , poetry / leftmargin         .value_required:n   = true
    , poetry / leftmargin         .initial:n          = 1 em
    , poetry / rightmargin        .tl_set:N           = \l_@@_poetry_rightmargin_tl
    , poetry / rightmargin        .value_required:n   = true
    , poetry / rightmargin        .initial:n          = \c_zero_dim
    , poetry / verse / left       .bool_set_inverse:N = \l_@@_poetry_verse_right_bool
    , poetry / verse / left       .default:n          = true
    , poetry / verse / right      .bool_set:N         = \l_@@_poetry_verse_right_bool
    , poetry / verse / right      .default:n          = true
    , poetry / verse / right      .initial:n          = true
    , poetry / verse / sep        .tl_set:N           = \l_@@_poetry_verse_sep_tl
    , poetry / verse / sep        .value_required:n   = true
    , poetry / verse / sep        .initial:n          = 0.05 em
  }
%    \end{macrocode}
% Process package options.
%    \begin{macrocode}
\ProcessKeyOptions
%    \end{macrocode}
%
% \begin{macro}{\@@_setup_style:nnn}
%   Specify options which can later be activated using the \opt{style} option.
%   If the first argument is \val{true}, then the options are appended rather
%   than replaced.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_setup_style:nnn
  {
    \bool_if:NTF #1
      {
        \tl_if_exist:cF { g__@@_style_ #2 _tl }
          { \tl_new:c { g__@@_style_ #2 _tl } }
        \@@_setup_style:nne \c_false_bool { #2 }
          { \tl_use:c { g__@@_style_ #2 _tl } , #3 }
      }
      {
        \tl_gset:cn { g__@@_style_ #2 _tl } { #3 }
        \keys_define:nn { scripture }
          { style / #2 .meta:n = { #3 } }
      }
  }
\cs_generate_variant:Nn \@@_setup_style:nnn { nne }
%    \end{macrocode}
% \end{macro}
%
% \subsection{Hooks}
%
% \begin{hooks}{scripture/chap/before, scripture/chap/after,
%   scripture/verse/before, scripture/verse/after}
% Hooks for before and after chapters and verses. The current chapter and
% verse is available in the hooks as \cs{scripturecurrentchapter} and
% \cs{scripturecurrentverse} respectively. These are global.
%    \begin{macrocode}
\hook_new_pair:nn { scripture / chap / before } { scripture / chap / after }
\hook_new_pair:nn { scripture / verse / before } { scripture / verse / after }
%    \end{macrocode}
% \end{hooks}
%
% \subsection{The main \env{scripture} environment}
%
% \begin{macro}{\l_@@_active_bool, \l_@@_active_inner_bool}
%   Flags to ensure that environments are not nested.
%    \begin{macrocode}
\bool_new:N \l_@@_active_bool
\bool_new:N \l_@@_active_inner_bool
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_clubpenalty_saved_int}
%   Holds saved club penalty so we can change and restore it around chapter
%   breaks.
%    \begin{macrocode}
\int_new:N \l_@@_clubpenalty_saved_int
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\g_@@_prev_inner_below_skip}
%   Save the last below skip of an inner environment so it can be removed if
%   the main scripture environment ends with and inner environment.
%    \begin{macrocode}
\skip_new:N \g_@@_prev_inner_below_skip
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_outer_itemindent_dim}
%   Holds the \cs{itemindent} of the outer list. Used to calculate the
%   \cs{itemindent} to retain correct indenting when a list environment is
%   the first thing in an outer list.
%    \begin{macrocode}
\dim_new:N \l_@@_outer_itemindent_dim
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_setup_list_noindent:n}
%   Set \cs{noindent} to do a negative horizontal skip a list is the first
%   item in a list then restore it at the end of the paragraph. This allows
%   \cs{itemindent} to be set to a negative value and still have \cs{noindent}
%   behave as expected.
%    \begin{macrocode}
\cs_new_protected_nopar:Nn \@@_setup_list_noindent:n
  {
    \legacy_if:nT {@newlist}
      {
        \cs_set_protected_nopar:Npn \noindent
          {
            \skip_horizontal:n { -#1 }
          }
        \hook_gput_next_code:nn { para / end }
          {
            \cs_gset_eq:NN \noindent \tex_noindent:D
          }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_skip_diff:NN}
%   Find the difference between two skips while avoiding negative stretch and
%   shrink components.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_skip_diff:NN
  {
    \skip_eval:n
      {
        \dim_eval:n { \dimexpr #1 - \dimexpr #2 }
        ~ plus ~
          \dim_max:nn { \gluestretch #1 - \gluestretch #2 } \c_zero_dim
        ~ minus ~
          \dim_max:nn { \glueshrink #1 - \glueshrink #2 } \c_zero_dim
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_extra_skip:}
%   Insert a little extra vertical space between two paragraphs. This function
%   tests if the previous paragraph is only one line in length and began
%   with a \cs{ch} function. If this condition is met, more space is added
%   if necessary to avoid the following paragraph clashing with the drop
%   chapter.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_extra_skip:
  {
    \int_compare:nNnT
      \g_@@_chap_par_prevgraf_int = 1
      {
        \dim_compare:nNnT
          { \parskip + \glueexpr \l_@@_extraskip_tl } < \baselineskip
          {
            \addvspace { \baselineskip }
          }
        \int_gzero:N \g_@@_chap_par_prevgraf_int
      }
    \addvspace { \l_@@_extraskip_tl }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_text_right:nn}
%   Align a word to the right and finish a paragraph, pushing to the next line
%   if there is not space for the word.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_text_right:nn
  {
    \bool_lazy_or:nnTF
      { \str_if_eq_p:Vn \l_@@_currenvir_str { flushright } }
      { \str_if_eq_p:Vn \l_@@_currenvir_str { center } }
      {
        \unskip
        \break
        \strut
        \hfill
        #2
        \para_end:
      }
      {
        {
          \unskip
          \hfil
          \penalty 50
          \skip_horizontal:n { #1 }
          \hbox:n {}
          \nobreak
          \hfill
          #2
          \skip_zero:N \parfillskip
          \int_zero:N \finalhyphendemerits
          \para_end:
        }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Formatting and printing quotation references}
%
% \begin{macro}{\l_@@_ref_box}
%   Box to hold the formatted reference.
%    \begin{macrocode}
\box_new:N \l_@@_ref_box
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_format_full_ref:n}
%   Format a scripture quotation with its reference.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_format_full_ref:n
  {
    \group_begin:
    \l_@@_ref_font_tl
    \str_if_eq:VnF \l_@@_ref_colour_tl { . }
      { \exp_args:NV \color_select:n \l_@@_ref_colour_tl }
    \@@_ref_format:n
      {
        #1
%    \end{macrocode}
% Append a Bible version if it has been specified.
%    \begin{macrocode}
        \tl_if_empty:NF \l_@@_version_tl
          {
            \tl_if_empty:nF { #1 }
              { \l_@@_version_delim_tl }
            \@@_version_format:n { \l_@@_version_tl }
          }
      }
    \group_end:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_reference:n}
%   Output the reference for the Scripture quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_reference:n
  {
    \hbox_set:Nn \l_@@_ref_box
      {
        \@@_format_full_ref:n { #1 }
      }
    \dim_compare:nNnT
      { \box_wd:N \l_@@_ref_box + \g_@@_final_line_dim + \l_@@_ref_sep_tl }
      >
      \linewidth
      {
        \skip_vertical:N \baselineskip
        \tl_if_eq:NnT \l_@@_ref_align_tl { left }
          {
            \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1
              { \skip_vertical:N \baselineskip }
          }
      }
    \tl_if_eq:NnTF \l_@@_ref_align_tl { right }
      { \hfill }
      {
        \dim_compare:nNnT
          { \box_wd:N \l_@@_ref_box + \g_@@_final_line_dim + \l_@@_ref_sep_tl }
          <
          \linewidth
          { \skip_horizontal:n { \g_@@_final_line_dim + \l_@@_ref_sep_tl } }
      }
    \box_use:N \l_@@_ref_box
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Red lettering}
%
% \begin{macro}{\g_@@_red_letter_active_bool}
%   Flag indicating if currently in a red letter block of text.
%    \begin{macrocode}
\bool_new:N \g_@@_red_letter_active_bool
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_red_letter_on:}
%   Mark the beginning of a section of text attributed to Jesus Christ.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_red_letter_on:
  {
    \bool_if:NT \l_@@_red_letter_bool
      {
        \bool_gset_true:N \g_@@_red_letter_active_bool
        \exp_args:NV \color_select:n \l_@@_red_letter_colour_tl
        \str_if_eq:VnF \l_@@_currenvir_str { scripture }
          {
            \hook_gput_next_code:nn { env / \l_@@_currenvir_str / after }
              {
                \exp_args:NV \color_select:n \l_@@_red_letter_colour_tl
              }
          }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_red_letter_off:}
%   Mark the beginning of a section of text attributed to Jesus Christ.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_red_letter_off:
  {
    \bool_if:NT \l_@@_red_letter_bool
      {
        \color_select:n { scripture default colour }
        \bool_gset_false:N \g_@@_red_letter_active_bool
        \str_if_eq:VnF \l_@@_currenvir_str { scripture }
          {
            \hook_gput_next_code:nn { env / \l_@@_currenvir_str / after }
              {
                \color_select:n { scripture default colour }
              }
          }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Selecting language}
%
% \begin{macro}{\@@_select_language:}
%   Select specified language if required.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_select_language:
  {
    \tl_if_empty:NF \l_@@_language_tl
      {
        \@ifpackageloaded { babel }
          {
            \selectlanguage { \l_@@_language_tl }
          }
          {
            \@ifpackageloaded { polyglossia }
              {
                \iflanguageloaded { \l_@@_language_tl }
                  {
                    \tl_if_empty:NTF \l_@@_language_variant_tl
                      {
                        \selectlanguage { \l_@@_language_tl }
                      }
                      {
                        \selectlanguage
                          [ variant = \l_@@_language_variant_tl ]
                          { \l_@@_language_tl }
                      }
                  }
                  {
                    \msg_error:nnx
                      { scripture }
                      { language-error }
                      { \l_@@_language_tl }
                  }
              }
              {
                \msg_warning:nnx
                  { scripture }
                  { language-warning }
                  { \l_@@_language_tl }
              }
          }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Formatting and printing chapter numbers}
%
% \begin{macro}{\l_@@_chap_box, l_@@_chap_tmp_box}
%   Boxes use to store and calculate drop chapter.
%    \begin{macrocode}
\box_new:N \l_@@_chap_box
\box_new:N \l_@@_chap_tmp_box
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_chap_fontsize_dim}
%   Calculated font size of a drop chapter number.
%    \begin{macrocode}
\dim_new:N \l_@@_chap_fontsize_dim
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_chap_height_dim}
%   Calculated height of a drop chapter number.
%    \begin{macrocode}
\dim_new:N \l_@@_chap_height_dim
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_chap_width_dim}
%   Calculated width of drop chapter number.
%    \begin{macrocode}
\dim_new:N \l_@@_chap_width_dim
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\g_@@_chap_par_prevgraf_int}
%   Store the number of lines a chapter paragraph takes up.
%    \begin{macrocode}
\int_new:N \g_@@_chap_par_prevgraf_int
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_chap_X_height_dim}
%   Calculated height of X at current font size. This is used as the height
%   for a drop chapter.
%    \begin{macrocode}
\dim_new:N \l_@@_chap_X_height_dim
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_drop_chap_set_up:n}
%   Set up chapter drop cap and calculate its various dimensions.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_drop_chap_set_up:n
  {
    \cs_gset_nopar:Npn \scripturecurrentchapter { #1 }
    \cs_gset_nopar:Npn \scripturecurrentverse { 1 }
    \hbox_set:Nn \l_@@_chap_tmp_box { X }
    \dim_set:Nn \l_@@_chap_X_height_dim
      { \box_ht:N \l_@@_chap_tmp_box }
    \dim_set:Nn \l_@@_chap_height_dim
      { \baselineskip + \l_@@_chap_X_height_dim }
    \dim_set:Nn \l_@@_chap_fontsize_dim
      {
        \f@size pt *
        \dim_ratio:nn
          { \l_@@_chap_height_dim }
          { \l_@@_chap_X_height_dim }
      }
    \hbox_set:Nn \l_@@_chap_tmp_box
      {
        \l_@@_chap_font_tl
        \fontsize
          { \l_@@_chap_fontsize_dim }
          { \l_@@_chap_fontsize_dim }
          \selectfont
        \str_if_eq:VnF \l_@@_chapter_colour_tl { . }
          { \exp_args:NV \color_select:n \l_@@_chapter_colour_tl }
        \@@_chap_format:n { #1 }
      }
    \dim_set:Nn \l_@@_chap_width_dim
      { \box_wd:N \l_@@_chap_tmp_box }
%    \end{macrocode}
%   Avoid breaks in the middle of drop chapters.
%    \begin{macrocode}
    \int_set_eq:NN \l_@@_clubpenalty_saved_int \clubpenalty
    \clubpenalty 10000
    \hook_gput_next_code:nn { para / after }
      {
        \int_gset_eq:NN \g_@@_chap_par_prevgraf_int \prevgraf
        \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1
          { \penalty 10000 }
        \hook_gput_next_code:nn { para / before }
          { \int_set_eq:NN \clubpenalty \l_@@_clubpenalty_saved_int }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_drop_chap_output:}
%   Output a drop chapter.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_drop_chap_output:
  {
    \noindent
    \parshape 3 ~
      \dim_eval:n
        { \@totalleftmargin + \l_@@_chap_width_dim + \l_@@_chap_sep_tl } ~
      \dim_eval:n
        { \linewidth - \l_@@_chap_width_dim - \l_@@_chap_sep_tl } ~
      \dim_eval:n
        { \@totalleftmargin + \l_@@_chap_width_dim + \l_@@_chap_sep_tl } ~
      \dim_eval:n
        { \linewidth - \l_@@_chap_width_dim - \l_@@_chap_sep_tl } ~
      \@totalleftmargin ~
      \linewidth
    \group_begin:
    \hook_use:n { scripture / chap / before }
    \box_use:N \l_@@_chap_box
    \hook_use:n { scripture / chap / after }
    \group_end:
    \bool_if:NT \l_@@_chap_show_verse_bool
      { \@@_verse_output:n { 1 } }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_nodrop_chap:n}
%   Format a non-drop chapter.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_nodrop_chap:n
  {
    \cs_gset_nopar:Npn \scripturecurrentchapter { #1 }
    \cs_gset_nopar:Npn \scripturecurrentverse { 1 }
    \group_begin:
    \bool_if:NTF \l_@@_chap_show_bool
      {
        \hook_use:n { scripture / chap / before }
        \group_begin:
        \str_if_eq:VnF \l_@@_chapter_colour_tl { . }
          { \exp_args:NV \color_select:n \l_@@_chapter_colour_tl }
        \l_@@_chap_font_tl
        \@@_chap_format:n { #1 }
        \group_end:
        \skip_horizontal:N \l_@@_chap_sep_tl
        \hook_use:n { scripture / chap / after }
        \bool_if:NT \l_@@_chap_show_verse_bool
          {
            \@@_verse_output:n { 1 }
          }
      }
      {
        \hook_use:n { scripture / chap / before }
        \hook_use:n { scripture / chap / after }
        \vs { 1 }
      }
    \group_end:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_chap:n}
%   Position a drop chapter.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_chap:n
  {
    \@@_drop_chap_set_up:n { #1 }
    \hbox_set:Nn \l_@@_chap_box
      {
        \box_move_down:nn
          { \baselineskip }
          { 
            \hbox_overlap_left:n
              {
                \box_use:N \l_@@_chap_tmp_box
                \skip_horizontal:N \l_@@_chap_sep_tl
              }
          }
      }
    \box_set_ht:Nn \l_@@_chap_box { \c_zero_dim }
    \box_set_dp:Nn \l_@@_chap_box { \c_zero_dim }
    \bool_if:NTF \l_@@_mid_para_chap_bool
      { \@@_mid_para_drop_chap_output: }
      {
        \par
        \@@_drop_chap_output:
      }
    \hook_gput_next_code:nn { para / before }
      {
        \legacy_if:nF { @newlist }
          {
            \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1
              { \extraskip }
            \int_gzero:N \g_@@_chap_par_prevgraf_int
          }
        \parshape 1 ~ \@totalleftmargin ~ \linewidth
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Formatting and printing verse numbers}
%
% \begin{macro}{\l_@@_verse_par_start_bool}
%   Flag for whether the current verse is at the start of a paragraph.
%    \begin{macrocode}
\bool_new:N \l_@@_verse_par_start_bool
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_no_verse_first_bool}
%   Suppress the next verse from formatting differently if it begins a new
%   paragraph.
%    \begin{macrocode}
\bool_new:N \l_@@_no_verse_first_bool
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_verse_output:n}
%   Output a formatted verse.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_verse_output:n
  {
    \cs_gset_nopar:Npn \scripturecurrentverse { #1 }
    \legacy_if:nTF { @endpe }
      { \bool_set_false:N \l_@@_verse_par_start_bool }
      { \bool_set_true:N \l_@@_verse_par_start_bool }
    \mode_if_vertical:TF
      { \mode_leave_vertical: }
      { \bool_set_false:N \l_@@_verse_par_start_bool }
    \bool_if:NT \l_@@_no_verse_first_bool
      {
        \bool_set_false:N \l_@@_verse_par_start_bool
        \bool_set_false:N \l_@@_no_verse_first_bool
      }
    \group_begin:
    \hook_use:n { scripture / verse / before }
    \bool_if:NT \l_@@_verse_show_bool
      {
        \group_begin:
        \l_@@_verse_font_tl
        \str_if_eq:VnF \l_@@_verse_colour_tl { . }
          { \exp_args:NV \color_select:n \l_@@_verse_colour_tl }
        \bool_lazy_all:nTF
          {
            { \l_@@_verse_first_bool }
            { \l_@@_verse_par_start_bool }
            { \bool_not_p:n { \str_if_eq_p:Vn \l_@@_currenvir_str { poetry } } }
          }
          {
            \@@_verse_first_format:n { #1 }
            \group_end:
            \kern \l_@@_verse_first_sep_tl
          }
          {
            \@@_verse_format:n { #1 }
            \group_end:
            \kern \l_@@_verse_sep_tl
          }
      }
    \hook_use:n { scripture / verse / after }
    \group_end:
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Calculating the length of the final line in a paragraph}
%
% \begin{macro}{\g_@@_final_line_dim}
%   Store the length of the final line in a paragraph.
%    \begin{macrocode}
\dim_new:N \g_@@_final_line_dim
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_calc_final_line_length:}
%   Calculate the length of the final line in a paragraph.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_calc_final_line_length:
  {
    \skip_set:Nn \abovedisplayshortskip { -\baselineskip }
    \skip_set_eq:NN \abovedisplayskip \abovedisplayshortskip
    \skip_zero:N \belowdisplayshortskip
    \skip_zero:N \belowdisplayskip
    $$
      \dim_compare:nNnT \predisplaysize > \c_zero_dim
        {
          \dim_gset:Nn \g_@@_final_line_dim
            { \predisplaysize - 2 em }
        }
      \cs_gset_nopar:Nx \@@_reset_spacing:
        {
          \dim_set:Nn \predisplaysize { \dim_use:N \predisplaysize }
          \int_set:Nn \prevgraf { \int_use:N \prevgraf }
        }
    $$
    \@@_reset_spacing:
    \dim_compare:nNnT \g_@@_final_line_dim > \paperwidth
      { \dim_gset:Nn \g_@@_final_line_dim { \@totalleftmargin + \linewidth } }
    \dim_compare:nNnT \g_@@_final_line_dim > { \c_zero_dim - 1 sp }
      { \skip_vertical:n { -\baselineskip - \parskip } }
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{The \env{scripture} environment}
%
% \begin{macro}{\l_@@_currenvir_str}
%   Store the current \pkg{scripture} environment.
%    \begin{macrocode}
\str_new:N \l_@@_currenvir_str
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_parskip_correction_skip}
%   Correction to ensure consistent \cs{parskip} at start of \env{scripture}
%   environment with non-zero \opt{parskip} option.
%    \begin{macrocode}
\skip_new:N \l_@@_parskip_correction_skip
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_added:n}
%   Mark text as added.
%    \begin{macrocode}
\cs_new_protected_nopar:Nn \@@_added:n
  {
    \group_begin:
    \l_@@_added_font_tl
    \@@_added_format:n { #1 }
    \group_end:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_name:n}
%   Output divine name.
%    \begin{macrocode}
\cs_new_protected_nopar:Nn \@@_name:n
  {
    \group_begin:
    \l_@@_name_font_tl
    \@@_name_format:n { #1 }
    \group_end:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_no_first_verse:}
%   Suppress special formatting for first verse if active.
%    \begin{macrocode}
\cs_new_protected_nopar:Nn \@@_no_first_verse:
  {
    \bool_set_true:N \l_@@_no_verse_first_bool
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_ch:nn}
%   Print a chapter number in the main scripture environment.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_ch_output:nn
  {
    \bool_if:NTF \l_@@_chap_show_bool
      {
        \bool_if:NTF \l_@@_chap_drop_bool
          {
            \@@_chap:n { #2 }
            \bool_if:nTF { #1 }
            {
              \hook_gput_next_code:nn { para / after }
                {
                  \int_gzero:N \g_@@_chap_par_prevgraf_int
                  \int_gzero:N \g_@@_mid_para_chap_prevgraf_int
                }
            }
            {
              \hook_gput_next_code:nn { para / after }
                { \int_gset_eq:NN \g_@@_mid_para_chap_prevgraf_int \prevgraf }
            }
          }
          { \@@_nodrop_chap:n { #2 } }
      }
      { \@@_nodrop_chap:n { #2 } }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_begin:n}
%   Begin a scripture quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_begin:n
  {
    \cs_set_eq:NN \@@_noindent_saved: \noindent
    \bool_if:NT \l_@@_active_bool
      {
        \msg_error:nn { scripture } { nested-environment }
      }
    \bool_set_true:N \l_@@_active_bool
    \tl_set:Nn \l_@@_currenvir_str { scripture }
    \tl_if_novalue:nF { #1 }
      {
        \keys_set:nn { scripture } { #1 }
      }
    \@@_select_language:
    \int_gzero:N \g_@@_chap_par_prevgraf_int
%    \end{macrocode}
% Empty \cs{everydisplay} to ensure it isn't interring with spacing.
%    \begin{macrocode}
    \everydisplay { }
    \int_set:Nn \predisplaypenalty { 10000 }
    \int_set_eq:NN \postdisplaypenalty \@lowpenalty
    \int_set:Nn \@beginparpenalty { -\@lowpenalty }
    \int_set_eq:NN \@endparpenalty \@lowpenalty
    \bool_gset_false:N \g_@@_poetry_end_bool
    \cs_set_eq:NN \extraskip \@@_extra_skip:
    \cs_set_eq:NN \redletteron \@@_red_letter_on:
    \cs_set_eq:NN \redletteroff \@@_red_letter_off:
    \DeclareDocumentCommand { \ch } { sm }
      { \@@_ch_output:nn { ##1 } { ##2 } }
    \cs_set_eq:NN \vs \@@_verse_output:n
    \cs_set_eq:NN \added \@@_added:n
    \cs_set_eq:NN \name \@@_name:n
    \cs_set_protected_nopar:Npn \LORD { \name { Lord } }
    \cs_set_protected_nopar:Npn \GOD { \name { God } }
    \cs_set_eq:NN \nofirstverse \@@_no_first_verse:
    \cs_set_protected_nopar:Npn \textright ##1
      { \@@_text_right:nn { \l_@@_text_right_sep_tl } { ##1 } }
    \hook_gclear_next_code:n { para / before }
    \l_@@_font_tl
    \exp_args:NnV \color_set:nn { scripture default colour } \l_@@_colour_tl
    \str_if_eq:VnF \l_@@_colour_tl { . }
      { \color_select:n { scripture default colour } }
    \bool_if:NTF \l_@@_inline_bool
      { \l_@@_inline_begin_tl }
      {
        \legacy_if:nTF { @newlist }
          { \dim_set_eq:NN \l_@@_outer_itemindent_dim \itemindent }
          { \dim_zero:N \l_@@_outer_itemindent_dim }
        \list { }
          {
            \dim_set_eq:NN \leftmargin \l_@@_leftmargin_tl
            \dim_set_eq:NN \rightmargin \l_@@_rightmargin_tl
            \dim_set:Nn \itemindent { \l_@@_parindent_tl - \l_@@_outer_itemindent_dim }
            \dim_set_eq:NN \listparindent \l_@@_parindent_tl
            \skip_zero:N \partopsep
            \skip_set_eq:NN \parsep \l_@@_parskip_tl
            \dim_compare:nNnTF \parskip > \l_@@_aboveskip_tl
              { \skip_zero:N \topsep }
              { \skip_set:Nn \topsep { \@@_skip_diff:NN \l_@@_aboveskip_tl \parskip } }
            \@@_setup_list_noindent:n { \l_@@_parindent_tl }
            \bool_if:NF \l_@@_indent_bool
              {
                \hook_gput_next_code:nn { para / begin }
                  {
                    \bool_lazy_any:nT
                      {
                        { \str_if_eq_p:Vn \l_@@_currenvir_str { midparachap } }
                        { \str_if_eq_p:Vn \l_@@_currenvir_str { narrow } }
                        { \str_if_eq_p:Vn \l_@@_currenvir_str { scripture } }
                      }
                      {
                        \legacy_if:nTF { @noparlist }
                          { \noindent }
                          { \para_omit_indent: }
                      }
                  }
              }
          }
        \dim_set_eq:NN \parindent \l_@@_parindent_tl
        \item
        \relax
    }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_end:n}
%   End a scripture quotation with a reference.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_end:n
  {
    \bool_if:NTF \l_@@_inline_bool
      {
        \unskip
        \@@_red_letter_off:
        \l_@@_inline_end_tl
        \bool_lazy_or:nnTF
          { \tl_if_novalue_p:n { #1 } }
          { \tl_if_empty_p:n { #1 } }
          {
            \tl_if_empty:NF \l_@@_version_tl
              {
                \skip_horizontal:N \l_@@_ref_sep_tl
                \@@_format_full_ref:n { }
              }
          }
          {
            \skip_horizontal:N \l_@@_ref_sep_tl
            \@@_format_full_ref:n { #1 }
          }
      }
      {
        \@@_red_letter_off:
        \skip_zero:N \parskip
        \int_set:Nn \postdisplaypenalty { 10000 }
        \@@_calc_final_line_length:
        \dim_gsub:Nn \g_@@_final_line_dim \@totalleftmargin
        \dim_compare:nNnTF \@outerparskip > \l_@@_belowskip_tl
          { \skip_zero:N \@topsepadd }
          { \skip_set:Nn \@topsepadd { \@@_skip_diff:NN \l_@@_belowskip_tl \@outerparskip } }
%    \end{macrocode}
% If a \env{scripture} quotation ends with an inner environment, remove the
% below skip of the inner environment.
%    \begin{macrocode}
        \int_compare:nNnT \prevgraf = \c_zero_int
          { \skip_vertical:n { -\g_@@_prev_inner_below_skip } }
        \hook_gclear_next_code:n { para / before }
        \parshape 1 ~ \@totalleftmargin ~ \linewidth
        \noindent
        \bool_lazy_or:nnTF
          { \tl_if_novalue_p:n { #1 } }
          { \tl_if_empty_p:n { #1 } }
          { 
            \tl_if_empty:NTF \l_@@_version_tl
              { \hbox:n { } }
              { \@@_reference:n { } }
          }
          { \@@_reference:n { #1 } }
%    \end{macrocode}
% Set \val{@noparlist} to \val{false} to ensure \cs{topsep} is always added
% \env{scripture} environment
%    \begin{macrocode}
        \@noparlistfalse
        \endlist
      }
    \cs_set_eq:NN \noindent \@@_noindent_saved:
  }
%    \end{macrocode}
% \end{macro}
%
% \subsection{Scripture internal environments}
%
% \subsubsection{The \env{center} environment}
%
% \begin{macro}{\@@_center_begin:n}
%   Begin a centred section in a scripture quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_center_begin:n
  {
    \bool_if:NT \l_@@_active_inner_bool
      {
        \msg_error:nn { scripture } { nested-environment }
      }
    \bool_set_true:N \l_@@_active_inner_bool
    \tl_set:Nn \l_@@_currenvir_str { center }
    \tl_if_novalue:nF { #1 }
      {
        \keys_set:nn
          { scripture / center }
          { #1 }
      }
    \legacy_if:nTF { @newlist }
      { \dim_add:Nn \l_@@_outer_itemindent_dim \itemindent }
      { \dim_zero:N \l_@@_outer_itemindent_dim }
    \list { }
      {
%    \end{macrocode}
% Ignore \opt{aboveskip} if at the beginning of a \env{scripture} environment.
%    \begin{macrocode}
        \dim_zero:N \labelsep
        \dim_set_eq:NN \leftmargin \l_@@_center_leftmargin_tl
        \dim_set_eq:NN \rightmargin \l_@@_center_rightmargin_tl
        \dim_set:Nn \itemindent { -\l_@@_outer_itemindent_dim }
        \dim_zero:N \listparindent
        \skip_set_eq:NN \parsep \parskip
        \skip_zero:N \partopsep
        \dim_compare:nNnTF \parskip > \l_@@_center_aboveskip_tl
          { \skip_zero:N \topsep }
          { \skip_set:Nn \topsep { \@@_skip_diff:NN \l_@@_center_aboveskip_tl \parskip } }
        \@@_setup_list_noindent:n { \c_zero_dim }
      }
    \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1
      { \addvspace { \baselineskip } }
    \int_gzero:N \g_@@_chap_par_prevgraf_int
    \centering
    \item
    \relax
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_center_end:}
%   End a centred section in a scripture quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_center_end:
  {
    \dim_gset:Nn \g_@@_final_line_dim { \@totalleftmargin + \linewidth }
    \dim_compare:nNnTF \@outerparskip > \l_@@_center_belowskip_tl
      { \skip_zero:N \@topsepadd }
      { \skip_set:Nn \@topsepadd { \@@_skip_diff:NN \l_@@_center_belowskip_tl \@outerparskip } }
    \skip_gset_eq:NN \g_@@_prev_inner_below_skip \@topsepadd
    \legacy_if_set_false:n { @noparlist }
    \endlist
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{The \env{flushright} environment}
%
% \begin{macro}{\@@_flushright_begin:n}
%   Begin a flushright section in a scripture quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_flushright_begin:n
  {
    \bool_if:NT \l_@@_active_inner_bool
      {
        \msg_error:nn { scripture } { nested-environment }
      }
    \bool_set_true:N \l_@@_active_inner_bool
    \tl_set:Nn \l_@@_currenvir_str { flushright }
    \tl_if_novalue:nF { #1 }
      {
        \keys_set:nn
          { scripture / flushright }
          { #1 }
      }
    \legacy_if:nTF { @newlist }
      { \dim_add:Nn \l_@@_outer_itemindent_dim \itemindent }
      { \dim_zero:N \l_@@_outer_itemindent_dim }
    \list { }
      {
%    \end{macrocode}
% Ignore \opt{aboveskip} if at the beginning of a \env{scripture} environment.
%    \begin{macrocode}
        \dim_zero:N \labelsep
        \dim_set_eq:NN \leftmargin \l_@@_flushright_leftmargin_tl
        \dim_set_eq:NN \rightmargin \l_@@_flushright_rightmargin_tl
        \dim_set:Nn \itemindent { -\l_@@_outer_itemindent_dim }
        \dim_zero:N \listparindent
        \skip_set_eq:NN \parsep \parskip
        \skip_zero:N \partopsep
        \dim_compare:nNnTF \parskip > \l_@@_flushright_aboveskip_tl
          { \skip_zero:N \topsep }
          { \skip_set:Nn \topsep { \@@_skip_diff:NN \l_@@_flushright_aboveskip_tl \parskip } }
        \@@_setup_list_noindent:n { \c_zero_dim }
      }
    \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1
      { \addvspace { \baselineskip } }
    \int_gzero:N \g_@@_chap_par_prevgraf_int
    \raggedleft
    \item
    \relax
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_flushright_end:}
%   End a flushright section in a scripture quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_flushright_end:
  {
    \dim_gset:Nn \g_@@_final_line_dim { \@totalleftmargin + \linewidth }
    \dim_compare:nNnTF \@outerparskip > \l_@@_flushright_belowskip_tl
      { \skip_zero:N \@topsepadd }
      { \skip_set:Nn \@topsepadd { \@@_skip_diff:NN \l_@@_flushright_belowskip_tl \@outerparskip } }
    \skip_gset_eq:NN \g_@@_prev_inner_below_skip \@topsepadd
    \legacy_if_set_false:n { @noparlist }
    \endlist
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{The \env{hanging} environment}
%
% \begin{macro}{\l_@@_hanging_parindent_saved_dim}
%   Save the \cs{parindent} for later use in \env{hanging} environment.
%    \begin{macrocode}
\dim_new:N \l_@@_hanging_parindent_saved_dim
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_hanging_ch:n}
%   Position a chapter in a \env{hanging} environment.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_hanging_ch:n
  {
    \bool_if:NTF \l_@@_chap_show_bool
      {
        \bool_if:NTF \l_@@_chap_drop_bool
          { \@@_hanging_chap:n { #1 } }
          { \@@_nodrop_chap:n { #1 } }
      }
      { \@@_nodrop_chap:n { #1 } }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_hanging_chap:n}
%   Position a drop chapter in a \env{hanging} environment.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_hanging_chap:n
  {
    \@@_drop_chap_set_up:n { #1 }
    \dim_compare:nNnTF
      \l_@@_chap_width_dim < \leftmargin
      {
        \tl_set:Nx \l_@@_chap_sep_tl
          {
            \dim_eval:n { \leftmargin - \l_@@_chap_width_dim }
          }
      }
      {
        \parshape 3 ~
          \dim_eval:n
            {
              \@totalleftmargin - \leftmargin + \l_@@_chap_width_dim +
              \l_@@_chap_sep_tl
            } ~
          \dim_eval:n
            {
              \linewidth + \leftmargin - \l_@@_chap_width_dim -
              \l_@@_chap_sep_tl
            } ~
          \dim_eval:n
            {
              \@totalleftmargin - \leftmargin + \l_@@_chap_width_dim +
              \l_@@_chap_sep_tl
            } ~
          \dim_eval:n
            {
              \linewidth + \leftmargin - \l_@@_chap_width_dim -
              \l_@@_chap_sep_tl
            } ~
          \@totalleftmargin ~ \linewidth
      }
    \tl_set:Nx \l_@@_chap_sep_tl
      {
        \dim_eval:n
          {
            \l_@@_chap_sep_tl + \l_@@_hanging_parindent_saved_dim
          }
      }
    \par
    \@@_nohang:
    \hbox_set:Nn \l_@@_chap_box
      {
        \box_move_down:nn
          { \baselineskip }
          { 
            \hbox_overlap_left:n
              {
                \box_use:N \l_@@_chap_tmp_box
                \skip_horizontal:N \l_@@_chap_sep_tl
              }
          }
      }
    \box_set_ht:Nn \l_@@_chap_box { \c_zero_dim }
    \box_set_dp:Nn \l_@@_chap_box { \c_zero_dim }
    \group_begin:
    \hook_use:n { scripture / chap / before }
    \box_use:N \l_@@_chap_box
    \hook_use:n { scripture / chap / after }
    \group_end:
    \bool_if:NT \l_@@_chap_show_verse_bool
      {
        \@@_verse_output:n { 1 }
      }
    \hook_gput_next_code:nn { para / begin }
      { \parshape 1 ~ \@totalleftmargin ~ \linewidth }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_hanging_verse:n}
%   Position a \cs{vs} in a \env{hanging} environment. The verse is set to
%   overlap to the left if at the beginning of a hanging paragraph.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_hanging_verse:n
  {
    \mode_if_vertical:TF
      {
        \strut
        \hbox_overlap_left:n
          {
            \@@_verse_output:n { #1 }
          }
      }
      { \@@_verse_output:n { #1 } }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_nohang:}
%   Don't hang a paragraph in a \env{hanging} environment. Instead the
%   paragraph is indented by \cs{parindent} from its normal hanging position.
%    \begin{macrocode}
\cs_new_protected_nopar:Nn \@@_nohang:
  {
    \noindent
    \hbox_to_wd:nn { \l_@@_hanging_parindent_saved_dim } { }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_hanging_begin:n}
%   Begin a hanging section in a scripture quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_hanging_begin:n
  {
    \bool_if:NT \l_@@_active_inner_bool
      {
        \msg_error:nn { scripture } { nested-environment }
      }
    \bool_set_true:N \l_@@_active_inner_bool
    \tl_set:Nn \l_@@_currenvir_str { hanging }
    \tl_if_novalue:nF { #1 }
      {
        \keys_set:nn
          { scripture / hanging }
          { #1 }
      }
    \DeclareDocumentCommand { \ch } { sm } { \@@_hanging_ch:n { ##2 } }
    \cs_set_eq:NN \vs \@@_hanging_verse:n
    \cs_set_eq:NN \nohang \@@_nohang:
    \dim_set_eq:NN \l_@@_hanging_parindent_saved_dim \parindent
    \legacy_if:nTF { @newlist }
      { \dim_add:Nn \l_@@_outer_itemindent_dim \itemindent }
      { \dim_zero:N \l_@@_outer_itemindent_dim }
    \list { }
      {
%    \end{macrocode}
% Ignore \opt{aboveskip} if at the beginning of a \env{scripture} environment.
%    \begin{macrocode}
        \dim_zero:N \labelsep
        \dim_set:Nn \leftmargin { \l_@@_hanging_leftmargin_tl + \l_@@_hanging_hang_tl }
        \dim_set_eq:NN \rightmargin \l_@@_hanging_rightmargin_tl
        \dim_set:Nn \itemindent { -\l_@@_hanging_hang_tl - \l_@@_outer_itemindent_dim }
        \dim_set:Nn \listparindent { -\l_@@_hanging_hang_tl }
        \skip_set_eq:NN \parsep \parskip
        \skip_zero:N \partopsep
        \dim_compare:nNnTF \parskip > \l_@@_hanging_aboveskip_tl
          { \skip_zero:N \topsep }
          { \skip_set:Nn \topsep { \@@_skip_diff:NN \l_@@_hanging_aboveskip_tl \parskip } }
        \@@_setup_list_noindent:n { -\l_@@_hanging_hang_tl }
      }
    \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1
      { \addvspace { \baselineskip } }
    \int_gzero:N \g_@@_chap_par_prevgraf_int
    \item
    \relax
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_hanging_end:}
%   End a hanging section in a scripture quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_hanging_end:
  {
    \@@_calc_final_line_length:
    \dim_compare:nNnTF \@outerparskip > \l_@@_hanging_belowskip_tl
      { \skip_zero:N \@topsepadd }
      { \skip_set:Nn \@topsepadd { \@@_skip_diff:NN \l_@@_hanging_belowskip_tl \@outerparskip } }
    \skip_gset_eq:NN \g_@@_prev_inner_below_skip \@topsepadd
    \legacy_if_set_false:n { @noparlist }
    \endlist
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{The \env{midparachap} environment}
%
% \begin{macro}{\@@_vbox_set_top:Nw}
%   Define missing \cs{vbox_set_top:Nw} function.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_vbox_set_top:Nw #1
  {
    \tex_setbox:D #1 \tex_vtop:D
      \c_group_begin_token
        \color_group_begin:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_mid_para_chap_bool}
%   Flag if setting a paragraph containing a mid-paragraph chapter.
%    \begin{macrocode}
\bool_new:N \l_@@_mid_para_chap_bool
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_mid_para_chap_line_box}
%   Store last line before a mid-paragraph chapter.
%    \begin{macrocode}
\box_new:N \l_@@_mid_para_chap_line_box
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\g_@@_mid_para_chap_prevdepth_dim}
%   Store the \cs{prevdepth} of the final paragraph in a \env{midparachap}
%   environment.
%    \begin{macrocode}
\dim_new:N \g_@@_mid_para_chap_prevdepth_dim
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_mid_para_chap_totalleftmargin_dim}
%   Save the \cs{@totalleftmargin} before starting a \env{midparachap}
%   environment.
%    \begin{macrocode}
\dim_new:N \l_@@_mid_para_chap_totalleftmargin_dim
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\g_@@_mid_para_chap_prevgraf_int}
%   Store the \cs{prevgraf} of the final paragraph in a \env{midparachap}
%   environment.
%    \begin{macrocode}
\int_new:N \g_@@_mid_para_chap_prevgraf_int
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_mid_para_chap_snap_box}
%   Store unpacked last line before a mid-paragraph chapter.
%    \begin{macrocode}
\box_new:N \l_@@_mid_para_chap_snap_box
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_mid_para_chap_spacefactor_int}
%   Store space factor before a mid-paragraph chapter.
%    \begin{macrocode}
\int_new:N \l_@@_mid_para_chap_spacefactor_int
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_mid_para_chap_box,
%               \l_@@_mid_para_chap_split_box,
%               \l_@@_mid_para_chap_split_top_box}
%   Boxes containing a paragraph with a chapter break and its split if needed.
%    \begin{macrocode}
\box_new:N \l_@@_mid_para_chap_box
\box_new:N \l_@@_mid_para_chap_split_box
\box_new:N \l_@@_mid_para_chap_split_top_box
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_mid_para_drop_chap_output:}
%   Output a mid-paragraph drop chapter.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_mid_para_drop_chap_output:
  {
    \unskip
    \int_set_eq:NN \l_@@_mid_para_chap_spacefactor_int \spacefactor
    \strut
    \par
    \box_set_to_last:N \l_@@_mid_para_chap_line_box
    \hbox_set:Nn \l_@@_mid_para_chap_snap_box
      {
        \hbox_unpack_drop:N \l_@@_mid_para_chap_line_box
        \unskip
        \unskip
        \unpenalty
      }
    \nointerlineskip
    \dim_compare:nNnTF
      {
        \box_wd:N \l_@@_mid_para_chap_snap_box +
        \l_@@_chap_width_dim +
        \l_@@_chap_sep_tl
      }
      <
      { \linewidth - \leftskip - \rightskip - 3 em }
      {
        \@@_drop_chap_output:
        \hbox_unpack_drop:N \l_@@_mid_para_chap_snap_box
        \int_set_eq:NN \spacefactor \l_@@_mid_para_chap_spacefactor_int
        \c_space_tl
        \@@_verse_output:n { 1 }
      }
      {
        \group_begin:
        \noindent
        \skip_horizontal:n { -\leftskip }
        \hbox_unpack_drop:N \l_@@_mid_para_chap_snap_box
        \skip_zero:N \parfillskip
        \par
        \group_end:
        \@@_drop_chap_output:
        \bool_if:NT \l_@@_midparachap_show_verse_bool
          {
            \@@_verse_output:n { 1 }
          }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_mid_para_chap_begin:n}
%   Begin a paragraph containing a mid-paragraph chapter.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_mid_para_chap_begin:n
  {
    \tl_set:Nn \l_@@_currenvir_str { midparachap }
    \tl_if_novalue:nF { #1 }
      {
        \keys_set:nn
          { scripture / midparachap }
          { #1 }
      }
    \bool_lazy_and:nnT
      { \bool_if_p:n \l_@@_chap_show_verse_bool }
      { \bool_if_p:n \l_@@_chap_drop_bool }
      {
        \bool_set_true:N \l_@@_midparachap_show_verse_bool
        \bool_set_false:N \l_@@_chap_show_verse_bool
      }
    \par
    \bool_set_true:N \l_@@_mid_para_chap_bool
    \@@_vbox_set_top:Nw \l_@@_mid_para_chap_box
    \dim_zero:N \leftskip
    \dim_zero:N \rightskip
    \dim_set_eq:NN \l_@@_mid_para_chap_totalleftmargin_dim \@totalleftmargin
    \dim_zero:N \@totalleftmargin
    \dim_set_eq:NN \hsize \linewidth
    \skip_zero:N \parskip
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_mid_para_chap_end:}
%   End a paragraph containing a mid-paragraph chapter.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_mid_para_chap_end:
  {
    \par
    \dim_gset_eq:NN \g_@@_mid_para_chap_prevdepth_dim \prevdepth
    \box_set_to_last:N \l_@@_mid_para_chap_line_box
    \hbox_set:Nn \l_@@_mid_para_chap_snap_box
      {
        \hbox_unpack:N \l_@@_mid_para_chap_line_box
        \unskip
        \unskip
        \unpenalty
      }
    \dim_gset:Nn \g_@@_final_line_dim
      { \box_wd:N \l_@@_mid_para_chap_snap_box + \l_@@_mid_para_chap_totalleftmargin_dim }
    \box_clear:N \l_@@_mid_para_chap_snap_box
    \nointerlineskip
    \int_compare:nNnT
      \prevgraf < 3
      {
        \noindent
        \skip_horizontal:n { \l_@@_chap_width_dim + \l_@@_chap_sep_tl }
        \dim_gadd:Nn \g_@@_final_line_dim { \l_@@_chap_width_dim + \l_@@_chap_sep_tl }
      }
    \box_use_drop:N \l_@@_mid_para_chap_line_box
    \vbox_set_end:
%    \end{macrocode}
% Attempt to allow the mid-paragraph chapter box to break across pages.
%    \begin{macrocode}
    \mode_if_inner:TF
      {
        \noindent
        \box_use_drop:N \l_@@_mid_para_chap_box
      }
      {
        \dim_compare:nNnTF
          { \box_ht_plus_dp:N \l_@@_mid_para_chap_box }
          >
          { \pagegoal - \pagetotal - \baselineskip }
          {
            \int_set:Nn \vbadness { 10000 }
            \vbox_set_split_to_ht:NNn
              \l_@@_mid_para_chap_split_box \l_@@_mid_para_chap_box
              { \pagegoal - \pagetotal - \baselineskip }
            \vbox_set_top:Nn \l_@@_mid_para_chap_split_top_box
              { \vbox_unpack_drop:N \l_@@_mid_para_chap_split_box }
            \noindent
            \box_use_drop:N \l_@@_mid_para_chap_split_top_box
            \goodbreak
            \box_use_drop:N \l_@@_mid_para_chap_box
          }
          {
            \noindent
            \box_use_drop:N \l_@@_mid_para_chap_box
          }
      }
    \par
    \dim_set_eq:NN \prevdepth \g_@@_mid_para_chap_prevdepth_dim
    \int_zero:N \prevgraf
    \skip_vertical:n { -\parskip - \baselineskip }
    \noindent
    \skip_horizontal:N \g_@@_final_line_dim
    \int_gset_eq:NN \g_@@_chap_par_prevgraf_int \g_@@_mid_para_chap_prevgraf_int
    \hook_gput_next_code:nn { para / before }
      {
        \int_gzero:N \g_@@_chap_par_prevgraf_int
        \parshape 1 ~ \@totalleftmargin ~ \linewidth
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{The \env{narrow} environment}
%
% \begin{macro}{\@@_narrow_begin:n}
%   Begin a narrow section in a scripture quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_narrow_begin:n
  {
    \bool_if:NT \l_@@_active_inner_bool
      {
        \msg_error:nn { scripture } { nested-environment }
      }
    \bool_set_true:N \l_@@_active_inner_bool
    \tl_set:Nn \l_@@_currenvir_str { narrow }
    \tl_if_novalue:nF { #1 }
      {
        \keys_set:nn
          { scripture / narrow }
          { #1 }
      }
    \legacy_if:nTF { @newlist }
      { \dim_add:Nn \l_@@_outer_itemindent_dim \itemindent }
      { \dim_zero:N \l_@@_outer_itemindent_dim }
    \list { }
      {
%    \end{macrocode}
% Ignore \opt{aboveskip} if at the beginning of a \env{scripture} environment.
%    \begin{macrocode}
        %\int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1
        %  { \addvspace { \baselineskip } }
        %\int_gzero:N \g_@@_chap_par_prevgraf_int
        \dim_zero:N \labelsep
        \dim_set_eq:NN \leftmargin \l_@@_narrow_leftmargin_tl
        \dim_set_eq:NN \rightmargin \l_@@_narrow_rightmargin_tl
        \dim_set_eq:NN \listparindent \parindent
        \mode_if_vertical:TF
          {
            \dim_set:Nn \itemindent { \parindent - \l_@@_outer_itemindent_dim }
            \@@_setup_list_noindent:n { \parindent }
          }
          {
            \dim_set:Nn \itemindent { -\l_@@_outer_itemindent_dim }
            \@@_setup_list_noindent:n { \c_zero_dim }
          }
        \skip_set_eq:NN \parsep \parskip
        \skip_zero:N \partopsep
        \dim_compare:nNnTF \parskip > \l_@@_narrow_aboveskip_tl
          { \skip_zero:N \topsep }
          { \skip_set:Nn \topsep { \@@_skip_diff:NN \l_@@_narrow_aboveskip_tl \parskip } }
      }
    \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1
      { \addvspace { \baselineskip } }
    \int_gzero:N \g_@@_chap_par_prevgraf_int
    \item
    \relax
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_narrow_end:}
%   End a narrow section in a scripture quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_narrow_end:
  {
    \@@_calc_final_line_length:
    \dim_compare:nNnTF \@outerparskip > \l_@@_narrow_belowskip_tl
      { \skip_zero:N \@topsepadd }
      { \skip_set:Nn \@topsepadd { \@@_skip_diff:NN \l_@@_narrow_belowskip_tl \@outerparskip } }
    \skip_gset_eq:NN \g_@@_prev_inner_below_skip \@topsepadd
    \legacy_if_set_false:n { @noparlist }
    \endlist
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{The \env{poetry} environment}
%
% \begin{hooks}{scripture/poetry/para/after}
%   This hook is an internal hook used to adjust the \cs{parshape} within a
%   \env{poetry} environment after drop chapter numbers.
%    \begin{macrocode}
\hook_new:n { scripture / poetry / para / after }
%    \end{macrocode}
% \end{hooks}
%
% \begin{macro}{\g_@@_poetry_end_bool}
%   Flag indicating that a \env{poetry} environment just ended.
%    \begin{macrocode}
\bool_new:N \g_@@_poetry_end_bool
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\g_@@_poetry_midparachap_show_verse_bool}
%   Flag indicating whether the verse number should be printed immediately
%   after a \cs{ch} or not in a \env{poetry} environment.
%    \begin{macrocode}
\bool_new:N \g_@@_poetry_midparachap_show_verse_bool
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_poetry_chap_indent_dim, \l_@@_poetry_chap_sep_dim}
%   Store calculated indent and sep when a drop chapter appears in a
%   \env{poetry} environment.
%    \begin{macrocode}
\dim_new:N \l_@@_poetry_chap_indent_dim
\dim_new:N \l_@@_poetry_chap_sep_dim
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_poetry_chap_parshape_correction_dim}
%   Correction to \cs{parshape} in chapter affected lines in a \env{poetry}
%   environment.
%    \begin{macrocode}
\dim_new:N \l_@@_poetry_chap_parshape_correction_dim
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_poetry_prevgraf_int}
%   Store the number of lines a line of poetry takes up.
%    \begin{macrocode}
\int_new:N \l_@@_poetry_prevgraf_int
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_poetry_extra_skip:}
%   Insert a little extra vertical space between two lines in a \env{poetry}
%   environment.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_poetry_extra_skip:
  {
    \skip_vertical:n { \l_@@_extraskip_tl - \baselineskip - \parskip }
    \bool_gset_false:N \g_@@_poetry_midparachap_show_verse_bool
    \strut
    \hook_gput_next_code:nn { para / after }
      {
        \hook_gput_next_code:nn { para / after }
          {
            \bool_gset_eq:NN
              \g_@@_poetry_midparachap_show_verse_bool
              \l_@@_midparachap_show_verse_bool
          }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_poetry_text_right:nn}
%   Align a word to the right and finish a paragraph, pushing to the next line
%   if there is not space for the word.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_poetry_text_right:nn
  {
    {
      \unskip
      \hfil
      \penalty 50
      \skip_horizontal:n { #1 }
      \hbox:n {}
      \nobreak
      \hfill
      #2
      \skip_zero:N \parfillskip
      \int_zero:N \finalhyphendemerits
    }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_selah_output:}
%   Output Selah at the end of a line.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_selah_output:
  {
    \group_begin:
    \l_@@_selah_font_tl
    \@@_poetry_text_right:nn
      { \l_@@_selah_sep_tl }
      { \@@_selah_format:n { \l_@@_selah_text_tl } }
    \group_end:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_poetry_ch:n}
%   Position a chapter in a \env{poetry} environment.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_poetry_ch:n
  {
    \bool_if:NTF \l_@@_chap_show_bool
      {
        \bool_if:NTF \l_@@_chap_drop_bool
          { \@@_poetry_chap:n { #1 } }
          { \@@_poetry_nodrop_chap:n { #1 } }
      }
      { \@@_poetry_nodrop_chap:n { #1 } }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_poetry_chap:n}
%   Position a drop chapter in a \env{poetry} environment.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_poetry_chap:n
  {
    \@@_drop_chap_set_up:n { #1 }
    \mode_if_vertical:TF
      {
        \dim_set_eq:NN \l_@@_poetry_chap_indent_dim \l_@@_poetry_indent_tl
        \mode_leave_vertical:
      }
      { \dim_zero:N \l_@@_poetry_chap_indent_dim }
    \dim_set_eq:NN \l_@@_poetry_chap_sep_dim \l_@@_chap_sep_tl
    \dim_compare:nNnT
      { \l_@@_chap_width_dim + \l_@@_chap_sep_tl }
      <
      { \l_@@_poetry_leftmargin_tl + \l_@@_poetry_chap_indent_dim }
      {
        \dim_set:Nn \l_@@_poetry_chap_sep_dim
          {
            \l_@@_poetry_leftmargin_tl + \l_@@_poetry_chap_indent_dim -
            \l_@@_chap_width_dim
          }
      }
    \hbox_set:Nn \l_@@_chap_box
      {
        \box_move_down:nn
          { \baselineskip }
          { 
            \hbox_overlap_left:n
              {
                \box_use:N \l_@@_chap_tmp_box
                \skip_horizontal:N \l_@@_poetry_chap_sep_dim
              }
          }
      }
    \box_set_ht:Nn \l_@@_chap_box { \c_zero_dim }
    \box_set_dp:Nn \l_@@_chap_box { \c_zero_dim }
    \dim_set:Nn \l_@@_poetry_chap_parshape_correction_dim
      {
        \l_@@_chap_width_dim + \l_@@_poetry_chap_sep_dim -
        \l_@@_poetry_leftmargin_tl - \l_@@_poetry_chap_indent_dim
      }
    \parshape 2 ~
      \dim_eval:n
        { \@totalleftmargin + \l_@@_poetry_chap_parshape_correction_dim } ~
      \dim_eval:n
        { \linewidth - \l_@@_poetry_chap_parshape_correction_dim } ~
      \dim_eval:n
        { \@totalleftmargin + \l_@@_poetry_big_indent_tl } ~
      \dim_eval:n
        { \linewidth - \l_@@_poetry_big_indent_tl }
%    \end{macrocode}
%   Because of interactions with \LaTeX{} \env{list} environments and
%   \cs{@@_obeylines:}, \cs{@@_poetry_par:} setting the \cs{parshape} for the
%   second line after a drop chapter number is more difficult than it should
%   be. There's probably a better way.
%    \begin{macrocode}
    \dim_compare:nNnT
      { \l_@@_chap_width_dim + \l_@@_poetry_chap_sep_dim }
      >
      \l_@@_poetry_leftmargin_tl
      {
        \hook_gput_next_code:nn { scripture / poetry / para / after }
          {
            \int_compare:nNnT \l_@@_poetry_prevgraf_int = 1
              {
%    \end{macrocode}
%   This \cs{parshape} is in effect when the next line is the second half of a
%   poetry verse.
%    \begin{macrocode}
                \dim_compare:nNnTF
                  { \l_@@_chap_width_dim + \l_@@_chap_sep_tl }
                  <
                  { \l_@@_poetry_leftmargin_tl + \l_@@_poetry_indent_tl }
                  { \dim_zero:N \l_@@_poetry_chap_parshape_correction_dim }
                  {
                    \dim_set:Nn \l_@@_poetry_chap_parshape_correction_dim
                      {
                        \l_@@_chap_width_dim + \l_@@_chap_sep_tl -
                        \l_@@_poetry_leftmargin_tl - \l_@@_poetry_indent_tl
                      }
                  }
                \parshape 2 ~
                  \dim_eval:n
                    { \@totalleftmargin + \l_@@_poetry_chap_parshape_correction_dim } ~
                  \dim_eval:n
                    { \linewidth - \l_@@_poetry_chap_parshape_correction_dim } ~
                  \dim_eval:n
                    { \@totalleftmargin + \l_@@_poetry_big_indent_tl } ~
                  \dim_eval:n
                    { \linewidth - \l_@@_poetry_big_indent_tl }
                \hook_gput_next_code:nn { para / after }
                  {
                    \hook_gclear_next_code:n { scripture / poetry / para / after }
                  }
                \hook_gput_next_code:nn { scripture / poetry / para / after }
                  {
%    \end{macrocode}
%   This \cs{parshape} is in effect when the next line is the first half of a
%   poetry verse.
%    \begin{macrocode}
                    \dim_compare:nNnTF
                      { \l_@@_chap_width_dim + \l_@@_chap_sep_tl }
                      <
                      \l_@@_poetry_leftmargin_tl
                      { \dim_zero:N \l_@@_poetry_chap_parshape_correction_dim }
                      {
                        \dim_set:Nn \l_@@_poetry_chap_parshape_correction_dim
                          {
                            \l_@@_chap_width_dim + \l_@@_chap_sep_tl -
                            \l_@@_poetry_leftmargin_tl
                          }
                      }
                    \parshape 2 ~
                      \dim_eval:n
                        { \@totalleftmargin + \l_@@_poetry_chap_parshape_correction_dim } ~
                      \dim_eval:n
                        { \linewidth - \l_@@_poetry_chap_parshape_correction_dim } ~
                      \dim_eval:n
                        { \@totalleftmargin + \l_@@_poetry_big_indent_tl } ~
                      \dim_eval:n
                        { \linewidth - \l_@@_poetry_big_indent_tl }
                  }
              }
          }
      }
    \group_begin:
    \hook_use:n { scripture / chap / before }
    \box_use:N \l_@@_chap_box
    \hook_use:n { scripture / chap / after }
    \group_end:
    \bool_lazy_or:nnT
      { \bool_if_p:n \l_@@_chap_show_verse_bool }
      { \bool_if_p:n \g_@@_poetry_midparachap_show_verse_bool }
      {
        \@@_verse_output:n { 1 }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_poetry_nodrop_chap:n}
%   Format a non-drop chapter for \env{poetry} environment in a
%   \env{scripture} quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_poetry_nodrop_chap:n
  {
    \cs_gset_nopar:Npn \scripturecurrentchapter { #1 }
    \cs_gset_nopar:Npn \scripturecurrentverse { 1 }
    \group_begin:
    \bool_if:NTF \l_@@_chap_show_bool
      {
        \hbox_overlap_left:n
          {
            \hook_use:n { scripture / chap / before }
            \group_begin:
            \l_@@_chap_font_tl
            \str_if_eq:VnF \l_@@_chapter_colour_tl { . }
              { \exp_args:NV \color_select:n \l_@@_chapter_colour_tl }
            \@@_chap_format:n { #1 }
            \group_end:
            \skip_horizontal:N \l_@@_chap_sep_tl
            \hook_use:n { scripture / chap / after }
          }
        \bool_lazy_or:nnT
          { \bool_if_p:n \l_@@_chap_show_verse_bool }
          { \bool_if_p:n \g_@@_poetry_midparachap_show_verse_bool }
          {
            \@@_verse_output:n { 1 }
          }
      }
      {
        \hook_use:n { scripture / chap / before }
        \hook_use:n { scripture / chap / after }
        \vs { 1 }
      }
    \group_end:
  }
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@@_poetry_mode_vertical_verse:n}
%   Format a verse for poetry scripture quotations in vertical and horizontal
%   mode.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_poetry_mode_vertical_verse:n
  {
    \group_begin:
    \tl_set_eq:NN \l_@@_verse_sep_tl \l_@@_poetry_verse_sep_tl
    \strut
    \bool_if:NTF \l_@@_poetry_verse_right_bool
      {
        \hbox_overlap_left:n
          {
            \@@_verse_output:n { #1 }
          }
      }
      {
        \hbox_overlap_left:n
          {
            \hbox_overlap_right:n
              {
                \@@_verse_output:n { #1 }
              }
            \skip_horizontal:N \l_@@_poetry_leftmargin_tl
          }
      }
    \group_end:
  }
\cs_new_protected:Nn \@@_poetry_mode_horizontal_verse:n
  {
    \group_begin:
    \tl_set_eq:NN \l_@@_verse_sep_tl \l_@@_poetry_verse_sep_tl
    \skip_horizontal:n { -\listparindent }
    \@@_poetry_mode_vertical_verse:n { #1 }
    \skip_horizontal:N \listparindent
    \group_end:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_poetry_par:}
%   par macro for poetry sections
%    \begin{macrocode}
\cs_new_protected:Nn \@@_poetry_par:
  {
    \mode_if_vertical:TF
      {
        \cs_set_eq:NN \vs \@@_poetry_mode_vertical_verse:n
        \noindent
      }
      {
        \cs_set_eq:NN \vs \@@_poetry_mode_horizontal_verse:n
        \@@_tmp_para_end:
        \int_set_eq:NN \l_@@_poetry_prevgraf_int \prevgraf
      }
    \parshape 2 ~ 
      \@totalleftmargin ~
      \linewidth ~
      \dim_eval:n
        { \@totalleftmargin + \l_@@_poetry_big_indent_tl } ~
      \dim_eval:n
        { \linewidth - \l_@@_poetry_big_indent_tl }
    \hook_use:n { scripture / poetry / para / after }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_obeylines:}
%   Special version of obeylines which doesn't insert par at end of
%   environment.
%    \begin{macrocode}
\group_begin:
  \char_set_catcode_active:N \^^M
  \cs_gset_protected_nopar:Nn \@@_obeylines: %
    {%
      \char_set_catcode_active:N \^^M%
      \cs_set_eq:NN ^^M \@@_obeylines_end:%
    }%
\group_end:
\cs_new_protected:Nn \@@_obeylines_end:
  {
    \peek_meaning:NF \end
      {
        \par
        \int_set:Nn \l_@@_poetry_prevgraf_int { \int_use:N \prevgraf }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_poetry_begin:}
%   Begin a poetry section in a scripture quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_poetry_begin:
  {
    \bool_if:NT \l_@@_active_inner_bool
      {
        \msg_error:nn { scripture } { nested-environment }
      }
    \bool_set_true:N \l_@@_active_inner_bool
    \tl_set:Nn \l_@@_currenvir_str { poetry }
    \bool_gset_false:N \g_@@_poetry_midparachap_show_verse_bool
    \DeclareDocumentCommand { \ch } { sm } { \@@_poetry_ch:n { ##2 } }
    \cs_set_eq:NN \vs \@@_poetry_mode_vertical_verse:n
    \cs_set_eq:NN \extraskip \@@_poetry_extra_skip:
    \cs_set_eq:NN \selah \@@_selah_output:
    \cs_set_protected_nopar:Npn \textright ##1
      { \@@_poetry_text_right:nn { \l_@@_text_right_sep_tl } { ##1 } }
    \legacy_if:nTF { @newlist }
      { \dim_add:Nn \l_@@_outer_itemindent_dim \itemindent }
      { \dim_zero:N \l_@@_outer_itemindent_dim }
    \list { }
      {
        \dim_zero:N \labelsep
        \dim_set_eq:NN \leftmargin \l_@@_poetry_leftmargin_tl
        \dim_set_eq:NN \rightmargin \l_@@_poetry_rightmargin_tl
        \dim_set:Nn \itemindent { \l_@@_poetry_indent_tl - \l_@@_outer_itemindent_dim }
        \dim_set_eq:NN \listparindent \l_@@_poetry_indent_tl
        \skip_zero:N \parsep
        \skip_zero:N \partopsep
        \dim_compare:nNnTF \parskip > { \l_@@_poetry_aboveskip_tl }
          { \skip_zero:N \topsep }
          { \skip_set:Nn \topsep { \@@_skip_diff:NN \l_@@_poetry_aboveskip_tl \parskip } }
        \@@_setup_list_noindent:n { \l_@@_poetry_indent_tl }
      }
    \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1
      { \addvspace { \baselineskip } }
    \int_gzero:N \g_@@_chap_par_prevgraf_int
    \raggedright
    \dim_set_eq:NN \parindent \l_@@_poetry_indent_tl
    \item
    \relax
    \cs_set_eq:NN \@@_tmp_para_end: \par
    \cs_set_eq:NN \par \@@_poetry_par:
    \hook_gput_next_code:nn { para / after }
      { \bool_gset_eq:NN \g_@@_poetry_midparachap_show_verse_bool \l_@@_midparachap_show_verse_bool }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_poetry_end:}
%   End a poetry section in a scripture quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_poetry_end:
  {
    \@@_calc_final_line_length:
    \dim_compare:nNnTF \@outerparskip > { \l_@@_poetry_belowskip_tl }
      { \skip_zero:N \@topsepadd }
      { \skip_set:Nn \@topsepadd { \@@_skip_diff:NN \l_@@_poetry_belowskip_tl \@outerparskip } }
    \skip_gset_eq:NN \g_@@_prev_inner_below_skip \@topsepadd
    \legacy_if_set_false:n { @noparlist }
    \endlist
    \bool_gset_true:N \g_@@_poetry_end_bool
    \hook_gput_next_code:nn { para / begin }
      { \bool_gset_false:N \g_@@_poetry_end_bool }
  }
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Public \LaTeX{} Interface}
%
% \begin{macro}{\scripturecurrentchapter, \scripturecurrentverse}
%   Globally stores the most recent argument of \cs{ch} and \cs{vs}. These
%   could be used in hooks, for example.
%    \begin{macrocode}
\cs_set_nopar:Npn \scripturecurrentchapter { }
\cs_set_nopar:Npn \scripturecurrentverse { }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\scripturesetup}
%   \begin{arguments}
%     \item \meta{|options|} to set.
%   \end{arguments}
%   Set key-value settings.
%    \begin{macrocode}
\NewDocumentCommand { \scripturesetup } { m }
  {
    \keys_set:nn { scripture } { #1 }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\scripturestyle}
%   \begin{arguments}
%     \item \meta{|name|} of the style.
%     \item \meta{|options|} to set for the style.
%   \end{arguments}
%   Set key-value settings to be applied when using the \opt{style} option
%   with value \val{name}. The starred version appends the \val{options} to
%   any existing ones.
%    \begin{macrocode}
\NewDocumentCommand { \scripturestyle } { s m m }
  {
    \@@_setup_style:nnn { #1 } { #2 } { #3 }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\textscripture}
%   \begin{arguments}
%     \item \meta{|reference|} of quotation.
%     \item \meta{|options|} to set.
%     \item \meta{|quotation|} text.
%   \end{arguments}
%   Set an inline quotation. This is equivalent to calling the
%   \env{scripture} environment with the \opt{inline} option set.
%    \begin{macrocode}
\NewDocumentCommand { \textscripture } { o o +m }
  {
    \tl_if_novalue:nTF { #2 }
      {
        \begin { scripture } [ #1 ] [ inline ]
      }
      {
        \begin { scripture } [ #1 ] [ inline, #2 ]
      }
    #3
    \end { scripture }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{envmacro}{scripture}
%   \begin{arguments}
%     \item \meta{|reference|} of quotation.
%     \item \meta{|options|} to set.
%   \end{arguments}
%   Format a scripture quotation with optional reference.
%    \begin{macrocode}
\NewDocumentEnvironment { scripture } { o o }
  {
    \@@_begin:n { #2 }
%    \end{macrocode}
% \begin{envmacro}{center}
%   \begin{arguments}
%     \item \meta{|options|} to set.
%   \end{arguments}
%    \begin{macrocode}
    \DeclareDocumentEnvironment { center } { o }
      {
        \@@_center_begin:n { ##1 }
        \ignorespaces
      }
      { \@@_center_end: }
%    \end{macrocode}
% \end{envmacro}
% \begin{envmacro}{flushright}
%   \begin{arguments}
%     \item \meta{|options|} to set.
%   \end{arguments}
%    \begin{macrocode}
    \DeclareDocumentEnvironment { flushright } { o }
      {
        \@@_flushright_begin:n { ##1 }
        \ignorespaces
      }
      { \@@_flushright_end: }
%    \end{macrocode}
% \end{envmacro}
% \begin{envmacro}{hanging}
%   \begin{arguments}
%     \item \meta{|options|} to set.
%   \end{arguments}
%    \begin{macrocode}
    \DeclareDocumentEnvironment { hanging } { o }
      {
        \@@_hanging_begin:n { ##1 }
        \ignorespaces
      }
      { \@@_hanging_end: }
%    \end{macrocode}
% \end{envmacro}
% \vspace{-2\baselineskip}
% \begin{envmacro}{midparachap}
%    \begin{macrocode}
    \DeclareDocumentEnvironment { midparachap } { o }
      {
        \@@_mid_para_chap_begin:n { ##1 }
        \ignorespaces
      }
      { \@@_mid_para_chap_end: }
%    \end{macrocode}
% \end{envmacro}
% \begin{envmacro}{narrow}
%   \begin{arguments}
%     \item \meta{|options|} to set.
%   \end{arguments}
%    \begin{macrocode}
    \DeclareDocumentEnvironment { narrow } { o }
      {
        \@@_narrow_begin:n { ##1 }
        \ignorespaces
      }
      { \@@_narrow_end: }
%    \end{macrocode}
% \end{envmacro}
% \begin{envmacro}{poetry}
%   \begin{arguments}
%     \item \meta{|options|} to set.
%   \end{arguments}
% The \env{poetryaux} environment is required because \cs{@@_obeylines:}
% breaks the reading of optional arguments.
%    \begin{macrocode}
    \DeclareDocumentEnvironment { poetryaux } { o }
      {
        \tl_if_novalue:nF { ##1 }
        {
          \keys_set:nn
            { scripture / poetry }
            { ##1 }
        }
        \@@_poetry_begin:
        \ignorespaces
      }
      { \@@_poetry_end: }
    \DeclareDocumentEnvironment { poetry } { }
      {
        \@@_obeylines:
        \poetryaux
      }
      { \endpoetryaux }
%    \end{macrocode}
% \end{envmacro}
%    \begin{macrocode}
    \bool_if:NT \l_@@_inline_bool
      {
        \tl_set:Nn \l_@@_aboveskip_tl { 0pt }
        \tl_set:Nn \l_@@_belowskip_tl { 0pt }
        \tl_set:Nn \l_@@_leftmargin_tl { 0pt }
        \tl_set:Nn \l_@@_rightmargin_tl { 0pt }
        \cs_set_eq:NN \@@_ref_format:n \@@_inline_ref_format:n
        \tl_set_eq:NN \l_@@_ref_sep_tl \l_@@_inline_ref_sep_tl
        \cs_set_eq:NN \@@_version_format:n \@@_inline_version_format:n
        \tl_set_eq:NN \l_@@_version_delim_tl \l_@@_inline_version_delim_tl
        \bool_set_true:N \l_@@_compact_bool
      }
    \bool_if:NT \l_@@_compact_bool
      {
        \scripturesetup { chapter / nodrop }
        \RenewDocumentEnvironment { center } { o } { \ignorespaces } { \unskip }
        \RenewDocumentEnvironment { flushright } { o } { \ignorespaces } { \unskip }
        \RenewDocumentEnvironment { hanging } { o } { \ignorespaces } { \unskip }
        \RenewDocumentEnvironment { midparachap } { o } { \ignorespaces } { \unskip }
        \RenewDocumentEnvironment { narrow } { o } { \ignorespaces } { \unskip }
        \RenewDocumentEnvironment { poetry } { o } { \ignorespaces } { \unskip }
        \cs_set_eq:NN \\ \unskip
        \cs_set_eq:NN \par \relax
        \cs_set_eq:NN \extraskip \relax
        \cs_set_eq:NN \nohang \relax
        \cs_set:Npn \selah
          {
            \group_begin:
            \l_@@_selah_font_tl
            \c_space_tl
            \@@_selah_format:n { \l_@@_selah_text_tl }
            \c_space_tl
            \group_end:
          }
        \cs_set_protected_nopar:Npn \textright ##1
          {
            \unskip
            \c_space_tl
            ##1
          }
        \mode_leave_vertical:
      }
    \ignorespaces
  }
  {
    \bool_if:NT \l_@@_compact_bool
      { \cs_set_eq:NN \par \endgraf }
    \@@_end:n { #1 }
  }
%    \end{macrocode}
% \end{envmacro}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
% \end{implementation}
%
% \PrintChanges
%
% \PrintIndex
