% \iffalse meta-comment
%
% Copyright (c) 2022-2025 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{lang=en}
\documentclass[a4paper]{l3doc}
\usepackage[bidi=basic, layout=lists]{babel}
\babelprovide[import, main]{australian}
\babelprovide[import, onchar=ids fonts]{ancientgreek}
\babelprovide[import, onchar=ids fonts]{japanese}
\babelprovide[import, mapdigits, onchar=ids fonts]{persian}
\babelfont[ancientgreek]{rm}[BoldFont=NewCM10-Bold]{NewCM10-Regular}
\babelfont[ancientgreek]{tt}{NewCMMono10-Regular}
\babelfont[japanese]{tt}[Scale=.9]{IPAMincho}
\babelfont[persian]{rm}[Renderer = Harfbuzz]{Amiri}
\babelfont[persian]{tt}[Renderer = Harfbuzz, Scale=.75]{Kawkab Mono Regular}
\usepackage{luatexja-fontspec}
\newcommand{\disablecjk}{%
  \ltjsetparameter{jacharrange={-1, -2, -3, -4, -5, -6, -7, -8, -9}}}
\newcommand{\enablecjk}{%
  \ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, -8, +9}}}
\disablecjk
\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
\hook_gput_code:nnn
  { env / scripture / begin }
  { scripturedoc }
  {
    \cs_set_eq:NN \list \__codedoc_oldlist:nn
  }
\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 }
  {
    \clist_map_inline:nn { #2 }
      {
        \MakeLinkTarget*{environment##1}
      }
    \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 }
  {
    \clist_map_inline:nn { #2 }
      {
        \MakeLinkTarget*{hook##1}
      }
    \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
    \clist_map_inline:nn { #2 }
      {
        \MakeLinkTarget*{option##1}
      }
    \__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: }
\DeclareDocumentEnvironment { function } { O{} +v }
  {
    \clist_map_inline:nn { #2 }
      {
        \MakeLinkTarget*{function##1}
      }
    \__codedoc_function:nnw {#1} {#2}
  }
  { \__codedoc_function_end: }
\DeclareDocumentCommand \env { m }
  {
    \hyperlink{environment#1}{\texttt{#1}}
  }
\DeclareDocumentCommand \opt { m }
  {
    \hyperlink{option#1}{\texttt{#1}}
  }
\DeclareDocumentCommand \hook { m }
  {
    \hyperlink{hook#1}{\texttt{#1}}
  }
\DeclareRobustCommand \val {\texttt}
\DeclareDocumentCommand \fn  { O{} m }
  {
    \hyperlink{function \c_backslash_str #2}{
      \__codedoc_cmd:no
        { module = scripture , replace = false , #1 }
        { \c_backslash_str #2} }
  }
\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{} \val{list}
%   based environment}
% \changes{v2.0}{2023/12/27}{Bug fixes}
% \changes{v2.1}{2025/01/02}{Bug fixes}
%
% \title{The \pkg{scripture} package}
% \author{David Purton\thanks{Email: \url{dcpurton@marshwiggle.net}}}
% \date{2025/01/02 v2.1}
%
% \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{} \val{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 \val{list} based environment within a
%     \env{scripture} environment.
%   \item Include any \cs{section} (or similar) functions within the
%     \env{scripture} environment. A simple \fn{heading} function is provided
%     instead.
% \end{itemize}
%
% The \env{poetry} environment uses \cs{obeylines}. This means that it can not
% be placed in the argument of a macro. If you want to use the \env{poetry}
% environment in a \pkg{beamer} slide, you must use the \texttt{fragile} option
% for the \pkg{beamer} \val{frame} environment.
%
% 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 \fn{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|\oarg{letter}\marg{chapter number}
%     |\ch*|\oarg{letter}\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. The drop text is aligned to the top of
%   \meta{letter} which defaults to the value of \opt{chapter/xchar}, which in
%   turn defaults to a capital \val{X} in the default font.
%
%   If the \opt{chapter/drop} 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{v2.1}{2024/11/19}{Add feature to insert simple headings}
% \changes{v2.1}{2024/11/19}{Add \fn{heading} function}
% \begin{function}[added=2024-11-19]{\heading}
%   \begin{syntax}
%     |\heading|\marg{section heading}
%   \end{syntax}
%   The \fn{heading} function provides a simple section heading command for
%   use within the \env{scripture} environment. Only one level is heading is
%   provided. Further levels should be placed outside of the \env{scripture}
%   environment. Additionally, the \fn{heading} function may not be used
%   within a \env{scripture} inner environment.
%
%   The settings of headings can be controlled using the following options:
%   \begin{itemize}
%     \item \opt{heading/aboveskip}
%     \item \opt{heading/afterindent}
%     \item \opt{heading/align}
%     \item \opt{heading/belowskip}
%     \item \opt{heading/font}
%     \item \opt{heading/format}
%     \item \opt{heading/hide}
%     \item \opt{heading/show}
%   \end{itemize}
%
%   \noindent\textbf{Notes:}
%   \begin{itemize}
%     \item \cs{section} and related functions are not supported within the
%       \env{scripture} environment.
%     \item The \fn{heading} function is ignored when the \opt{inline} option
%       is \val{true}.
%   \end{itemize}
% \end{function}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Luke 21:5–6]
%   \heading{Signs of the End of the Age}
%
%   \vs{5}Some of his disciples were remarking
%   about how the temple was adorned with beautiful
%   stones and with gifts dedicated to God. But
%   Jesus said, \vs{6}``As for what you see here,
%   the time will come when not one stone will be
%   left on another; every one of them will be
%   thrown down.''
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Luke 21:5–6]
%   \heading{Signs of the End of the Age}
%
%   \vs{5}Some of his disciples were remarking
%   about how the temple was adorned with beautiful
%   stones and with gifts dedicated to God. But
%   Jesus said, \vs{6}``As for what you see here,
%   the time will come when not one stone will be
%   left on another; every one of them will be
%   thrown down.''
% \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 \fn{name}
%   function. The font and format can be set using the \opt{name/font} and
%   \opt{name/format} options. The \fn{LORD} and \fn{GOD} macros equivalent to
%   \fn{name}|{Lord}| and \fn{name}|{God}| respectively.
%
%   \textbf{Note:} Watch out that trailing spaces are not eaten by \fn{LORD}
%   and \fn{GOD}. Using \fn{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 \fn{nofirstverse} function}
% \begin{function}[added=2022-11-13]{\nofirstverse}
%   \begin{syntax}
%     |\nofirstverse|
%   \end{syntax}
%   When \opt{verse/first} is |true|, this causes the next \fn{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{v2.1}{2024/01/18}{Add \fn{nopilcrow} function}
% \begin{function}[added=2024-01-18]{\nopilcrow}
%   \begin{syntax}
%     |\nopilcrow|
%   \end{syntax}
%   When \opt{pilcrow} is |true|, this causes the next pilcrow that would
%   normally by printed to be suppressed. You might do this if your quote
%   begins half way through a paragraph and so should not be marked with a
%   pilcrow.
% \end{function}
%
% \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 \fn{redletteron} and \fn{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 \fn{redletteron} or \fn{redletteroff} occurs inside the
%   inner environment. If you experience problems with unexpected colour, try
%   to ensure that matching \fn{redletteron} and \fn{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 \fn{scripturecurrentchapter} and
% \fn{scripturecurrentverse} variables}
% \begin{function}[added=2022-08-07]{\scripturecurrentchapter, \scripturecurrentverse}
%   \begin{syntax}
%     |\scripturecurrentchapter|
%     |\scripturecurrentverse|
%   \end{syntax}
%   \fn{scripturecurrentchapter} and \fn{scripturecurrentverse} globally hold
%   the most recent values parsed to \fn{ch} and \fn{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 \fn{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 \fn{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 \fn{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 \fn{textscripture} function}
% \begin{function}[added=2023-01-07]{\textscripture}
%   \begin{syntax}
%     |\textscripture|\oarg{reference}\oarg{options}\marg{quotation}
%   \end{syntax}
%   \fn{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 \meta{\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 \meta{\val{reference}} and \meta{\opt{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
%   \fn{textscripture} function. If you have anything other than expected
%   macros and environments inside your \fn{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{chapter/font} is set for the chapter.
%   \item[\hook{scripture/chap/after}] This hook is executed immediately after
%     the \opt{chapter/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/verse/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 \texttt{reference/delim} option}
%
% Default formatting \meta{|options|} can be set using
% \cs{usepackage}|[|\meta{|options|}|]{scripture}| or
% \fn{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 \fn{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 \fn{added} function. |#1| contains the
%   text of the argument to \fn{added}.
% \end{option}
%
% \changes{v2.1}{2024/06/01}{Add \opt{after} option}
% \begin{option}[added=2024-06-01]{after}
%   \begin{syntax}
%     after = \meta{token list} \hfill Default: \emph{Empty}
%   \end{syntax}
%   Execute \meta{|token list|} at the end of the \env{scripture} environment.
% \end{option}
%
% \changes{v2.1}{2024/06/01}{Add \opt{before} option}
% \begin{option}[added=2024-06-01]{before}
%   \begin{syntax}
%     before = \meta{token list} \hfill Default: \emph{Empty}
%   \end{syntax}
%   Execute \meta{|token list|} at the beginning of the \env{scripture}
%   environment.
% \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{v2.1}{2024/12/30}{Add \opt{chapter/align} option}
% \begin{option}[added=2024-12-30]{chapter/align}
%   \begin{syntax}
%     chapter/align = left \textbar\ right\hfill Default: left
%   \end{syntax}
%   When \opt{chapter/align} is set to \val{right} a chapter will overlap to
%   the left when \opt{chapter/nodrop} is set.
%
%   See also \opt{chapter/valign}.
% \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 \fn{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}
%
% \changes{v2.1}{2024/01/05}{Add feature to set chapters in a paragraph of
% their own}
% \changes{v2.1}{2024/01/05}{Add \opt{chapter/para} option}
% \begin{option}[added=2024-01-05]{chapter/para}
%   \begin{syntax}
%     chapter/para = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Set chapters in their own paragraph. The spacing before and after the
%   chapter heading can be set using the \opt{chapter/para/aboveskip} and
%   \opt{chapter/para/belowskip} options. The value of \meta{|boolean|} is
%   optional and assumed to be \val{true} if not present.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[John 1:1][chapter/para,
%     chapter/format=CHAPTER~#1, version=KJV]
%   \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/para,
%     chapter/format=CHAPTER~#1, version=KJV]
%   \ch{1}In the beginning was the Word, and the
%   Word was with God, and the Word was God.
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v2.1}{2024/01/05}{Add \opt{chapter/para/aboveskip} option}
% \begin{option}[added=2024-01-05]{chapter/para/aboveskip}
%   \begin{syntax}
%     chapter/para/aboveskip = \meta{skip} \hfill Default: \cs{bigskipamount}
%   \end{syntax}
%   \meta{|skip|} added above \fn{ch} when \opt{chapter/para} is in effect.
%   To be consistent with how the \pkg{parskip} package treats headings, no
%   additional \cs{parskip} is inserted.
% \end{option}
%
% \changes{v2.1}{2024/01/05}{Add \opt{chapter/para/belowskip} option}
% \begin{option}[added=2024-01-05]{chapter/para/belowskip}
%   \begin{syntax}
%     chapter/para/belowskip = \meta{skip} \hfill Default: \cs{medskipamount}
%   \end{syntax}
%   \meta{|skip|} added below \fn{ch} when \opt{chapter/para} is in effect.
%   To be consistent with how the \pkg{parskip} package treats headings, no
%   additional \cs{parskip} is inserted.
% \end{option}
%
% \changes{v2.1}{2024/01/05}{Add \opt{chapter/para/indent} option}
% \begin{option}[added=2024-01-05]{chapter/para/indent}
%   \begin{syntax}
%     chapter/para/indent = \meta{boolean} \hfill Default: true
%   \end{syntax}
%   Whether to indent the line following a chapter heading when the
%   \opt{chapter/para} option is set to \val{true}. This only has an effect in
%   the \env{scripture}, \env{narrow} and \env{midparachap} environments. The
%   value of \meta{|boolean|} is optional and assumed to be \val{true} if not
%   present.
% \end{option}
%
% \begin{option}{chapter/sep}
%   \begin{syntax}
%     chapter/sep = \meta{dimen} \hfill Default: 0.5em
%   \end{syntax}
%   \meta{|dimen|} used to separate a \fn{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 \fn{vs}|{1}| should be automatically inserted after \fn{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{v2.1}{2024/12/30}{Add \opt{chapter/smash} option}
% \begin{option}[added=2024-12-30]{chapter/smash}
%   \begin{syntax}
%     chapter/smash = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Whether a chapter should be wrapped in \cs{smash} when
%   \opt{chapter/nodrop} is set. This allows the chapter number to be larger
%   than the line height without affecting line spacing. The value of
%   \meta{|boolean|} is optional and assumed to be \val{true} if not present.
% \end{option}
%
% \changes{v2.1}{2024/12/30}{Add \opt{chapter/valign} option}
% \begin{option}[added=2024-12-30]{chapter/valign}
%   \begin{syntax}
%     chapter/align = bottom \textbar\ middle \textbar\ top\hfill Default: bottom
%   \end{syntax}
%   Sets how a chapter will align vertically when \opt{chapter/nodrop} is set.
%   \begin{itemize}
%     \item \val{bottom}: Chapter will align at the text base line.
%     \item \val{middle}: Chapter will align at the center of text.
%     \item \val{top}: Chapter will align at the top of text.
%   \end{itemize}
%
%   See also \opt{chapter/align}.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \documentclass{article}
% \usepackage{babel}
% \babelprovide[import, main]{english}
% \babelprovide[import,
%   onchar=ids fonts]{ancientgreek}
% \babelfont[ancientgreek]{rm}[
%   BoldFont=NewCM10-Bold]{NewCM10-Regular}
% \usepackage{scripture}
% \begin{document}
% \begin{scripture}[Κατά Μάρκον 1:1--3][
%     chapter/font=\huge\bfseries,
%     chapter/align=right, chapter/nodrop,
%     chapter/smash, chapter/valign=top,
%     hanging/hang=1em, hanging/leftmargin=2em,
%     hanging/verse/sep=1em, language=ancientgreek,
%     verse/font=\sffamily\bfseries,
%     verse/sep=0.25em, version=THGNT]
%   \begin{hanging}
%     \ch{1}Ἀρχὴ τοῦ εὐαγγελίου Ἰησοῦ χριστοῦ υἱοῦ
%     θεοῦ· \vs{2}καθὼς γέγραπται ἐν τῷ Ἡσαΐᾳ τῷ
%     προφήτῃ· ἰδοὺ ἀποστέλλω τὸν ἄγγελόν μου πρὸ
%     προσώπου σου, ὃς κατασκευάσει τὴν ὁδόν σου.
%     \vs{3}φωνὴ βοῶντος ἐν τῇ ἐρήμῳ ἑτοιμάσατε τὴν
%     ὁδὸν κυρίου, εὐθείας ποιεῖτε τὰς τρίβους αὐτοῦ.
%   \end{hanging}
% \end{scripture}
% \end{document}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Κατά Μάρκον 1:1--3][
%     chapter/font=\huge\bfseries,
%     chapter/align=right, chapter/nodrop,
%     chapter/smash, chapter/valign=top,
%     hanging/hang=1em, hanging/leftmargin=2em,
%     hanging/verse/sep=1em, language=ancientgreek,
%     verse/font=\sffamily\bfseries,
%     verse/sep=0.25em, version=THGNT]
%   \begin{hanging}
%     \ch{1}Ἀρχὴ τοῦ εὐαγγελίου Ἰησοῦ χριστοῦ υἱοῦ
%     θεοῦ· \vs{2}καθὼς γέγραπται ἐν τῷ Ἡσαΐᾳ τῷ
%     προφήτῃ· ἰδοὺ ἀποστέλλω τὸν ἄγγελόν μου πρὸ
%     προσώπου σου, ὃς κατασκευάσει τὴν ὁδόν σου.
%     \vs{3}φωνὴ βοῶντος ἐν τῇ ἐρήμῳ ἑτοιμάσατε τὴν
%     ὁδὸν κυρίου, εὐθείας ποιεῖτε τὰς τρίβους αὐτοῦ.
%   \end{hanging}
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v2.1}{2025/01/01}{Add \opt{chapter/xchar} option}
% \begin{option}[added=2025-01-01]{chapter/xchar}
%   \begin{syntax}
%     chapter/xchar = \meta{character}\hfill Default: X
%   \end{syntax}
%   Sets the character to which drop chapters and vertically aligned non-drop
%   chapters are aligned. This can also be set for individual chapters using
%   an optional argument to \fn{ch}.
% \end{option}
%
% \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 \fn{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 \name{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 \name{Lord},
%     and he answered me.
%   \end{poetry}
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v2.1}{2025/01/01}{Add \opt{defaults} option}
% \begin{option}[added=2025-01-01]{defaults}
%   \begin{syntax}
%     defaults
%   \end{syntax}
%   Resets options to defaults.
% \end{option}
%
% \begin{option}{extraskip}
%   \begin{syntax}
%     extraskip = \meta{skip} \hfill Default: \cs{medskipamount}
%   \end{syntax}
%   \meta{|skip|} used for the \fn{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{v2.1}{2024/11/19}{Add \opt{heading/aboveskip} option}
% \begin{option}[added=2024-11-19]{heading/aboveskip}
%   \begin{syntax}
%     heading/aboveskip = \meta{skip} \hfill Default: \cs{bigskipamount}
%   \end{syntax}
%   \meta{|skip|} inserted above a \fn{heading}.
% \end{option}
%
% \changes{v2.1}{2024/11/19}{Add \opt{heading/afterindent} option}
% \begin{option}[added=2024-11-19]{heading/afterindent}
%   \begin{syntax}
%     heading/afterindent = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Whether to indent the first paragraph following a \fn{heading}. The value
%   of \meta{|boolean|} is optional and assumed to be \val{true} if not
%   present.
% \end{option}
%
% \changes{v2.1}{2024/11/19}{Add \opt{heading/align} option}
% \begin{option}[added=2024-11-19]{heading/align}
%   \begin{syntax}
%     heading/align = left \textbar\ right \textbar\ center \hfill Default: left
%   \end{syntax}
%   Set the alignment of a \fn{heading}.
% \end{option}
%
% \changes{v2.1}{2024/11/19}{Add \opt{heading/belowskip} option}
% \begin{option}[added=2024-11-19]{heading/belowskip}
%   \begin{syntax}
%     heading/belowskip = \meta{skip} \hfill Default: \cs{medskipamount}
%   \end{syntax}
%   \meta{|skip|} inserted below a \fn{heading}.
% \end{option}
%
% \changes{v2.1}{2024/11/19}{Add \opt{heading/font} option}
% \begin{option}[added=2024-11-19]{heading/font}
%   \begin{syntax}
%     heading/font = \meta{font} \hfill Default: \cs{small}\cs{itshape}
%   \end{syntax}
%   \meta{|font|} used for a \fn{heading}.
% \end{option}
%
% \changes{v2.1}{2024/11/19}{Add \opt{heading/format} option}
% \begin{option}[added=2024-11-19]{heading/format}
%   \begin{syntax}
%     heading/format = \meta{macro} \hfill Default: \#1
%   \end{syntax}
%   \meta{|macro|} used to format a \fn{heading}. |#1| contains the text of
%   the \val{heading}.
% \end{option}
%
% \changes{v2.1}{2024/11/19}{Add \opt{heading/hide} option}
% \begin{option}[added=2024-11-19]{heading/hide}
%   \begin{syntax}
%     heading/hide = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Whether to hide \fn{heading} functions. The value of \meta{|boolean|} is
%   optional and assumed to be \val{true} if not present. This option is the
%   opposite of \opt{heading/show}.
% \end{option}
%
% \changes{v2.1}{2024/11/19}{Add \opt{heading/show} option}
% \begin{option}[added=2024-11-19]{heading/show}
%   \begin{syntax}
%     heading/show = \meta{boolean} \hfill Default: true
%   \end{syntax}
%   Whether to show \fn{heading} functions. The value of \meta{|boolean|} is
%   optional and assumed to be \val{true} if not present. This option is the
%   opposite of \opt{heading/hide}.
% \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.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 and
%   sets the \meta{\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 \meta{\val{reference}} and \meta{\opt{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 \fn{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 \fn{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 \meta{\val{reference}} for an inline
%   \env{scripture} quotation. |#1| contains the text of the
%   \meta{\val{reference}} and \meta{\opt{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 \meta{\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 \meta{\val{reference}} and the
%   \meta{\opt{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 \meta{\opt{version}} for an inline
%   \env{scripture} quotation. |#1| contains the text of the
%   \meta{\opt{version}}.
% \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.
%
%   Right-to-left languages are only supported with \pkg{babel} and Lua\LaTeX.
%   You will need to pass \texttt{bidi=basic, layout=lists} as options to
%   \pkg{babel} to ensure everything is laid out correctly.
% \end{option}
%
% \begin{scriptureexample}
% \begingroup
% \catcode`@=13
% \def@#1{\ifcase#1\relax \egroup \or \bgroup\textdir TLT \else
%   \bgroup\textdir TRT \fi}
% \begin{verbatim}
% \documentclass{article}
% \usepackage[bidi=basic, layout=lists]{babel}
% \babelprovide[import, main]{english}
% \babelprovide[import, mapdigits]{persian}
% \babelfont[persian]{rm}[
%   Renderer=Harfbuzz]{Amiri}
% \usepackage{scripture}
% \begin{document}
% \begin{scripture}[اِشعیا 56‏:1‏--2][version=NMV,
%     language=persian]
%                      @9@1\ch{56}@0خداوند چنین می‌فرماید:@0
%                                    \begin{poetry}
%                           @9»انصاف را نگاه داشته،@0
%                          @9عدالت را به عمل آورید،@0
%
%                         @9زیرا نجات من نزدیک شده،@0
%               @9و عدالت من به‌زودی منکشف خواهد شد.@0
%
%               @9@1\vs{2}@0خوشا به حال آن که چنین کند،@0
%                       @9و کسی که بدین متمسک گردد؛@0
%
%      @9که شَبّات را نگاه داشته، آن را بی‌حرمت نسازد،@0
%              @9و دست خویش از هر عمل بد باز دارد.«@0
%                                      \end{poetry}
% \end{scripture}
% \end{document}
% \end{verbatim}
% \endgroup
%
% \tcblower
%
% \shapemode 2
% \begin{scripture}[اِشعیا 56‏:1‏--2][version=NMV,
%     language=persian]
%   \ch{56}خداوند چنین می‌فرماید:
%   \begin{poetry}
%     «انصاف را نگاه داشته،
%     عدالت را به عمل آورید،
%
%     زیرا نجات من نزدیک شده،
%     و عدالت من به‌زودی منکشف خواهد شد.
%
%     \vs{2}خوشا به حال آن که چنین کند،
%     و کسی که بدین متمسک گردد؛
%
%     که شَبّات را نگاه داشته، آن را بی‌حرمت نسازد،
%     و دست خویش از هر عمل بد باز دارد.»
%   \end{poetry}
% \end{scripture}
% \end{scriptureexample}
%
% \textbf{Note} that for CJK scripts the \pkg{scripture} package is compatible
% with specialist packages like \pkg{luatexja} and \pkg{ctex}. These packages
% can give nicer kerning and protrusion out of the box. Although with some
% effort you can set up \pkg{babel} along with \pkg{microtype} to give
% comparable output.
%
% \begin{scriptureexample}
% \begin{verbatim}
% \documentclass{article}
% \usepackage{luatexja}
% \usepackage{scripture}
% \begin{document}
% \begin{scripture}[マルコの福音書 9:33--37][
%     version=NJB]
%   \vs{33}一行はカペナウムに着いた。イエスは家に入ってか
%          ら、弟子たちにお尋ねになった。「来る途中、何を
%          論じ合っていたのですか。」
%   \vs{34}彼らは黙っていた。来る途中、だれが一番偉いか論
%          じ合っていたからである。
%   \vs{35}イエスは腰を下ろすと、十二人を呼んで言われた。
%          「だれでも先頭に立ちたいと思う者は、皆の後にな
%          り、皆に仕える者になりなさい。」
%   \vs{36}それから、イエスは一人の子どもの手を取って、彼
%          らの真ん中に立たせ、腕に抱いて彼らに言われた。
%   \vs{37}「だれでも、このような子どもたちの一人を、わた
%          しの名のゆえに受け入れる人は、わたしを受け入れ
%          るのです。また、だれでもわたしを受け入れる人は
%          、わたしではなく、わたしを遣わされた方を受け入
%          れるのです。」
% \end{scripture}
% \end{document}
% \end{verbatim}
%
% \tcblower
%
% \enablecjk
%
% \begin{scripture}[マルコの福音書 9:33--37][
%     version=NJB]
%   \vs{33}一行はカペナウムに着いた。イエスは家に入ってか
%          ら、弟子たちにお尋ねになった。「来る途中、何を
%          論じ合っていたのですか。」
%   \vs{34}彼らは黙っていた。来る途中、だれが一番偉いか論
%          じ合っていたからである。
%   \vs{35}イエスは腰を下ろすと、十二人を呼んで言われた。
%          「だれでも先頭に立ちたいと思う者は、皆の後にな
%          り、皆に仕える者になりなさい。」
%   \vs{36}それから、イエスは一人の子どもの手を取って、彼
%          らの真ん中に立たせ、腕に抱いて彼らに言われた。
%   \vs{37}「だれでも、このような子どもたちの一人を、わた
%          しの名のゆえに受け入れる人は、わたしを受け入れ
%          るのです。また、だれでもわたしを受け入れる人は
%          、わたしではなく、わたしを遣わされた方を受け入
%          れるのです。」
% \end{scripture}
% \end{scriptureexample}
%
% \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 \fn{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 \fn{name}
%   function. |#1| contains the text of the argument to \fn{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{v2.1}{2024/01/18}{Add feature to add pilcrows at the start of
% paragraphs.}
% \changes{v2.1}{2024/01/18}{Add \opt{pilcrow} option}
% \begin{option}[added=2024-01-18]{pilcrow}
%   \begin{syntax}
%     pilcrow = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Whether to insert a pilcrow (\P) at the beginning of each paragraph. This
%   option only has an effect when using the \opt{compact} and/or
%   \opt{verse/para} options. The value of \meta{|boolean|} is optional and
%   assumed to be \val{true} if not present.
%
%   A subsequent pilcrow can be suppressed with the \fn{nopilcrow} macro.
%   Inner environments start a new paragraph only if there is a blank line
%   before them and similarly, there is only a new paragraph after an inner
%   environment if it is followed by a blank line. New paragraphs are not
%   inserted within a poetry environment, so to obtain a paragraph break
%   within a block of poetry, use two \env{poetry} environments separated by a
%   blank line. The exception to this is the \env{midparachap} environment
%   which always starts and ends a paragraph.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Deuteronomy 5:1][chapter/para,
%     chapter/format=CHAPTER~#1, verse/para,
%     verse/font=\bfseries, verse/format=#1,
%     verse/sep=0.5em, pilcrow]
%   \ch{5}Moses summoned all Israel and said:
%
%   Hear, Israel, the decrees and the laws I declare
%   in your hearing today. Learn them and be sure to
%   follow them.
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Deuteronomy 5:1][chapter/para,
%     chapter/format=CHAPTER~#1, verse/para,
%     verse/font=\bfseries, verse/format=#1,
%     verse/sep=0.5em, pilcrow]
%   \ch{5}Moses summoned all Israel and said:
%
%   Hear, Israel, the decrees and the laws I declare
%   in your hearing today. Learn them and be sure to
%   follow them.
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v2.1}{2024/01/18}{Add \opt{pilcrow/sep} option}
% \begin{option}[added=2024-01-18]{pilcrow/sep}
%   \begin{syntax}
%     pilcrow/sep = \meta{dimen} \hfill Default: 0.25em
%   \end{syntax}
%   \meta{|dimen|} used to separate a pilcrow (\P) from the following text.
% \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 optional and assumed to be \val{true} if not present.
%   The text needs to be marked up with \fn{redletteron} and \fn{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}. \fn{redletteron} and
%   \fn{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 \meta{\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 \meta{\val{reference}} for a
%   \env{scripture} quotation. |#1| contains the text of the
%   \meta{\val{reference}} and
%   \meta{\opt{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 \meta{\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}
%
% \changes{v2.1}{2024/01/10}{Add feature to place the reference at the start
% of the quotation.}
% \changes{v2.1}{2024/01/10}{Add \opt{reference/position} option}
% \begin{option}[added=2024-01-10]{reference/position}
%   \begin{syntax}
%     reference/position = start \textbar\ end \hfill Default: end
%   \end{syntax}
%   Set the position of the reference at either the start or end of the
%   quotation. If \val{start} is specified, then the reference will be set
%   inline unless the quotation begins with an inner environment. Any \fn{vs}
%   or \fn{ch} is suppressed at the start of the quotation in the main
%   \env{scripture} environment.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[John 1:1][version=NIV,
%     reference/position=start]
%   \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][version=NIV,
%     reference/position=start]
%   \ch{1}In the beginning was the Word, and the
%   Word was with God, and the Word was God.
% \end{scripture}
% \end{scriptureexample}
%
% \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 \meta{\val{reference}} before the \meta{\val{reference}}
%   is pushed to the following line.
% \end{option}
%
% \changes{v2.1}{2024/01/10}{Add \opt{reference/start/inline} option}
% \begin{option}[added=2024-01-10]{reference/start/inline}
%   \begin{syntax}
%     reference/start/inline = \meta{boolean} \hfill Default: true
%   \end{syntax}
%   When \opt{reference/position} is set to \val{start}, this option controls
%   whether the reference is set inline or on a line of its own before the
%   quotation. Note that if the quotation begins with an inner environment the
%   reference will always be on a new line unless the \opt{compact} option is
%   also set. The value of \meta{|boolean|} is optional and assumed to be
%   \val{true} if not present. This option is the opposite of
%   \opt{reference/start/newline}.
% \end{option}
%
% \changes{v2.1}{2024/01/10}{Add \opt{reference/start/newline} option}
% \begin{option}[added=2024-01-10]{reference/start/newline}
%   \begin{syntax}
%     reference/start/newline = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   When \opt{reference/position} is set to \val{start}, this option controls
%   whether the reference is set inline or on a line of its own before the
%   quotation. Note that if the quotation begins with an inner environment the
%   reference will always be on a new line unless the \opt{compact} option is
%   also set. The value of \meta{|boolean|} is optional and assumed to be
%   \val{true} if not present. This option is the opposite of
%   \opt{reference/start/inline}.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[John 1:1]%
%     [reference/position=start,
%      reference/start/newline]
%   \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]%
%     [reference/position=start,
%      reference/start/newline]
%   \ch{1}In the beginning was the Word, and the
%   Word was with God, and the Word was God.
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v2.1}{2024/01/10}{Add \opt{reference/start/sep} option}
% \begin{option}[added=2024-01-10]{reference/start/sep}
%   \begin{syntax}
%     reference/start/sep = \meta{dimen} \hfill Default: 1em
%   \end{syntax}
%   The space inserted between the reference and the quotation when
%   \opt{reference/position} is set to \val{start}. This only applies when the
%   reference is inline and not on a line of its own.
% \end{option}
%
% \changes{v2.1}{2024/01/10}{Add \opt{reference/start/vsep} option}
% \begin{option}[added=2024-01-10]{reference/start/vsep}
%   \begin{syntax}
%     reference/start/vsep = \meta{skip} \hfill Default: 0pt
%   \end{syntax}
%   The vertical skip inserted between the reference and the quotation when
%   \opt{reference/position} is set to \val{start}. This only applies when the
%   reference is on a line of its own.
% \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 \fn{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 \fn{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 \fn{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 \fn{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 \fn{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 \fn{nofirstverse} 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 \fn{vs} in a paragraph. |#1|
%   contains the argument of \fn{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 \fn{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 \fn{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 \fn{vs} function. |#1| contains the
%   argument of \fn{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{v2.1}{2024/01/13}{Add feature to set each verse on a new line.}
% \changes{v2.1}{2024/01/13}{Add \opt{verse/para} option}
% \begin{option}[added=2024-01-13]{verse/para}
%   \begin{syntax}
%     verse/para = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Whether to set each verse on its own line. The value of \meta{|boolean|}
%   is optional and assumed to be \val{true} if not present. Drop chapters and
%   the shape of inner environments is preserved with this option unless the
%   \opt{compact} option is also set.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Jonah 1:17--2:2a][verse/para,
%     verse/sep=0.5em, pilcrow, chapter/para,
%     chapter/format=CHAPTER~#1]
%   \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 \name{Lord},
%     and he answered me.
%   \end{poetry}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Jonah 1:17--2:2a][verse/para,
%     verse/format=#1, verse/font=\bfseries,
%     verse/sep=0.5em, pilcrow, chapter/para,
%     chapter/format=CHAPTER~#1]
%   \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 \name{Lord},
%     and he answered me.
%   \end{poetry}
% \end{scripture}
% \end{scriptureexample}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Jonah 1:17--2:2a][verse/para,
%     verse/sep=0.5em, pilcrow, chapter/para,
%     chapter/format=CHAPTER~#1, 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 \name{Lord},
%     and he answered me.
%   \end{poetry}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Jonah 1:17--2:2a][verse/para,
%     verse/format=#1, verse/font=\bfseries,
%     verse/sep=0.5em, pilcrow, chapter/para,
%     chapter/format=CHAPTER~#1, 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 \name{Lord},
%     and he answered me.
%   \end{poetry}
% \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 \fn{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{\opt{version}} added to the \meta{\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 \meta{\val{reference}} and the
%   \meta{\opt{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 \meta{\opt{version}} for a
%   \env{scripture} quotation. |#1| contains the text of the
%   \meta{\opt{version}}.
% \end{option}
%
% \changes{v2.1}{2024/01/10}{Add \opt{version/position} option}
% \begin{option}[added=2024-01-10]{version/position}
%   \begin{syntax}
%     version/position = withref \textbar\ end \hfill Default: withref
%   \end{syntax}
%   Set the position of the version at either with the reference or at the end
%   of the quotation if \opt{reference/position} is set to \val{start}.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[John 1:1][version=NIV,
%     reference/position=start,
%     version/position=end]
%   \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][version=NIV,
%     reference/position=start,
%     version/position=end]
%   \ch{1}In the beginning was the Word, and the
%   Word was with God, and the Word was God.
% \end{scripture}
% \end{scriptureexample}
%
% \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, \fn{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, \fn{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, \fn{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}
%
% \changes{v2.1}{2024/12/31}{Add \opt{hanging/chapter/indent} option}
% \begin{option}[added=2024-12-31]{hanging/chapter/indent}
%   \begin{syntax}
%     hanging/chapter/indent = \meta{boolean} \hfill Default: true
%   \end{syntax}
%   Indent the first line of chapters in \env{hanging} environments. If this
%   is set to \val{false}, then the paragraph will be set has a normal hanging
%   paragraph (if there is room).
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \begin{scripture}[Genesis 1:1--3][%
%     hanging/chapter/indent=false]
%   \begin{hanging}
%     \ch{1}In the beginning God created the heavens
%     and the earth. \vs{2}Now the earth was
%     formless and empty, darkness was over the
%     surface of the deep, and the Spirit of God was
%     hovering over the waters.
%
%     \vs{3}And God said, ``Let there be light,''
%     and there was light.
%   \end{hanging}
% \end{scripture}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Genesis 1:1--3][%
%     hanging/chapter/indent=false]
%   \begin{hanging}
%     \ch{1}In the beginning God created the heavens
%     and the earth. \vs{2}Now the earth was
%     formless and empty, darkness was over the
%     surface of the deep, and the Spirit of God was
%     hovering over the waters.
%
%     \vs{3}And God said, ``Let there be light,''
%     and there was light.
%   \end{hanging}
% \end{scripture}
% \end{scriptureexample}
%
% \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}
%
% \changes{v2.1}{2024/12/17}{Add \opt{hanging/verse/left} option}
% \begin{option}[added=2024-12-17]{hanging/verse/left}
%   \begin{syntax}
%     hanging/verse/left = \meta{boolean} \hfill Default: false
%   \end{syntax}
%   Align verse numbers in \env{hanging} environments at the left margin of
%   the \env{hanging} environment. This is only used for verses at the start
%   of a paragraph. This option is the opposite of \opt{hanging/verse/right}.
% \end{option}
%
% \begin{scriptureexample}
% \begin{verbatim}
% \documentclass{article}
% \usepackage{babel}
% \babelprovide[import, main]{english}
% \babelprovide[import,
%   onchar=ids fonts]{ancientgreek}
% \babelfont[ancientgreek]{rm}[
%   BoldFont=NewCM10-Bold]{NewCM10-Regular}
% \usepackage{scripture}
% \begin{document}
% \begin{scripture}[Κατά Μάρκον 1:28--30][
%     hanging/hang=1em, hanging/leftmargin=2em,
%     hanging/verse/left, hanging/verse/sep=1em,
%     language=ancientgreek, verse/sep=0.25em,
%     verse/font=\sffamily\bfseries, version=THGNT]
%   \begin{hanging}
%     \vs{28}Καὶ ἐξῆλθεν ἡ ἀκοὴ αὐτοῦ εὐθὺς πανταχοῦ
%     εἰς ὅλην τὴν περίχωρον τῆς Γαλιλαίας.
%
%     \vs{29}Καὶ εὐθὺς ἐκ τῆς συναγωγῆς ἐξελθόντες
%     ἦλθον εἰς τὴν οἰκίαν Σίμωνος καὶ Ἀνδρέου μετὰ
%     Ἰακώβου καὶ Ἰωάννου. \vs{30}ἡ δὲ πενθερὰ
%     Σίμωνος κατέκειτο πυρέσσουσα, καὶ εὐθὺς
%     λέγουσιν αὐτῷ περὶ αὐτῆς.
%   \end{hanging}
% \end{scripture}
% \end{document}
% \end{verbatim}
%
% \tcblower
%
% \begin{scripture}[Κατά Μάρκον 1:28--30][
%     hanging/hang=1em, hanging/leftmargin=2em,
%     hanging/verse/left, hanging/verse/sep=1em,
%     language=ancientgreek, verse/sep=0.25em,
%     verse/font=\sffamily\bfseries, version=THGNT]
%   \begin{hanging}
%     \vs{28}Καὶ ἐξῆλθεν ἡ ἀκοὴ αὐτοῦ εὐθὺς πανταχοῦ
%     εἰς ὅλην τὴν περίχωρον τῆς Γαλιλαίας.
%
%     \vs{29}Καὶ εὐθὺς ἐκ τῆς συναγωγῆς ἐξελθόντες
%     ἦλθον εἰς τὴν οἰκίαν Σίμωνος καὶ Ἀνδρέου μετὰ
%     Ἰακώβου καὶ Ἰωάννου. \vs{30}ἡ δὲ πενθερὰ
%     Σίμωνος κατέκειτο πυρέσσουσα, καὶ εὐθὺς
%     λέγουσιν αὐτῷ περὶ αὐτῆς.
%   \end{hanging}
% \end{scripture}
% \end{scriptureexample}
%
% \changes{v2.1}{2024/12/17}{Add \opt{hanging/verse/right} option}
% \begin{option}[added=2024-12-17]{hanging/verse/right}
%   \begin{syntax}
%     hanging/verse/right = \meta{boolean} \hfill Default: true
%   \end{syntax}
%   Align verse numbers in \env{hanging} environments at the left margin of
%   the \env{hanging} environment. The verse numbers overlap to the left. This
%   is only used for verses at the start of a paragraph. This option is the
%   opposite of \opt{hanging/verse/left}.
% \end{option}
%
% \changes{v2.1}{2024/12/17}{Add \opt{hanging/verse/sep} option}
% \begin{option}[added=2024-12-17]{hanging/verse/sep}
%   \begin{syntax}
%     hanging/verse/sep = \meta{dimen} \hfill Default: 0.05em
%   \end{syntax}
%   \meta{|dimen|} used to separate a \fn{vs} from the following text in a
%   \env{hanging} environment. This is only used for verses at the start of a
%   paragraph.
% \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, \fn{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 \fn{vs}|{1}| should automatically be inserted after a \fn{ch}
%   when the \fn{ch} occurs mid-paragraph. This also affects \fn{ch} in
%   \env{poetry} environments. 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 \fn{vs}|{1}| should automatically be inserted after a \fn{ch}
%   when the \fn{ch} occurs mid-paragraph. This also affects \fn{ch} in
%   \env{poetry} environments. 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, \fn{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, \fn{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}[Acts 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}[Acts 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.05em
%   \end{syntax}
%   \meta{|dimen|} used to separate a \fn{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}{2025/01/02}{2.1}
  {Format Scripture Quotations (DCP)}
%    \end{macrocode}
%
% \subsection{Hacks and workarounds}
%
% Work around odd interaction between \cs{textdir} and display math. See
% \url{https://tex.stackexchange.com/q/716621/87678}.
%
%    \begin{macrocode}
\bool_new:N \l_@@_textdir_change_in_group_bool
\cs_new_protected:Nn \@@_set_textdirection:
  {
    \sys_if_engine_luatex:T
      {
        \textdirection \int_use:N \textdirection
        \bool_set_true:N \l_@@_textdir_change_in_group_bool
      }
  }
%    \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 \fn{heading} is not used in the main \env{scripture}
% environment.
%
%    \begin{macrocode}
\msg_new:nnnn { scripture } { heading-error }
  { \token_to_str:N \heading \c_space_tl not~support~within~inner~ 
    environments. }
  { You~have~tried~to~use~\token_to_str:N \heading \c_space_tl within~the~
    `#1'~environment,~but~this~macro~is~only~supported~in~the~main~
    `scripture'~environment. }
%    \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 }
    , after                       .tl_set:N           = \l_@@_after_tl
    , after                       .value_required:n   = true
    , after                       .initial:n          =
    , before                      .tl_set:N           = \l_@@_before_tl
    , before                      .value_required:n   = true
    , before                      .initial:n          =
    , 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 / align             .choices:nn         = { left, right }
                                                        {
                                                          \tl_if_exist:NF \l_@@_chapter_align_tl
                                                            { \tl_new:N \l_@@_chapter_align_tl }
                                                          \str_case:Vn \l_keys_choice_tl
                                                            {
                                                              { left }
                                                                {
                                                                  \tl_set:Nn \l_@@_chapter_align_tl
                                                                    { l }
                                                                }
                                                              { right }
                                                                {
                                                                  \tl_set:Nn \l_@@_chapter_align_tl
                                                                    { r }
                                                                }
                                                            }
                                                        }
    , chapter / align             .value_required:n   = true
    , chapter / align             .initial:n          = left
    , 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 / para              .bool_set:N         = \l_@@_chap_para_bool
    , chapter / para              .default:n          = true
    , chapter / para              .initial:n          = false
    , chapter / para / aboveskip  .tl_set:N           = \l_@@_chap_para_aboveskip_tl
    , chapter / para / aboveskip  .value_required:n   = true
    , chapter / para / aboveskip  .initial:n          = \bigskipamount
    , chapter / para / belowskip  .tl_set:N           = \l_@@_chap_para_belowskip_tl
    , chapter / para / belowskip  .value_required:n   = true
    , chapter / para / belowskip  .initial:n          = \medskipamount
    , chapter / para / indent     .code:n             = {
                                                          \bool_set:Nn
                                                            \l_@@_chap_para_afterindent_bool
                                                            { \str_if_eq_p:nn { #1 } { true } }
                                                        }
    , chapter / para / indent     .default:n          = true
    , chapter / para / indent     .initial:n          = true
    , chapter / sep               .tl_set:N           = \l_@@_chap_sep_tl
    , chapter / sep               .value_required:n   = true
    , chapter / sep               .initial:n          = 0.5em
    , 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
    , chapter / smash             .bool_set:N         = \l_@@_chap_smash_bool
    , chapter / smash             .default:n          = true
    , chapter / smash             .initial:n          = false
    , chapter / valign            .choices:nn         = { bottom, middle, top }
                                                        {
                                                          \tl_if_exist:NF \l_@@_chapter_valign_tl
                                                            { \tl_new:N \l_@@_chapter_valign_tl }
                                                          \str_case:Vn \l_keys_choice_tl
                                                            {
                                                              { bottom }
                                                                {
                                                                  \tl_set:Nn \l_@@_chapter_valign_tl
                                                                    { b }
                                                                }
                                                              { middle }
                                                                {
                                                                  \tl_set:Nn \l_@@_chapter_valign_tl
                                                                    { vc }
                                                                }
                                                              { top }
                                                                {
                                                                  \tl_set:Nn \l_@@_chapter_valign_tl
                                                                    { t }
                                                                }
                                                            }
                                                        }
    , chapter / valign            .value_required:n   = true
    , chapter / valign            .initial:n          = bottom
    , chapter / xchar             .tl_set:N           = \l_@@_X_char_tl
    , chapter / xchar             .value_required:n   = true
    , chapter / xchar             .initial:n          = X
    , defaults                    .code:n             = \cs_if_exist_use:N \@@_setup_reset_defaults:
    , defaults                    .value_forbidden:n  = true
    , 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          =
    , heading / aboveskip         .tl_set:N           = \l_@@_heading_aboveskip_tl
    , heading / aboveskip         .value_required:n   = true
    , heading / aboveskip         .initial:n          = \bigskipamount
    , heading / afterindent       .bool_set:N         = \l_@@_heading_afterindent_bool
    , heading / afterindent       .default:n          = true
    , heading / afterindent       .initial:n          = false
    , heading / align             .choices:nn         = { left, right, center }
                                                        {
                                                          \tl_if_exist:NF \l_@@_heading_align_tl
                                                            { \tl_new:N \l_@@_heading_align_tl }
                                                          \str_case:Vn \l_keys_choice_tl
                                                            {
                                                              { left }
                                                                {
                                                                  \tl_set:Nn \l_@@_heading_align_tl
                                                                    { \raggedright }
                                                                }
                                                              { right }
                                                                {
                                                                  \tl_set:Nn \l_@@_heading_align_tl
                                                                    { \raggedleft }
                                                                }
                                                              { center }
                                                                {
                                                                  \tl_set:Nn \l_@@_heading_align_tl
                                                                    { \centering }
                                                                }
                                                            }
                                                        }
    , heading / align             .value_required:n   = true
    , heading / align             .initial:n          = left
    , heading / belowskip         .tl_set:N           = \l_@@_heading_belowskip_tl
    , heading / belowskip         .value_required:n   = true
    , heading / belowskip         .initial:n          = \medskipamount
    , heading / font              .tl_set:N           = \l_@@_heading_font_tl
    , heading / font              .value_required:n   = true
    , heading / font              .initial:n          = \small\itshape
    , heading / format            .cs_set:Np          = \@@_heading_format:n #1
    , heading / format            .value_required:n   = true
    , heading / format            .initial:n          = #1
    , heading / hide              .bool_set_inverse:N = \l_@@_heading_show_bool
    , heading / hide              .default:n          = true
    , heading / show              .bool_set:N         = \l_@@_heading_show_bool
    , heading / show              .default:n          = true
    , heading / show              .initial:n          = true
    , 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.5em
    , 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
    , pilcrow                     .bool_set:N         = \l_@@_pilcrow_bool
    , pilcrow                     .default:n          = true
    , pilcrow                     .initial:n          = false
    , pilcrow / sep               .tl_set:N           = \l_@@_pilcrow_sep_tl
    , pilcrow / sep               .value_required:n   = true
    , pilcrow / sep               .initial:n          = 0.25em
    , 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 / position        .choices:nn         = { start, end }
                                                        {
                                                          \tl_if_exist:NF \l_@@_ref_position_tl
                                                            { \tl_new:N \l_@@_ref_position_tl }
                                                          \tl_set_eq:NN \l_@@_ref_position_tl \l_keys_choice_tl
                                                        }
    , reference / position        .value_required:n   = true
    , reference / position        .initial:n          = end
    , reference / sep             .tl_set:N           = \l_@@_ref_sep_tl
    , reference / sep             .value_required:n   = true
    , reference / sep             .initial:n          = 2em
    , reference / start / inline  .bool_set_inverse:N = \l_@@_ref_start_newline_bool
    , reference / start / inline  .default:n          = true
    , reference / start / newline .bool_set:N         = \l_@@_ref_start_newline_bool
    , reference / start / newline .default:n          = true
    , reference / start / newline .initial:n          = false
    , reference / start / sep     .tl_set:N           = \l_@@_ref_start_sep_tl
    , reference / start / sep     .value_required:n   = true
    , reference / start / sep     .initial:n          = 1em
    , reference / start / vsep    .tl_set:N           = \l_@@_ref_vertical_sep_tl
    , reference / start / vsep    .value_required:n   = true
    , reference / start / vsep    .initial:n          = 0pt
    , 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          = 1em
    , 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          = 1em
    , 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 / para                .bool_set:N         = \l_@@_verse_para_bool
    , verse / para                .default:n          = true
    , verse / para                .initial:n          = false
    , verse / para / indent       .tl_set:N           = \l_@@_para_indent_tl
    , verse / para / indent       .value_required:n   = true
    , verse / para / indent       .initial:n          = \l_@@_parindent_tl
    , verse / sep                 .tl_set:N           = \l_@@_verse_sep_tl
    , verse / sep                 .value_required:n   = true
    , verse / sep                 .initial:n          = 0.05em
    , 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)
    , version / position          .choices:nn         = { withref, end }
                                                        {
                                                          \tl_if_exist:NF \l_@@_version_position_tl
                                                            { \tl_new:N \l_@@_version_position_tl }
                                                          \tl_set_eq:NN \l_@@_version_position_tl \l_keys_choice_tl
                                                        }
    , version / position          .value_required:n   = true
    , version / position          .initial:n          = withref
%    \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 / chapter / indent  .bool_set:N         = \l_@@_hanging_chapter_indent_bool
    , hanging / chapter / indent  .default:n          = true
    , hanging / chapter / indent  .initial:n          = true
    , hanging / hang              .tl_set:N           = \l_@@_hanging_hang_tl
    , hanging / hang              .value_required:n   = true
    , hanging / hang              .initial:n          = 2em
    , hanging / leftmargin        .tl_set:N           = \l_@@_hanging_leftmargin_tl
    , hanging / leftmargin        .value_required:n   = true
    , hanging / leftmargin        .initial:n          = 1em
    , hanging / rightmargin       .tl_set:N           = \l_@@_hanging_rightmargin_tl
    , hanging / rightmargin       .value_required:n   = true
    , hanging / rightmargin       .initial:n          = \c_zero_dim
    , hanging / verse / left      .bool_set_inverse:N = \l_@@_hanging_verse_right_bool
    , hanging / verse / left      .default:n          = true
    , hanging / verse / right     .bool_set:N         = \l_@@_hanging_verse_right_bool
    , hanging / verse / right     .default:n          = true
    , hanging / verse / right     .initial:n          = true
    , hanging / verse / sep       .tl_set:N           = \l_@@_hanging_verse_sep_tl
    , hanging / verse / sep       .value_required:n   = true
    , hanging / verse / sep       .initial:n          = 0.05em
%    \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          = 1em
    , narrow / rightmargin        .tl_set:N           = \l_@@_narrow_rightmargin_tl
    , narrow / rightmargin        .value_required:n   = true
    , narrow / rightmargin        .initial:n          = 1em
%    \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          = 4em
    , poetry / indent             .tl_set:N           = \l_@@_poetry_indent_tl
    , poetry / indent             .value_required:n   = true
    , poetry / indent             .initial:n          = 1em
    , poetry / leftmargin         .tl_set:N           = \l_@@_poetry_leftmargin_tl
    , poetry / leftmargin         .value_required:n   = true
    , poetry / leftmargin         .initial:n          = 1em
    , 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.05em
  }
%    \end{macrocode}
% Process package options.
%    \begin{macrocode}
\ProcessKeyOptions
%    \end{macrocode}
%
% Create interface to reset all keys to defaults.
%    \begin{macrocode}
\tl_new:N \l_@@_default_options_tl
\keys_precompile:nnN { scripture }
  {
    , aboveskip                   = \c_zero_skip
    , added / font                =
    , added / format              = \emph { #1 }
    , after                       =
    , before                      =
    , belowskip                   = \c_zero_skip
    , colour                      = .
    , compact                     = false
    , chapter / align             = left
    , chapter / font              = \bfseries
    , chapter / colour            = .
    , chapter / drop              = true
    , chapter / format            = #1
    , chapter / para              = false
    , chapter / para / aboveskip  = \bigskipamount
    , chapter / para / belowskip  = \medskipamount
    , chapter / para / indent     = true
    , chapter / sep               = 0.5em
    , chapter / show              = true
    , chapter / showverse         = false
    , chapter / smash             = false
    , chapter / valign            = bottom
    , chapter / xchar             = X
    , extraskip                   = \medskipamount
    , font                        =
    , heading / aboveskip         = \bigskipamount
    , heading / afterindent       = false
    , heading / align             = left
    , heading / belowskip         = \medskipamount
    , heading / font              = \small\itshape
    , heading / format            = #1
    , heading / show              = true
    , indent                      = true
    , inline                      = false
    , inline / begin              = ``
    , inline / end                = ''
    , inline / reference / format = (#1)
    , inline / reference / sep    = 0.5em
    , inline / version / delim    = \c_space_tl
    , inline / version / format   = #1
    , language                    =
    , language / variant          =
    , leftmargin                  = \c_zero_dim
    , name / font                 = \scshape
    , name / format               = #1
    , parindent                   = \parindent
    , parskip                     = \parskip
    , pilcrow                     = false
    , pilcrow / sep               = 0.25em
    , redletter                   = false
    , redletter / colour          = red!80!black
    , reference / align           = right
    , reference / colour          = .
    , reference / font            = \bfseries
    , reference / format          = #1
    , reference / position        = end
    , reference / sep             = 2em
    , reference / start / newline = false
    , reference / start / sep     = 1em
    , reference / start / vsep    = 0pt
    , rightmargin                 = \c_zero_dim
    , selah / text                = Selah
    , selah / font                = \itshape
    , selah / format              = #1
    , selah / sep                 = 1em
    , textright / sep             = 1em
    , verse / colour              = .
    , verse / first               = false
    , verse / firstformat         = #1
    , verse / firstsep            = 0.5em
    , verse / font                =
    , verse / format              = \textsuperscript{#1}
    , verse / para                = false
    , verse / para / indent       = \l_@@_parindent_tl
    , verse / sep                 = 0.05em
    , verse / show                = true
    , version                     =
    , version / delim             = \c_space_tl
    , version / format            = (#1)
    , version / position          = withref
    , center / aboveskip          = \medskipamount
    , center / belowskip          = \medskipamount
    , center / leftmargin         = \c_zero_dim
    , center / rightmargin        = \c_zero_dim
    , flushright / aboveskip      = \medskipamount
    , flushright / belowskip      = \medskipamount
    , flushright / leftmargin     = \c_zero_dim
    , flushright / rightmargin    = \c_zero_dim
    , hanging / aboveskip         = \medskipamount
    , hanging / belowskip         = \medskipamount
    , hanging / chapter / indent  = true
    , hanging / hang              = 2em
    , hanging / leftmargin        = 1em
    , hanging / rightmargin       = \c_zero_dim
    , hanging / verse / right     = true
    , hanging / verse / sep       = 0.05em
    , midparachap / showverse     = true
    , narrow / aboveskip          = \medskipamount
    , narrow / belowskip          = \medskipamount
    , narrow / leftmargin         = 1em
    , narrow / rightmargin        = 1em
    , poetry / aboveskip          = \medskipamount
    , poetry / belowskip          = \medskipamount
    , poetry / bigindent          = 4em
    , poetry / indent             = 1em
    , poetry / leftmargin         = 1em
    , poetry / rightmargin        = \c_zero_dim
    , poetry / verse / right      = true
    , poetry / verse / sep        = 0.05em
  }
  \l_@@_default_options_tl
\cs_new_protected:Nn \@@_setup_reset_defaults:
  {
    \l_@@_default_options_tl
  }
%    \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 \fn{scripturecurrentchapter} and
% \fn{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}
%
% \begin{hooks}{scripture/pilcrow, scripture/poetry/pilcrow}
% These are internal hooks used to insert a pilcrow at the beginning of a
% paragraph. Pilcrows are activated using the \opt{pilcrow} option and are
% only in effect when the \opt{verse/para} and/or \opt{compact} options are in
% use.
%    \begin{macrocode}
\hook_new:n { scripture / pilcrow }
\hook_new:n { scripture / poetry / pilcrow }
%    \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}{\g_@@_mode_vertical_inner_bool}
%   Whether an inner environment is starting in vertical mode. This flag is
%   only used with the \opt{compact} and \opt{verse/para} options.
%    \begin{macrocode}
\bool_new:N \g_@@_mode_vertical_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 }
            \bool_if:NT \l_@@_verse_para_bool
              {
                \peek_meaning:NTF \vs
                  {
                    \bool_gset_true:N \g_@@_suppress_next_verse_para_bool
                    \@@_set_pilcrow_hook:
                  }
                  {
                    \str_if_eq:VnF \l_@@_currenvir_str { poetry }
                      { \@@_pilcrow_output: }
                  }
              }
          }
        \hook_gput_next_code:nn { para / end }
          {
            \bool_if:NTF \l_@@_verse_para_bool
              {
                \str_if_eq:VnTF \l_@@_currenvir_str { poetry }
                  { \cs_set_eq:NN \noindent \tex_noindent:D }
                  { \cs_set_eq:NN \noindent \@@_para_noindent: }
              }
              { \cs_set_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 \fn{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:
  {
    \mode_if_vertical:F \para_end:
    \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:nn}
%   Format a scripture quotation with its reference.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_format_full_ref:nn
  {
    \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:oF { #2 }
          {
            \tl_if_empty:oF { #1 }
              { \l_@@_version_delim_tl }
            \@@_version_format:n { #2 }
          }
      }
    \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:nn { #1 } \l_@@_version_tl
      }
    \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}
%
% \begin{macro}{\@@_reference_start_inline:}
%   Output the reference for the Scripture quotation when inline at the start.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_reference_start_inline:
  {
    \tl_if_empty:NF \l_@@_ref_tl
      {
        \tl_if_eq:NnTF \l_@@_version_position_tl { withref }
          { \@@_format_full_ref:nn { \l_@@_ref_tl } { \l_@@_version_tl } }
          { \@@_format_full_ref:nn { \l_@@_ref_tl } { } }
        \skip_horizontal:N \l_@@_ref_start_sep_tl
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_reference_start_newline:}
%   Output the reference for the Scripture quotation when on a new line at the
%   start.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_reference_start_newline:
  {
    \tl_if_empty:NF \l_@@_ref_tl
      {
        \bool_gset_eq:NN \g_tmpa_bool \g_@@_suppress_next_pilcrow_bool
        \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool
        \noindent
        \bool_gset_eq:NN \g_@@_suppress_next_pilcrow_bool \g_tmpa_bool
        \str_if_eq:VnF \l_@@_currenvir_str { scripture }
          { \skip_horizontal:n { -\leftmargin } }
        \tl_if_eq:NnTF \l_@@_version_position_tl { withref }
          { \@@_format_full_ref:nn { \l_@@_ref_tl } { \l_@@_version_tl } }
          { \@@_format_full_ref:nn { \l_@@_ref_tl } { } }
        \bool_lazy_or:nnT
          { \str_if_eq_p:Vn \l_@@_currenvir_str { flushright } }
          { \str_if_eq_p:Vn \l_@@_currenvir_str { center } }
          {
            \hfill
            \strut
          }
        \bool_if:NTF \l_@@_compact_bool
          { \para_end: }
          {
            \bool_lazy_all:nTF
              {
                { \l_@@_verse_para_bool }
                { \bool_not_p:n { \str_if_eq_p:Vn \l_@@_currenvir_str { hanging } } }
                { \bool_not_p:n { \str_if_eq_p:Vn \l_@@_currenvir_str { poetry } } }
              }
              { \para_end: }
              { \par }
          }
        \nobreak
        \@afterheading
        \addvspace { \l_@@_ref_vertical_sep_tl }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_reference_start_peek:}
%   Peek ahead at the beginning of the \env{scripture} environment to control
%   how references are inserted at the start of a quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_reference_start_peek:
  {
    \peek_remove_spaces:n
      {
        \bool_lazy_and:nnTF
          { \str_if_eq_p:Vn \l_@@_ref_position_tl { start } }
          { \bool_not_p:n { \tl_if_empty_p:N \l_@@_ref_tl } }
          {
            \bool_lazy_or:nnF
              { \str_if_eq_p:Vn \l_@@_currenvir_str { scripture } }
              { \str_if_eq_p:Vn \l_@@_currenvir_str { midparachap } }
              {
                \bool_if:NF \l_@@_compact_bool
                  { \bool_set_true:N \l_@@_ref_start_newline_bool }
              }
            \peek_analysis_map_inline:n
              {
                \bool_case:nF
                  {
                    { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \heading }
                      { \@@_reference_start_newline: }
                    { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \noindent }
                      {
                        \bool_if:NTF \l_@@_ref_start_newline_bool
                          { \@@_reference_start_newline: }
                          { \@@_reference_start_inline: }
                      }
                    { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \nohang }
                      {
                        \bool_if:NTF \l_@@_ref_start_newline_bool
                          { \@@_reference_start_newline: }
                          { \@@_reference_start_inline: }
                      }
                    { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \nopilcrow }
                      {
                        \bool_if:NTF \l_@@_ref_start_newline_bool
                          { \@@_reference_start_newline: }
                          { \@@_reference_start_inline: }
                        \peek_analysis_map_break:n
                          {
                            ##1
                            \@@_fix_protrusion:n { }
                          }
                      }
                    { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \begin }
                      {
                        \bool_if:NF \l_@@_indent_bool
                          {
                            \hook_gput_next_code:nn { para / begin }
                              {
                                \bool_lazy_or:nnT
                                  { \str_if_eq_p:Vn \l_@@_currenvir_str { midparachap } }
                                  { \str_if_eq_p:Vn \l_@@_currenvir_str { scripture } }
                                  { \para_omit_indent: }
                              }
                          }
                      }
                    { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \ch }
                      {
                        \bool_if:NTF \l_@@_ref_start_newline_bool
                          { \@@_reference_start_newline: }
                          {
                            \cs_set_eq:NN \@@_temp_ch \ch
                            \RenewDocumentCommand \ch { s o m }
                              {
                                \tl_if_novalue:nF { ##2 }
                                  {
                                    \tl_set:Nn \l_@@_X_char_tl { ##2 }
                                  }
                                \cs_set_eq:NN \ch \@@_temp_ch
                              }
                            \@@_reference_start_inline:
                          }
                      }
                    { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \vs }
                      {
                        \bool_if:NTF \l_@@_ref_start_newline_bool
                          { \@@_reference_start_newline: }
                          {
                            \cs_set_eq:NN \@@_temp_vs \vs
                            \RenewDocumentCommand \vs { m }
                              { \cs_set_eq:NN \vs \@@_temp_vs }
                            \@@_reference_start_inline:
                          }
                      }
                  }
                  {
                    \bool_if:NTF \l_@@_ref_start_newline_bool
                      {
                        \@@_reference_start_newline:
                        \bool_if:NTF \l_@@_compact_bool
                          {
                            \bool_if:NT \g_@@_mode_vertical_inner_bool
                              { \@@_pilcrow_output: }
                          }
                          {
                            \str_if_eq:VnF \l_@@_currenvir_str { poetry }
                            { \@@_pilcrow_output: }
                          }
                      }
                      { \@@_reference_start_inline: }
                  }
                \exp_args:No \token_if_eq_meaning:NNF { ##1 } \begin
                  {
                    \tl_clear:N \l_@@_ref_tl
                    \tl_if_eq:NnF \l_@@_version_position_tl { end }
                      { \tl_clear:N \l_@@_version_tl }
                  }
                \peek_analysis_map_break:n
                  { \@@_fix_protrusion:o { ##1 } }
              }
          }
          {
            \peek_analysis_map_inline:n
              {
                \bool_case:nF
                  {
                    { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \heading }
                      { }
                    { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \noindent }
                      { }
                    { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \nohang }
                      { }
                    { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \nopilcrow }
                      {
                        \peek_analysis_map_break:n
                          {
                            ##1
                            \@@_fix_protrusion:n { }
                          }
                      }
                    { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \begin }
                      {
                        \bool_if:NF \l_@@_indent_bool
                          {
                            \hook_gput_next_code:nn { para / begin }
                              {
                                \bool_lazy_or:nnT
                                  { \str_if_eq_p:Vn \l_@@_currenvir_str { midparachap } }
                                  { \str_if_eq_p:Vn \l_@@_currenvir_str { scripture } }
                                  { \para_omit_indent: }
                              }
                          }
                      }
                    { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \ch }
                      { }
                    { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \vs }
                      {
                        \mode_if_vertical:F
                          { \@@_set_pilcrow_hook: }
                      }
                  }
                  {
                    \bool_if:NTF \l_@@_compact_bool
                      {
                        \bool_if:NT \g_@@_mode_vertical_inner_bool
                          { \@@_pilcrow_output: }
                      }
                      {
                        \str_if_eq:VnF \l_@@_currenvir_str { poetry }
                        { \@@_pilcrow_output: }
                      }
                  }
                \peek_analysis_map_break:n
                  {
                    \@@_fix_protrusion:o { ##1 }
                  }
              }
          }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_compact_par:}
%   \cs{par} macro used when the \opt{compact} option is in use.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_compact_par:
  {
    \bool_gset_false:N \g_@@_mode_vertical_inner_bool
    \dim_set:Nn \parindent { \l_@@_parindent_tl }
    \peek_remove_spaces:n
      {
        \peek_analysis_map_inline:n
          {
            \bool_case:n
              {
                { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \begin }
                  { \bool_gset_true:N \g_@@_mode_vertical_inner_bool }
                { \str_if_eq_p:Vn \l_@@_currenvir_str { poetry } }
                  { }
                { \exp_args:No \token_if_letter_p:N { ##1 } }
                  { \@@_pilcrow_output: }
                { \exp_args:No \token_if_active_p:N { ##1 } }
                  { \@@_pilcrow_output: }
                { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \vs }
                  { \@@_set_pilcrow_hook: }
              }
            \peek_analysis_map_break:n { ##1 }
          }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_para_noindent:}
%   \cs{noindent} macro used when the \opt{verse/para} option is in use.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_para_noindent:
  {
    \legacy_if:nTF { @newlist }
      {
        \tex_noindent:D
        \peek_meaning:NTF \vs
          {
            \bool_gset_true:N \g_@@_suppress_next_verse_para_bool
            \@@_set_pilcrow_hook:
          }
          { \@@_pilcrow_output: }
      }
      {
        \peek_meaning:NTF \vs
          {
            \bool_if:NT \l_@@_verse_para_bool
              { \para_end: }
            \tex_noindent:D
            \bool_gset_true:N \g_@@_suppress_next_verse_para_bool
            \@@_set_pilcrow_hook:
          }
          { \@@_pilcrow_output: }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\g_@@_para_mode_vertical_bool}
%   Flag that \cs{@@_para_par:} has been encountered and pilcrow not yet
%   printed.
%    \begin{macrocode}
\bool_new:N \g_@@_para_mode_vertical_bool
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\g_@@_post_env_indent_box}
%   Box to store the indent after an inner environment in the case where it is
%   dropped by \cs{@@_dopeend:}. This box is then inserted if the next thing
%   is a \fn{vs}. Only used when the \opt{verse/para} option is active.
%    \begin{macrocode}
\box_new:N \g_@@_post_env_indent_box
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_para_par:}
%   \cs{par} macro used when the \opt{verse/para} option is in use.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_para_par:
  {
    \bool_gset_true:N \g_@@_para_mode_vertical_bool
    \dim_set:Nn \parindent { \l_@@_parindent_tl }
    \peek_remove_spaces:n
      {
        \peek_analysis_map_inline:n
          {
            \bool_case:n
              {
                { \exp_args:No \token_if_letter_p:N { ##1 } }
                  { \@@_pilcrow_output: }
                { \exp_args:No \token_if_active_p:N { ##1 } }
                  { \@@_pilcrow_output: }
                { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \vs }
                  { \@@_set_pilcrow_hook: }
              }
            \peek_analysis_map_break:n { ##1 }
          }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_doendpe:}
%   Custom version of \cs{@doendpe} macro used when the \opt{verse/para}
%   option is in use. This handles pilcrows after inner environments.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_doendpe:
  {
    \box_gclear:N \g_@@_post_env_indent_box
    \legacy_if_set_true:n { @endpe }
    \cs_set_nopar:Npn \par
      {
        \@restorepar
        \clubpenalty \@clubpenalty
        \everypar { }
        \par
        \legacy_if_set_false:n { @endpe }
        \bool_gset_false:N \g_@@_suppress_next_pilcrow_bool
        \@@_para_par:
      }
    \everypar
      {
        \box_gset_to_last:N \g_@@_post_env_indent_box
        \hook_gput_next_code:nn { para / after }
          { \box_gclear:N \g_@@_post_env_indent_box }
        \everypar { }
        \legacy_if_set_false:n { @endpe }
        \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool
        \bool_if:NT \l_@@_verse_para_bool
          {
            \box_set_wd:Nn
              \g_@@_post_env_indent_box
              { \l_@@_para_indent_tl }
          }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_fix_protrusion:n, \@@_fix_protrusion:o}
%   The use of \cs{peek} macros breaks protrusion at the beginning of list
%   environments. This function checks conditions and add \cs{leftprotrusion}.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_fix_protrusion:n
  {
    \bool_if:NTF \l_@@_compact_bool
      {
        \str_if_eq:VnT \l_@@_currenvir_str { scripture }
          { \cs_if_exist_use:N \leftprotrusion }
      }
      { \cs_if_exist_use:N \leftprotrusion }
    #1
  }
\cs_generate_variant:Nn \@@_fix_protrusion:n { o }
%    \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 }
          {
            \@@_set_textdirection:
            \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}{\g_@@_chap_width_dim}
%   Calculated width of drop chapter number.
%    \begin{macrocode}
\dim_new:N \g_@@_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}{\l_@@_para_chap_indent_dim}
%   Indent used to center chapters when placed in their own paragraph.
%    \begin{macrocode}
\dim_new:N \l_@@_para_chap_indent_dim
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_nodrop_chap_coffin}
%   Coffin to place non-drop chapters inside.
%    \begin{macrocode}
\coffin_new:N \l_@@_nodrop_chap_coffin
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l_@@_nodrop_chap_voffset_dim}
%   Vertical offset to use when setting non-drop chapters.
%    \begin{macrocode}
\dim_new:N \l_@@_nodrop_chap_voffset_dim
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_get_X_height:}
%   Calculate the height of \cs{l_@@_X_char_tl} for vertical alignment of
%   non-drop chapters.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_get_X_height:
  {
    \hbox_set:Nn \l_@@_chap_tmp_box { \l_@@_X_char_tl }
    \dim_set:Nn \l_@@_chap_X_height_dim
      { \box_ht:N \l_@@_chap_tmp_box }
  }
%    \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 }
    \@@_get_X_height:
    \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_gset:Nn \g_@@_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
    \bool_if:NF \l_@@_verse_para_bool
    {
      \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:
  {
    \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool
    \cs_if_eq:NNTF \noindent \@@_para_noindent:
      {
        \legacy_if:nTF { @newlist }
          {
            \skip_horizontal:n { -\l_@@_parindent_tl }
          }
          { \tex_noindent:D }
        \@@_pilcrow_output:
      }
      { \noindent }
    \parshape 3 ~
      \dim_eval:n
        { \@totalleftmargin + \g_@@_chap_width_dim + \l_@@_chap_sep_tl } ~
      \dim_eval:n
        { \linewidth - \g_@@_chap_width_dim - \l_@@_chap_sep_tl } ~
      \dim_eval:n
        { \@totalleftmargin + \g_@@_chap_width_dim + \l_@@_chap_sep_tl } ~
      \dim_eval:n
        { \linewidth - \g_@@_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 } }
    \bool_if:NT \l_@@_verse_para_bool
    {
      \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 }
        }
    }
    \hook_gclear_next_code:n { scripture / pilcrow }
  }
%    \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:NT \l_@@_verse_para_bool
      {
        \legacy_if:nF { @newlist }
          { \mode_if_vertical:F \para_end: }
      }
    \bool_if:NTF \l_@@_chap_show_bool
      {
        \@@_get_X_height:
        \hcoffin_set:Nn \l_@@_nodrop_chap_coffin
          {
            \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 }
            \kern \l_@@_chap_sep_tl
          }
        \dim_zero:N \l_@@_nodrop_chap_voffset_dim
        \tl_if_eq:NnT \l_@@_chapter_valign_tl { t }
          { \dim_set_eq:NN \l_@@_nodrop_chap_voffset_dim \l_@@_chap_X_height_dim }
        \tl_if_eq:NnT \l_@@_chapter_valign_tl { vc }
          { \dim_set:Nn \l_@@_nodrop_chap_voffset_dim { 0.5 \l_@@_chap_X_height_dim } }
        \hook_use:n { scripture / chap / before }
        \bool_if:NTF \l_@@_chap_smash_bool
          {
            \mode_leave_vertical:
            \smash
              {
                \exp_args:NNoo
                  \coffin_typeset:Nnnnn \l_@@_nodrop_chap_coffin
                    { \l_@@_chapter_align_tl }
                    { \l_@@_chapter_valign_tl }
                    { 0pt }
                    { \l_@@_nodrop_chap_voffset_dim }
              }
          }
          {
            \exp_args:NNoo
              \coffin_typeset:Nnnnn \l_@@_nodrop_chap_coffin
                { \l_@@_chapter_align_tl }
                { \l_@@_chapter_valign_tl }
                { 0pt }
                { \l_@@_nodrop_chap_voffset_dim }
          }
        \nobreak
        \skip_horizontal:N \c_zero_skip
        \hook_use:n { scripture / chap / after }
        \bool_if:NT \l_@@_chap_show_verse_bool
          {
            \@@_verse_output:n { 1 }
          }
        \str_if_eq:VnF \l_@@_currenvir_str { midparachap }
          { \@@_pilcrow_output: }
      }
      {
        \hook_use:n { scripture / chap / before }
        \hook_use:n { scripture / chap / after }
        \vs { 1 }
      }
    \group_end:
    \parshape 1 ~ \@totalleftmargin ~ \linewidth
    \hook_gclear_next_code:n { scripture / pilcrow }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_para_chap:n}
%   Format a chapter in its own paragraph.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_para_chap:n
  {
    \cs_gset_nopar:Npn \scripturecurrentchapter { #1 }
    \cs_gset_nopar:Npn \scripturecurrentverse { 1 }
    \group_begin:
    \skip_zero:N \parskip
    \bool_if:NTF \l_@@_chap_show_bool
      {
        \dim_set_eq:NN \l_@@_para_chap_indent_dim \linewidth
        \str_if_eq:VnTF \l_@@_currenvir_str { scripture }
          {
            \dim_set:Nn \l_@@_para_chap_indent_dim { 0.5 \l_@@_para_chap_indent_dim }
          }
          {
            \dim_add:Nn \l_@@_para_chap_indent_dim { \leftmargin + \rightmargin }
            \dim_set:Nn \l_@@_para_chap_indent_dim { 0.5 \l_@@_para_chap_indent_dim }
            \dim_sub:Nn \l_@@_para_chap_indent_dim \leftmargin
          }
        \mode_if_vertical:F \para_end:
        \addvspace { \l_@@_chap_para_aboveskip_tl }
        \bool_gset_eq:NN \g_tmpa_bool \g_@@_suppress_next_pilcrow_bool
        \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool
        \str_if_eq:VnTF \l_@@_currenvir_str { midparachap }
          { \tex_noindent:D }
          { \noindent }
        \bool_gset_eq:NN \g_@@_suppress_next_pilcrow_bool \g_tmpa_bool
        \skip_horizontal:N \l_@@_para_chap_indent_dim
        \hbox_overlap_center:n
          {
            \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:
            \hook_use:n { scripture / chap / after }
          }
        \para_end:
        \nobreak
        \bool_lazy_any:nTF
          {
            { \str_if_eq_p:Vn \l_@@_currenvir_str { scripture } }
            { \str_if_eq_p:Vn \l_@@_currenvir_str { midparachap } }
            { \str_if_eq_p:Vn \l_@@_currenvir_str { narrow } }
          }
          { \legacy_if_set:nn { @afterindent } { \l_@@_chap_para_afterindent_bool } }
          { \legacy_if_set_true:n { @afterindent } }
        \@afterheading
      }
      {
        \hook_use:n { scripture / chap / before }
        \hook_use:n { scripture / chap / after }
      }
    \peek_meaning:NTF \c_space_token
      {
        \addvspace { \l_@@_chap_para_belowskip_tl }
        \group_end:
        \hook_use:n { scripture / poetry / pilcrow }
      }
      {
        \addvspace { \l_@@_chap_para_belowskip_tl }
        \cs_if_eq:NNTF \vs \@@_poetry_mode_vertical_verse:n
          {
            \bool_gset_eq:NN \g_tmpa_bool \g_@@_suppress_next_pilcrow_bool
            \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool
            \noindent
            \vs { 1 }
            \bool_gset_eq:NN \g_@@_suppress_next_pilcrow_bool \g_tmpa_bool
          }
          {
            \str_if_eq:VnT \l_@@_currenvir_str { midparachap }
              { \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool }
            \vs { 1 }
          }
        \group_end:
        \hook_use:n { scripture / poetry / pilcrow }
      }
  }
%    \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: }
      {
        \para_end:
        \@@_drop_chap_output:
        \str_if_eq:VnF \l_@@_currenvir_str { midparachap }
          { \@@_pilcrow_output: }
      }
    \hook_gput_next_code:nn { para / before }
      {
        \legacy_if:nF { @newlist }
          {
            \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1
              {
                \dim_compare:nNnT \parskip < \baselineskip
                  {
                    \dim_compare:nNnT { \g_@@_chap_width_dim + \l_@@_chap_sep_tl } > \parindent
                      {
                        \hook_gput_next_code:nn { para / begin }
                          {
                            \para_omit_indent:
                            \skip_horizontal:n {\g_@@_chap_width_dim + \l_@@_chap_sep_tl }
                          }
                      }
                  }
              }
            \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}{\g_@@_suppress_next_verse_para_bool}
%   Suppress the next verse from starting a new paragraph when
%   \opt{verse/para} is in use.
%    \begin{macrocode}
\bool_new:N \g_@@_suppress_next_verse_para_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:
    \bool_if:NT \l_@@_verse_para_bool
      {
        \box_if_empty:NF \g_@@_post_env_indent_box
          { \box_use_drop:N \g_@@_post_env_indent_box }
      }
    \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
          }
        \nobreak
        \skip_horizontal:N \c_zero_skip
      }
    \hook_use:n { scripture / verse / after }
    \hook_use:n { scripture / pilcrow }
    \group_end:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_verse_compact_output:n}
%   Output a formatted verse.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_verse_compact_output:n
  {
    \mode_if_vertical:T
      { \@@_set_pilcrow_hook: }
    \@@_verse_output:n { #1 }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_verse_para_output:n}
%   Output a formatted verse when \opt{verse/para} is set.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_verse_para_output:n
  {
    \mode_if_vertical:T
      { \@@_set_pilcrow_hook: }
    \hook_if_empty:nT { scripture / pilcrow }
      { \dim_set:Nn \parindent \l_@@_para_indent_tl }
    \bool_if:NTF \g_@@_suppress_next_verse_para_bool
      { \bool_gset_false:N \g_@@_suppress_next_verse_para_bool }
      {
        \legacy_if:nF { @newlist }
          {
            \mode_if_vertical:F
              {
                \para_end:
                \parshape 1 ~ \@totalleftmargin ~ \linewidth
              }
          }
      }
    \@@_verse_output:n { #1 }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_hanging_verse_para:n}
%   Output a formatted verse when \opt{verse/para} is set and in a hanging
%   environment.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_hanging_verse_para:n
  {
    \mode_if_vertical:T
      { \@@_set_pilcrow_hook: }
    \bool_if:NF \g_@@_suppress_next_verse_para_bool
      {
        \legacy_if:nF { @newlist }
          {
            \mode_if_vertical:F
              {
                \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool
                \hook_gput_next_code:nn { para / begin }
                  { \parshape 1 ~ \@totalleftmargin ~ \linewidth }
                \par
                \tex_noindent:D
              }
          }
      }
    \bool_gset_false:N \g_@@_suppress_next_verse_para_bool
    \@@_hanging_verse:n { #1 }
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Printing pilcrows}
%
% \begin{macro}{\g_@@_suppress_next_pilcrow_bool}
%   Flag to suppress the next pilcrow.
%    \begin{macrocode}
\bool_new:N \g_@@_suppress_next_pilcrow_bool
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_set_pilcrow_hook:}
%   Set the next \hook{scripture/pilcrow} hook to output a pilcrow providing
%   the hook is currently empty.
%   \opt{verse/para} or \opt{compact} options are set.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_set_pilcrow_hook:
  {
    \hook_if_empty:nT { scripture / pilcrow }
      {
        \hook_gput_next_code:nn { scripture / pilcrow } { \@@_pilcrow_output: }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_pilcrow_output:}
%   Output a pilcrow (\P). Pilrows only display when either the
%   \opt{verse/para} or \opt{compact} options are set.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_pilcrow_output:
  {
    \bool_gset_false:N \g_@@_para_mode_vertical_bool
    \bool_gset_false:N \g_@@_mode_vertical_inner_bool
    \bool_if:NT \l_@@_pilcrow_bool
      {
        \bool_lazy_or:nnT \l_@@_verse_para_bool \l_@@_compact_bool
          {
            \bool_if:NTF \g_@@_suppress_next_pilcrow_bool
              { \bool_gset_false:N \g_@@_suppress_next_pilcrow_bool }
              {
                \P
                \kern \l_@@_pilcrow_sep_tl
                \nobreak
                \skip_horizontal:N \c_zero_skip
              }
          }
      }
  }
%    \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
    $$
      \hook_use:n { para / after }
      \dim_compare:nNnTF \predisplaysize > \c_zero_dim
        {
          \dim_gset:Nn \g_@@_final_line_dim
            { \predisplaysize - 2em }
        }
        {
          \bool_if:NT \l_@@_textdir_change_in_group_bool
            {
              \str_if_eq:VnT \l_@@_currenvir_str { scripture }
                { \int_set:Nn \prevgraf { \int_use:N \prevgraf - 1 } }
            }
        }
      \cs_gset_nopar:Nx \@@_reset_spacing:
        {
          \dim_set:Nn \predisplaysize { \dim_use:N \predisplaysize }
          \int_set:Nn \prevgraf { \int_use:N \prevgraf }
          \int_gset:Nn \g_@@_chap_par_prevgraf_int { \int_use:N \g_@@_chap_par_prevgraf_int }
        }
    $$
    \@@_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 - 1sp }
      { \skip_vertical:n { -\baselineskip - \parskip } }
  }
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{The \env{scripture} environment}
%
% \begin{macro}{\l_@@_currenvir_str}
%   Store the current \env{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}{\l_@@_ref_tl}
%   Store the reference passed to the \env{scripture} environment.
%    \begin{macrocode}
\tl_new:N \l_@@_ref_tl
%    \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}{\@@_heading:n}
%   Output a non-canonical heading.
%    \begin{macrocode}
\cs_new_protected_nopar:Nn \@@_heading:n
  {
    \str_if_eq:VnTF \l_@@_currenvir_str { scripture }
      {
        \bool_if:NTF \l_@@_heading_show_bool
          {
            \parshape 1 ~ \@totalleftmargin ~ \linewidth
            \group_begin:
            \bool_set_false:N \l_@@_pilcrow_bool
            \legacy_if:nTF { @newlist }
              {
                \skip_horizontal:n { -\parindent }
              }
              {
                \@@_list_para_end:
                \addvspace { \l_@@_heading_aboveskip_tl }
                \tex_noindent:D
              }
            \l_@@_heading_align_tl
            \l_@@_heading_font_tl
            \@@_heading_format:n { #1 }
            \@@_list_para_end:
            \group_end:
            \bool_if:NTF \l_@@_verse_para_bool
              {
                \cs_set_eq:NN \noindent \_@@_para_noindent:
              }
              {
                \cs_set_eq:NN \noindent \tex_noindent:D
              }
            \legacy_if_set:nn { @afterindent } \l_@@_heading_afterindent_bool
            \bool_if:NF \l_@@_heading_afterindent_bool
              {
                \hook_gput_next_code:nn { para / before }
                  { \para_omit_indent: }
              }
            \nobreak
            \@afterheading
            \addvspace { \l_@@_heading_belowskip_tl }
          }
          { \ignorespaces }
      }
      {
        \msg_error:nnx { scripture } { heading-error } { \l_@@_currenvir_str }
      }
  }
%    \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_output: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_lazy_and:nnTF
            { #1 }
            { \bool_not_p:n { \l_@@_compact_bool } }
            {
              \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 }
            }
          }
          {
            \bool_if:NTF \l_@@_chap_para_bool
              { \@@_para_chap:n { #2 } }
              { \@@_nodrop_chap:n { #2 } }
          }
      }
      {
        \bool_if:NTF \l_@@_chap_para_bool
          { \@@_para_chap:n { #2 } }
          { \@@_nodrop_chap:n { #2 } }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_begin:nn}
%   Begin a scripture quotation.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_begin:nn
  {
    \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_if_novalue:nF { #1 }
      { \tl_set:Nn \l_@@_ref_tl { #1 } }
    \str_set:Nn \l_@@_currenvir_str { scripture }
    \tl_if_novalue:nF { #2 }
      {
        \keys_set:nn { scripture } { #2 }
      }
    \l_@@_before_tl
    \@@_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:
    \cs_set:Npn \nopilcrow { \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool }
    \bool_gset_false:N \g_@@_suppress_next_pilcrow_bool
    \bool_gset_false:N \g_@@_suppress_next_verse_para_bool
    \bool_gset_false:N \g_@@_mode_vertical_inner_bool
    \box_gclear:N \g_@@_post_env_indent_box
    \skip_gzero:N \g_@@_prev_inner_below_skip
    \bool_if:NT \l_@@_chap_para_bool
      { \bool_set_false:N \l_@@_chap_drop_bool }
    \DeclareDocumentCommand { \ch } { s o m }
      {
        \tl_if_novalue:nF { ##2 }
          {
            \tl_set:Nn \l_@@_X_char_tl { ##2 }
          }
        \@@_ch_output:nn { ##1 } { ##3 }
      }
    \cs_set_eq:NN \vs \@@_verse_output:n
    \cs_set_eq:NN \added \@@_added:n
    \cs_set_eq:NN \heading \@@_heading: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 }
    \hook_gclear_next_code:n { scripture / pilcow }
    \hook_gclear_next_code:n { scripture / poetry / pilcow }
    \l_@@_font_tl
    \tl_set:Ne \l_@@_parindent_tl { \dim_eval:n { \l_@@_parindent_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_if:NTF \l_@@_compact_bool
                      { \para_omit_indent: }
                      {
                        \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 }
                              {
                                \bool_lazy_and:nnF
                                  { \str_if_eq_p:Vn \l_@@_currenvir_str { narrow } }
                                  { \str_if_eq_p:Vn \l_@@_ref_position_tl { start } }
                                  { \noindent }
                              }
                              { \para_omit_indent: }
                          }
                      }
                  }
              }
          }
        \cs_set_eq:NN \@@_list_para_end: \@par
        \item
        \relax
    }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_end:}
%   End a scripture quotation with a reference.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_end:
  {
    \tl_if_eq:NnT \l_@@_ref_position_tl { start }
      {
        \tl_clear:N \l_@@_ref_tl
        \tl_if_eq:NnT \l_@@_version_position_tl { withref }
          { \tl_clear:N \l_@@_version_tl }
      }
    \cs_set_eq:NN \noindent \tex_noindent:D
    \bool_if:NTF \l_@@_inline_bool
      {
        \unskip
        \@@_red_letter_off:
        \l_@@_inline_end_tl
        \bool_lazy_or:nnTF
          { \tl_if_novalue_p:n \l_@@_ref_tl }
          { \tl_if_empty_p:N \l_@@_ref_tl }
          {
            \tl_if_empty:NF \l_@@_version_tl
              {
                \skip_horizontal:N \l_@@_ref_sep_tl
                \@@_format_full_ref:nn { } \l_@@_version_tl
              }
          }
          {
            \skip_horizontal:N \l_@@_ref_sep_tl
            \@@_format_full_ref:nn \l_@@_ref_tl \l_@@_version_tl
          }
      }
      {
        \@@_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. Also correct for \cs{textdir} quirk.
%    \begin{macrocode}
        \int_compare:nNnT \prevgraf = \c_zero_int
          {
            \bool_if:NT \l_@@_textdir_change_in_group_bool
              { \skip_vertical:n { -\baselineskip } }
            \skip_vertical:n { -\g_@@_prev_inner_below_skip }
          }
        \hook_gclear_next_code:n { para / before }
        \noindent
        \bool_lazy_or:nnTF
          { \tl_if_novalue_p:n \l_@@_ref_tl }
          { \tl_if_empty_p:N \l_@@_ref_tl }
          { 
            \tl_if_empty:NTF \l_@@_version_tl
              { \hbox:n { } }
              { \@@_reference:n { } }
          }
          { \@@_reference:n \l_@@_ref_tl }
        \parshape 1 ~ \@totalleftmargin ~ \linewidth
%    \end{macrocode}
% Set \val{@noparlist} to \val{false} to ensure \cs{topsep} is always added
% \env{scripture} environment
%    \begin{macrocode}
        \legacy_if_set_false:n { @noparlist }
        \endlist
      }
    \cs_set_eq:NN \noindent \@@_noindent_saved:
    \l_@@_after_tl
  }
%    \end{macrocode}
% \end{macro}
%
% \subsection{Scripture internal environments}
%
% \begin{macro}{\@@_compact_end_inner:}
%   End a compact inner environment
%    \begin{macrocode}
\cs_new_protected:Nn \@@_compact_end_inner:
  {
    \bool_gset_false:N \g_@@_mode_vertical_inner_bool
    \str_if_eq:VnT \l_@@_ref_position_tl { start }
      {
        \tl_gclear:N \l_@@_ref_tl
      }
    \bool_lazy_and:nnT \l_@@_verse_para_bool \l_@@_chap_drop_bool
      {
        \cs_set_eq:NN \par \para_end:
        \@@_calc_final_line_length:
        \int_gset_eq:NN \g_@@_mid_para_chap_prevgraf_int \g_@@_chap_par_prevgraf_int
        \tex_noindent:D
        \bool_lazy_and:nnTF
          { \bool_if_p:N \l_@@_compact_bool }
          { \int_compare_p:nNn \g_@@_mid_para_chap_prevgraf_int = 1 }
          {
            \hook_gput_next_code:nn { env / \l_@@_currenvir_str / after }
              {
                \parshape 3 ~
                  \@totalleftmargin ~ \linewidth ~
                  \dim_eval:n
                    { \@totalleftmargin + \g_@@_chap_width_dim + \l_@@_chap_sep_tl } ~
                  \dim_eval:n
                    { \linewidth - \g_@@_chap_width_dim - \l_@@_chap_sep_tl } ~
                  \@totalleftmargin ~ \linewidth
              }
            \hbox_to_wd:nn { \g_@@_final_line_dim - \g_@@_chap_width_dim - \l_@@_chap_sep_tl } { }
          }
          {
            \hbox_to_wd:nn \g_@@_final_line_dim { }
          }
        \c_space_token
        \kern 0pt
        \cs_set_eq:NN \par \relax
        \hook_gput_next_code:nn { para / before }
          {
            \int_compare:nNnT \g_@@_mid_para_chap_prevgraf_int = 1
              {
                \dim_compare:nNnT \parskip < \baselineskip
                  {
                    \dim_compare:nNnT { \g_@@_chap_width_dim + \l_@@_chap_sep_tl } > \parindent
                      {
                        \hook_gput_next_code:nn { para / begin }
                          {
                            \para_omit_indent:
                            \skip_horizontal:n {\g_@@_chap_width_dim + \l_@@_chap_sep_tl }
                          }
                      }
                  }
              }
            \int_gzero:N \g_@@_chap_par_prevgraf_int
            \parshape 1 ~ \@totalleftmargin ~ \linewidth
          }
      }
    \unskip
  }
%    \end{macrocode}
% \end{macro}
%
%
%
% \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
    \str_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 }
    \cs_set_eq:NN \par \para_end:
    \list { }
      {
        \bool_lazy_or:nnF
          { \mode_if_vertical_p: }
          { \g_@@_para_mode_vertical_bool }
          { \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool }
        \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
    \bool_if:NT \l_@@_verse_para_bool
      {
        \cs_set_eq:NN \par \@@_para_par:
        \cs_set_protected:Npn \\
          {
            \mode_if_horizontal:TF
              { \unskip }
              { \@nolnerr }
          }
      }
    \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:
  {
    \cs_set_eq:NN \par \para_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
    \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool
  }
%    \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
    \str_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 }
    \cs_set_eq:NN \par \para_end:
    \list { }
      {
        \bool_lazy_or:nnF
          { \mode_if_vertical_p: }
          { \g_@@_para_mode_vertical_bool }
          { \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool }
        \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
    \bool_if:NT \l_@@_verse_para_bool
      {
        \cs_set_eq:NN \par \@@_para_par:
        \cs_set_protected:Npn \\
          {
            \mode_if_horizontal:TF
              { \unskip }
              { \@nolnerr }
          }
      }
    \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:
  {
    \cs_set_eq:NN \par \para_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
    \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool
  }
%    \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_gset_false:N \g_@@_suppress_next_pilcrow_bool
    \bool_if:NTF \l_@@_chap_show_bool
      {
        \bool_if:NTF \l_@@_chap_drop_bool
          { \@@_hanging_chap:n { #1 } }
          {
            \bool_if:NTF \l_@@_chap_para_bool
              { \@@_para_chap:n { #1 } }
              { \@@_nodrop_chap:n { #1 } }
          }
      }
      {
        \bool_if:NTF \l_@@_chap_para_bool
          { \@@_para_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
      { \g_@@_chap_width_dim + \l_@@_chap_sep_tl } < \leftmargin
      {
        \bool_if:NT \l_@@_hanging_chapter_indent_bool
          {
            \tl_set:Nx \l_@@_chap_sep_tl
              {
                \dim_eval:n { \leftmargin - \g_@@_chap_width_dim }
              }
          }
      }
      {
        \parshape 3 ~
          \dim_eval:n
            {
              \@totalleftmargin - \leftmargin + \g_@@_chap_width_dim +
              \l_@@_chap_sep_tl
            } ~
          \dim_eval:n
            {
              \linewidth + \leftmargin - \g_@@_chap_width_dim -
              \l_@@_chap_sep_tl
            } ~
          \dim_eval:n
            {
              \@totalleftmargin - \leftmargin + \g_@@_chap_width_dim +
              \l_@@_chap_sep_tl
            } ~
          \dim_eval:n
            {
              \linewidth + \leftmargin - \g_@@_chap_width_dim -
              \l_@@_chap_sep_tl
            } ~
          \@totalleftmargin ~ \linewidth
      }
    \par
    \bool_if:NTF \l_@@_hanging_chapter_indent_bool
      {
        \tl_set:Nx \l_@@_chap_sep_tl
          {
            \dim_eval:n
              {
                \l_@@_chap_sep_tl + \l_@@_hanging_parindent_saved_dim
              }
          }
        \@@_nohang:
      }
      {
        \mode_leave_vertical:
        \dim_compare:nNnTF
          { \g_@@_chap_width_dim + \l_@@_chap_sep_tl } > \l_@@_hanging_leftmargin_tl
          {
            \dim_compare:nNnTF
              { \g_@@_chap_width_dim + \l_@@_chap_sep_tl } > \leftmargin
              {
                \skip_horizontal:n { \l_@@_hanging_hang_tl }
              }
              {
                \skip_horizontal:n
                  {
                    \l_@@_chap_sep_tl +
                    \g_@@_chap_width_dim -
                    \l_@@_hanging_leftmargin_tl
                  }
              }
          }
          {
            \tl_set:Nx \l_@@_chap_sep_tl
              {
                \dim_eval:n
                  { \l_@@_hanging_leftmargin_tl - \g_@@_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_@@_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 }
      }
    \@@_pilcrow_output:
    \bool_if:NT \l_@@_verse_para_bool
    {
      \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
            }
        }
    }
    \hook_gput_next_code:nn { para / begin }
      {
        \int_compare:nNnTF \g_@@_chap_par_prevgraf_int = \c_one_int
          {
            \dim_compare:nNnTF
              { \l_@@_hanging_leftmargin_tl } < { \g_@@_chap_width_dim + \l_@@_chap_sep_tl }
              {
                \parshape 2 ~
                  \dim_eval:n
                    {
                      \@totalleftmargin - \leftmargin + \g_@@_chap_width_dim +
                      \l_@@_chap_sep_tl
                    } ~
                  \dim_eval:n
                    {
                      \linewidth + \leftmargin - \g_@@_chap_width_dim -
                      \l_@@_chap_sep_tl
                    } ~
                  \@totalleftmargin ~ \linewidth
              }
              { \parshape 1 ~ \@totalleftmargin ~ \linewidth }
            \hook_gput_next_code:nn { para / begin }
              { \parshape 1 ~ \@totalleftmargin ~ \linewidth }
          }
          { \parshape 1 ~ \@totalleftmargin ~ \linewidth }
        \int_gzero:N \g_@@_chap_par_prevgraf_int
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_hanging_verse:n}
%   Position a \fn{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
      {
        \tl_set_eq:NN \l_tmpa_tl \l_@@_verse_sep_tl
        \tl_set_eq:NN \l_@@_verse_sep_tl \l_@@_hanging_verse_sep_tl
        \bool_lazy_and:nnTF
          { \legacy_if_p:n { @newlist } }
          { \g_@@_suppress_next_pilcrow_bool }
          {
            \strut
            \bool_if:NTF \l_@@_hanging_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_@@_hanging_leftmargin_tl
                  }
              }
          }
          {
            \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool
            \strut
            \bool_if:NTF \l_@@_hanging_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_@@_hanging_leftmargin_tl
                  }
              }
            \@@_pilcrow_output:
          }
        \tl_set_eq:NN \l_@@_verse_sep_tl \l_tmpa_tl
      }
      { \@@_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:
  {
    \legacy_if:nTF {@newlist}
      { \skip_horizontal:n { \l_@@_hanging_hang_tl } }
      { \tex_noindent:D }
    \hbox_to_wd:nn { \l_@@_hanging_parindent_saved_dim } { }
    \peek_meaning:NT \vs
      {
        \bool_gset_true:N \g_@@_suppress_next_verse_para_bool
        \@@_set_pilcrow_hook:
      }
  }
%    \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
    \str_set:Nn \l_@@_currenvir_str { hanging }
    \tl_if_novalue:nF { #1 }
      {
        \keys_set:nn
          { scripture / hanging }
          { #1 }
      }
    \DeclareDocumentCommand { \ch } { s o m }
      {
        \tl_if_novalue:nF { ##2 }
          {
            \tl_set:Nn \l_@@_X_char_tl { ##2 }
          }
        \@@_hanging_ch:n { ##3 }
      }
    \bool_if:NTF \l_@@_verse_para_bool
      { \cs_set_eq:NN \vs \@@_hanging_verse_para:n }
      { \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 }
    \cs_set_eq:NN \par \para_end:
    \hook_gclear_next_code:n { para/ before }
    \list { }
      {
        \bool_lazy_or:nnF
          { \mode_if_vertical_p: }
          { \g_@@_para_mode_vertical_bool }
          { \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool }
        \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
    \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool
  }
%    \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}{\@@_mid_para_chap_end_orig:n,
%               \@@_mid_para_chap_end:n}
% Custom \cs{end} macro for the \env{midparachap} environment. This is only
% used when the \opt{verse/para} and/or \opt{compact} options are in use.
%    \begin{macrocode}
\cs_set_eq:Nc \@@_mid_para_chap_end_orig:n { end ~ }
\cs_new_nopar:Nn \@@_mid_para_chap_end:n
  {
    \@@_mid_para_chap_end_orig:n { #1 }
    \bool_if:NT \l_@@_compact_bool
      { \c_space_token }
    \peek_remove_spaces:n
      {
        \peek_analysis_map_inline:n
          {
            \bool_case:n
              {
                { \exp_args:No \token_if_letter_p:N { ##1 } }
                  { \@@_pilcrow_output: }
                { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \vs }
                  { \@@_set_pilcrow_hook: }
              }
            \peek_analysis_map_break:n { ##1 }
          }
      }
  }
%    \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 +
        \g_@@_chap_width_dim +
        \l_@@_chap_sep_tl
      }
      <
      { \linewidth - \leftskip - \rightskip - 3em }
      {
        \@@_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
  {
    \str_set:Nn \l_@@_currenvir_str { midparachap }
    \tl_if_novalue:nF { #1 }
      {
        \keys_set:nn
          { scripture / midparachap }
          { #1 }
      }
    \bool_lazy_and:nnT \l_@@_chap_show_verse_bool \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 { \g_@@_chap_width_dim + \l_@@_chap_sep_tl }
        \dim_gadd:Nn \g_@@_final_line_dim { \g_@@_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 }
      {
        \legacy_if:nF { @newlist }
          {
            \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1
              {
                \dim_compare:nNnT \parskip < \baselineskip
                  {
                    \dim_compare:nNnT { \g_@@_chap_width_dim + \l_@@_chap_sep_tl } > \parindent
                      {
                        \hook_gput_next_code:nn { para / begin }
                          {
                            \para_omit_indent:
                            \skip_horizontal:n {\g_@@_chap_width_dim + \l_@@_chap_sep_tl }
                          }
                      }
                  }
              }
            \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
    \str_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 }
    \cs_set_eq:NN \par \para_end:
    \list { }
      {
        \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
        \bool_lazy_or:nnTF
          { \mode_if_vertical_p: }
          { \g_@@_para_mode_vertical_bool }
          {
            \dim_set:Nn \itemindent { \parindent - \l_@@_outer_itemindent_dim }
            \@@_setup_list_noindent:n { \parindent }
          }
          {
            \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool
            \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
    \bool_if:NT \l_@@_verse_para_bool
      { \cs_set_eq:NN \par \@@_para_par: }
    \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:
  {
    \cs_set_eq:NN \par \para_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
    \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool
  }
%    \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}{\l_@@_poetry_midparachap_show_verse_bool}
%   Flag indicating whether the verse number should be printed immediately
%   after a \fn{ch} or not in a \env{poetry} environment.
%    \begin{macrocode}
\bool_new:N \l_@@_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_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 } }
          {
            \bool_if:NTF \l_@@_chap_para_bool
              { \@@_para_chap:n { #1 } }
              { \@@_poetry_nodrop_chap:n { #1 } }
          }
      }
      {
        \bool_if:NTF \l_@@_chap_para_bool
          { \@@_para_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 }
     \hook_gput_next_code:nn { para / after }
       {
         \hook_gput_next_code:nn { para / after }
           { \int_gzero:N \g_@@_chap_par_prevgraf_int }
       }
    \cs_if_eq:NNTF \vs \@@_poetry_mode_vertical_verse:n
      {
        \dim_zero:N \l_@@_poetry_chap_indent_dim
        \noindent
      }
      {
        \dim_set_eq:NN \l_@@_poetry_chap_indent_dim \l_@@_poetry_indent_tl
        \mode_leave_vertical:
      }
    \dim_set_eq:NN \l_@@_poetry_chap_sep_dim \l_@@_chap_sep_tl
    \dim_compare:nNnT
      { \g_@@_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 -
            \g_@@_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
      {
        \g_@@_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}
%   Set the \cs{parshape} for the second line after a drop chapter number.
%    \begin{macrocode}
    \dim_compare:nNnT
      { \g_@@_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
              {
                \cs_if_eq:NNTF \vs \@@_poetry_mode_vertical_verse:n
%    \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
                      { \g_@@_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
                          {
                            \g_@@_chap_width_dim + \l_@@_chap_sep_tl -
                            \l_@@_poetry_leftmargin_tl
                          }
                      }
                    \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1
                      {
                        \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}
%   This \cs{parshape} is in effect when the next line is the second half of a
%   poetry verse.
%    \begin{macrocode}
                  {
                    \dim_compare:nNnTF
                      { \g_@@_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
                          {
                            \g_@@_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 }
                  }
              }
          }
      }
    \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 \l_@@_chap_show_verse_bool \l_@@_poetry_midparachap_show_verse_bool
      { \@@_verse_output:n { 1 } }
    \hook_use:n { scripture / poetry / pilcrow }
  }
%    \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:
    \cs_if_eq:NNT \vs \@@_poetry_mode_vertical_verse:n
      { \noindent }
    \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 \l_@@_chap_show_verse_bool \l_@@_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:
    \hook_use:n { scripture / poetry / pilcrow }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_poetry_mode_vertical_verse:n}
%   Format a verse for poetry scripture quotations in vertical 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
    \hook_gclear_next_code:n { scripture / pilcrow }
    \strut
    \int_compare:nNnTF \g_@@_chap_par_prevgraf_int = 1
      {
        \@@_verse_output:n { #1 }
      }
      {
        \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:
    \bool_if:NF \g_@@_suppress_next_pilcrow_bool
      { \hook_use:n { scripture / poetry / pilcrow } }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_poetry_mode_horizontal_verse:n}
%   Format a verse for poetry scripture quotations in horizontal mode.
%    \begin{macrocode}
\cs_new_protected:Nn \@@_poetry_mode_horizontal_verse:n
  {
    \group_begin:
    \tl_set_eq:NN \l_@@_verse_sep_tl \l_@@_poetry_verse_sep_tl
    \int_compare:nNnTF \g_@@_chap_par_prevgraf_int = 1
      {
        \@@_poetry_mode_vertical_verse:n { #1 }
      }
      {
        \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:
  {
    \para_end:
    \int_set:Nn \l_@@_poetry_prevgraf_int { \int_use:N \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_eol:%
    }%
\group_end:
\cs_new_protected:Nn \@@_obeylines_eol:
  {
    \mode_if_vertical:TF
      {
        \cs_set_eq:NN \vs \@@_poetry_mode_vertical_verse:n
        \hook_gput_next_code:nn { scripture / poetry / para / after }
          { \bool_set_false:N \l_@@_poetry_midparachap_show_verse_bool }
      }
      { \cs_set_eq:NN \vs \@@_poetry_mode_horizontal_verse:n }
    \peek_analysis_map_inline:n
      {
        \bool_case:nF
          {
            { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \ch }
              {
                \bool_set_eq:NN \l_@@_poetry_midparachap_show_verse_bool \l_@@_midparachap_show_verse_bool
                \@@_poetry_par:
                \peek_analysis_map_break:n { ##1 }
              }
            { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \end }
              { \peek_analysis_map_break:n { ##1 } }
            { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \extraskip }
              { \peek_analysis_map_break:n { ##1 } }
            { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \nopilcrow }
              {
                \@@_poetry_par:
                \cs_if_eq:NNT \vs \@@_poetry_mode_vertical_verse:n
                  { \noindent }
                \peek_analysis_map_break:n
                  {
                    \@@_fix_protrusion:o { ##1 }
                  }
              }
            { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \vs }
              {
                \@@_poetry_par:
                \cs_if_eq:NNT \vs \@@_poetry_mode_vertical_verse:n
                  { \noindent }
                \peek_analysis_map_break:n { ##1 }
              }
            { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \@@_obeylines_eol: }
              { \cs_set_eq:NN \vs \@@_poetry_mode_vertical_verse:n }
          }
          {
            \@@_poetry_par:
            \cs_if_eq:NNT \vs \@@_poetry_mode_vertical_verse:n
              { \noindent }
            \bool_if:NT \l_@@_verse_para_bool
              {
                \@@_pilcrow_output:
                \bool_set_false:N \l_@@_verse_para_bool
                \bool_set_false:N \l_@@_pilcrow_bool
              }
            \peek_analysis_map_break:n
              {
                \@@_fix_protrusion:o { ##1 }
              }
          }
      }
  }
%    \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
    \str_set:Nn \l_@@_currenvir_str { poetry }
    \bool_gset_false:N \g_@@_poetry_midparachap_show_verse_bool
    \DeclareDocumentCommand { \ch } { s o m }
      {
        \tl_if_novalue:nF { ##2 }
          {
            \tl_set:Nn \l_@@_X_char_tl { ##2 }
          }
        \@@_poetry_ch:n { ##3 }
      }
    \cs_set_eq:NN \vs \@@_poetry_mode_vertical_verse:n
    \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 }
    \cs_set_eq:NN \par \para_end:
    \cs_set_eq:NN \noindent \tex_noindent:D
    \hook_gput_next_code:nn { scripture / poetry / pilcrow }
      {
        \@@_pilcrow_output:
        \bool_set_false:N \l_@@_pilcrow_bool
        \bool_set_false:N \l_@@_verse_para_bool
      }
    \list { }
      {
        \bool_lazy_or:nnF
          { \mode_if_vertical_p: }
          { \g_@@_para_mode_vertical_bool }
          { \bool_gset_true:N \g_@@_suppress_next_pilcrow_bool }
        \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
  }
%    \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_@@_suppress_next_pilcrow_bool
    \hook_gclear_next_code:n { scripture / poetry / pilcrow }
    \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 \fn{ch} and \fn{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}. You may want to pass \opt{defaults} as the first
%   option to ensure any unset options in your style are expected defaults.
%   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:nn { #1 } { #2 }
%    \end{macrocode}
% \begin{envmacro}{center}
%   \begin{arguments}
%     \item \meta{|options|} to set.
%   \end{arguments}
%    \begin{macrocode}
    \DeclareDocumentEnvironment { center } { o }
      {
        \@@_center_begin:n { ##1 }
        \@@_reference_start_peek:
      }
      { \@@_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 }
        \@@_reference_start_peek:
      }
      { \@@_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 }
        \@@_reference_start_peek:
      }
      { \@@_hanging_end: }
%    \end{macrocode}
% \end{envmacro}
% \vspace{-2\baselineskip}
% \begin{envmacro}{midparachap}
%    \begin{macrocode}
    \DeclareDocumentEnvironment { midparachap } { o }
      {
        \@@_mid_para_chap_begin:n { ##1 }
        \@@_reference_start_peek:
      }
      { \@@_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 }
        \@@_reference_start_peek:
      }
      { \@@_narrow_end: }
%    \end{macrocode}
% \end{envmacro}
% \begin{envmacro}{poetry}
%   \begin{arguments}
%     \item \meta{|options|} to set.
%   \end{arguments}
% The \val{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:
        \@@_reference_start_peek:
      }
      { \@@_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_false:N \l_@@_chap_para_bool
        \bool_set_true:N \l_@@_compact_bool
        \bool_set_false:N \l_@@_heading_show_bool
      }
    \bool_if:NT \l_@@_chap_para_bool
      {
        \RenewDocumentEnvironment { midparachap } { o } { \ignorespaces } { \unskip }
      }
    \bool_if:NT \l_@@_verse_para_bool
      {
        \cs_set_eq:NN \vs \@@_verse_para_output:n
        \cs_set_eq:NN \par \@@_para_par:
        \cs_set_eq:NN \@par \@@_para_par:
        \cs_set_eq:NN \@doendpe \@@_doendpe:
        \cs_set_eq:NN \noindent \@@_para_noindent:
        \cs_set_protected:Npn \\
          {
            \mode_if_horizontal:TF
              { \unskip }
              { \@nolnerr }
          }
        \RenewDocumentEnvironment { midparachap } { o }
          {
            \str_set:Nn \l_@@_currenvir_str { midparachap }
            \cs_set_eq:NN \noindent \tex_noindent:D
            \cs_set_eq:cN { end ~ } \@@_mid_para_chap_end:n
            \@@_reference_start_peek:
          }
          {
            \para_end:
            \bool_gset_false:N \g_@@_suppress_next_pilcrow_bool
          }
      }
    \bool_if:NT \l_@@_compact_bool
      {
        \cs_set_eq:NN \noindent \@@_para_noindent:
        \bool_if:NF \l_@@_verse_para_bool
          {
            \bool_set_false:N \l_@@_chap_drop_bool
            \bool_set_false:N \l_@@_chap_drop_llap_bool
            \bool_set_false:N \l_@@_chap_drop_smash_bool
            \bool_set_false:N \l_@@_chap_para_bool
            \cs_set_eq:NN \vs \@@_verse_compact_output:n
          }
        \bool_gset:Nn \g_@@_mode_vertical_inner_bool
          { \mode_if_vertical_p: }
        \RenewDocumentEnvironment { center } { o }
          {
            \str_set:Nn \l_@@_currenvir_str { center }
            \@@_reference_start_peek:
          }
          { \@@_compact_end_inner: }
        \RenewDocumentEnvironment { flushright } { o }
          {
            \str_set:Nn \l_@@_currenvir_str { flushright }
            \@@_reference_start_peek:
          }
          { \@@_compact_end_inner: }
        \RenewDocumentEnvironment { hanging } { o }
          {
            \str_set:Nn \l_@@_currenvir_str { hanging }
            \@@_reference_start_peek:
          }
          { \@@_compact_end_inner: }
        \RenewDocumentEnvironment { midparachap } { o }
          {
            \str_set:Nn \l_@@_currenvir_str { midparachap }
            \cs_set_eq:cN { end ~ } \@@_mid_para_chap_end:n
            \@@_reference_start_peek:
          }
          { \@@_compact_end_inner: }
        \RenewDocumentEnvironment { narrow } { o }
          {
            \str_set:Nn \l_@@_currenvir_str { narrow }
            \@@_reference_start_peek:
          }
          { \@@_compact_end_inner: }
        \RenewDocumentEnvironment { poetry } { o }
          {
            \str_set:Nn \l_@@_currenvir_str { poetry }
            \@@_reference_start_peek:
          }
          { \@@_compact_end_inner: }
        \cs_set_eq:NN \\ \unskip
        \cs_set_eq:NN \par \@@_compact_par:
        \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
          }
      }
    \@@_reference_start_peek:
  }
  {
    \bool_lazy_or:nnT \l_@@_compact_bool \l_@@_verse_para_bool
      { \cs_set_eq:NN \par \para_end: }
    \@@_end:
  }
%    \end{macrocode}
% \end{envmacro}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
% \end{implementation}
%
% \PrintChanges
%
% \PrintIndex