diff options
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/scripture/README.md | 4 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/scripture/scripture.pdf | bin | 755299 -> 872053 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/scripture/scripture.dtx | 1642 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/scripture/scripture.sty | 668 |
4 files changed, 1999 insertions, 315 deletions
diff --git a/Master/texmf-dist/doc/latex/scripture/README.md b/Master/texmf-dist/doc/latex/scripture/README.md index 9aab2b86ec0..a90ab28fe7f 100644 --- a/Master/texmf-dist/doc/latex/scripture/README.md +++ b/Master/texmf-dist/doc/latex/scripture/README.md @@ -57,10 +57,10 @@ l3build install --full ## Licence ``` -Copyright (c) 2018-2022 David Purton <dcpurton@marshwiggle.net> +Copyright (c) 2022 David Purton <dcpurton@marshwiggle.net> This work may be distributed and/or modified under the conditions of -the LaTeX Project2 Public License, either version 1.3c of this license +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 diff --git a/Master/texmf-dist/doc/latex/scripture/scripture.pdf b/Master/texmf-dist/doc/latex/scripture/scripture.pdf Binary files differindex 6ebd1f263fb..7eb267b1a7d 100644 --- a/Master/texmf-dist/doc/latex/scripture/scripture.pdf +++ b/Master/texmf-dist/doc/latex/scripture/scripture.pdf diff --git a/Master/texmf-dist/source/latex/scripture/scripture.dtx b/Master/texmf-dist/source/latex/scripture/scripture.dtx index e9d51175fbe..f298f02a23a 100644 --- a/Master/texmf-dist/source/latex/scripture/scripture.dtx +++ b/Master/texmf-dist/source/latex/scripture/scripture.dtx @@ -16,10 +16,18 @@ \usepackage[skins]{tcolorbox} \newtcolorbox{scriptureexample}[1][]{% bicolor, colframe=cyan, colback=cyan!10, colbacklower=white, left=2mm, + fonttitle=\normalsize\sffamily\bfseries, + subtitle style={before skip=3mm, after skip=3mm}, right=2mm, fontupper=\footnotesize, fontlower=\footnotesize, sidebyside, sidebyside gap=6mm, sidebyside align=top, lefthand ratio=0.6, before skip=\bigskipamount, after skip=\bigskipamount, #1 } +\tcbset{% + sidebysidecompare/.style={% + enhanced, colback=white, lefthand ratio=0.5, segmentation empty}, + compare/.style={% + standard, colback=white, sidebyside=false} +} \ExplSyntaxOn \makeatletter \cs_new_protected:Npn \__dcp_codedoc_environment_index:n #1 @@ -70,12 +78,77 @@ \tl_set:Nn \saved@indexname { \l__codedoc_index_key_tl } } } +\cs_new_protected:Npn \__dcp_codedoc_hook_index:n #1 + { + \@bsphack + \begingroup + \__codedoc_target: + \index + { + #1\actualchar{\protect\ttfamily#1}~(hook) + \encapchar hdclindex{\the\c@HD@hypercount}{usage} + } + \index + { + hooks:\levelchar#1\actualchar{\protect\ttfamily#1} + \encapchar hdclindex{\the\c@HD@hypercount}{usage} + } + \endgroup + \@esphack + } +\cs_new_protected:Npn \__dcp_codedoc_hookmacro_index:nN #1#2 + { + \DoNotIndex {#1} + \bool_if:NT #2 + { + \__codedoc_if_macro_internal:nF {#1} + { \seq_gput_right:Nn \g_doc_macros_seq {#1} } + \hbox_set:Nw \l__codedoc_macro_index_box + \hbox_unpack_drop:N \l__codedoc_macro_index_box + \int_gincr:N \c@CodelineNo + \@bsphack + \begingroup + \__codedoc_target: + \index + { + #1\actualchar{\protect\ttfamily#1}~(hook) + \encapchar hdclindex{\the\c@HD@hypercount}{main} + } + \index + { + hooks:\levelchar#1\actualchar{\protect\ttfamily#1} + \encapchar hdclindex{\the\c@HD@hypercount}{main} + } + \endgroup + \@esphack + \int_gdecr:N \c@CodelineNo + \exp_args:NNNo \hbox_set_end: + \tl_set:Nn \saved@indexname { \l__codedoc_index_key_tl } + } + } \DeclareDocumentEnvironment { environment } { O{} +v } { \cs_set_eq:NN \__codedoc_function_index:n \__dcp_codedoc_environment_index:n \__codedoc_function:nnw {#1} {#2} } { \__codedoc_function_end: } +\DeclareDocumentEnvironment { hooks } { O{} +v } + { + \bool_if:NTF \l__codedoc_in_implementation_bool + { + \cs_set_eq:NN \__codedoc_macro_index:nN \__dcp_codedoc_hookmacro_index:nN + \__codedoc_macro:nnw { var , #1 } {#2} + } + { + \cs_set_eq:NN \__codedoc_function_index:n \__dcp_codedoc_hook_index:n + \__codedoc_function:nnw {#1} {#2} + } + } + { + \bool_if:NTF \l__codedoc_in_implementation_bool + { \__codedoc_macro_end: } + { \__codedoc_function_end: } + } \DeclareDocumentEnvironment { option } { O{} +v } { \cs_set_eq:NN \__codedoc_function_index:n \SpecialOptionIndex @@ -90,9 +163,14 @@ { \__codedoc_macro_end: } \DeclareDocumentCommand \opt { m } { - \SpecialOptionIndex{#1} + \SpecialOptionIndex {#1} \texttt{#1} } +\DeclareDocumentCommand \hook { m } + { + \__dcp_codedoc_hook_index:n {#1} + \texttt {#1} + } \DeclareRobustCommand \val {\texttt} \makeatother \ExplSyntaxOff @@ -103,10 +181,11 @@ % \fi % % \changes{v1.0}{2022/07/27}{First public release} +% \changes{v1.1}{2022/08/27}{Bug fixes} % % \title{The \pkg{scripture} package} % \author{David Purton\thanks{Email: \url{dcpurton@marshwiggle.net}}} -% \date{2022/07/27 v1.0} +% \date{2022/08/27 v1.1} % % \maketitle % @@ -156,6 +235,12 @@ % \item Include any other \env{list} based environment within a % \env{scripture} environment. % \end{itemize} +% +% 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. % % \section{Documentation} % @@ -168,7 +253,6 @@ % \begin{verbatim} % \begin{scripture}[Isaiah 56:1--2][version=NIVUK] % \ch{56}This is what the \textsc{Lord} says: -% % \begin{poetry} % `Maintain justice % and do what is right, @@ -189,7 +273,6 @@ % % \begin{scripture}[Isaiah 56:1--2][version=NIVUK] % \ch{56}This is what the \textsc{Lord} says: -% % \begin{poetry} % `Maintain justice % and do what is right, @@ -225,6 +308,66 @@ % 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 \textsc{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 \textsc{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 \textsc{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 \textsc{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| @@ -234,6 +377,30 @@ % 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} +% % \begin{function}{\nohang} % \begin{syntax} % |\nohang| @@ -243,6 +410,85 @@ % Remaining lines continue to be indented by a length of \opt{hanging/hang}. % \end{function} % +% \begin{scriptureexample} +% \begin{verbatim} +% \begin{scripture}[Genesis 1:10--11] +% \begin{hanging} +% \noindent\vs{10}God called the dry ground +% `land', and the gathered waters he called +% `seas'. And God saw that it was good. +% +% \nohang\vs{11}Then God said, `Let the land +% produce vegetation: seed-bearing plants and +% trees on the land that bear fruit with seed +% in it, according to their various kinds.' +% And it was so. +% \end{hanging} +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[Genesis 1:10--11] +% \begin{hanging} +% \noindent\vs{10}God called the dry ground +% `land', and the gathered waters he called +% `seas'. And God saw that it was good. +% +% \nohang\vs{11}Then God said, `Let the land +% produce vegetation: seed-bearing plants and +% trees on the land that bear fruit with seed +% in it, according to their various kinds.' +% And it was so. +% \end{hanging} +% \end{scripture} +% \end{scriptureexample} +% +% \changes{v1.1}{2022/08/07}{Add \cs{scripturecurrentchapter} and +% \cs{scripturecurrentverse} variables} +% \begin{function}[added=2022-08-07]{\scripturecurrentchapter, +% \scripturecurrentverse} +% \begin{syntax} +% |\scripturecurrentchapter| +% |\scripturecurrentverse| +% \end{syntax} +% \cs{scripturecurrentcapter} and \cs{scripturecurrentverse} globally hold +% the most recent values parsed to \cs{ch} and \cs{vs}. They can initialised +% with \cs{renewcommand*} if required and could be used in hooks, for +% example. +% \end{function} +% +% \changes{v1.1}{2022/07/29}{Add \cs{selah} function} +% \begin{function}[added=2022-07-29]{\selah} +% \begin{syntax} +% |\selah| +% \end{syntax} +% In a \env{poetry} environment, this function inserts \emph{Selah} at the +% end of the current line or the end of the following line if there is +% insufficient room. See options \opt{selah/font}, \opt{selah/format}, +% \opt{selah/sep} and \opt{selah/text} for options controlling the output. +% \end{function} +% +% \begin{scriptureexample} +% \begin{verbatim} +% \begin{scripture}[Psalm 3:2][version=NIV84] +% \begin{poetry} +% \vs{2}Many are saying of me, +% ``God will not deliver him.''\selah +% \end{poetry} +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[Psalm 3:2][version=NIV84] +% \begin{poetry} +% \vs{2}Many are saying of me, +% ``God will not deliver him.''\selah +% \end{poetry} +% \end{scripture} +% \end{scriptureexample} +% % \begin{function}{\scripturesetup} % \begin{syntax} % |\scripturesetup|\marg{options} @@ -283,9 +529,8 @@ % \begin{scriptureexample} % \begin{verbatim} % \begin{scripture}[Daniel 5:25] -% \vs{25}‘This is the inscription that was +% \vs{25}`This is the inscription that was % written: -% % \begin{center} % \textsc{mene, mene, tekel, parsin} % \end{center} @@ -295,9 +540,8 @@ % \tcblower % % \begin{scripture}[Daniel 5:25] -% \vs{25}‘This is the inscription that was +% \vs{25}`This is the inscription that was % written: -% % \begin{center} % \textsc{mene, mene, tekel, parsin} % \end{center} @@ -322,8 +566,8 @@ % \begin{verbatim} % \begin{scripture}[Jeremiah 2:29] % \begin{poetry}[belowskip=0pt] -% \vs{5}‘Why do you bring charges against me? -% You have all rebelled against me,’ +% \vs{5}`Why do you bring charges against me? +% You have all rebelled against me,' % \end{poetry} % % \begin{flushright}[aboveskip=0pt] @@ -336,8 +580,8 @@ % % \begin{scripture}[Jeremiah 2:29] % \begin{poetry}[belowskip=0pt] -% \vs{5}‘Why do you bring charges against me? -% You have all rebelled against me,’ +% \vs{5}`Why do you bring charges against me? +% You have all rebelled against me,' % \end{poetry} % % \begin{flushright}[aboveskip=0pt] @@ -363,11 +607,11 @@ % \begin{verbatim} % \begin{scripture}[Genesis 1:3--5] % \begin{hanging} -% \vs{3}And God said, ‘Let there be light,’ and +% \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 +% 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} @@ -378,11 +622,11 @@ % % \begin{scripture}[Genesis 1:3--5] % \begin{hanging} -% \vs{3}And God said, ‘Let there be light,’ and +% \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 +% 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} @@ -391,7 +635,7 @@ % % \begin{environment}{midparachap} % \begin{syntax} -% |\begin{midparachap}| +% |\begin{midparachap}|\oarg{options} % \quad\meta{text containing a chapter break} % |\end{midparachap}| % \end{syntax} @@ -400,6 +644,9 @@ % \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] @@ -455,13 +702,12 @@ % the secretary, and Joah son of Asaph the % recorder went out to them. % -% \vs{19}The field commander said to them, ‘Tell +% \vs{19}The field commander said to them, `Tell % Hezekiah: -% % \begin{narrow} -% ‘“This is what the great king, the king of -% Assyria, says: on what are you basing this -% confidence of yours? +% `\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} @@ -474,13 +720,12 @@ % the secretary, and Joah son of Asaph the % recorder went out to them. % -% \vs{19}The field commander said to them, ‘Tell +% \vs{19}The field commander said to them, `Tell % Hezekiah: -% % \begin{narrow} -% ‘“This is what the great king, the king of -% Assyria, says: on what are you basing this -% confidence of yours? +% `\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} @@ -500,7 +745,7 @@ % \noindent Environment for typesetting poetry sections of scripture % quotations. % -% Poetry sections of the Bible often have a first have and a parallel second +% 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. @@ -514,7 +759,7 @@ % \vs{2}Hear me, you heavens! Listen, earth! % For the \textsc{Lord} has spoken: % -% ‘I reared children and brought them up, +% `I reared children and brought them up, % but they have rebelled against me. % \end{poetry} % \end{scripture} @@ -527,7 +772,7 @@ % \vs{2}Hear me, you heavens! Listen, earth! % For the \textsc{Lord} has spoken: % -% ‘I reared children and brought them up, +% `I reared children and brought them up, % but they have rebelled against me. % \end{poetry} % \end{scripture} @@ -564,6 +809,91 @@ % \end{scripture} % \end{scriptureexample} % +% \subsection{Provided hooks} +% +% \changes{v1.1}{2022/08/07}{Add before and after hooks for verses and +% chapters} +% \begin{hooks}[added=2022-08-07]{scripture/chap/before, scripture/chap/after, +% scripture/verse/before, scripture/verse/after} +% The following public hooks are available: +% +% \begin{description} +% \item[\hook{scripture/chap/before}] This hook is executed immediately +% before the \opt{chap/font} is set for the chapter. +% \item[\hook{scripture/chap/after}] This hook is executed immediately after +% the \opt{chap/sep} space is inserted. +% \item[\hook{scripture/verse/before}] This hook is executed immediately +% before the \opt{verse/font} is set for the verse. +% \item[\hook{scripture/chap/after}] This hook is executed immediately after +% the \opt{verse/sep} space is inserted. +% \end{description} +% \end{hooks} +% +% The following example illustrates how these hooks could be used to place the +% first and last verse on the page into the header. +% +% \begin{scriptureexample} +% \begin{verbatim} +% \documentclass{article} +% \usepackage{scripture} +% \AddToHook{scripture/chap/after}{% +% \markboth +% {Mark \scripturecurrentchapter +% :\scripturecurrentverse} +% {Mark \scripturecurrentchapter +% :\scripturecurrentverse}} +% \AddToHook{scripture/verse/after}{% +% \markboth +% {Mark \scripturecurrentchapter +% :\scripturecurrentverse} +% {Mark \scripturecurrentchapter +% :\scripturecurrentverse}} +% \renewcommand*{\scripturecurrentchapter}{1} +% \usepackage{fancyhdr} +% \pagestyle{fancy} +% \fancyhf{} +% \lhead{\textbf{\rightmark}} +% \rhead{\textbf{\leftmark} \textbar\ \thepage} +% \begin{document} +% \noindent +% \begin{scripture} +% \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} +% +% \noindent +% \begin{scripture} +% \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} % @@ -586,6 +916,61 @@ % \meta{|skip|} inserted below the \env{scripture} environment. % \end{option} % +% \changes{v1.1}{2022/08/15}{Add \opt{compact} option} +% \begin{option}[added=2022-08-15]{compact} +% \begin{syntax} +% |compact =| \meta{boolean} \hfill Default: false +% \end{syntax} +% This option removes all paragraph breaks along with any \cs{extraskip} in +% the quotation so the whole quotation is a single paragraph of running +% prose. This option implies \opt{chapter/nodrop} and all options relating +% to inner environments are ignored. +% +% The value of \meta{|boolean|} is optional and assumed to be \val{true} if +% not present. +% +% \textbf{Warning:} This option redefines \cs{par} to \cs{relax} inside the +% \env{scripture} environment. If you have anything other than expected +% macros and environments inside your \env{scripture} environment \TeX{} +% will likely get stuck in an infinite loop. +% \end{option} +% +% \begin{scriptureexample} +% \begin{verbatim} +% \begin{scripture}[Jonah 1:17--2:2a][compact] +% \begin{midparachap} +% \vs{17}Now the \textsc{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 \textsc{Lord} his God. \vs{2}He +% said: +% \end{midparachap} +% \begin{poetry} +% `In my distress I called to the Lord, +% and he answered me. +% \end{poetry} +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[Jonah 1:17--2:2a][compact] +% \begin{midparachap} +% \vs{17}Now the \textsc{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 \textsc{Lord} his God. \vs{2}He +% said: +% \end{midparachap} +% \begin{poetry} +% `In my distress I called to the Lord, +% and he answered me. +% \end{poetry} +% \end{scripture} +% \end{scriptureexample} +% % \begin{option}{leftmargin} % \begin{syntax} % |leftmargin =| \meta{dimen} \hfill Default: 0pt @@ -602,6 +987,16 @@ % environment. % \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} @@ -609,16 +1004,51 @@ % \meta{|font|} used for the \cs{ch} function. % \end{option} % -% \begin{option}{chapter/drop} +% \changes{v1.1}{2022/07/28}{Add \opt{chapter/format} option} +% \begin{option}[added=2022-07-28]{chapter/format} % \begin{syntax} -% |chapter/drop =| \meta{boolean} \hfill Default: true +% |chapter/format =| \meta{macro} \hfill Default: \#1 % \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}. +% \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 @@ -629,6 +1059,28 @@ % opposite of \opt{chapter/drop}. % \end{option} % +% \begin{scriptureexample} +% \begin{verbatim} +% \begin{scripture}[John 1:1--3][chapter/nodrop] +% \ch{1}In the beginning was the Word, and the +% Word was with God, and the Word was God. +% \vs{2}He was with God in the beginning. +% \vs{3}Through him all things were made; without +% him nothing was made that has been made. +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[John 1:1--3][chapter/nodrop] +% \ch{1}In the beginning was the Word, and the +% Word was with God, and the Word was God. +% \vs{2}He was with God in the beginning. +% \vs{3}Through him all things were made; without +% him nothing was made that has been made. +% \end{scripture} +% \end{scriptureexample} +% % \begin{option}{chapter/sep} % \begin{syntax} % |chapter/sep =| \meta{dimen} \hfill Default: 0.5em @@ -636,9 +1088,19 @@ % \meta{|dimen|} used to separate a \cs{ch} from the following text. % \end{option} % +% \changes{v1.1}{2022/08/15}{Add \opt{chapter/show} option} +% \begin{option}[added=2022-08-15]{chapter/show} +% \begin{syntax} +% |chapter/show =| \meta{boolean} \hfill Default: true +% \end{syntax} +% Whether chapters should be shown or hidden. The value of \meta{|boolean|} +% is optional and assumed to be \val{true} if not present. This option is +% the opposite of \opt{chapter/hide}. +% \end{option} +% % \begin{option}{extraskip} % \begin{syntax} -% |extraskip =| \meta{skip} \hfill Default: \cs{medskip} +% |extraskip =| \meta{skip} \hfill Default: \cs{medskipamount} % \end{syntax} % \meta{|skip|} used for the \cs{extraskip} function. % \end{option} @@ -655,8 +1117,8 @@ % |indent =| \meta{boolean} \hfill Default: true % \end{syntax} % Whether to indent the first line of a \env{scripture} environment or not -% by \cs{parindent}. The value of \meta{|boolean|} is optional and assumed to -% be \val{true} if not present. This option is the opposite of +% 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} % @@ -665,11 +1127,31 @@ % |noindent =| \meta{boolean} \hfill Default: false % \end{syntax} % Whether to indent the first line of a \env{scripture} environment or not -% by \cs{parindent}. The value of \meta{|boolean|} is optional and assumed to -% be \val{true} if not present. This option is the opposite of +% 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} @@ -695,7 +1177,7 @@ % % \begin{option}{reference/font} % \begin{syntax} -% |reference/font =| \meta{font} \hfill Default: bfseries +% |reference/font =| \meta{font} \hfill Default: \cs{bfseries} % \end{syntax} % \meta{|font|} used when printing the \val{reference} for a \env{scripture} % quotation. @@ -718,6 +1200,36 @@ % the following line. % \end{option} % +% \begin{option}{selah/font} +% \begin{syntax} +% |selah/font =| \meta{font} \hfill Default: \cs{itshape} +% \end{syntax} +% \meta{|font|} used when printing \cs{selah} in a \env{poetry} environment. +% \end{option} +% +% \begin{option}{selah/format} +% \begin{syntax} +% |selah/format =| \meta{macro} \hfill Default: \#1 +% \end{syntax} +% \meta{|macro|} used to format the \cs{selah} in a \env{poetry} +% environment. |#1| contains the value of \opt{selah/text}. +% \end{option} +% +% \begin{option}{selah/sep} +% \begin{syntax} +% |selah/sep =| \meta{dimen} \hfill Default: 1em +% \end{syntax} +% The minimum \meta{|dimen|} allowed between the end of a poetry line and +% \emph{Selah} before the \emph{Selah} is pushed to the following line. +% \end{option} +% +% \begin{option}{selah/text} +% \begin{syntax} +% |selah/text =| \meta{text} \hfill Default: Selah +% \end{syntax} +% \meta{|text|} used to for \cs{selah} in a \env{poetry} environment. +% \end{option} +% % \begin{option}{verse/font} % \begin{syntax} % |verse/font =| \meta{font} \hfill Default: \emph{Empty} @@ -733,6 +1245,62 @@ % argument of \cs{vs}. % \end{option} % +% \changes{v1.1}{2022/08/15}{Add \opt{verse/hide} option} +% \begin{option}[added=2022-08-15]{verse/hide} +% \begin{syntax} +% |verse/hide =| \meta{boolean} \hfill Default: false +% \end{syntax} +% Whether verses should be shown or hidden. The value of \meta{|boolean|} is +% optional and assumed to be \val{true} if not present. This option is the +% opposite of \opt{verse/show}. Note that the \hook{scripture/verse/before} +% and \hook{scripture/verse/after} hooks are still executed when verses are +% hidden. +% \end{option} +% +% \begin{scriptureexample} +% \begin{verbatim} +% \begin{scripture}[Colossians 1:15--16][verse/hide] +% \vs{15}The Son is the image of the invisible +% God, the firstborn over all creation. +% \vs{16}For in him all things were created: +% things in heaven and on earth, visible and +% invisible, whether thrones or powers or rulers +% or authorities; all things have been created +% through him and for him. +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[Colossians 1:15--16][verse/hide] +% \vs{15}The Son is the image of the invisible +% God, the firstborn over all creation. +% \vs{16}For in him all things were created: +% things in heaven and on earth, visible and +% invisible, whether thrones or powers or rulers +% or authorities; all things have been created +% through him and for him. +% \end{scripture} +% \end{scriptureexample} +% +% \changes{v1.1}{2022/07/28}{Add \opt{verse/sep} option with small default} +% \begin{option}[added=2022-07-28]{verse/sep} +% \begin{syntax} +% |verse/sep =| \meta{dimen} \hfill Default: 0.05 em +% \end{syntax} +% \meta{|dimen|} used to separate a \cs{vs} from the following text. +% \end{option} +% +% \changes{v1.1}{2022/08/15}{Add \opt{verse/show} option} +% \begin{option}[added=2022-08-15]{verse/show} +% \begin{syntax} +% |verse/show =| \meta{boolean} \hfill Default: true +% \end{syntax} +% Whether verses should be shown or hidden. The value of \meta{|boolean|} +% is optional and assumed to be \val{true} if not present. This option is +% the opposite of \opt{verse/hide}. +% \end{option} +% % \begin{option}{version} % \begin{syntax} % |version =| \meta{version} \hfill Default: \emph{Empty} @@ -766,14 +1334,14 @@ % % \begin{option}{center/aboveskip} % \begin{syntax} -% |center/aboveskip =| \meta{skip} \hfill Default: \cs{medskip} +% |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{medskip} +% |center/belowskip =| \meta{skip} \hfill Default: \cs{medskipamount} % \end{syntax} % \meta{|skip|} inserted below the \env{center} environment. % \end{option} @@ -801,14 +1369,14 @@ % % \begin{option}{flushright/aboveskip} % \begin{syntax} -% |flushright/aboveskip =| \meta{skip} \hfill Default: \cs{medskip} +% |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{medskip} +% |flushright/belowskip =| \meta{skip} \hfill Default: \cs{medskipamount} % \end{syntax} % \meta{|skip|} inserted below the \env{flushright} environment. % \end{option} @@ -836,14 +1404,14 @@ % % \begin{option}{hanging/aboveskip} % \begin{syntax} -% |hanging/aboveskip =| \meta{skip} \hfill Default: \cs{medskip} +% |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{medskip} +% |hanging/belowskip =| \meta{skip} \hfill Default: \cs{medskipamount} % \end{syntax} % \meta{|skip|} inserted below the \env{hanging} environment. % \end{option} @@ -870,6 +1438,79 @@ % \meta{|dimen|} used for the right margin of the \env{hanging} environment. % \end{option} % +% \subsubsection{Options for the \env{midparachap} environment} +% \label{midparachapoptions} +% +% If these options are passed directly to the \env{midparachap} environment +% rather than to the package, \cs{scripturesetup} or the \env{scripture} +% environment, then the |midparachap/| prefix should be dropped. +% +% \begin{option}{midparachap/hideverse} +% \begin{syntax} +% |midparachap/hideverse =| \meta{boolean} \hfill Default: false +% \end{syntax} +% Whether a \cs{vs}|{1}| should automatically be inserted after a \cs{ch} +% when the \cs{ch} occurs mid-paragraph. This also affects \cs{ch} in +% \env{poetry} environments. \cs{extraskip} begins a new paragraph in a +% \env{poetry} environment. The value of \meta{|boolean|} is optional and +% assumed to be \val{true} if not present. This option is the opposite of +% \opt{midparachap/showverse}. +% \end{option} +% +% \begin{scriptureexample} +% \begin{verbatim} +% \begin{scripture}[Hosea 11:12--12:1]% +% [midparachap/hideverse] +% \begin{poetry} +% \vs{12}Ephraim has surrounded me with lies, +% Israel with deceit. +% +% And Judah is unruly against God, +% even against the faithful Holy One. +% +% \ch{12}Ephraim feeds on the wind; +% he pursues the east wind all day +% and multiplies lies and violence. +% +% He makes a treaty with Assyria +% and sends olive oil to Egypt. +% \end{poetry} +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[Hosea 11:12--12:1]% +% [midparachap/hideverse] +% \begin{poetry} +% \vs{12}Ephraim has surrounded me with lies, +% Israel with deceit. +% +% And Judah is unruly against God, +% even against the faithful Holy One. +% +% \ch{12}Ephraim feeds on the wind; +% he pursues the east wind all day +% and multiplies lies and violence. +% +% He makes a treaty with Assyria +% and sends olive oil to Egypt. +% \end{poetry} +% \end{scripture} +% \end{scriptureexample} +% +% \begin{option}{midparachap/showverse} +% \begin{syntax} +% |midparachap/showverse =| \meta{boolean} \hfill Default: true +% \end{syntax} +% Whether a \cs{vs}|{1}| should automatically be inserted after a \cs{ch} +% when the \cs{ch} occurs mid-paragraph. This also affects \cs{ch} in +% \env{poetry} environments. \cs{extraskip} begins a new paragraph in a +% \env{poetry} environment. The value of \meta{|boolean|} is optional and +% assumed to be \val{true} if not present. This option is the opposite of +% \opt{midparachap/hideverse}. +% \end{option} +% % \subsubsection{Options for the \env{narrow} environment} % \label{narrowoptions} % @@ -879,14 +1520,14 @@ % % \begin{option}{narrow/aboveskip} % \begin{syntax} -% |narrow/aboveskip =| \meta{skip} \hfill Default: \cs{medskip} +% |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{medskip} +% |narrow/belowskip =| \meta{skip} \hfill Default: \cs{medskipamount} % \end{syntax} % \meta{|skip|} inserted below the \env{narrow} environment. % \end{option} @@ -914,14 +1555,14 @@ % % \begin{option}{poetry/aboveskip} % \begin{syntax} -% |poetry/aboveskip =| \meta{skip} \hfill Default: \cs{medskip} +% |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{medskip} +% |poetry/belowskip =| \meta{skip} \hfill Default: \cs{medskipamount} % \end{syntax} % \meta{|skip|} inserted below the \env{poetry} environment. % \end{option} @@ -956,6 +1597,80 @@ % \meta{|dimen|} used for the right margin of the \env{poetry} environment. % \end{option} % +% \changes{v1.1}{2022/07/31}{Add \opt{poetry/verse/left} option} +% \begin{option}[added=2022-07-31]{poetry/verse/left} +% \begin{syntax} +% |poetry/verse/left =| \meta{boolean} \hfill Default: false +% \end{syntax} +% Align verse numbers in \env{poetry} environments at the left margin of the +% \env{scripture} environment. This option is the opposite of +% \opt{poetry/verse/right}. +% \end{option} +% +% \begin{scriptureexample}[lefthand ratio=0.65] +% \begin{verbatim} +% \begin{scripture}[Atcs 15:15--18]% +% [poetry/leftmargin=2em, poetry/verse/left] +% \vs{15}The words of the prophets are in +% agreement with this, as it is written: +% \begin{poetry} +% \vs{16}`\thinspace``After this I will return +% and rebuild David’s fallen tent. +% +% Its ruins I will rebuild, +% and I will restore it, +% +% \vs{17}that the rest of mankind may seek the Lord, +% even all the Gentiles who bear my name, +% +% says the Lord, who does these things''--- +% \vs{18}things known from long ago. +% \end{poetry} +% \end{scripture} +% \end{verbatim} +% +% \tcblower +% +% \begin{scripture}[Atcs 15:15--18]% +% [poetry/leftmargin=2em, poetry/verse/left] +% \vs{15}The words of the prophets are in +% agreement with this, as it is written: +% \begin{poetry} +% \vs{16}`\thinspace``After this I will return +% and rebuild David’s fallen tent. +% +% Its ruins I will rebuild, +% and I will restore it, +% +% \vs{17}that the rest of mankind may seek the Lord, +% even all the Gentiles who bear my name, +% +% says the Lord, who does these things''--- +% \vs{18}things known from long ago. +% \end{poetry} +% \end{scripture} +% \end{scriptureexample} +% +% \changes{v1.1}{2022/07/31}{Add \opt{poetry/verse/right} option} +% \begin{option}[added=2022-07-31]{poetry/verse/right} +% \begin{syntax} +% |poetry/verse/right =| \meta{boolean} \hfill Default: true +% \end{syntax} +% Align verse numbers in \env{poetry} environments at the left margin of the +% poetry environment. The verse numbers overlap to the left. This option is +% the opposite of \opt{poetry/verse/left}. +% \end{option} +% +% \changes{v1.1}{2022/07/31}{Add \opt{poetry/verse/sep} option} +% \begin{option}[added=2022-07-31]{poetry/verse/sep} +% \begin{syntax} +% |poetry/verse/sep =| \meta{dimen} \hfill Default: 0.05 em +% \end{syntax} +% \meta{|dimen|} used to separate a \cs{vs} from the following text in a +% \env{poetry} environment. This is only used for verses at the start of a +% line. +% \end{option} +% % \end{documentation} % % \begin{implementation} @@ -969,7 +1684,7 @@ % % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}[2021-11-15] -\ProvidesExplPackage{scripture}{2022/07/27}{1.0} +\ProvidesExplPackage{scripture}{2022/08/27}{1.1} {Format Scripture Quotations (DCP)} \RequirePackage{l3keys2e} % \end{macrocode} @@ -999,6 +1714,9 @@ , belowskip .tl_set:N = \l_@@_belowskip_tl , belowskip .value_required:n = true , belowskip .initial:n = \c_zero_skip + , compact .bool_set:N = \l_@@_compact_bool + , compact .default:n = true + , compact .initial:n = false , leftmargin .tl_set:N = \l_@@_leftmargin_tl , leftmargin .value_required:n = true , leftmargin .initial:n = \c_zero_dim @@ -1011,11 +1729,19 @@ , chapter / drop .bool_set:N = \l_@@_chap_drop_bool , chapter / drop .default:n = true , chapter / drop .initial:n = true + , chapter / format .cs_set:Np = \@@_chap_format:n #1 + , chapter / format .value_required:n = true + , chapter / format .initial:n = #1 + , chapter / hide .bool_set_inverse:N = \l_@@_chap_show_bool + , chapter / hide .default:n = true , chapter / nodrop .bool_set_inverse:N = \l_@@_chap_drop_bool , chapter / nodrop .default:n = true , chapter / sep .tl_set:N = \l_@@_chap_sep_tl , chapter / sep .value_required:n = true , chapter / sep .initial:n = 0.5 em + , chapter / show .bool_set:N = \l_@@_chap_show_bool + , chapter / show .default:n = true + , chapter / show .initial:n = true , extraskip .tl_set:N = \l_@@_extraskip_tl , extraskip .value_required:n = true , extraskip .initial:n = \medskipamount @@ -1045,12 +1771,32 @@ , reference / sep .tl_set:N = \l_@@_ref_sep_tl , reference / sep .value_required:n = true , reference / sep .initial:n = 2 em + , selah / text .tl_set:N = \l_@@_selah_text_tl + , selah / text .value_required:n = true + , selah / text .initial:n = Selah + , selah / font .tl_set:N = \l_@@_selah_font_tl + , selah / font .value_required:n = true + , selah / font .initial:n = \itshape + , selah / format .cs_set:Np = \@@_selah_format:n #1 + , selah / format .value_required:n = true + , selah / format .initial:n = #1 + , selah / sep .tl_set:N = \l_@@_selah_sep_tl + , selah / sep .value_required:n = true + , selah / sep .initial:n = 1 em , verse / font .tl_set:N = \l_@@_verse_font_tl , verse / font .value_required:n = true , verse / font .initial:n = , verse / format .cs_set:Np = \@@_verse_format:n #1 , verse / format .value_required:n = true , verse / format .initial:n = \textsuperscript{#1} + , verse / hide .bool_set_inverse:N = \l_@@_verse_show_bool + , verse / hide .default:n = true + , verse / sep .tl_set:N = \l_@@_verse_sep_tl + , verse / sep .value_required:n = true + , verse / sep .initial:n = 0.05 em + , verse / show .bool_set:N = \l_@@_verse_show_bool + , verse / show .default:n = true + , verse / show .initial:n = true , version .tl_set:N = \l_@@_version_tl , version .value_required:n = true , version .initial:n = @@ -1109,6 +1855,14 @@ , hanging / rightmargin .value_required:n = true , hanging / rightmargin .initial:n = \c_zero_dim % \end{macrocode} +% Options for the mid-paragraph chapters (including the \env{midparachap} environment). +% \begin{macrocode} + , midparachap / hideverse .bool_set_inverse:N = \l_@@_midparachap_show_verse_bool + , midparachap / hideverse .default:n = true + , midparachap / showverse .bool_set:N = \l_@@_midparachap_show_verse_bool + , midparachap / showverse .default:n = true + , midparachap / showverse .initial:n = true +% \end{macrocode} % Options for the \env{narrow} environment. % \begin{macrocode} , narrow / aboveskip .tl_set:N = \l_@@_narrow_aboveskip_tl @@ -1144,6 +1898,14 @@ , poetry / rightmargin .tl_set:N = \l_@@_poetry_rightmargin_tl , poetry / rightmargin .value_required:n = true , poetry / rightmargin .initial:n = \c_zero_dim + , poetry / verse / left .bool_set_inverse:N = \l_@@_poetry_verse_right_bool + , poetry / verse / left .default:n = true + , poetry / verse / right .bool_set:N = \l_@@_poetry_verse_right_bool + , poetry / verse / right .default:n = true + , poetry / verse / right .initial:n = true + , poetry / verse / sep .tl_set:N = \l_@@_poetry_verse_sep_tl + , poetry / verse / sep .value_required:n = true + , poetry / verse / sep .initial:n = 0.05 em } % \end{macrocode} % Process package options using \pkg{l3keys2e} package. @@ -1151,6 +1913,19 @@ \ProcessKeysOptions { scripture } % \end{macrocode} % +% \subsection{hooks} +% +% \begin{hooks}{scripture/chap/before, scripture/chap/after, +% scripture/verse/before, scripture/verse/after} +% Hooks for before and after chapters and verses. The current chapter and +% verse is available in the hooks as \cs{scripturecurrentchapter} and +% \cs{scripturecurrentverse} respectively. These are global. +% \begin{macrocode} +\hook_new_pair:nn { scripture / chap / before } { scripture / chap / after } +\hook_new_pair:nn { scripture / verse / before } { scripture / verse / after } +% \end{macrocode} +% \end{hooks} +% % \subsection{The main \env{scripture} environment} % % \begin{macro}{\l_@@_active_bool, \l_@@_active_inner_bool} @@ -1161,6 +1936,14 @@ % \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}{\@@_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 @@ -1171,22 +1954,52 @@ \cs_new_protected:Nn \@@_extra_skip: { \int_compare:nNnT - \l_@@_chap_par_prevgraf_int = 1 + \g_@@_chap_par_prevgraf_int = 1 { \dim_compare:nNnT { \parskip + \l_@@_extraskip_tl } < \baselineskip { \addvspace { \baselineskip } } - \int_zero:N \l_@@_chap_par_prevgraf_int + \int_gzero:N \g_@@_chap_par_prevgraf_int } \addvspace { \l_@@_extraskip_tl } } % \end{macrocode} % \end{macro} % +% \begin{macro}{\@@_text_right:n} +% 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 + { + { + \unskip + \hfil + \penalty 50 + \skip_horizontal:n { #1 } + \hbox:n {} + \nobreak + \hfill + #2 + \skip_zero:N \parfillskip + \int_zero:N \finalhyphendemerits + \para_end: + } + } +% \end{macrocode} +% \end{macro} +% % \subsubsection{Formatting and printing quotation references} % +% \begin{macro}{\l_@@_ref_box} +% Box to hold the formatted reference. +% \begin{macrocode} +\box_new:N \l_@@_ref_box +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\@@_format_full_ref:n} % Format a scripture quotation with its reference. % \begin{macrocode} @@ -1213,9 +2026,8 @@ % \begin{macrocode} \cs_new_protected:Nn \@@_reference:n { - \hbox_set:Nn \l_tmpa_box + \hbox_set:Nn \l_@@_ref_box { - \skip_horizontal:N \l_@@_ref_sep_tl \@@_format_full_ref:n { #1 } } % \end{macrocode} @@ -1227,9 +2039,9 @@ \bool_if:NT \g_@@_poetry_end_bool { \skip_vertical:n { -\parskip } } \dim_compare:nNnT - { \box_wd:N \l_tmpa_box + \g_@@_final_line_dim } + { \box_wd:N \l_@@_ref_box + \g_@@_final_line_dim + \l_@@_ref_sep_tl } > - { \linewidth - \@totalleftmargin } + \linewidth { \skip_vertical:N \baselineskip } % \end{macrocode} % If a \env{scripture} quotation ends with an inner environment, there will @@ -1238,13 +2050,21 @@ \int_compare:nNnT \prevgraf = \c_zero_int { \skip_vertical:n { -\baselineskip } } \l_@@_ref_delim_tl - \box_use:N \l_tmpa_box + \box_use:N \l_@@_ref_box } % \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} @@ -1266,10 +2086,10 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\l_@@_chap_par_prevgraf_int} +% \begin{macro}{\g_@@_chap_par_prevgraf_int} % Store the number of lines a chapter paragraph takes up. % \begin{macrocode} -\int_new:N \l_@@_chap_par_prevgraf_int +\int_new:N \g_@@_chap_par_prevgraf_int % \end{macrocode} % \end{macro} % @@ -1286,9 +2106,11 @@ % \begin{macrocode} \cs_new_protected:Nn \@@_drop_chap_set_up:n { - \hbox_set:Nn \l_tmpa_box { X } + \cs_gset_nopar:Npn \scripturecurrentchapter { #1 } + \cs_gset_nopar:Npn \scripturecurrentverse { 1 } + \hbox_set:Nn \l_@@_chap_tmp_box { X } \dim_set:Nn \l_@@_chap_X_height_dim - { \box_ht:N \l_tmpa_box } + { \box_ht:N \l_@@_chap_tmp_box } \dim_set:Nn \l_@@_chap_height_dim { \baselineskip + \l_@@_chap_X_height_dim } \dim_set:Nn \l_@@_chap_fontsize_dim @@ -1298,17 +2120,31 @@ { \l_@@_chap_height_dim } { \l_@@_chap_X_height_dim } } - \hbox_set:Nn \l_tmpa_box + \hbox_set:Nn \l_@@_chap_tmp_box { \l_@@_chap_font_tl \fontsize { \l_@@_chap_fontsize_dim } { \l_@@_chap_fontsize_dim } \selectfont - #1 + \@@_chap_format:n { #1 } } \dim_set:Nn \l_@@_chap_width_dim - { \box_wd:N \l_tmpa_box } + { \box_wd:N \l_@@_chap_tmp_box } +% \end{macrocode} +% Avoid breaks in the middle of drop chapters. +% \begin{macrocode} + \int_set_eq:NN \l_@@_clubpenalty_saved_int \clubpenalty + \clubpenalty 10000 + \hook_gput_next_code:nn { para / after } + { + \int_gset_eq:NN \g_@@_chap_par_prevgraf_int \prevgraf + \int_compare:nNnT + \g_@@_chap_par_prevgraf_int = 1 + { \penalty 10000 } + \hook_gput_next_code:nn { para / before } + { \int_set_eq:NN \clubpenalty \l_@@_clubpenalty_saved_int } + } } % \end{macrocode} % \end{macro} @@ -1330,7 +2166,11 @@ { \linewidth - \l_@@_chap_width_dim - \l_@@_chap_sep_tl } ~ \@totalleftmargin ~ \linewidth - \box_use:N \l_tmpb_box + \group_begin: + \hook_use:n { scripture / chap / before } + \box_use:N \l_@@_chap_box + \hook_use:n { scripture / chap / after } + \group_end: } % \end{macrocode} % \end{macro} @@ -1340,11 +2180,25 @@ % \begin{macrocode} \cs_new_protected:Nn \@@_nodrop_chap:n { + \cs_gset_nopar:Npn \scripturecurrentchapter { #1 } + \cs_gset_nopar:Npn \scripturecurrentverse { 1 } \group_begin: - \l_@@_chap_font_tl - #1 + \bool_if:NTF \l_@@_chap_show_bool + { + \hook_use:n { scripture / chap / before } + \group_begin: + \l_@@_chap_font_tl + #1 + \group_end: + \skip_horizontal:N \l_@@_chap_sep_tl + \hook_use:n { scripture / chap / after } + } + { + \hook_use:n { scripture / chap / before } + \hook_use:n { scripture / chap / after } + \vs { 1 } + } \group_end: - \skip_horizontal:N \l_@@_chap_sep_tl } % \end{macrocode} % \end{macro} @@ -1355,31 +2209,32 @@ \cs_new_protected:Nn \@@_chap:n { \@@_drop_chap_set_up:n { #1 } - \hbox_set:Nn \l_tmpb_box + \hbox_set:Nn \l_@@_chap_box { \box_move_down:nn { \baselineskip } { \hbox_overlap_left:n { - \box_use:N \l_tmpa_box + \box_use:N \l_@@_chap_tmp_box \skip_horizontal:N \l_@@_chap_sep_tl } } } - \box_set_ht:Nn \l_tmpb_box { \c_zero_dim } - \box_set_dp:Nn \l_tmpb_box { \c_zero_dim } + \box_set_ht:Nn \l_@@_chap_box { \c_zero_dim } + \box_set_dp:Nn \l_@@_chap_box { \c_zero_dim } \bool_if:NTF \l_@@_mid_para_chap_bool { \@@_mid_para_drop_chap_output: } { \par \@@_drop_chap_output: } - \hook_gput_next_code:nn { para / after } - { \int_set_eq:NN \l_@@_chap_par_prevgraf_int \prevgraf } \hook_gput_next_code:nn { para / before } { - \int_zero:N \l_@@_chap_par_prevgraf_int + \int_compare:nNnT + \g_@@_chap_par_prevgraf_int = 1 + { \extraskip } + \int_gzero:N \g_@@_chap_par_prevgraf_int \int_compare:nNnT \@listdepth > \c_zero_int { \parshape 1 ~ \@totalleftmargin ~ \linewidth } @@ -1395,11 +2250,18 @@ % \begin{macrocode} \cs_new_protected:Nn \@@_verse_output:n { + \cs_gset_nopar:Npn \scripturecurrentverse { #1 } \mode_if_vertical:T { \mode_leave_vertical: } \group_begin: - \l_@@_verse_font_tl - \@@_verse_format:n { #1 } + \hook_use:n { scripture / verse / before } + \bool_if:NT \l_@@_verse_show_bool + { + \l_@@_verse_font_tl + \@@_verse_format:n { #1 } + \kern \l_@@_verse_sep_tl + } + \hook_use:n { scripture / verse / after } \group_end: } % \end{macrocode} @@ -1450,6 +2312,21 @@ % % \subsubsection{The \env{scripture} environment} % +% \begin{macro}{\l_@@_currenvir_str} +% Store the current \pkg{scripture} environment. +% \begin{macrocode} +\str_new:N \l_@@_currenvir_str +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\l_@@_parskip_correction_skip} +% Correction to ensure consistent \cs{parskip} at start of \env{scripture} +% environment with non-zero \opt{parskip} option. +% \begin{macrocode} +\skip_new:N \l_@@_parskip_correction_skip +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\g_@@_start_bool} % Flag indicating whether we are currently setting the first paragraph in a % \env{scripture} environment. If this is \val{true}, any \opt{aboveskip} @@ -1469,6 +2346,7 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l_@@_active_bool + \tl_set:Nn \l_@@_currenvir_str { scripture } \tl_if_novalue:nF { #1 } { \keys_set:nn { scripture } { #1 } @@ -1491,27 +2369,39 @@ } \DeclareDocumentCommand { \ch } { sm } { - \bool_if:NTF \l_@@_chap_drop_bool + \bool_if:NTF \l_@@_chap_show_bool { - \@@_chap:n { ##2 } - \bool_if:nT { ##1 } + \bool_if:NTF \l_@@_chap_drop_bool { - \hook_gput_next_code:nn { para / after } - { \int_zero:N \l_@@_chap_par_prevgraf_int } + \@@_chap:n { ##2 } + \bool_if:nT { ##1 } + { + \hook_gput_next_code:nn { para / after } + { \int_gzero:N \g_@@_chap_par_prevgraf_int } + } } + { \@@_nodrop_chap:n { ##2 } } } { \@@_nodrop_chap:n { ##2 } } } +% \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 \bool_gset_true:N \g_@@_start_bool \bool_gset_false:N \g_@@_poetry_end_bool \dim_set_eq:NN \parindent \l_@@_parindent_tl \cs_set_eq:NN \extraskip \@@_extra_skip: \cs_set_eq:NN \vs \@@_verse_output:n \hook_gclear_next_code:n { para / before } - \hook_gput_next_code:nn { para / end } - { \skip_set_eq:NN \parskip \l_@@_parskip_tl } - \hook_gput_next_code:nn { para / after } - { \bool_gset_false:N \g_@@_start_bool } + \skip_set:Nn \l_@@_parskip_correction_skip { \parskip - \l_@@_parskip_tl } + \mode_if_vertical:T + { + \addvspace { \l_@@_parskip_correction_skip } + } + \skip_set_eq:NN \parskip \l_@@_parskip_tl \l_@@_font_tl % \end{macrocode} % For left and right margins, use \cs{parshape} is already in a list, @@ -1535,7 +2425,18 @@ } } \bool_if:NF \l_@@_indent_bool - { \noindent } + { + \hook_gput_next_code:nn { para / begin } + { + \bool_lazy_any:nT + { + { \str_if_eq_p:Vn \l_@@_currenvir_str { midparachap } } + { \str_if_eq_p:Vn \l_@@_currenvir_str { narrow } } + { \str_if_eq_p:Vn \l_@@_currenvir_str { scripture } } + } + { \para_omit_indent: } + } + } } % \end{macrocode} % \end{macro} @@ -1557,13 +2458,18 @@ \unskip \unskip } - { \@@_calc_final_line_length: } + { + \tl_if_novalue:nTF { #1 } + { \int_zero:N \postdisplaypenalty } + { \int_set_eq:NN \postdisplaypenalty \@highpenalty } + \@@_calc_final_line_length: + } % \end{macrocode} % Restore left margin by resetting the \cs{parshape} if in a list % based environment, otherwise the space required for the reference is % incorrectly calculated. % \begin{macrocode} - \bool_lazy_or:nnT + \bool_lazy_or:nnTF { \dim_compare_p:n { \l_@@_leftmargin_tl > 0pt } } { \dim_compare_p:n { \l_@@_rightmargin_tl > 0pt } } { @@ -1575,6 +2481,7 @@ \parshape 1 ~ \@totalleftmargin ~ \linewidth } } + { \parshape 1 ~ \@totalleftmargin ~ \linewidth } \tl_if_novalue:nF { #1 } { \@@_reference:n { #1 } @@ -1633,13 +2540,15 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l_@@_active_inner_bool + \tl_set:Nn \l_@@_currenvir_str { center } \tl_if_novalue:nF { #1 } { \keys_set:nn { scripture / center } { #1 } } - \par + \mode_if_horizontal:T + { \par } \list { } { \skip_set_eq:NN \l_@@_delta_below_skip \l_@@_center_belowskip_tl @@ -1647,7 +2556,12 @@ % Ignore \opt{aboveskip} if at the beginning of a \env{scripture} environment. % \begin{macrocode} \bool_if:NTF \g_@@_start_bool - { \skip_zero:N \topsep } + { + \skip_zero:N \topsep + \skip_sub:Nn \topsep \parskip + \skip_add:Nn \l_@@_delta_below_skip \parskip + \bool_gset_false:N \g_@@_start_bool + } { \dim_compare:nTF { \parskip >= \l_@@_center_aboveskip_tl > \c_zero_skip } @@ -1659,6 +2573,9 @@ \skip_set_eq:NN \topsep \l_@@_center_aboveskip_tl \skip_sub:Nn \l_@@_delta_below_skip \l_@@_center_aboveskip_tl } + \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1 + { \addvspace { \baselineskip } } + \int_gzero:N \g_@@_chap_par_prevgraf_int } \skip_set_eq:NN \parsep \parskip \skip_zero:N \partopsep @@ -1679,6 +2596,7 @@ { \@@_calc_final_line_length: \skip_add:Nn \@topsepadd \l_@@_delta_below_skip + \int_set_eq:NN \@endparpenalty \@lowpenalty \endlist } % \end{macrocode} @@ -1696,13 +2614,15 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l_@@_active_inner_bool + \tl_set:Nn \l_@@_currenvir_str { flushright } \tl_if_novalue:nF { #1 } { \keys_set:nn { scripture / flushright } { #1 } } - \par + \mode_if_horizontal:T + { \par } \list { } { \skip_set_eq:NN \l_@@_delta_below_skip \l_@@_flushright_belowskip_tl @@ -1710,7 +2630,12 @@ % Ignore \opt{aboveskip} if at the beginning of a \env{scripture} environment. % \begin{macrocode} \bool_if:NTF \g_@@_start_bool - { \skip_zero:N \topsep } + { + \skip_zero:N \topsep + \skip_sub:Nn \topsep \parskip + \skip_add:Nn \l_@@_delta_below_skip \parskip + \bool_gset_false:N \g_@@_start_bool + } { \dim_compare:nTF { \parskip >= \l_@@_flushright_aboveskip_tl > \c_zero_skip } @@ -1722,6 +2647,9 @@ \skip_set_eq:NN \topsep \l_@@_flushright_aboveskip_tl \skip_sub:Nn \l_@@_delta_below_skip \l_@@_flushright_aboveskip_tl } + \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1 + { \addvspace { \baselineskip } } + \int_gzero:N \g_@@_chap_par_prevgraf_int } \dim_set_eq:NN \leftmargin \l_@@_flushright_leftmargin_tl \dim_set_eq:NN \rightmargin \l_@@_flushright_rightmargin_tl @@ -1744,6 +2672,7 @@ { \@@_calc_final_line_length: \skip_add:Nn \@topsepadd \l_@@_delta_below_skip + \int_set_eq:NN \@endparpenalty \@lowpenalty \endlist } % \end{macrocode} @@ -1807,21 +2736,25 @@ } \@@_nohang: } - \hbox_set:Nn \l_tmpb_box + \hbox_set:Nn \l_@@_chap_box { \box_move_down:nn { \baselineskip } { \hbox_overlap_left:n { - \box_use:N \l_tmpa_box + \box_use:N \l_@@_chap_tmp_box \skip_horizontal:N \l_@@_chap_sep_tl } } } - \box_set_ht:Nn \l_tmpb_box { \c_zero_dim } - \box_set_dp:Nn \l_tmpb_box { \c_zero_dim } - \box_use:N \l_tmpb_box + \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: \hook_gput_next_code:nn { para / begin } { \parshape 1 ~ \@totalleftmargin ~ \linewidth } } @@ -1869,13 +2802,15 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l_@@_active_inner_bool + \tl_set:Nn \l_@@_currenvir_str { hanging } \tl_if_novalue:nF { #1 } { \keys_set:nn { scripture / hanging } { #1 } } - \par + \mode_if_horizontal:T + { \par } \list { } { \skip_set_eq:NN \l_@@_delta_below_skip \l_@@_hanging_belowskip_tl @@ -1883,7 +2818,12 @@ % Ignore \opt{aboveskip} if at the beginning of a \env{scripture} environment. % \begin{macrocode} \bool_if:NTF \g_@@_start_bool - { \dim_zero:N \topsep } + { + \dim_zero:N \topsep + \skip_sub:Nn \topsep \parskip + \skip_add:Nn \l_@@_delta_below_skip \parskip + \bool_gset_false:N \g_@@_start_bool + } { \dim_compare:nTF { \parskip >= \l_@@_hanging_aboveskip_tl > \c_zero_skip } @@ -1895,9 +2835,9 @@ \skip_set_eq:NN \topsep \l_@@_hanging_aboveskip_tl \skip_sub:Nn \l_@@_delta_below_skip \l_@@_hanging_aboveskip_tl } - \int_compare:nNnT \l_@@_chap_par_prevgraf_int = 1 + \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1 { \addvspace { \baselineskip } } - \int_zero:N \l_@@_chap_par_prevgraf_int + \int_gzero:N \g_@@_chap_par_prevgraf_int } \dim_set:Nn \leftmargin { \l_@@_hanging_leftmargin_tl + \l_@@_hanging_hang_tl } @@ -1909,9 +2849,16 @@ \dim_zero:N \labelsep \dim_set_eq:NN \l_@@_hanging_parindent_saved_dim \parindent } - \bool_if:NTF \l_@@_chap_drop_bool - { \cs_set_eq:NN \ch \@@_hanging_chap:n } - { \cs_set_eq:NN \ch \@@_nodrop_chap:n } + \DeclareDocumentCommand { \ch } { sm } + { + \bool_if:NTF \l_@@_chap_show_bool + { + \bool_if:NTF \l_@@_chap_drop_bool + { \@@_hanging_chap:n { ##2 } } + { \@@_nodrop_chap:n { ##2 } } + } + { \@@_nodrop_chap:n { ##2 } } + } \cs_set_eq:NN \vs \@@_hanging_verse:n \cs_set_eq:NN \nohang \@@_nohang: \item @@ -1927,6 +2874,7 @@ { \@@_calc_final_line_length: \skip_add:Nn \@topsepadd \l_@@_delta_below_skip + \int_set_eq:NN \@endparpenalty \@lowpenalty \endlist } % \end{macrocode} @@ -1960,9 +2908,17 @@ % \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}{\g_@@_mid_para_chap_prevgraf_int} -% Store the number of lines a paragraph containing a mid-paragraph chapter -% takes up. +% 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} @@ -1982,10 +2938,14 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\l_@@_mid_para_chap_box} -% Box containing a paragraph with a chapter break. +% \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} % @@ -1998,7 +2958,6 @@ \int_set_eq:NN \l_@@_mid_para_chap_spacefactor_int \spacefactor \strut \par - \int_gset_eq:NN \g_@@_mid_para_chap_prevgraf_int \prevgraf \box_set_to_last:N \l_@@_mid_para_chap_line_box \hbox_set:Nn \l_@@_mid_para_chap_snap_box { @@ -2030,23 +2989,33 @@ \hbox_unpack_drop:N \l_@@_mid_para_chap_snap_box \skip_zero:N \parfillskip \par - \int_gadd:Nn \g_@@_mid_para_chap_prevgraf_int \prevgraf \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:} +% \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: +\cs_new_protected:Nn \@@_mid_para_chap_begin:n { + \tl_set:Nn \l_@@_currenvir_str { midparachap } + \tl_if_novalue:nF { #1 } + { + \keys_set:nn + { scripture / midparachap } + { #1 } + } \par \bool_set_true:N \l_@@_mid_para_chap_bool - \skip_zero:N \parskip \@@_vbox_set_top:Nw \l_@@_mid_para_chap_box + \skip_zero:N \parskip } % \end{macrocode} % \end{macro} @@ -2056,33 +3025,73 @@ % \begin{macrocode} \cs_new_protected:Nn \@@_mid_para_chap_end: { - \@@_calc_final_line_length: - \int_gadd:Nn \g_@@_mid_para_chap_prevgraf_int { \prevgraf - 1 } + \par + \int_gset_eq:NN \g_@@_mid_para_chap_prevgraf_int \prevgraf + \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 } + \box_clear:N \l_@@_mid_para_chap_snap_box + \nointerlineskip + \int_compare:nNnT + \prevgraf < 3 + { + \noindent + \skip_horizontal:n { \l_@@_chap_width_dim + \l_@@_chap_sep_tl } + \dim_gadd:Nn \g_@@_final_line_dim { \l_@@_chap_width_dim + \l_@@_chap_sep_tl } + } + \box_use_drop:N \l_@@_mid_para_chap_line_box \vbox_set_end: % \end{macrocode} % Attempt to allow the mid-paragraph chapter box to break across pages. % \begin{macrocode} - \dim_compare:nNnTF - { \box_ht_plus_dp:N \l_@@_mid_para_chap_box } - > - { \pagegoal - \pagetotal - \baselineskip } + \mode_if_inner:TF { - \int_set:Nn \vbadness { 10000 } - \vbox_set_split_to_ht:NNn - \l_tmpa_box \l_@@_mid_para_chap_box - { \pagegoal - \pagetotal - \baselineskip } - \box_use_drop:N \l_tmpa_box - \goodbreak + \noindent \box_use_drop:N \l_@@_mid_para_chap_box } { - \box_use_drop:N \l_@@_mid_para_chap_box - \skip_vertical:n { \baselineskip - \lineskip } + \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 - \@@_reset_spacing: + \int_gset_eq:NN \g_@@_chap_par_prevgraf_int \g_@@_mid_para_chap_prevgraf_int + \hook_gput_next_code:nn { para / before } + { + \int_gzero:N \g_@@_chap_par_prevgraf_int + \int_compare:nNnT + \@listdepth > \c_zero_int + { \parshape 1 ~ \@totalleftmargin ~ \linewidth } + } } % \end{macrocode} % \end{macro} @@ -2099,13 +3108,15 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l_@@_active_inner_bool + \tl_set:Nn \l_@@_currenvir_str { narrow } \tl_if_novalue:nF { #1 } { \keys_set:nn { scripture / narrow } { #1 } } - \par + \mode_if_horizontal:T + { \par } \list { } { \skip_set_eq:NN \l_@@_delta_below_skip \l_@@_narrow_belowskip_tl @@ -2113,7 +3124,12 @@ % Ignore \opt{aboveskip} if at the beginning of a \env{scripture} environment. % \begin{macrocode} \bool_if:NTF \g_@@_start_bool - { \skip_zero:N \topsep } + { + \skip_zero:N \topsep + \skip_sub:Nn \topsep \parskip + \skip_add:Nn \l_@@_delta_below_skip \parskip + \bool_gset_false:N \g_@@_start_bool + } { \dim_compare:nTF { \parskip >= \l_@@_narrow_aboveskip_tl > \c_zero_skip } @@ -2125,6 +3141,9 @@ \skip_set_eq:NN \topsep \l_@@_narrow_aboveskip_tl \skip_sub:Nn \l_@@_delta_below_skip \l_@@_narrow_aboveskip_tl } + \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1 + { \addvspace { \baselineskip } } + \int_gzero:N \g_@@_chap_par_prevgraf_int } \dim_set_eq:NN \leftmargin \l_@@_narrow_leftmargin_tl \dim_set_eq:NN \rightmargin \l_@@_narrow_rightmargin_tl @@ -2147,6 +3166,7 @@ { \@@_calc_final_line_length: \skip_add:Nn \@topsepadd \l_@@_delta_below_skip + \int_set_eq:NN \@endparpenalty \@lowpenalty \endlist } % \end{macrocode} @@ -2154,6 +3174,14 @@ % % \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} @@ -2161,6 +3189,31 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\g_@@_poetry_midparachap_show_verse_bool} +% Flag indicating whether the verse number should be printed immediately +% after a \cs{ch} or not in a \env{poetry} environment. +% \begin{macrocode} +\bool_new:N \g_@@_poetry_midparachap_show_verse_bool +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\l_@@_poetry_chap_indent_dim, \l_@@_poetry_chap_sep_dim} +% Store calculated indent and sep when a drop chapter appears in a +% \env{poetry} environment. +% \begin{macrocode} +\dim_new:N \l_@@_poetry_chap_indent_dim +\dim_new:N \l_@@_poetry_chap_sep_dim +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\l_@@_poetry_chap_parshape_correction_dim} +% Correction to \cs{parshape} in chapter affected lines in a \env{poetry} +% environment. +% \begin{macrocode} +\dim_new:N \l_@@_poetry_chap_parshape_correction_dim +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\l_@@_poetry_prevgraf_int} % Store the number of lines a line of poetry takes up. % \begin{macrocode} @@ -2168,81 +3221,201 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\@@_poetry_extra_skip:} +% Insert a little extra vertical space between two lines in a \env{poetry} +% environment. +% \begin{macrocode} +\cs_new_protected:Nn \@@_poetry_extra_skip: + { + \skip_vertical:n { \l_@@_extraskip_tl - \baselineskip - \parskip } + \bool_gset_false:N \g_@@_poetry_midparachap_show_verse_bool + \strut + \hook_gput_next_code:nn { para / after } + { + \hook_gput_next_code:nn { para / after } + { + \bool_gset_eq:NN + \g_@@_poetry_midparachap_show_verse_bool + \l_@@_midparachap_show_verse_bool + } + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_poetry_text_right:n} +% 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_chap:n} % Position a chapter in a \env{poetry} environment. % \begin{macrocode} \cs_new_protected:Nn \@@_poetry_chap:n { \@@_drop_chap_set_up:n { #1 } - \dim_compare:nNnT \l_@@_chap_width_dim < \l_@@_poetry_leftmargin_tl + \mode_if_vertical:TF { - \tl_set:Nx \l_@@_chap_sep_tl + \dim_set_eq:NN \l_@@_poetry_chap_indent_dim \l_@@_poetry_indent_tl + \mode_leave_vertical: + } + { \dim_zero:N \l_@@_poetry_chap_indent_dim } + \dim_set_eq:NN \l_@@_poetry_chap_sep_dim \l_@@_chap_sep_tl + \dim_compare:nNnT + { \l_@@_chap_width_dim + \l_@@_chap_sep_tl } + < + { \l_@@_poetry_leftmargin_tl + \l_@@_poetry_chap_indent_dim } + { + \dim_set:Nn \l_@@_poetry_chap_sep_dim { - \dim_eval:n - { - \l_@@_poetry_leftmargin_tl - \l_@@_chap_width_dim - } + \l_@@_poetry_leftmargin_tl + \l_@@_poetry_chap_indent_dim - + \l_@@_chap_width_dim } } - \hbox_set:Nn \l_tmpb_box + \hbox_set:Nn \l_@@_chap_box { \box_move_down:nn { \baselineskip } { \hbox_overlap_left:n { - \box_use:N \l_tmpa_box - \skip_horizontal:N \l_@@_chap_sep_tl + \box_use:N \l_@@_chap_tmp_box + \skip_horizontal:N \l_@@_poetry_chap_sep_dim } } } - \box_set_ht:Nn \l_tmpb_box { \c_zero_dim } - \box_set_dp:Nn \l_tmpb_box { \c_zero_dim } + \box_set_ht:Nn \l_@@_chap_box { \c_zero_dim } + \box_set_dp:Nn \l_@@_chap_box { \c_zero_dim } + \dim_set:Nn \l_@@_poetry_chap_parshape_correction_dim + { + \l_@@_chap_width_dim + \l_@@_poetry_chap_sep_dim - + \l_@@_poetry_leftmargin_tl - \l_@@_poetry_chap_indent_dim + } \parshape 2 ~ \dim_eval:n - { - \@totalleftmargin - \l_@@_poetry_leftmargin_tl + - \l_@@_chap_width_dim + \l_@@_chap_sep_tl - } ~ + { \@totalleftmargin + \l_@@_poetry_chap_parshape_correction_dim } ~ \dim_eval:n - { - \linewidth - \@totalleftmargin + \l_@@_poetry_leftmargin_tl - - \l_@@_chap_width_dim - \l_@@_chap_sep_tl - } ~ + { \linewidth - \l_@@_poetry_chap_parshape_correction_dim } ~ \dim_eval:n { \@totalleftmargin + \l_@@_poetry_big_indent_tl } ~ \dim_eval:n { \linewidth - \l_@@_poetry_big_indent_tl } +% \end{macrocode} +% Because of interactions with \LaTeX{} \env{list} environments and +% \cs{@@_obeylines:}, \cs{@@_poetry_par:} setting the \cs{parshape} for the +% second line after a drop chapter number is more difficult than it should +% be. There's probably a better way. +% \begin{macrocode} \dim_compare:nNnT - { \l_@@_chap_width_dim + \l_@@_chap_sep_tl } + { \l_@@_chap_width_dim + \l_@@_poetry_chap_sep_dim } > - { \l_@@_poetry_leftmargin_tl + \listparindent } + \l_@@_poetry_leftmargin_tl { - \hook_gput_next_code:nn { para / begin } + \hook_gput_next_code:nn { scripture / poetry / para / after } { \int_compare:nNnT \l_@@_poetry_prevgraf_int = 1 { - \parshape 2 ~ +% \end{macrocode} +% This \cs{parshape} is in effect when the next line is the second half of a +% poetry verse. +% \begin{macrocode} + \dim_compare:nNnTF + { \l_@@_chap_width_dim + \l_@@_chap_sep_tl } + < + { \l_@@_poetry_leftmargin_tl + \l_@@_poetry_indent_tl } + { \dim_zero:N \l_@@_poetry_chap_parshape_correction_dim } + { + \dim_set:Nn \l_@@_poetry_chap_parshape_correction_dim + { + \l_@@_chap_width_dim + \l_@@_chap_sep_tl - + \l_@@_poetry_leftmargin_tl - \l_@@_poetry_indent_tl + } + } + \parshape 2 ~ \dim_eval:n - { - \@totalleftmargin - \l_@@_poetry_leftmargin_tl + - \l_@@_chap_width_dim + \l_@@_chap_sep_tl - - \listparindent - } ~ + { \@totalleftmargin + \l_@@_poetry_chap_parshape_correction_dim } ~ \dim_eval:n - { - \linewidth - \@totalleftmargin + \l_@@_poetry_leftmargin_tl - - \l_@@_chap_width_dim - \l_@@_chap_sep_tl + - \listparindent - } ~ + { \linewidth - \l_@@_poetry_chap_parshape_correction_dim } ~ \dim_eval:n { \@totalleftmargin + \l_@@_poetry_big_indent_tl } ~ \dim_eval:n { \linewidth - \l_@@_poetry_big_indent_tl } + \hook_gput_next_code:nn { para / after } + { + \hook_gclear_next_code:n { scripture / poetry / para / after } + } + \hook_gput_next_code:nn { scripture / poetry / para / after } + { +% \end{macrocode} +% This \cs{parshape} is in effect when the next line is the first half of a +% poetry verse. +% \begin{macrocode} + \dim_compare:nNnTF + { \l_@@_chap_width_dim + \l_@@_chap_sep_tl } + < + \l_@@_poetry_leftmargin_tl + { \dim_zero:N \l_@@_poetry_chap_parshape_correction_dim } + { + \dim_set:Nn \l_@@_poetry_chap_parshape_correction_dim + { + \l_@@_chap_width_dim + \l_@@_chap_sep_tl - + \l_@@_poetry_leftmargin_tl + } + } + \parshape 2 ~ + \dim_eval:n + { \@totalleftmargin + \l_@@_poetry_chap_parshape_correction_dim } ~ + \dim_eval:n + { \linewidth - \l_@@_poetry_chap_parshape_correction_dim } ~ + \dim_eval:n + { \@totalleftmargin + \l_@@_poetry_big_indent_tl } ~ + \dim_eval:n + { \linewidth - \l_@@_poetry_big_indent_tl } + } } } } - \box_use:N \l_tmpb_box + \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 \g_@@_poetry_midparachap_show_verse_bool + { + \@@_verse_output:n { 1 } + } } % \end{macrocode} % \end{macro} @@ -2253,14 +3426,32 @@ % \begin{macrocode} \cs_new_protected:Nn \@@_poetry_nodrop_chap:n { - \hbox_overlap_left:n + \cs_gset_nopar:Npn \scripturecurrentchapter { #1 } + \cs_gset_nopar:Npn \scripturecurrentverse { 1 } + \group_begin: + \bool_if:NTF \l_@@_chap_show_bool { - \group_begin: - \l_@@_chap_font_tl - #1 - \group_end: - \skip_horizontal:N \l_@@_chap_sep_tl + \hbox_overlap_left:n + { + \hook_use:n { scripture / chap / before } + \group_begin: + \l_@@_chap_font_tl + #1 + \group_end: + \skip_horizontal:N \l_@@_chap_sep_tl + \hook_use:n { scripture / chap / after } + } + \bool_if:NT \g_@@_poetry_midparachap_show_verse_bool + { + \@@_verse_output:n { 1 } + } } + { + \hook_use:n { scripture / chap / before } + \hook_use:n { scripture / chap / after } + \vs { 1 } + } + \group_end: } % \end{macrocode} % \end{macro} @@ -2272,17 +3463,36 @@ % \begin{macrocode} \cs_new_protected:Nn \@@_poetry_mode_vertical_verse:n { + \group_begin: + \tl_set_eq:NN \l_@@_verse_sep_tl \l_@@_poetry_verse_sep_tl \strut - \hbox_overlap_left:n + \bool_if:NTF \l_@@_poetry_verse_right_bool { - \@@_verse_output:n { #1 } + \hbox_overlap_left:n + { + \@@_verse_output:n { #1 } + } } + { + \hbox_overlap_left:n + { + \hbox_overlap_right:n + { + \@@_verse_output:n { #1 } + } + \skip_horizontal:N \l_@@_poetry_leftmargin_tl + } + } + \group_end: } \cs_new_protected:Nn \@@_poetry_mode_horizontal_verse:n { + \group_begin: + \tl_set_eq:NN \l_@@_verse_sep_tl \l_@@_poetry_verse_sep_tl \skip_horizontal:n { -\listparindent } \@@_poetry_mode_vertical_verse:n { #1 } \skip_horizontal:N \listparindent + \group_end: } % \end{macrocode} % \end{macro} @@ -2300,6 +3510,7 @@ { \cs_set_eq:NN \vs \@@_poetry_mode_horizontal_verse:n \@@_tmp_para_end: + \int_set_eq:NN \l_@@_poetry_prevgraf_int \prevgraf } \parshape 2 ~ \@totalleftmargin ~ @@ -2308,6 +3519,7 @@ { \@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} @@ -2345,13 +3557,18 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l_@@_active_inner_bool - \par + \tl_set:Nn \l_@@_currenvir_str { poetry } + \mode_if_horizontal:T + { \par } \list { } { \skip_set_eq:NN \l_@@_delta_below_skip \l_@@_poetry_belowskip_tl \bool_if:NTF \g_@@_start_bool { \skip_zero:N \topsep + \skip_sub:Nn \topsep \parskip + \skip_add:Nn \l_@@_delta_below_skip \parskip + \bool_gset_false:N \g_@@_start_bool } { \dim_compare:nTF @@ -2364,9 +3581,9 @@ \skip_set_eq:NN \topsep \l_@@_poetry_aboveskip_tl \skip_sub:Nn \l_@@_delta_below_skip \l_@@_poetry_aboveskip_tl } - \int_compare:nNnT \l_@@_chap_par_prevgraf_int = 1 + \int_compare:nNnT \g_@@_chap_par_prevgraf_int = 1 { \addvspace { \baselineskip } } - \int_zero:N \l_@@_chap_par_prevgraf_int + \int_gzero:N \g_@@_chap_par_prevgraf_int } \dim_set_eq:NN \leftmargin \l_@@_poetry_leftmargin_tl \dim_set_eq:NN \rightmargin \l_@@_poetry_rightmargin_tl @@ -2379,14 +3596,26 @@ \raggedright \dim_set_eq:NN \listparindent \l_@@_poetry_indent_tl \dim_set_eq:NN \parindent \l_@@_poetry_indent_tl - \bool_if:NTF \l_@@_chap_drop_bool - { \cs_set_eq:NN \ch \@@_poetry_chap:n } - { \cs_set_eq:NN \ch \@@_poetry_nodrop_chap:n } + \bool_gset_false:N \g_@@_poetry_midparachap_show_verse_bool + \DeclareDocumentCommand { \ch } { sm } + { + \bool_if:NTF \l_@@_chap_show_bool + { + \bool_if:NTF \l_@@_chap_drop_bool + { \@@_poetry_chap:n { ##2 } } + { \@@_poetry_nodrop_chap:n { ##2 } } + } + { \@@_poetry_nodrop_chap:n { ##2 } } + } \cs_set_eq:NN \vs \@@_poetry_mode_vertical_verse:n + \cs_set_eq:NN \extraskip \@@_poetry_extra_skip: + \cs_set_eq:NN \selah \@@_selah_output: \item \relax \cs_set_eq:NN \@@_tmp_para_end: \par \cs_set_eq:NN \par \@@_poetry_par: + \hook_gput_next_code:nn { para / after } + { \bool_gset_eq:NN \g_@@_poetry_midparachap_show_verse_bool \l_@@_midparachap_show_verse_bool } } % \end{macrocode} % \end{macro} @@ -2398,6 +3627,7 @@ { \@@_calc_final_line_length: \skip_add:Nn \@topsepadd \l_@@_delta_below_skip + \int_set_eq:NN \@endparpenalty \@lowpenalty \endlist \bool_gset_true:N \g_@@_poetry_end_bool \hook_gput_next_code:nn { para / begin } @@ -2409,6 +3639,15 @@ % % \subsection{Public \LaTeX{} Interface} % +% \begin{macro}{\scripturecurrentchapter, \scripturecurrentverse} +% Globally stores the most recent argument of \cs{ch} and \cs{vs}. These +% could be used in hooks, for example. +% \begin{macrocode} +\cs_set_nopar:Npn \scripturecurrentchapter { } +\cs_set_nopar:Npn \scripturecurrentverse { } +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\scripturesetup} % \begin{arguments} % \item \meta{|options|} to set. @@ -2475,9 +3714,9 @@ % \vspace{-2\baselineskip} % \begin{envmacro}{midparachap} % \begin{macrocode} - \DeclareDocumentEnvironment { midparachap } { } + \DeclareDocumentEnvironment { midparachap } { o } { - \@@_mid_para_chap_begin: + \@@_mid_para_chap_begin:n { ##1 } \ignorespaces } { \@@_mid_para_chap_end: } @@ -2524,9 +3763,38 @@ % \end{macrocode} % \end{envmacro} % \begin{macrocode} - \ignorespaces + \bool_if:NT \l_@@_compact_bool + { + \scripturesetup { chapter / nodrop } + \RenewDocumentEnvironment { center } { o } { \ignorespaces } { } + \RenewDocumentEnvironment { flushright } { o } { \ignorespaces } { } + \RenewDocumentEnvironment { hanging } { o } { \ignorespaces } { } + \RenewDocumentEnvironment { midparachap } { o } { \ignorespaces } { } + \RenewDocumentEnvironment { narrow } { o } { \ignorespaces } { } + \RenewDocumentEnvironment { poetry } { o } { \ignorespaces } { } + \cs_set_eq:NN \par \relax + \cs_set_eq:NN \extraskip \relax + \cs_set_eq:NN \nohang \relax + \cs_set:Npn \selah + { + \group_begin: + \l_@@_selah_font_tl + \c_space_tl + \@@_selah_format:n { \l_@@_selah_text_tl } + \c_space_tl + \group_end: + } + \mode_leave_vertical: + } + \peek_remove_spaces:n + { + \peek_meaning:NF \begin + { \bool_gset_false:N \g_@@_start_bool } + } } { + \bool_if:NT \l_@@_compact_bool + { \cs_set_eq:NN \par \endgraf } \@@_end:n { #1 } } % \end{macrocode} diff --git a/Master/texmf-dist/tex/latex/scripture/scripture.sty b/Master/texmf-dist/tex/latex/scripture/scripture.sty index b5d5a2a799b..613fe5df290 100644 --- a/Master/texmf-dist/tex/latex/scripture/scripture.sty +++ b/Master/texmf-dist/tex/latex/scripture/scripture.sty @@ -25,7 +25,7 @@ %% and the derived files scripture.sty and scripture.pdf %% \NeedsTeXFormat{LaTeX2e}[2021-11-15] -\ProvidesExplPackage{scripture}{2022/07/27}{1.0} +\ProvidesExplPackage{scripture}{2022/08/27}{1.1} {Format Scripture Quotations (DCP)} \RequirePackage{l3keys2e} \msg_new:nnnn { scripture } { nested-environment } @@ -40,6 +40,9 @@ , belowskip .tl_set:N = \l__scripture_belowskip_tl , belowskip .value_required:n = true , belowskip .initial:n = \c_zero_skip + , compact .bool_set:N = \l__scripture_compact_bool + , compact .default:n = true + , compact .initial:n = false , leftmargin .tl_set:N = \l__scripture_leftmargin_tl , leftmargin .value_required:n = true , leftmargin .initial:n = \c_zero_dim @@ -52,11 +55,19 @@ , chapter / drop .bool_set:N = \l__scripture_chap_drop_bool , chapter / drop .default:n = true , chapter / drop .initial:n = true + , chapter / format .cs_set:Np = \__scripture_chap_format:n #1 + , chapter / format .value_required:n = true + , chapter / format .initial:n = #1 + , chapter / hide .bool_set_inverse:N = \l__scripture_chap_show_bool + , chapter / hide .default:n = true , chapter / nodrop .bool_set_inverse:N = \l__scripture_chap_drop_bool , chapter / nodrop .default:n = true , chapter / sep .tl_set:N = \l__scripture_chap_sep_tl , chapter / sep .value_required:n = true , chapter / sep .initial:n = 0.5 em + , chapter / show .bool_set:N = \l__scripture_chap_show_bool + , chapter / show .default:n = true + , chapter / show .initial:n = true , extraskip .tl_set:N = \l__scripture_extraskip_tl , extraskip .value_required:n = true , extraskip .initial:n = \medskipamount @@ -86,12 +97,32 @@ , reference / sep .tl_set:N = \l__scripture_ref_sep_tl , reference / sep .value_required:n = true , reference / sep .initial:n = 2 em + , selah / text .tl_set:N = \l__scripture_selah_text_tl + , selah / text .value_required:n = true + , selah / text .initial:n = Selah + , selah / font .tl_set:N = \l__scripture_selah_font_tl + , selah / font .value_required:n = true + , selah / font .initial:n = \itshape + , selah / format .cs_set:Np = \__scripture_selah_format:n #1 + , selah / format .value_required:n = true + , selah / format .initial:n = #1 + , selah / sep .tl_set:N = \l__scripture_selah_sep_tl + , selah / sep .value_required:n = true + , selah / sep .initial:n = 1 em , verse / font .tl_set:N = \l__scripture_verse_font_tl , verse / font .value_required:n = true , verse / font .initial:n = , verse / format .cs_set:Np = \__scripture_verse_format:n #1 , verse / format .value_required:n = true , verse / format .initial:n = \textsuperscript{#1} + , verse / hide .bool_set_inverse:N = \l__scripture_verse_show_bool + , verse / hide .default:n = true + , verse / sep .tl_set:N = \l__scripture_verse_sep_tl + , verse / sep .value_required:n = true + , verse / sep .initial:n = 0.05 em + , verse / show .bool_set:N = \l__scripture_verse_show_bool + , verse / show .default:n = true + , verse / show .initial:n = true , version .tl_set:N = \l__scripture_version_tl , version .value_required:n = true , version .initial:n = @@ -140,6 +171,11 @@ , hanging / rightmargin .tl_set:N = \l__scripture_hanging_rightmargin_tl , hanging / rightmargin .value_required:n = true , hanging / rightmargin .initial:n = \c_zero_dim + , midparachap / hideverse .bool_set_inverse:N = \l__scripture_midparachap_show_verse_bool + , midparachap / hideverse .default:n = true + , midparachap / showverse .bool_set:N = \l__scripture_midparachap_show_verse_bool + , midparachap / showverse .default:n = true + , midparachap / showverse .initial:n = true , narrow / aboveskip .tl_set:N = \l__scripture_narrow_aboveskip_tl , narrow / aboveskip .value_required:n = true , narrow / aboveskip .initial:n = \medskipamount @@ -170,24 +206,52 @@ , poetry / rightmargin .tl_set:N = \l__scripture_poetry_rightmargin_tl , poetry / rightmargin .value_required:n = true , poetry / rightmargin .initial:n = \c_zero_dim + , poetry / verse / left .bool_set_inverse:N = \l__scripture_poetry_verse_right_bool + , poetry / verse / left .default:n = true + , poetry / verse / right .bool_set:N = \l__scripture_poetry_verse_right_bool + , poetry / verse / right .default:n = true + , poetry / verse / right .initial:n = true + , poetry / verse / sep .tl_set:N = \l__scripture_poetry_verse_sep_tl + , poetry / verse / sep .value_required:n = true + , poetry / verse / sep .initial:n = 0.05 em } \ProcessKeysOptions { scripture } +\hook_new_pair:nn { scripture / chap / before } { scripture / chap / after } +\hook_new_pair:nn { scripture / verse / before } { scripture / verse / after } \bool_new:N \l__scripture_active_bool \bool_new:N \l__scripture_active_inner_bool +\int_new:N \l__scripture_clubpenalty_saved_int \cs_new_protected:Nn \__scripture_extra_skip: { \int_compare:nNnT - \l__scripture_chap_par_prevgraf_int = 1 + \g__scripture_chap_par_prevgraf_int = 1 { \dim_compare:nNnT { \parskip + \l__scripture_extraskip_tl } < \baselineskip { \addvspace { \baselineskip } } - \int_zero:N \l__scripture_chap_par_prevgraf_int + \int_gzero:N \g__scripture_chap_par_prevgraf_int } \addvspace { \l__scripture_extraskip_tl } } +\cs_new_protected:Nn \__scripture_text_right:nn + { + { + \unskip + \hfil + \penalty 50 + \skip_horizontal:n { #1 } + \hbox:n {} + \nobreak + \hfill + #2 + \skip_zero:N \parfillskip + \int_zero:N \finalhyphendemerits + \para_end: + } + } +\box_new:N \l__scripture_ref_box \cs_new_protected:Nn \__scripture_format_full_ref:n { \group_begin: @@ -202,33 +266,36 @@ } \cs_new_protected:Nn \__scripture_reference:n { - \hbox_set:Nn \l_tmpa_box + \hbox_set:Nn \l__scripture_ref_box { - \skip_horizontal:N \l__scripture_ref_sep_tl \__scripture_format_full_ref:n { #1 } } \bool_if:NT \g__scripture_poetry_end_bool { \skip_vertical:n { -\parskip } } \dim_compare:nNnT - { \box_wd:N \l_tmpa_box + \g__scripture_final_line_dim } + { \box_wd:N \l__scripture_ref_box + \g__scripture_final_line_dim + \l__scripture_ref_sep_tl } > - { \linewidth - \@totalleftmargin } + \linewidth { \skip_vertical:N \baselineskip } \int_compare:nNnT \prevgraf = \c_zero_int { \skip_vertical:n { -\baselineskip } } \l__scripture_ref_delim_tl - \box_use:N \l_tmpa_box + \box_use:N \l__scripture_ref_box } +\box_new:N \l__scripture_chap_box +\box_new:N \l__scripture_chap_tmp_box \dim_new:N \l__scripture_chap_fontsize_dim \dim_new:N \l__scripture_chap_height_dim \dim_new:N \l__scripture_chap_width_dim -\int_new:N \l__scripture_chap_par_prevgraf_int +\int_new:N \g__scripture_chap_par_prevgraf_int \dim_new:N \l__scripture_chap_X_height_dim \cs_new_protected:Nn \__scripture_drop_chap_set_up:n { - \hbox_set:Nn \l_tmpa_box { X } + \cs_gset_nopar:Npn \scripturecurrentchapter { #1 } + \cs_gset_nopar:Npn \scripturecurrentverse { 1 } + \hbox_set:Nn \l__scripture_chap_tmp_box { X } \dim_set:Nn \l__scripture_chap_X_height_dim - { \box_ht:N \l_tmpa_box } + { \box_ht:N \l__scripture_chap_tmp_box } \dim_set:Nn \l__scripture_chap_height_dim { \baselineskip + \l__scripture_chap_X_height_dim } \dim_set:Nn \l__scripture_chap_fontsize_dim @@ -238,17 +305,28 @@ { \l__scripture_chap_height_dim } { \l__scripture_chap_X_height_dim } } - \hbox_set:Nn \l_tmpa_box + \hbox_set:Nn \l__scripture_chap_tmp_box { \l__scripture_chap_font_tl \fontsize { \l__scripture_chap_fontsize_dim } { \l__scripture_chap_fontsize_dim } \selectfont - #1 + \__scripture_chap_format:n { #1 } } \dim_set:Nn \l__scripture_chap_width_dim - { \box_wd:N \l_tmpa_box } + { \box_wd:N \l__scripture_chap_tmp_box } + \int_set_eq:NN \l__scripture_clubpenalty_saved_int \clubpenalty + \clubpenalty 10000 + \hook_gput_next_code:nn { para / after } + { + \int_gset_eq:NN \g__scripture_chap_par_prevgraf_int \prevgraf + \int_compare:nNnT + \g__scripture_chap_par_prevgraf_int = 1 + { \penalty 10000 } + \hook_gput_next_code:nn { para / before } + { \int_set_eq:NN \clubpenalty \l__scripture_clubpenalty_saved_int } + } } \cs_new_protected:Nn \__scripture_drop_chap_output: { @@ -264,44 +342,63 @@ { \linewidth - \l__scripture_chap_width_dim - \l__scripture_chap_sep_tl } ~ \@totalleftmargin ~ \linewidth - \box_use:N \l_tmpb_box + \group_begin: + \hook_use:n { scripture / chap / before } + \box_use:N \l__scripture_chap_box + \hook_use:n { scripture / chap / after } + \group_end: } \cs_new_protected:Nn \__scripture_nodrop_chap:n { + \cs_gset_nopar:Npn \scripturecurrentchapter { #1 } + \cs_gset_nopar:Npn \scripturecurrentverse { 1 } \group_begin: - \l__scripture_chap_font_tl - #1 + \bool_if:NTF \l__scripture_chap_show_bool + { + \hook_use:n { scripture / chap / before } + \group_begin: + \l__scripture_chap_font_tl + #1 + \group_end: + \skip_horizontal:N \l__scripture_chap_sep_tl + \hook_use:n { scripture / chap / after } + } + { + \hook_use:n { scripture / chap / before } + \hook_use:n { scripture / chap / after } + \vs { 1 } + } \group_end: - \skip_horizontal:N \l__scripture_chap_sep_tl } \cs_new_protected:Nn \__scripture_chap:n { \__scripture_drop_chap_set_up:n { #1 } - \hbox_set:Nn \l_tmpb_box + \hbox_set:Nn \l__scripture_chap_box { \box_move_down:nn { \baselineskip } { \hbox_overlap_left:n { - \box_use:N \l_tmpa_box + \box_use:N \l__scripture_chap_tmp_box \skip_horizontal:N \l__scripture_chap_sep_tl } } } - \box_set_ht:Nn \l_tmpb_box { \c_zero_dim } - \box_set_dp:Nn \l_tmpb_box { \c_zero_dim } + \box_set_ht:Nn \l__scripture_chap_box { \c_zero_dim } + \box_set_dp:Nn \l__scripture_chap_box { \c_zero_dim } \bool_if:NTF \l__scripture_mid_para_chap_bool { \__scripture_mid_para_drop_chap_output: } { \par \__scripture_drop_chap_output: } - \hook_gput_next_code:nn { para / after } - { \int_set_eq:NN \l__scripture_chap_par_prevgraf_int \prevgraf } \hook_gput_next_code:nn { para / before } { - \int_zero:N \l__scripture_chap_par_prevgraf_int + \int_compare:nNnT + \g__scripture_chap_par_prevgraf_int = 1 + { \extraskip } + \int_gzero:N \g__scripture_chap_par_prevgraf_int \int_compare:nNnT \@listdepth > \c_zero_int { \parshape 1 ~ \@totalleftmargin ~ \linewidth } @@ -309,11 +406,18 @@ } \cs_new_protected:Nn \__scripture_verse_output:n { + \cs_gset_nopar:Npn \scripturecurrentverse { #1 } \mode_if_vertical:T { \mode_leave_vertical: } \group_begin: - \l__scripture_verse_font_tl - \__scripture_verse_format:n { #1 } + \hook_use:n { scripture / verse / before } + \bool_if:NT \l__scripture_verse_show_bool + { + \l__scripture_verse_font_tl + \__scripture_verse_format:n { #1 } + \kern \l__scripture_verse_sep_tl + } + \hook_use:n { scripture / verse / after } \group_end: } \dim_new:N \g__scripture_final_line_dim @@ -345,6 +449,8 @@ \skip_vertical:n { -\baselineskip - \parskip } } } +\str_new:N \l__scripture_currenvir_str +\skip_new:N \l__scripture_parskip_correction_skip \bool_new:N \g__scripture_start_bool \cs_new_protected:Nn \__scripture_begin:n { @@ -353,6 +459,7 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l__scripture_active_bool + \tl_set:Nn \l__scripture_currenvir_str { scripture } \tl_if_novalue:nF { #1 } { \keys_set:nn { scripture } { #1 } @@ -369,27 +476,36 @@ } \DeclareDocumentCommand { \ch } { sm } { - \bool_if:NTF \l__scripture_chap_drop_bool + \bool_if:NTF \l__scripture_chap_show_bool { - \__scripture_chap:n { ##2 } - \bool_if:nT { ##1 } + \bool_if:NTF \l__scripture_chap_drop_bool { - \hook_gput_next_code:nn { para / after } - { \int_zero:N \l__scripture_chap_par_prevgraf_int } + \__scripture_chap:n { ##2 } + \bool_if:nT { ##1 } + { + \hook_gput_next_code:nn { para / after } + { \int_gzero:N \g__scripture_chap_par_prevgraf_int } + } } + { \__scripture_nodrop_chap:n { ##2 } } } { \__scripture_nodrop_chap:n { ##2 } } } + \everydisplay { } + \int_set:Nn \predisplaypenalty { 10000 } + \int_set_eq:NN \postdisplaypenalty \@lowpenalty \bool_gset_true:N \g__scripture_start_bool \bool_gset_false:N \g__scripture_poetry_end_bool \dim_set_eq:NN \parindent \l__scripture_parindent_tl \cs_set_eq:NN \extraskip \__scripture_extra_skip: \cs_set_eq:NN \vs \__scripture_verse_output:n \hook_gclear_next_code:n { para / before } - \hook_gput_next_code:nn { para / end } - { \skip_set_eq:NN \parskip \l__scripture_parskip_tl } - \hook_gput_next_code:nn { para / after } - { \bool_gset_false:N \g__scripture_start_bool } + \skip_set:Nn \l__scripture_parskip_correction_skip { \parskip - \l__scripture_parskip_tl } + \mode_if_vertical:T + { + \addvspace { \l__scripture_parskip_correction_skip } + } + \skip_set_eq:NN \parskip \l__scripture_parskip_tl \l__scripture_font_tl \bool_lazy_or:nnT { \dim_compare_p:n { \l__scripture_leftmargin_tl > 0pt } } @@ -409,7 +525,18 @@ } } \bool_if:NF \l__scripture_indent_bool - { \noindent } + { + \hook_gput_next_code:nn { para / begin } + { + \bool_lazy_any:nT + { + { \str_if_eq_p:Vn \l__scripture_currenvir_str { midparachap } } + { \str_if_eq_p:Vn \l__scripture_currenvir_str { narrow } } + { \str_if_eq_p:Vn \l__scripture_currenvir_str { scripture } } + } + { \para_omit_indent: } + } + } } \cs_new_protected:Nn \__scripture_end:n { @@ -418,8 +545,13 @@ \unskip \unskip } - { \__scripture_calc_final_line_length: } - \bool_lazy_or:nnT + { + \tl_if_novalue:nTF { #1 } + { \int_zero:N \postdisplaypenalty } + { \int_set_eq:NN \postdisplaypenalty \@highpenalty } + \__scripture_calc_final_line_length: + } + \bool_lazy_or:nnTF { \dim_compare_p:n { \l__scripture_leftmargin_tl > 0pt } } { \dim_compare_p:n { \l__scripture_rightmargin_tl > 0pt } } { @@ -431,6 +563,7 @@ \parshape 1 ~ \@totalleftmargin ~ \linewidth } } + { \parshape 1 ~ \@totalleftmargin ~ \linewidth } \tl_if_novalue:nF { #1 } { \__scripture_reference:n { #1 } @@ -467,18 +600,25 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l__scripture_active_inner_bool + \tl_set:Nn \l__scripture_currenvir_str { center } \tl_if_novalue:nF { #1 } { \keys_set:nn { scripture / center } { #1 } } - \par + \mode_if_horizontal:T + { \par } \list { } { \skip_set_eq:NN \l__scripture_delta_below_skip \l__scripture_center_belowskip_tl \bool_if:NTF \g__scripture_start_bool - { \skip_zero:N \topsep } + { + \skip_zero:N \topsep + \skip_sub:Nn \topsep \parskip + \skip_add:Nn \l__scripture_delta_below_skip \parskip + \bool_gset_false:N \g__scripture_start_bool + } { \dim_compare:nTF { \parskip >= \l__scripture_center_aboveskip_tl > \c_zero_skip } @@ -490,6 +630,9 @@ \skip_set_eq:NN \topsep \l__scripture_center_aboveskip_tl \skip_sub:Nn \l__scripture_delta_below_skip \l__scripture_center_aboveskip_tl } + \int_compare:nNnT \g__scripture_chap_par_prevgraf_int = 1 + { \addvspace { \baselineskip } } + \int_gzero:N \g__scripture_chap_par_prevgraf_int } \skip_set_eq:NN \parsep \parskip \skip_zero:N \partopsep @@ -504,6 +647,7 @@ { \__scripture_calc_final_line_length: \skip_add:Nn \@topsepadd \l__scripture_delta_below_skip + \int_set_eq:NN \@endparpenalty \@lowpenalty \endlist } \cs_new_protected:Nn \__scripture_flushright_begin:n @@ -513,18 +657,25 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l__scripture_active_inner_bool + \tl_set:Nn \l__scripture_currenvir_str { flushright } \tl_if_novalue:nF { #1 } { \keys_set:nn { scripture / flushright } { #1 } } - \par + \mode_if_horizontal:T + { \par } \list { } { \skip_set_eq:NN \l__scripture_delta_below_skip \l__scripture_flushright_belowskip_tl \bool_if:NTF \g__scripture_start_bool - { \skip_zero:N \topsep } + { + \skip_zero:N \topsep + \skip_sub:Nn \topsep \parskip + \skip_add:Nn \l__scripture_delta_below_skip \parskip + \bool_gset_false:N \g__scripture_start_bool + } { \dim_compare:nTF { \parskip >= \l__scripture_flushright_aboveskip_tl > \c_zero_skip } @@ -536,6 +687,9 @@ \skip_set_eq:NN \topsep \l__scripture_flushright_aboveskip_tl \skip_sub:Nn \l__scripture_delta_below_skip \l__scripture_flushright_aboveskip_tl } + \int_compare:nNnT \g__scripture_chap_par_prevgraf_int = 1 + { \addvspace { \baselineskip } } + \int_gzero:N \g__scripture_chap_par_prevgraf_int } \dim_set_eq:NN \leftmargin \l__scripture_flushright_leftmargin_tl \dim_set_eq:NN \rightmargin \l__scripture_flushright_rightmargin_tl @@ -552,6 +706,7 @@ { \__scripture_calc_final_line_length: \skip_add:Nn \@topsepadd \l__scripture_delta_below_skip + \int_set_eq:NN \@endparpenalty \@lowpenalty \endlist } \dim_new:N \l__scripture_hanging_parindent_saved_dim @@ -601,21 +756,25 @@ } \__scripture_nohang: } - \hbox_set:Nn \l_tmpb_box + \hbox_set:Nn \l__scripture_chap_box { \box_move_down:nn { \baselineskip } { \hbox_overlap_left:n { - \box_use:N \l_tmpa_box + \box_use:N \l__scripture_chap_tmp_box \skip_horizontal:N \l__scripture_chap_sep_tl } } } - \box_set_ht:Nn \l_tmpb_box { \c_zero_dim } - \box_set_dp:Nn \l_tmpb_box { \c_zero_dim } - \box_use:N \l_tmpb_box + \box_set_ht:Nn \l__scripture_chap_box { \c_zero_dim } + \box_set_dp:Nn \l__scripture_chap_box { \c_zero_dim } + \group_begin: + \hook_use:n { scripture / chap / before } + \box_use:N \l__scripture_chap_box + \hook_use:n { scripture / chap / after } + \group_end: \hook_gput_next_code:nn { para / begin } { \parshape 1 ~ \@totalleftmargin ~ \linewidth } } @@ -643,18 +802,25 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l__scripture_active_inner_bool + \tl_set:Nn \l__scripture_currenvir_str { hanging } \tl_if_novalue:nF { #1 } { \keys_set:nn { scripture / hanging } { #1 } } - \par + \mode_if_horizontal:T + { \par } \list { } { \skip_set_eq:NN \l__scripture_delta_below_skip \l__scripture_hanging_belowskip_tl \bool_if:NTF \g__scripture_start_bool - { \dim_zero:N \topsep } + { + \dim_zero:N \topsep + \skip_sub:Nn \topsep \parskip + \skip_add:Nn \l__scripture_delta_below_skip \parskip + \bool_gset_false:N \g__scripture_start_bool + } { \dim_compare:nTF { \parskip >= \l__scripture_hanging_aboveskip_tl > \c_zero_skip } @@ -666,9 +832,9 @@ \skip_set_eq:NN \topsep \l__scripture_hanging_aboveskip_tl \skip_sub:Nn \l__scripture_delta_below_skip \l__scripture_hanging_aboveskip_tl } - \int_compare:nNnT \l__scripture_chap_par_prevgraf_int = 1 + \int_compare:nNnT \g__scripture_chap_par_prevgraf_int = 1 { \addvspace { \baselineskip } } - \int_zero:N \l__scripture_chap_par_prevgraf_int + \int_gzero:N \g__scripture_chap_par_prevgraf_int } \dim_set:Nn \leftmargin { \l__scripture_hanging_leftmargin_tl + \l__scripture_hanging_hang_tl } @@ -680,9 +846,16 @@ \dim_zero:N \labelsep \dim_set_eq:NN \l__scripture_hanging_parindent_saved_dim \parindent } - \bool_if:NTF \l__scripture_chap_drop_bool - { \cs_set_eq:NN \ch \__scripture_hanging_chap:n } - { \cs_set_eq:NN \ch \__scripture_nodrop_chap:n } + \DeclareDocumentCommand { \ch } { sm } + { + \bool_if:NTF \l__scripture_chap_show_bool + { + \bool_if:NTF \l__scripture_chap_drop_bool + { \__scripture_hanging_chap:n { ##2 } } + { \__scripture_nodrop_chap:n { ##2 } } + } + { \__scripture_nodrop_chap:n { ##2 } } + } \cs_set_eq:NN \vs \__scripture_hanging_verse:n \cs_set_eq:NN \nohang \__scripture_nohang: \item @@ -692,6 +865,7 @@ { \__scripture_calc_final_line_length: \skip_add:Nn \@topsepadd \l__scripture_delta_below_skip + \int_set_eq:NN \@endparpenalty \@lowpenalty \endlist } \cs_new_protected:Npn \__scripture_vbox_set_top:Nw #1 @@ -702,17 +876,19 @@ } \bool_new:N \l__scripture_mid_para_chap_bool \box_new:N \l__scripture_mid_para_chap_line_box +\dim_new:N \g__scripture_mid_para_chap_prevdepth_dim \int_new:N \g__scripture_mid_para_chap_prevgraf_int \box_new:N \l__scripture_mid_para_chap_snap_box \int_new:N \l__scripture_mid_para_chap_spacefactor_int \box_new:N \l__scripture_mid_para_chap_box +\box_new:N \l__scripture_mid_para_chap_split_box +\box_new:N \l__scripture_mid_para_chap_split_top_box \cs_new_protected:Nn \__scripture_mid_para_drop_chap_output: { \unskip \int_set_eq:NN \l__scripture_mid_para_chap_spacefactor_int \spacefactor \strut \par - \int_gset_eq:NN \g__scripture_mid_para_chap_prevgraf_int \prevgraf \box_set_to_last:N \l__scripture_mid_para_chap_line_box \hbox_set:Nn \l__scripture_mid_para_chap_snap_box { @@ -744,44 +920,94 @@ \hbox_unpack_drop:N \l__scripture_mid_para_chap_snap_box \skip_zero:N \parfillskip \par - \int_gadd:Nn \g__scripture_mid_para_chap_prevgraf_int \prevgraf \group_end: \__scripture_drop_chap_output: + \bool_if:NT \l__scripture_midparachap_show_verse_bool + { + \__scripture_verse_output:n { 1 } + } } } -\cs_new_protected:Nn \__scripture_mid_para_chap_begin: +\cs_new_protected:Nn \__scripture_mid_para_chap_begin:n { + \tl_set:Nn \l__scripture_currenvir_str { midparachap } + \tl_if_novalue:nF { #1 } + { + \keys_set:nn + { scripture / midparachap } + { #1 } + } \par \bool_set_true:N \l__scripture_mid_para_chap_bool - \skip_zero:N \parskip \__scripture_vbox_set_top:Nw \l__scripture_mid_para_chap_box + \skip_zero:N \parskip } \cs_new_protected:Nn \__scripture_mid_para_chap_end: { - \__scripture_calc_final_line_length: - \int_gadd:Nn \g__scripture_mid_para_chap_prevgraf_int { \prevgraf - 1 } + \par + \int_gset_eq:NN \g__scripture_mid_para_chap_prevgraf_int \prevgraf + \dim_gset_eq:NN \g__scripture_mid_para_chap_prevdepth_dim \prevdepth + \box_set_to_last:N \l__scripture_mid_para_chap_line_box + \hbox_set:Nn \l__scripture_mid_para_chap_snap_box + { + \hbox_unpack:N \l__scripture_mid_para_chap_line_box + \unskip + \unskip + \unpenalty + } + \dim_gset:Nn \g__scripture_final_line_dim { \box_wd:N \l__scripture_mid_para_chap_snap_box } + \box_clear:N \l__scripture_mid_para_chap_snap_box + \nointerlineskip + \int_compare:nNnT + \prevgraf < 3 + { + \noindent + \skip_horizontal:n { \l__scripture_chap_width_dim + \l__scripture_chap_sep_tl } + \dim_gadd:Nn \g__scripture_final_line_dim { \l__scripture_chap_width_dim + \l__scripture_chap_sep_tl } + } + \box_use_drop:N \l__scripture_mid_para_chap_line_box \vbox_set_end: - \dim_compare:nNnTF - { \box_ht_plus_dp:N \l__scripture_mid_para_chap_box } - > - { \pagegoal - \pagetotal - \baselineskip } + \mode_if_inner:TF { - \int_set:Nn \vbadness { 10000 } - \vbox_set_split_to_ht:NNn - \l_tmpa_box \l__scripture_mid_para_chap_box - { \pagegoal - \pagetotal - \baselineskip } - \box_use_drop:N \l_tmpa_box - \goodbreak + \noindent \box_use_drop:N \l__scripture_mid_para_chap_box } { - \box_use_drop:N \l__scripture_mid_para_chap_box - \skip_vertical:n { \baselineskip - \lineskip } + \dim_compare:nNnTF + { \box_ht_plus_dp:N \l__scripture_mid_para_chap_box } + > + { \pagegoal - \pagetotal - \baselineskip } + { + \int_set:Nn \vbadness { 10000 } + \vbox_set_split_to_ht:NNn + \l__scripture_mid_para_chap_split_box \l__scripture_mid_para_chap_box + { \pagegoal - \pagetotal - \baselineskip } + \vbox_set_top:Nn \l__scripture_mid_para_chap_split_top_box + { \vbox_unpack_drop:N \l__scripture_mid_para_chap_split_box } + \noindent + \box_use_drop:N \l__scripture_mid_para_chap_split_top_box + \goodbreak + \box_use_drop:N \l__scripture_mid_para_chap_box + } + { + \noindent + \box_use_drop:N \l__scripture_mid_para_chap_box + } } \par + \dim_set_eq:NN \prevdepth \g__scripture_mid_para_chap_prevdepth_dim + \int_zero:N \prevgraf + \skip_vertical:n { -\parskip - \baselineskip } \noindent \skip_horizontal:N \g__scripture_final_line_dim - \__scripture_reset_spacing: + \int_gset_eq:NN \g__scripture_chap_par_prevgraf_int \g__scripture_mid_para_chap_prevgraf_int + \hook_gput_next_code:nn { para / before } + { + \int_gzero:N \g__scripture_chap_par_prevgraf_int + \int_compare:nNnT + \@listdepth > \c_zero_int + { \parshape 1 ~ \@totalleftmargin ~ \linewidth } + } } \cs_new_protected:Nn \__scripture_narrow_begin:n { @@ -790,18 +1016,25 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l__scripture_active_inner_bool + \tl_set:Nn \l__scripture_currenvir_str { narrow } \tl_if_novalue:nF { #1 } { \keys_set:nn { scripture / narrow } { #1 } } - \par + \mode_if_horizontal:T + { \par } \list { } { \skip_set_eq:NN \l__scripture_delta_below_skip \l__scripture_narrow_belowskip_tl \bool_if:NTF \g__scripture_start_bool - { \skip_zero:N \topsep } + { + \skip_zero:N \topsep + \skip_sub:Nn \topsep \parskip + \skip_add:Nn \l__scripture_delta_below_skip \parskip + \bool_gset_false:N \g__scripture_start_bool + } { \dim_compare:nTF { \parskip >= \l__scripture_narrow_aboveskip_tl > \c_zero_skip } @@ -813,6 +1046,9 @@ \skip_set_eq:NN \topsep \l__scripture_narrow_aboveskip_tl \skip_sub:Nn \l__scripture_delta_below_skip \l__scripture_narrow_aboveskip_tl } + \int_compare:nNnT \g__scripture_chap_par_prevgraf_int = 1 + { \addvspace { \baselineskip } } + \int_gzero:N \g__scripture_chap_par_prevgraf_int } \dim_set_eq:NN \leftmargin \l__scripture_narrow_leftmargin_tl \dim_set_eq:NN \rightmargin \l__scripture_narrow_rightmargin_tl @@ -829,107 +1065,236 @@ { \__scripture_calc_final_line_length: \skip_add:Nn \@topsepadd \l__scripture_delta_below_skip + \int_set_eq:NN \@endparpenalty \@lowpenalty \endlist } +\hook_new:n { scripture / poetry / para / after } \bool_new:N \g__scripture_poetry_end_bool +\bool_new:N \g__scripture_poetry_midparachap_show_verse_bool +\dim_new:N \l__scripture_poetry_chap_indent_dim +\dim_new:N \l__scripture_poetry_chap_sep_dim +\dim_new:N \l__scripture_poetry_chap_parshape_correction_dim \int_new:N \l__scripture_poetry_prevgraf_int +\cs_new_protected:Nn \__scripture_poetry_extra_skip: + { + \skip_vertical:n { \l__scripture_extraskip_tl - \baselineskip - \parskip } + \bool_gset_false:N \g__scripture_poetry_midparachap_show_verse_bool + \strut + \hook_gput_next_code:nn { para / after } + { + \hook_gput_next_code:nn { para / after } + { + \bool_gset_eq:NN + \g__scripture_poetry_midparachap_show_verse_bool + \l__scripture_midparachap_show_verse_bool + } + } + } +\cs_new_protected:Nn \__scripture_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 + } + } +\cs_new_protected:Nn \__scripture_selah_output: + { + \group_begin: + \l__scripture_selah_font_tl + \__scripture_poetry_text_right:nn + { \l__scripture_selah_sep_tl } + { \__scripture_selah_format:n { \l__scripture_selah_text_tl } } + \group_end: + } \cs_new_protected:Nn \__scripture_poetry_chap:n { \__scripture_drop_chap_set_up:n { #1 } - \dim_compare:nNnT \l__scripture_chap_width_dim < \l__scripture_poetry_leftmargin_tl + \mode_if_vertical:TF { - \tl_set:Nx \l__scripture_chap_sep_tl + \dim_set_eq:NN \l__scripture_poetry_chap_indent_dim \l__scripture_poetry_indent_tl + \mode_leave_vertical: + } + { \dim_zero:N \l__scripture_poetry_chap_indent_dim } + \dim_set_eq:NN \l__scripture_poetry_chap_sep_dim \l__scripture_chap_sep_tl + \dim_compare:nNnT + { \l__scripture_chap_width_dim + \l__scripture_chap_sep_tl } + < + { \l__scripture_poetry_leftmargin_tl + \l__scripture_poetry_chap_indent_dim } + { + \dim_set:Nn \l__scripture_poetry_chap_sep_dim { - \dim_eval:n - { - \l__scripture_poetry_leftmargin_tl - \l__scripture_chap_width_dim - } + \l__scripture_poetry_leftmargin_tl + \l__scripture_poetry_chap_indent_dim - + \l__scripture_chap_width_dim } } - \hbox_set:Nn \l_tmpb_box + \hbox_set:Nn \l__scripture_chap_box { \box_move_down:nn { \baselineskip } { \hbox_overlap_left:n { - \box_use:N \l_tmpa_box - \skip_horizontal:N \l__scripture_chap_sep_tl + \box_use:N \l__scripture_chap_tmp_box + \skip_horizontal:N \l__scripture_poetry_chap_sep_dim } } } - \box_set_ht:Nn \l_tmpb_box { \c_zero_dim } - \box_set_dp:Nn \l_tmpb_box { \c_zero_dim } + \box_set_ht:Nn \l__scripture_chap_box { \c_zero_dim } + \box_set_dp:Nn \l__scripture_chap_box { \c_zero_dim } + \dim_set:Nn \l__scripture_poetry_chap_parshape_correction_dim + { + \l__scripture_chap_width_dim + \l__scripture_poetry_chap_sep_dim - + \l__scripture_poetry_leftmargin_tl - \l__scripture_poetry_chap_indent_dim + } \parshape 2 ~ \dim_eval:n - { - \@totalleftmargin - \l__scripture_poetry_leftmargin_tl + - \l__scripture_chap_width_dim + \l__scripture_chap_sep_tl - } ~ + { \@totalleftmargin + \l__scripture_poetry_chap_parshape_correction_dim } ~ \dim_eval:n - { - \linewidth - \@totalleftmargin + \l__scripture_poetry_leftmargin_tl - - \l__scripture_chap_width_dim - \l__scripture_chap_sep_tl - } ~ + { \linewidth - \l__scripture_poetry_chap_parshape_correction_dim } ~ \dim_eval:n { \@totalleftmargin + \l__scripture_poetry_big_indent_tl } ~ \dim_eval:n { \linewidth - \l__scripture_poetry_big_indent_tl } \dim_compare:nNnT - { \l__scripture_chap_width_dim + \l__scripture_chap_sep_tl } + { \l__scripture_chap_width_dim + \l__scripture_poetry_chap_sep_dim } > - { \l__scripture_poetry_leftmargin_tl + \listparindent } + \l__scripture_poetry_leftmargin_tl { - \hook_gput_next_code:nn { para / begin } + \hook_gput_next_code:nn { scripture / poetry / para / after } { \int_compare:nNnT \l__scripture_poetry_prevgraf_int = 1 { + \dim_compare:nNnTF + { \l__scripture_chap_width_dim + \l__scripture_chap_sep_tl } + < + { \l__scripture_poetry_leftmargin_tl + \l__scripture_poetry_indent_tl } + { \dim_zero:N \l__scripture_poetry_chap_parshape_correction_dim } + { + \dim_set:Nn \l__scripture_poetry_chap_parshape_correction_dim + { + \l__scripture_chap_width_dim + \l__scripture_chap_sep_tl - + \l__scripture_poetry_leftmargin_tl - \l__scripture_poetry_indent_tl + } + } \parshape 2 ~ \dim_eval:n - { - \@totalleftmargin - \l__scripture_poetry_leftmargin_tl + - \l__scripture_chap_width_dim + \l__scripture_chap_sep_tl - - \listparindent - } ~ + { \@totalleftmargin + \l__scripture_poetry_chap_parshape_correction_dim } ~ \dim_eval:n - { - \linewidth - \@totalleftmargin + \l__scripture_poetry_leftmargin_tl - - \l__scripture_chap_width_dim - \l__scripture_chap_sep_tl + - \listparindent - } ~ + { \linewidth - \l__scripture_poetry_chap_parshape_correction_dim } ~ \dim_eval:n { \@totalleftmargin + \l__scripture_poetry_big_indent_tl } ~ \dim_eval:n { \linewidth - \l__scripture_poetry_big_indent_tl } + \hook_gput_next_code:nn { para / after } + { + \hook_gclear_next_code:n { scripture / poetry / para / after } + } + \hook_gput_next_code:nn { scripture / poetry / para / after } + { + \dim_compare:nNnTF + { \l__scripture_chap_width_dim + \l__scripture_chap_sep_tl } + < + \l__scripture_poetry_leftmargin_tl + { \dim_zero:N \l__scripture_poetry_chap_parshape_correction_dim } + { + \dim_set:Nn \l__scripture_poetry_chap_parshape_correction_dim + { + \l__scripture_chap_width_dim + \l__scripture_chap_sep_tl - + \l__scripture_poetry_leftmargin_tl + } + } + \parshape 2 ~ + \dim_eval:n + { \@totalleftmargin + \l__scripture_poetry_chap_parshape_correction_dim } ~ + \dim_eval:n + { \linewidth - \l__scripture_poetry_chap_parshape_correction_dim } ~ + \dim_eval:n + { \@totalleftmargin + \l__scripture_poetry_big_indent_tl } ~ + \dim_eval:n + { \linewidth - \l__scripture_poetry_big_indent_tl } + } } } } - \box_use:N \l_tmpb_box + \group_begin: + \hook_use:n { scripture / chap / before } + \box_use:N \l__scripture_chap_box + \hook_use:n { scripture / chap / after } + \group_end: + \bool_if:NT \g__scripture_poetry_midparachap_show_verse_bool + { + \__scripture_verse_output:n { 1 } + } } \cs_new_protected:Nn \__scripture_poetry_nodrop_chap:n { - \hbox_overlap_left:n + \cs_gset_nopar:Npn \scripturecurrentchapter { #1 } + \cs_gset_nopar:Npn \scripturecurrentverse { 1 } + \group_begin: + \bool_if:NTF \l__scripture_chap_show_bool { - \group_begin: - \l__scripture_chap_font_tl - #1 - \group_end: - \skip_horizontal:N \l__scripture_chap_sep_tl + \hbox_overlap_left:n + { + \hook_use:n { scripture / chap / before } + \group_begin: + \l__scripture_chap_font_tl + #1 + \group_end: + \skip_horizontal:N \l__scripture_chap_sep_tl + \hook_use:n { scripture / chap / after } + } + \bool_if:NT \g__scripture_poetry_midparachap_show_verse_bool + { + \__scripture_verse_output:n { 1 } + } } + { + \hook_use:n { scripture / chap / before } + \hook_use:n { scripture / chap / after } + \vs { 1 } + } + \group_end: } \cs_new_protected:Nn \__scripture_poetry_mode_vertical_verse:n { + \group_begin: + \tl_set_eq:NN \l__scripture_verse_sep_tl \l__scripture_poetry_verse_sep_tl \strut - \hbox_overlap_left:n + \bool_if:NTF \l__scripture_poetry_verse_right_bool + { + \hbox_overlap_left:n + { + \__scripture_verse_output:n { #1 } + } + } { - \__scripture_verse_output:n { #1 } + \hbox_overlap_left:n + { + \hbox_overlap_right:n + { + \__scripture_verse_output:n { #1 } + } + \skip_horizontal:N \l__scripture_poetry_leftmargin_tl + } } + \group_end: } \cs_new_protected:Nn \__scripture_poetry_mode_horizontal_verse:n { + \group_begin: + \tl_set_eq:NN \l__scripture_verse_sep_tl \l__scripture_poetry_verse_sep_tl \skip_horizontal:n { -\listparindent } \__scripture_poetry_mode_vertical_verse:n { #1 } \skip_horizontal:N \listparindent + \group_end: } \cs_new_protected:Nn \__scripture_poetry_par: { @@ -941,6 +1306,7 @@ { \cs_set_eq:NN \vs \__scripture_poetry_mode_horizontal_verse:n \__scripture_tmp_para_end: + \int_set_eq:NN \l__scripture_poetry_prevgraf_int \prevgraf } \parshape 2 ~ \@totalleftmargin ~ @@ -949,6 +1315,7 @@ { \@totalleftmargin + \l__scripture_poetry_big_indent_tl } ~ \dim_eval:n { \linewidth - \l__scripture_poetry_big_indent_tl } + \hook_use:n { scripture / poetry / para / after } } \group_begin: \char_set_catcode_active:N \^^M @@ -973,13 +1340,18 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l__scripture_active_inner_bool - \par + \tl_set:Nn \l__scripture_currenvir_str { poetry } + \mode_if_horizontal:T + { \par } \list { } { \skip_set_eq:NN \l__scripture_delta_below_skip \l__scripture_poetry_belowskip_tl \bool_if:NTF \g__scripture_start_bool { \skip_zero:N \topsep + \skip_sub:Nn \topsep \parskip + \skip_add:Nn \l__scripture_delta_below_skip \parskip + \bool_gset_false:N \g__scripture_start_bool } { \dim_compare:nTF @@ -992,9 +1364,9 @@ \skip_set_eq:NN \topsep \l__scripture_poetry_aboveskip_tl \skip_sub:Nn \l__scripture_delta_below_skip \l__scripture_poetry_aboveskip_tl } - \int_compare:nNnT \l__scripture_chap_par_prevgraf_int = 1 + \int_compare:nNnT \g__scripture_chap_par_prevgraf_int = 1 { \addvspace { \baselineskip } } - \int_zero:N \l__scripture_chap_par_prevgraf_int + \int_gzero:N \g__scripture_chap_par_prevgraf_int } \dim_set_eq:NN \leftmargin \l__scripture_poetry_leftmargin_tl \dim_set_eq:NN \rightmargin \l__scripture_poetry_rightmargin_tl @@ -1007,24 +1379,39 @@ \raggedright \dim_set_eq:NN \listparindent \l__scripture_poetry_indent_tl \dim_set_eq:NN \parindent \l__scripture_poetry_indent_tl - \bool_if:NTF \l__scripture_chap_drop_bool - { \cs_set_eq:NN \ch \__scripture_poetry_chap:n } - { \cs_set_eq:NN \ch \__scripture_poetry_nodrop_chap:n } + \bool_gset_false:N \g__scripture_poetry_midparachap_show_verse_bool + \DeclareDocumentCommand { \ch } { sm } + { + \bool_if:NTF \l__scripture_chap_show_bool + { + \bool_if:NTF \l__scripture_chap_drop_bool + { \__scripture_poetry_chap:n { ##2 } } + { \__scripture_poetry_nodrop_chap:n { ##2 } } + } + { \__scripture_poetry_nodrop_chap:n { ##2 } } + } \cs_set_eq:NN \vs \__scripture_poetry_mode_vertical_verse:n + \cs_set_eq:NN \extraskip \__scripture_poetry_extra_skip: + \cs_set_eq:NN \selah \__scripture_selah_output: \item \relax \cs_set_eq:NN \__scripture_tmp_para_end: \par \cs_set_eq:NN \par \__scripture_poetry_par: + \hook_gput_next_code:nn { para / after } + { \bool_gset_eq:NN \g__scripture_poetry_midparachap_show_verse_bool \l__scripture_midparachap_show_verse_bool } } \cs_new_protected:Nn \__scripture_poetry_end: { \__scripture_calc_final_line_length: \skip_add:Nn \@topsepadd \l__scripture_delta_below_skip + \int_set_eq:NN \@endparpenalty \@lowpenalty \endlist \bool_gset_true:N \g__scripture_poetry_end_bool \hook_gput_next_code:nn { para / begin } { \bool_gset_false:N \g__scripture_poetry_end_bool } } +\cs_set_nopar:Npn \scripturecurrentchapter { } +\cs_set_nopar:Npn \scripturecurrentverse { } \NewDocumentCommand { \scripturesetup } { m } { \keys_set:nn { scripture } { #1 } @@ -1050,9 +1437,9 @@ \ignorespaces } { \__scripture_hanging_end: } - \DeclareDocumentEnvironment { midparachap } { } + \DeclareDocumentEnvironment { midparachap } { o } { - \__scripture_mid_para_chap_begin: + \__scripture_mid_para_chap_begin:n { ##1 } \ignorespaces } { \__scripture_mid_para_chap_end: } @@ -1080,9 +1467,38 @@ \poetryaux } { \endpoetryaux } - \ignorespaces + \bool_if:NT \l__scripture_compact_bool + { + \scripturesetup { chapter / nodrop } + \RenewDocumentEnvironment { center } { o } { \ignorespaces } { } + \RenewDocumentEnvironment { flushright } { o } { \ignorespaces } { } + \RenewDocumentEnvironment { hanging } { o } { \ignorespaces } { } + \RenewDocumentEnvironment { midparachap } { o } { \ignorespaces } { } + \RenewDocumentEnvironment { narrow } { o } { \ignorespaces } { } + \RenewDocumentEnvironment { poetry } { o } { \ignorespaces } { } + \cs_set_eq:NN \par \relax + \cs_set_eq:NN \extraskip \relax + \cs_set_eq:NN \nohang \relax + \cs_set:Npn \selah + { + \group_begin: + \l__scripture_selah_font_tl + \c_space_tl + \__scripture_selah_format:n { \l__scripture_selah_text_tl } + \c_space_tl + \group_end: + } + \mode_leave_vertical: + } + \peek_remove_spaces:n + { + \peek_meaning:NF \begin + { \bool_gset_false:N \g__scripture_start_bool } + } } { + \bool_if:NT \l__scripture_compact_bool + { \cs_set_eq:NN \par \endgraf } \__scripture_end:n { #1 } } %% |