diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/scripture/scripture.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/scripture/scripture.sty | 1911 |
1 files changed, 1673 insertions, 238 deletions
diff --git a/Master/texmf-dist/tex/latex/scripture/scripture.sty b/Master/texmf-dist/tex/latex/scripture/scripture.sty index 5cdbca4dce9..512dcccca7b 100644 --- a/Master/texmf-dist/tex/latex/scripture/scripture.sty +++ b/Master/texmf-dist/tex/latex/scripture/scripture.sty @@ -25,8 +25,17 @@ %% and the derived files scripture.sty and scripture.pdf %% \NeedsTeXFormat{LaTeX2e}[2022-11-01] -\ProvidesExplPackage{scripture}{2023/12/27}{2.0} +\ProvidesExplPackage{scripture}{2025/01/02}{2.1} {Format Scripture Quotations (DCP)} +\bool_new:N \l__scripture_textdir_change_in_group_bool +\cs_new_protected:Nn \__scripture_set_textdirection: + { + \sys_if_engine_luatex:T + { + \textdirection \int_use:N \textdirection + \bool_set_true:N \l__scripture_textdir_change_in_group_bool + } + } \msg_new:nnnn { scripture } { nested-environment } { Nesting~of~scripture~environments~not~supported. } { You~have~tried~to~nest~a~scripture~environment~or \\ @@ -39,6 +48,12 @@ { Language~requested~without~support. } { You~have~requested~language=#1,~but~neither~babel~nor~polyglossia~ have~been~loaded~and~set~up.~Ignoring~option~language=#1. } +\msg_new:nnnn { scripture } { heading-error } + { \token_to_str:N \heading \c_space_tl not~support~within~inner~ + environments. } + { You~have~tried~to~use~\token_to_str:N \heading \c_space_tl within~the~ + `#1'~environment,~but~this~macro~is~only~supported~in~the~main~ + `scripture'~environment. } \msg_new:nnnn { scripture } { unknown-style } { Style~#1~not~defined. } { You~have~requested~style=#1,~but~it~has~not~been~defined.~ @@ -55,6 +70,12 @@ , added / format .cs_set:Np = \__scripture_added_format:n #1 , added / format .value_required:n = true , added / format .initial:n = \emph { #1 } + , after .tl_set:N = \l__scripture_after_tl + , after .value_required:n = true + , after .initial:n = + , before .tl_set:N = \l__scripture_before_tl + , before .value_required:n = true + , before .initial:n = , belowskip .tl_set:N = \l__scripture_belowskip_tl , belowskip .value_required:n = true , belowskip .initial:n = \c_zero_skip @@ -65,6 +86,26 @@ , compact .bool_set:N = \l__scripture_compact_bool , compact .default:n = true , compact .initial:n = false + , chapter / align .choices:nn = { left, right } + { + \tl_if_exist:NF \l__scripture_chapter_align_tl + { \tl_new:N \l__scripture_chapter_align_tl } + \str_case:Vn \l_keys_choice_tl + { + { left } + { + \tl_set:Nn \l__scripture_chapter_align_tl + { l } + } + { right } + { + \tl_set:Nn \l__scripture_chapter_align_tl + { r } + } + } + } + , chapter / align .value_required:n = true + , chapter / align .initial:n = left , chapter / font .tl_set:N = \l__scripture_chap_font_tl , chapter / font .value_required:n = true , chapter / font .initial:n = \bfseries @@ -82,21 +123,115 @@ , chapter / hide .default:n = true , chapter / nodrop .bool_set_inverse:N = \l__scripture_chap_drop_bool , chapter / nodrop .default:n = true + , chapter / para .bool_set:N = \l__scripture_chap_para_bool + , chapter / para .default:n = true + , chapter / para .initial:n = false + , chapter / para / aboveskip .tl_set:N = \l__scripture_chap_para_aboveskip_tl + , chapter / para / aboveskip .value_required:n = true + , chapter / para / aboveskip .initial:n = \bigskipamount + , chapter / para / belowskip .tl_set:N = \l__scripture_chap_para_belowskip_tl + , chapter / para / belowskip .value_required:n = true + , chapter / para / belowskip .initial:n = \medskipamount + , chapter / para / indent .code:n = { + \bool_set:Nn + \l__scripture_chap_para_afterindent_bool + { \str_if_eq_p:nn { #1 } { true } } + } + , chapter / para / indent .default:n = true + , chapter / para / indent .initial:n = true , chapter / sep .tl_set:N = \l__scripture_chap_sep_tl , chapter / sep .value_required:n = true - , chapter / sep .initial:n = 0.5 em + , chapter / sep .initial:n = 0.5em , chapter / show .bool_set:N = \l__scripture_chap_show_bool , chapter / show .default:n = true , chapter / show .initial:n = true , chapter / showverse .bool_set:N = \l__scripture_chap_show_verse_bool , chapter / showverse .default:n = true , chapter / showverse .initial:n = false + , chapter / smash .bool_set:N = \l__scripture_chap_smash_bool + , chapter / smash .default:n = true + , chapter / smash .initial:n = false + , chapter / valign .choices:nn = { bottom, middle, top } + { + \tl_if_exist:NF \l__scripture_chapter_valign_tl + { \tl_new:N \l__scripture_chapter_valign_tl } + \str_case:Vn \l_keys_choice_tl + { + { bottom } + { + \tl_set:Nn \l__scripture_chapter_valign_tl + { b } + } + { middle } + { + \tl_set:Nn \l__scripture_chapter_valign_tl + { vc } + } + { top } + { + \tl_set:Nn \l__scripture_chapter_valign_tl + { t } + } + } + } + , chapter / valign .value_required:n = true + , chapter / valign .initial:n = bottom + , chapter / xchar .tl_set:N = \l__scripture_X_char_tl + , chapter / xchar .value_required:n = true + , chapter / xchar .initial:n = X + , defaults .code:n = \cs_if_exist_use:N \__scripture_setup_reset_defaults: + , defaults .value_forbidden:n = true , extraskip .tl_set:N = \l__scripture_extraskip_tl , extraskip .value_required:n = true , extraskip .initial:n = \medskipamount , font .tl_set:N = \l__scripture_font_tl , font .value_required:n = true , font .initial:n = + , heading / aboveskip .tl_set:N = \l__scripture_heading_aboveskip_tl + , heading / aboveskip .value_required:n = true + , heading / aboveskip .initial:n = \bigskipamount + , heading / afterindent .bool_set:N = \l__scripture_heading_afterindent_bool + , heading / afterindent .default:n = true + , heading / afterindent .initial:n = false + , heading / align .choices:nn = { left, right, center } + { + \tl_if_exist:NF \l__scripture_heading_align_tl + { \tl_new:N \l__scripture_heading_align_tl } + \str_case:Vn \l_keys_choice_tl + { + { left } + { + \tl_set:Nn \l__scripture_heading_align_tl + { \raggedright } + } + { right } + { + \tl_set:Nn \l__scripture_heading_align_tl + { \raggedleft } + } + { center } + { + \tl_set:Nn \l__scripture_heading_align_tl + { \centering } + } + } + } + , heading / align .value_required:n = true + , heading / align .initial:n = left + , heading / belowskip .tl_set:N = \l__scripture_heading_belowskip_tl + , heading / belowskip .value_required:n = true + , heading / belowskip .initial:n = \medskipamount + , heading / font .tl_set:N = \l__scripture_heading_font_tl + , heading / font .value_required:n = true + , heading / font .initial:n = \small\itshape + , heading / format .cs_set:Np = \__scripture_heading_format:n #1 + , heading / format .value_required:n = true + , heading / format .initial:n = #1 + , heading / hide .bool_set_inverse:N = \l__scripture_heading_show_bool + , heading / hide .default:n = true + , heading / show .bool_set:N = \l__scripture_heading_show_bool + , heading / show .default:n = true + , heading / show .initial:n = true , indent .bool_set:N = \l__scripture_indent_bool , indent .default:n = true , indent .initial:n = true @@ -105,16 +240,16 @@ , inline .initial:n = false , inline / begin .tl_set:N = \l__scripture_inline_begin_tl , inline / begin .value_required:n = true - , inline / begin .initial:n = ``\, + , inline / begin .initial:n = `` , inline / end .tl_set:N = \l__scripture_inline_end_tl , inline / end .value_required:n = true - , inline / end .initial:n = \,'' + , inline / end .initial:n = '' , inline / reference / format .cs_set:Np = \__scripture_inline_ref_format:n #1 , inline / reference / format .value_required:n = true , inline / reference / format .initial:n = (#1) , inline / reference / sep .tl_set:N = \l__scripture_inline_ref_sep_tl , inline / reference / sep .value_required:n = true - , inline / reference / sep .initial:n = 0.5 em + , inline / reference / sep .initial:n = 0.5em , inline / version / delim .tl_set:N = \l__scripture_inline_version_delim_tl , inline / version / delim .value_required:n = true , inline / version / delim .initial:n = \c_space_tl @@ -144,6 +279,12 @@ , parskip .tl_set:N = \l__scripture_parskip_tl , parskip .value_required:n = true , parskip .initial:n = \parskip + , pilcrow .bool_set:N = \l__scripture_pilcrow_bool + , pilcrow .default:n = true + , pilcrow .initial:n = false + , pilcrow / sep .tl_set:N = \l__scripture_pilcrow_sep_tl + , pilcrow / sep .value_required:n = true + , pilcrow / sep .initial:n = 0.25em , redletter .bool_set:N = \l__scripture_red_letter_bool , redletter .default:n = true , redletter .initial:n = false @@ -171,9 +312,28 @@ , reference / format .initial:n = #1 , reference / newline .meta:n = { reference / sep = \linewidth } , reference / newline .value_forbidden:n = true + , reference / position .choices:nn = { start, end } + { + \tl_if_exist:NF \l__scripture_ref_position_tl + { \tl_new:N \l__scripture_ref_position_tl } + \tl_set_eq:NN \l__scripture_ref_position_tl \l_keys_choice_tl + } + , reference / position .value_required:n = true + , reference / position .initial:n = end , reference / sep .tl_set:N = \l__scripture_ref_sep_tl , reference / sep .value_required:n = true - , reference / sep .initial:n = 2 em + , reference / sep .initial:n = 2em + , reference / start / inline .bool_set_inverse:N = \l__scripture_ref_start_newline_bool + , reference / start / inline .default:n = true + , reference / start / newline .bool_set:N = \l__scripture_ref_start_newline_bool + , reference / start / newline .default:n = true + , reference / start / newline .initial:n = false + , reference / start / sep .tl_set:N = \l__scripture_ref_start_sep_tl + , reference / start / sep .value_required:n = true + , reference / start / sep .initial:n = 1em + , reference / start / vsep .tl_set:N = \l__scripture_ref_vertical_sep_tl + , reference / start / vsep .value_required:n = true + , reference / start / vsep .initial:n = 0pt , rightmargin .tl_set:N = \l__scripture_rightmargin_tl , rightmargin .value_required:n = true , rightmargin .initial:n = \c_zero_dim @@ -188,7 +348,7 @@ , 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 + , selah / sep .initial:n = 1em , style .choice: , style / unknown .code:n = \msg_error:nnx { scripture } @@ -196,7 +356,7 @@ { \exp_not:n {#1} } , textright / sep .tl_set:N = \l__scripture_text_right_sep_tl , textright / sep .value_required:n = true - , textright / sep .initial:n = 1 em + , textright / sep .initial:n = 1em , verse / colour .tl_set:N = \l__scripture_verse_colour_tl , verse / colour .value_required:n = true , verse / colour .initial:n = . @@ -218,9 +378,15 @@ , verse / format .initial:n = \textsuperscript{#1} , verse / hide .bool_set_inverse:N = \l__scripture_verse_show_bool , verse / hide .default:n = true + , verse / para .bool_set:N = \l__scripture_verse_para_bool + , verse / para .default:n = true + , verse / para .initial:n = false + , verse / para / indent .tl_set:N = \l__scripture_para_indent_tl + , verse / para / indent .value_required:n = true + , verse / para / indent .initial:n = \l__scripture_parindent_tl , verse / sep .tl_set:N = \l__scripture_verse_sep_tl , verse / sep .value_required:n = true - , verse / sep .initial:n = 0.05 em + , verse / sep .initial:n = 0.05em , verse / show .bool_set:N = \l__scripture_verse_show_bool , verse / show .default:n = true , verse / show .initial:n = true @@ -233,6 +399,14 @@ , version / format .cs_set:Np = \__scripture_version_format:n #1 , version / format .value_required:n = true , version / format .initial:n = (#1) + , version / position .choices:nn = { withref, end } + { + \tl_if_exist:NF \l__scripture_version_position_tl + { \tl_new:N \l__scripture_version_position_tl } + \tl_set_eq:NN \l__scripture_version_position_tl \l_keys_choice_tl + } + , version / position .value_required:n = true + , version / position .initial:n = withref , center / aboveskip .tl_set:N = \l__scripture_center_aboveskip_tl , center / aboveskip .value_required:n = true , center / aboveskip .initial:n = \medskipamount @@ -263,15 +437,26 @@ , hanging / belowskip .tl_set:N = \l__scripture_hanging_belowskip_tl , hanging / belowskip .value_required:n = true , hanging / belowskip .initial:n = \medskipamount + , hanging / chapter / indent .bool_set:N = \l__scripture_hanging_chapter_indent_bool + , hanging / chapter / indent .default:n = true + , hanging / chapter / indent .initial:n = true , hanging / hang .tl_set:N = \l__scripture_hanging_hang_tl , hanging / hang .value_required:n = true - , hanging / hang .initial:n = 2 em + , hanging / hang .initial:n = 2em , hanging / leftmargin .tl_set:N = \l__scripture_hanging_leftmargin_tl , hanging / leftmargin .value_required:n = true - , hanging / leftmargin .initial:n = 1 em + , hanging / leftmargin .initial:n = 1em , hanging / rightmargin .tl_set:N = \l__scripture_hanging_rightmargin_tl , hanging / rightmargin .value_required:n = true , hanging / rightmargin .initial:n = \c_zero_dim + , hanging / verse / left .bool_set_inverse:N = \l__scripture_hanging_verse_right_bool + , hanging / verse / left .default:n = true + , hanging / verse / right .bool_set:N = \l__scripture_hanging_verse_right_bool + , hanging / verse / right .default:n = true + , hanging / verse / right .initial:n = true + , hanging / verse / sep .tl_set:N = \l__scripture_hanging_verse_sep_tl + , hanging / verse / sep .value_required:n = true + , hanging / verse / sep .initial:n = 0.05em , 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 @@ -285,10 +470,10 @@ , narrow / belowskip .initial:n = \medskipamount , narrow / leftmargin .tl_set:N = \l__scripture_narrow_leftmargin_tl , narrow / leftmargin .value_required:n = true - , narrow / leftmargin .initial:n = 1 em + , narrow / leftmargin .initial:n = 1em , narrow / rightmargin .tl_set:N = \l__scripture_narrow_rightmargin_tl , narrow / rightmargin .value_required:n = true - , narrow / rightmargin .initial:n = 1 em + , narrow / rightmargin .initial:n = 1em , poetry / aboveskip .tl_set:N = \l__scripture_poetry_aboveskip_tl , poetry / aboveskip .value_required:n = true , poetry / aboveskip .initial:n = \medskipamount @@ -297,13 +482,13 @@ , poetry / belowskip .initial:n = \medskipamount , poetry / bigindent .tl_set:N = \l__scripture_poetry_big_indent_tl , poetry / bigindent .value_required:n = true - , poetry / bigindent .initial:n = 4 em + , poetry / bigindent .initial:n = 4em , poetry / indent .tl_set:N = \l__scripture_poetry_indent_tl , poetry / indent .value_required:n = true - , poetry / indent .initial:n = 1 em + , poetry / indent .initial:n = 1em , poetry / leftmargin .tl_set:N = \l__scripture_poetry_leftmargin_tl , poetry / leftmargin .value_required:n = true - , poetry / leftmargin .initial:n = 1 em + , poetry / leftmargin .initial:n = 1em , poetry / rightmargin .tl_set:N = \l__scripture_poetry_rightmargin_tl , poetry / rightmargin .value_required:n = true , poetry / rightmargin .initial:n = \c_zero_dim @@ -314,9 +499,127 @@ , 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 + , poetry / verse / sep .initial:n = 0.05em } \ProcessKeyOptions +\tl_new:N \l__scripture_default_options_tl +\keys_precompile:nnN { scripture } + { + , aboveskip = \c_zero_skip + , added / font = + , added / format = \emph { #1 } + , after = + , before = + , belowskip = \c_zero_skip + , colour = . + , compact = false + , chapter / align = left + , chapter / font = \bfseries + , chapter / colour = . + , chapter / drop = true + , chapter / format = #1 + , chapter / para = false + , chapter / para / aboveskip = \bigskipamount + , chapter / para / belowskip = \medskipamount + , chapter / para / indent = true + , chapter / sep = 0.5em + , chapter / show = true + , chapter / showverse = false + , chapter / smash = false + , chapter / valign = bottom + , chapter / xchar = X + , extraskip = \medskipamount + , font = + , heading / aboveskip = \bigskipamount + , heading / afterindent = false + , heading / align = left + , heading / belowskip = \medskipamount + , heading / font = \small\itshape + , heading / format = #1 + , heading / show = true + , indent = true + , inline = false + , inline / begin = `` + , inline / end = '' + , inline / reference / format = (#1) + , inline / reference / sep = 0.5em + , inline / version / delim = \c_space_tl + , inline / version / format = #1 + , language = + , language / variant = + , leftmargin = \c_zero_dim + , name / font = \scshape + , name / format = #1 + , parindent = \parindent + , parskip = \parskip + , pilcrow = false + , pilcrow / sep = 0.25em + , redletter = false + , redletter / colour = red!80!black + , reference / align = right + , reference / colour = . + , reference / font = \bfseries + , reference / format = #1 + , reference / position = end + , reference / sep = 2em + , reference / start / newline = false + , reference / start / sep = 1em + , reference / start / vsep = 0pt + , rightmargin = \c_zero_dim + , selah / text = Selah + , selah / font = \itshape + , selah / format = #1 + , selah / sep = 1em + , textright / sep = 1em + , verse / colour = . + , verse / first = false + , verse / firstformat = #1 + , verse / firstsep = 0.5em + , verse / font = + , verse / format = \textsuperscript{#1} + , verse / para = false + , verse / para / indent = \l__scripture_parindent_tl + , verse / sep = 0.05em + , verse / show = true + , version = + , version / delim = \c_space_tl + , version / format = (#1) + , version / position = withref + , center / aboveskip = \medskipamount + , center / belowskip = \medskipamount + , center / leftmargin = \c_zero_dim + , center / rightmargin = \c_zero_dim + , flushright / aboveskip = \medskipamount + , flushright / belowskip = \medskipamount + , flushright / leftmargin = \c_zero_dim + , flushright / rightmargin = \c_zero_dim + , hanging / aboveskip = \medskipamount + , hanging / belowskip = \medskipamount + , hanging / chapter / indent = true + , hanging / hang = 2em + , hanging / leftmargin = 1em + , hanging / rightmargin = \c_zero_dim + , hanging / verse / right = true + , hanging / verse / sep = 0.05em + , midparachap / showverse = true + , narrow / aboveskip = \medskipamount + , narrow / belowskip = \medskipamount + , narrow / leftmargin = 1em + , narrow / rightmargin = 1em + , poetry / aboveskip = \medskipamount + , poetry / belowskip = \medskipamount + , poetry / bigindent = 4em + , poetry / indent = 1em + , poetry / leftmargin = 1em + , poetry / rightmargin = \c_zero_dim + , poetry / verse / right = true + , poetry / verse / sep = 0.05em + } + \l__scripture_default_options_tl +\cs_new_protected:Nn \__scripture_setup_reset_defaults: + { + \l__scripture_default_options_tl + } \cs_new_protected:Nn \__scripture_setup_style:nnn { \bool_if:NTF #1 @@ -335,22 +638,43 @@ \cs_generate_variant:Nn \__scripture_setup_style:nnn { nne } \hook_new_pair:nn { scripture / chap / before } { scripture / chap / after } \hook_new_pair:nn { scripture / verse / before } { scripture / verse / after } +\hook_new:n { scripture / pilcrow } +\hook_new:n { scripture / poetry / pilcrow } \bool_new:N \l__scripture_active_bool \bool_new:N \l__scripture_active_inner_bool +\bool_new:N \g__scripture_mode_vertical_inner_bool \int_new:N \l__scripture_clubpenalty_saved_int \skip_new:N \g__scripture_prev_inner_below_skip \dim_new:N \l__scripture_outer_itemindent_dim \cs_new_protected_nopar:Nn \__scripture_setup_list_noindent:n { - \legacy_if:nT {@newlist} + \legacy_if:nT { @newlist } { \cs_set_protected_nopar:Npn \noindent { \skip_horizontal:n { -#1 } + \bool_if:NT \l__scripture_verse_para_bool + { + \peek_meaning:NTF \vs + { + \bool_gset_true:N \g__scripture_suppress_next_verse_para_bool + \__scripture_set_pilcrow_hook: + } + { + \str_if_eq:VnF \l__scripture_currenvir_str { poetry } + { \__scripture_pilcrow_output: } + } + } } \hook_gput_next_code:nn { para / end } { - \cs_gset_eq:NN \noindent \tex_noindent:D + \bool_if:NTF \l__scripture_verse_para_bool + { + \str_if_eq:VnTF \l__scripture_currenvir_str { poetry } + { \cs_set_eq:NN \noindent \tex_noindent:D } + { \cs_set_eq:NN \noindent \__scripture_para_noindent: } + } + { \cs_set_eq:NN \noindent \tex_noindent:D } } } } @@ -367,6 +691,7 @@ } \cs_new_protected:Nn \__scripture_extra_skip: { + \mode_if_vertical:F \para_end: \int_compare:nNnT \g__scripture_chap_par_prevgraf_int = 1 { @@ -409,7 +734,7 @@ } } \box_new:N \l__scripture_ref_box -\cs_new_protected:Nn \__scripture_format_full_ref:n +\cs_new_protected:Nn \__scripture_format_full_ref:nn { \group_begin: \l__scripture_ref_font_tl @@ -418,11 +743,11 @@ \__scripture_ref_format:n { #1 - \tl_if_empty:NF \l__scripture_version_tl + \tl_if_empty:oF { #2 } { - \tl_if_empty:nF { #1 } + \tl_if_empty:oF { #1 } { \l__scripture_version_delim_tl } - \__scripture_version_format:n { \l__scripture_version_tl } + \__scripture_version_format:n { #2 } } } \group_end: @@ -431,7 +756,7 @@ { \hbox_set:Nn \l__scripture_ref_box { - \__scripture_format_full_ref:n { #1 } + \__scripture_format_full_ref:nn { #1 } \l__scripture_version_tl } \dim_compare:nNnT { \box_wd:N \l__scripture_ref_box + \g__scripture_final_line_dim + \l__scripture_ref_sep_tl } @@ -456,6 +781,337 @@ } \box_use:N \l__scripture_ref_box } +\cs_new_protected:Nn \__scripture_reference_start_inline: + { + \tl_if_empty:NF \l__scripture_ref_tl + { + \tl_if_eq:NnTF \l__scripture_version_position_tl { withref } + { \__scripture_format_full_ref:nn { \l__scripture_ref_tl } { \l__scripture_version_tl } } + { \__scripture_format_full_ref:nn { \l__scripture_ref_tl } { } } + \skip_horizontal:N \l__scripture_ref_start_sep_tl + } + } +\cs_new_protected:Nn \__scripture_reference_start_newline: + { + \tl_if_empty:NF \l__scripture_ref_tl + { + \bool_gset_eq:NN \g_tmpa_bool \g__scripture_suppress_next_pilcrow_bool + \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool + \noindent + \bool_gset_eq:NN \g__scripture_suppress_next_pilcrow_bool \g_tmpa_bool + \str_if_eq:VnF \l__scripture_currenvir_str { scripture } + { \skip_horizontal:n { -\leftmargin } } + \tl_if_eq:NnTF \l__scripture_version_position_tl { withref } + { \__scripture_format_full_ref:nn { \l__scripture_ref_tl } { \l__scripture_version_tl } } + { \__scripture_format_full_ref:nn { \l__scripture_ref_tl } { } } + \bool_lazy_or:nnT + { \str_if_eq_p:Vn \l__scripture_currenvir_str { flushright } } + { \str_if_eq_p:Vn \l__scripture_currenvir_str { center } } + { + \hfill + \strut + } + \bool_if:NTF \l__scripture_compact_bool + { \para_end: } + { + \bool_lazy_all:nTF + { + { \l__scripture_verse_para_bool } + { \bool_not_p:n { \str_if_eq_p:Vn \l__scripture_currenvir_str { hanging } } } + { \bool_not_p:n { \str_if_eq_p:Vn \l__scripture_currenvir_str { poetry } } } + } + { \para_end: } + { \par } + } + \nobreak + \@afterheading + \addvspace { \l__scripture_ref_vertical_sep_tl } + } + } +\cs_new_protected:Nn \__scripture_reference_start_peek: + { + \peek_remove_spaces:n + { + \bool_lazy_and:nnTF + { \str_if_eq_p:Vn \l__scripture_ref_position_tl { start } } + { \bool_not_p:n { \tl_if_empty_p:N \l__scripture_ref_tl } } + { + \bool_lazy_or:nnF + { \str_if_eq_p:Vn \l__scripture_currenvir_str { scripture } } + { \str_if_eq_p:Vn \l__scripture_currenvir_str { midparachap } } + { + \bool_if:NF \l__scripture_compact_bool + { \bool_set_true:N \l__scripture_ref_start_newline_bool } + } + \peek_analysis_map_inline:n + { + \bool_case:nF + { + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \heading } + { \__scripture_reference_start_newline: } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \noindent } + { + \bool_if:NTF \l__scripture_ref_start_newline_bool + { \__scripture_reference_start_newline: } + { \__scripture_reference_start_inline: } + } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \nohang } + { + \bool_if:NTF \l__scripture_ref_start_newline_bool + { \__scripture_reference_start_newline: } + { \__scripture_reference_start_inline: } + } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \nopilcrow } + { + \bool_if:NTF \l__scripture_ref_start_newline_bool + { \__scripture_reference_start_newline: } + { \__scripture_reference_start_inline: } + \peek_analysis_map_break:n + { + ##1 + \__scripture_fix_protrusion:n { } + } + } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \begin } + { + \bool_if:NF \l__scripture_indent_bool + { + \hook_gput_next_code:nn { para / begin } + { + \bool_lazy_or:nnT + { \str_if_eq_p:Vn \l__scripture_currenvir_str { midparachap } } + { \str_if_eq_p:Vn \l__scripture_currenvir_str { scripture } } + { \para_omit_indent: } + } + } + } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \ch } + { + \bool_if:NTF \l__scripture_ref_start_newline_bool + { \__scripture_reference_start_newline: } + { + \cs_set_eq:NN \__scripture_temp_ch \ch + \RenewDocumentCommand \ch { s o m } + { + \tl_if_novalue:nF { ##2 } + { + \tl_set:Nn \l__scripture_X_char_tl { ##2 } + } + \cs_set_eq:NN \ch \__scripture_temp_ch + } + \__scripture_reference_start_inline: + } + } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \vs } + { + \bool_if:NTF \l__scripture_ref_start_newline_bool + { \__scripture_reference_start_newline: } + { + \cs_set_eq:NN \__scripture_temp_vs \vs + \RenewDocumentCommand \vs { m } + { \cs_set_eq:NN \vs \__scripture_temp_vs } + \__scripture_reference_start_inline: + } + } + } + { + \bool_if:NTF \l__scripture_ref_start_newline_bool + { + \__scripture_reference_start_newline: + \bool_if:NTF \l__scripture_compact_bool + { + \bool_if:NT \g__scripture_mode_vertical_inner_bool + { \__scripture_pilcrow_output: } + } + { + \str_if_eq:VnF \l__scripture_currenvir_str { poetry } + { \__scripture_pilcrow_output: } + } + } + { \__scripture_reference_start_inline: } + } + \exp_args:No \token_if_eq_meaning:NNF { ##1 } \begin + { + \tl_clear:N \l__scripture_ref_tl + \tl_if_eq:NnF \l__scripture_version_position_tl { end } + { \tl_clear:N \l__scripture_version_tl } + } + \peek_analysis_map_break:n + { \__scripture_fix_protrusion:o { ##1 } } + } + } + { + \peek_analysis_map_inline:n + { + \bool_case:nF + { + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \heading } + { } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \noindent } + { } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \nohang } + { } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \nopilcrow } + { + \peek_analysis_map_break:n + { + ##1 + \__scripture_fix_protrusion:n { } + } + } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \begin } + { + \bool_if:NF \l__scripture_indent_bool + { + \hook_gput_next_code:nn { para / begin } + { + \bool_lazy_or:nnT + { \str_if_eq_p:Vn \l__scripture_currenvir_str { midparachap } } + { \str_if_eq_p:Vn \l__scripture_currenvir_str { scripture } } + { \para_omit_indent: } + } + } + } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \ch } + { } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \vs } + { + \mode_if_vertical:F + { \__scripture_set_pilcrow_hook: } + } + } + { + \bool_if:NTF \l__scripture_compact_bool + { + \bool_if:NT \g__scripture_mode_vertical_inner_bool + { \__scripture_pilcrow_output: } + } + { + \str_if_eq:VnF \l__scripture_currenvir_str { poetry } + { \__scripture_pilcrow_output: } + } + } + \peek_analysis_map_break:n + { + \__scripture_fix_protrusion:o { ##1 } + } + } + } + } + } +\cs_new_protected:Nn \__scripture_compact_par: + { + \bool_gset_false:N \g__scripture_mode_vertical_inner_bool + \dim_set:Nn \parindent { \l__scripture_parindent_tl } + \peek_remove_spaces:n + { + \peek_analysis_map_inline:n + { + \bool_case:n + { + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \begin } + { \bool_gset_true:N \g__scripture_mode_vertical_inner_bool } + { \str_if_eq_p:Vn \l__scripture_currenvir_str { poetry } } + { } + { \exp_args:No \token_if_letter_p:N { ##1 } } + { \__scripture_pilcrow_output: } + { \exp_args:No \token_if_active_p:N { ##1 } } + { \__scripture_pilcrow_output: } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \vs } + { \__scripture_set_pilcrow_hook: } + } + \peek_analysis_map_break:n { ##1 } + } + } + } +\cs_new_protected:Nn \__scripture_para_noindent: + { + \legacy_if:nTF { @newlist } + { + \tex_noindent:D + \peek_meaning:NTF \vs + { + \bool_gset_true:N \g__scripture_suppress_next_verse_para_bool + \__scripture_set_pilcrow_hook: + } + { \__scripture_pilcrow_output: } + } + { + \peek_meaning:NTF \vs + { + \bool_if:NT \l__scripture_verse_para_bool + { \para_end: } + \tex_noindent:D + \bool_gset_true:N \g__scripture_suppress_next_verse_para_bool + \__scripture_set_pilcrow_hook: + } + { \__scripture_pilcrow_output: } + } + } +\bool_new:N \g__scripture_para_mode_vertical_bool +\box_new:N \g__scripture_post_env_indent_box +\cs_new_protected:Nn \__scripture_para_par: + { + \bool_gset_true:N \g__scripture_para_mode_vertical_bool + \dim_set:Nn \parindent { \l__scripture_parindent_tl } + \peek_remove_spaces:n + { + \peek_analysis_map_inline:n + { + \bool_case:n + { + { \exp_args:No \token_if_letter_p:N { ##1 } } + { \__scripture_pilcrow_output: } + { \exp_args:No \token_if_active_p:N { ##1 } } + { \__scripture_pilcrow_output: } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \vs } + { \__scripture_set_pilcrow_hook: } + } + \peek_analysis_map_break:n { ##1 } + } + } + } +\cs_new_protected:Nn \__scripture_doendpe: + { + \box_gclear:N \g__scripture_post_env_indent_box + \legacy_if_set_true:n { @endpe } + \cs_set_nopar:Npn \par + { + \@restorepar + \clubpenalty \@clubpenalty + \everypar { } + \par + \legacy_if_set_false:n { @endpe } + \bool_gset_false:N \g__scripture_suppress_next_pilcrow_bool + \__scripture_para_par: + } + \everypar + { + \box_gset_to_last:N \g__scripture_post_env_indent_box + \hook_gput_next_code:nn { para / after } + { \box_gclear:N \g__scripture_post_env_indent_box } + \everypar { } + \legacy_if_set_false:n { @endpe } + \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool + \bool_if:NT \l__scripture_verse_para_bool + { + \box_set_wd:Nn + \g__scripture_post_env_indent_box + { \l__scripture_para_indent_tl } + } + } + } +\cs_new_protected:Nn \__scripture_fix_protrusion:n + { + \bool_if:NTF \l__scripture_compact_bool + { + \str_if_eq:VnT \l__scripture_currenvir_str { scripture } + { \cs_if_exist_use:N \leftprotrusion } + } + { \cs_if_exist_use:N \leftprotrusion } + #1 + } +\cs_generate_variant:Nn \__scripture_fix_protrusion:n { o } \bool_new:N \g__scripture_red_letter_active_bool \cs_new_protected:Nn \__scripture_red_letter_on: { @@ -493,6 +1149,7 @@ { \@ifpackageloaded { babel } { + \__scripture_set_textdirection: \selectlanguage { \l__scripture_language_tl } } { @@ -530,16 +1187,23 @@ \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 +\dim_new:N \g__scripture_chap_width_dim \int_new:N \g__scripture_chap_par_prevgraf_int \dim_new:N \l__scripture_chap_X_height_dim +\dim_new:N \l__scripture_para_chap_indent_dim +\coffin_new:N \l__scripture_nodrop_chap_coffin +\dim_new:N \l__scripture_nodrop_chap_voffset_dim +\cs_new_protected:Nn \__scripture_get_X_height: + { + \hbox_set:Nn \l__scripture_chap_tmp_box { \l__scripture_X_char_tl } + \dim_set:Nn \l__scripture_chap_X_height_dim + { \box_ht:N \l__scripture_chap_tmp_box } + } \cs_new_protected:Nn \__scripture_drop_chap_set_up:n { \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__scripture_chap_tmp_box } + \__scripture_get_X_height: \dim_set:Nn \l__scripture_chap_height_dim { \baselineskip + \l__scripture_chap_X_height_dim } \dim_set:Nn \l__scripture_chap_fontsize_dim @@ -560,31 +1224,44 @@ { \exp_args:NV \color_select:n \l__scripture_chapter_colour_tl } \__scripture_chap_format:n { #1 } } - \dim_set:Nn \l__scripture_chap_width_dim + \dim_gset:Nn \g__scripture_chap_width_dim { \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 } - } + \bool_if:NF \l__scripture_verse_para_bool + { + \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: { - \noindent + \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool + \cs_if_eq:NNTF \noindent \__scripture_para_noindent: + { + \legacy_if:nTF { @newlist } + { + \skip_horizontal:n { -\l__scripture_parindent_tl } + } + { \tex_noindent:D } + \__scripture_pilcrow_output: + } + { \noindent } \parshape 3 ~ \dim_eval:n - { \@totalleftmargin + \l__scripture_chap_width_dim + \l__scripture_chap_sep_tl } ~ + { \@totalleftmargin + \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } ~ \dim_eval:n - { \linewidth - \l__scripture_chap_width_dim - \l__scripture_chap_sep_tl } ~ + { \linewidth - \g__scripture_chap_width_dim - \l__scripture_chap_sep_tl } ~ \dim_eval:n - { \@totalleftmargin + \l__scripture_chap_width_dim + \l__scripture_chap_sep_tl } ~ + { \@totalleftmargin + \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } ~ \dim_eval:n - { \linewidth - \l__scripture_chap_width_dim - \l__scripture_chap_sep_tl } ~ + { \linewidth - \g__scripture_chap_width_dim - \l__scripture_chap_sep_tl } ~ \@totalleftmargin ~ \linewidth \group_begin: @@ -594,27 +1271,76 @@ \group_end: \bool_if:NT \l__scripture_chap_show_verse_bool { \__scripture_verse_output:n { 1 } } + \bool_if:NT \l__scripture_verse_para_bool + { + \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 } + } + } + \hook_gclear_next_code:n { scripture / pilcrow } } \cs_new_protected:Nn \__scripture_nodrop_chap:n { \cs_gset_nopar:Npn \scripturecurrentchapter { #1 } \cs_gset_nopar:Npn \scripturecurrentverse { 1 } \group_begin: + \bool_if:NT \l__scripture_verse_para_bool + { + \legacy_if:nF { @newlist } + { \mode_if_vertical:F \para_end: } + } \bool_if:NTF \l__scripture_chap_show_bool { + \__scripture_get_X_height: + \hcoffin_set:Nn \l__scripture_nodrop_chap_coffin + { + \str_if_eq:VnF \l__scripture_chapter_colour_tl { . } + { \exp_args:NV \color_select:n \l__scripture_chapter_colour_tl } + \l__scripture_chap_font_tl + \__scripture_chap_format:n { #1 } + \kern \l__scripture_chap_sep_tl + } + \dim_zero:N \l__scripture_nodrop_chap_voffset_dim + \tl_if_eq:NnT \l__scripture_chapter_valign_tl { t } + { \dim_set_eq:NN \l__scripture_nodrop_chap_voffset_dim \l__scripture_chap_X_height_dim } + \tl_if_eq:NnT \l__scripture_chapter_valign_tl { vc } + { \dim_set:Nn \l__scripture_nodrop_chap_voffset_dim { 0.5 \l__scripture_chap_X_height_dim } } \hook_use:n { scripture / chap / before } - \group_begin: - \str_if_eq:VnF \l__scripture_chapter_colour_tl { . } - { \exp_args:NV \color_select:n \l__scripture_chapter_colour_tl } - \l__scripture_chap_font_tl - \__scripture_chap_format:n { #1 } - \group_end: - \skip_horizontal:N \l__scripture_chap_sep_tl + \bool_if:NTF \l__scripture_chap_smash_bool + { + \mode_leave_vertical: + \smash + { + \exp_args:NNoo + \coffin_typeset:Nnnnn \l__scripture_nodrop_chap_coffin + { \l__scripture_chapter_align_tl } + { \l__scripture_chapter_valign_tl } + { 0pt } + { \l__scripture_nodrop_chap_voffset_dim } + } + } + { + \exp_args:NNoo + \coffin_typeset:Nnnnn \l__scripture_nodrop_chap_coffin + { \l__scripture_chapter_align_tl } + { \l__scripture_chapter_valign_tl } + { 0pt } + { \l__scripture_nodrop_chap_voffset_dim } + } + \nobreak + \skip_horizontal:N \c_zero_skip \hook_use:n { scripture / chap / after } \bool_if:NT \l__scripture_chap_show_verse_bool { \__scripture_verse_output:n { 1 } } + \str_if_eq:VnF \l__scripture_currenvir_str { midparachap } + { \__scripture_pilcrow_output: } } { \hook_use:n { scripture / chap / before } @@ -622,6 +1348,87 @@ \vs { 1 } } \group_end: + \parshape 1 ~ \@totalleftmargin ~ \linewidth + \hook_gclear_next_code:n { scripture / pilcrow } + } +\cs_new_protected:Nn \__scripture_para_chap:n + { + \cs_gset_nopar:Npn \scripturecurrentchapter { #1 } + \cs_gset_nopar:Npn \scripturecurrentverse { 1 } + \group_begin: + \skip_zero:N \parskip + \bool_if:NTF \l__scripture_chap_show_bool + { + \dim_set_eq:NN \l__scripture_para_chap_indent_dim \linewidth + \str_if_eq:VnTF \l__scripture_currenvir_str { scripture } + { + \dim_set:Nn \l__scripture_para_chap_indent_dim { 0.5 \l__scripture_para_chap_indent_dim } + } + { + \dim_add:Nn \l__scripture_para_chap_indent_dim { \leftmargin + \rightmargin } + \dim_set:Nn \l__scripture_para_chap_indent_dim { 0.5 \l__scripture_para_chap_indent_dim } + \dim_sub:Nn \l__scripture_para_chap_indent_dim \leftmargin + } + \mode_if_vertical:F \para_end: + \addvspace { \l__scripture_chap_para_aboveskip_tl } + \bool_gset_eq:NN \g_tmpa_bool \g__scripture_suppress_next_pilcrow_bool + \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool + \str_if_eq:VnTF \l__scripture_currenvir_str { midparachap } + { \tex_noindent:D } + { \noindent } + \bool_gset_eq:NN \g__scripture_suppress_next_pilcrow_bool \g_tmpa_bool + \skip_horizontal:N \l__scripture_para_chap_indent_dim + \hbox_overlap_center:n + { + \hook_use:n { scripture / chap / before } + \group_begin: + \str_if_eq:VnF \l__scripture_chapter_colour_tl { . } + { \exp_args:NV \color_select:n \l__scripture_chapter_colour_tl } + \l__scripture_chap_font_tl + \__scripture_chap_format:n { #1 } + \group_end: + \hook_use:n { scripture / chap / after } + } + \para_end: + \nobreak + \bool_lazy_any:nTF + { + { \str_if_eq_p:Vn \l__scripture_currenvir_str { scripture } } + { \str_if_eq_p:Vn \l__scripture_currenvir_str { midparachap } } + { \str_if_eq_p:Vn \l__scripture_currenvir_str { narrow } } + } + { \legacy_if_set:nn { @afterindent } { \l__scripture_chap_para_afterindent_bool } } + { \legacy_if_set_true:n { @afterindent } } + \@afterheading + } + { + \hook_use:n { scripture / chap / before } + \hook_use:n { scripture / chap / after } + } + \peek_meaning:NTF \c_space_token + { + \addvspace { \l__scripture_chap_para_belowskip_tl } + \group_end: + \hook_use:n { scripture / poetry / pilcrow } + } + { + \addvspace { \l__scripture_chap_para_belowskip_tl } + \cs_if_eq:NNTF \vs \__scripture_poetry_mode_vertical_verse:n + { + \bool_gset_eq:NN \g_tmpa_bool \g__scripture_suppress_next_pilcrow_bool + \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool + \noindent + \vs { 1 } + \bool_gset_eq:NN \g__scripture_suppress_next_pilcrow_bool \g_tmpa_bool + } + { + \str_if_eq:VnT \l__scripture_currenvir_str { midparachap } + { \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool } + \vs { 1 } + } + \group_end: + \hook_use:n { scripture / poetry / pilcrow } + } } \cs_new_protected:Nn \__scripture_chap:n { @@ -643,15 +1450,29 @@ \bool_if:NTF \l__scripture_mid_para_chap_bool { \__scripture_mid_para_drop_chap_output: } { - \par + \para_end: \__scripture_drop_chap_output: + \str_if_eq:VnF \l__scripture_currenvir_str { midparachap } + { \__scripture_pilcrow_output: } } \hook_gput_next_code:nn { para / before } { \legacy_if:nF { @newlist } { \int_compare:nNnT \g__scripture_chap_par_prevgraf_int = 1 - { \extraskip } + { + \dim_compare:nNnT \parskip < \baselineskip + { + \dim_compare:nNnT { \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } > \parindent + { + \hook_gput_next_code:nn { para / begin } + { + \para_omit_indent: + \skip_horizontal:n {\g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } + } + } + } + } \int_gzero:N \g__scripture_chap_par_prevgraf_int } \parshape 1 ~ \@totalleftmargin ~ \linewidth @@ -659,6 +1480,7 @@ } \bool_new:N \l__scripture_verse_par_start_bool \bool_new:N \l__scripture_no_verse_first_bool +\bool_new:N \g__scripture_suppress_next_verse_para_bool \cs_new_protected:Nn \__scripture_verse_output:n { \cs_gset_nopar:Npn \scripturecurrentverse { #1 } @@ -674,6 +1496,11 @@ \bool_set_false:N \l__scripture_no_verse_first_bool } \group_begin: + \bool_if:NT \l__scripture_verse_para_bool + { + \box_if_empty:NF \g__scripture_post_env_indent_box + { \box_use_drop:N \g__scripture_post_env_indent_box } + } \hook_use:n { scripture / verse / before } \bool_if:NT \l__scripture_verse_show_bool { @@ -697,10 +1524,87 @@ \group_end: \kern \l__scripture_verse_sep_tl } + \nobreak + \skip_horizontal:N \c_zero_skip } \hook_use:n { scripture / verse / after } + \hook_use:n { scripture / pilcrow } \group_end: } +\cs_new_protected:Nn \__scripture_verse_compact_output:n + { + \mode_if_vertical:T + { \__scripture_set_pilcrow_hook: } + \__scripture_verse_output:n { #1 } + } +\cs_new_protected:Nn \__scripture_verse_para_output:n + { + \mode_if_vertical:T + { \__scripture_set_pilcrow_hook: } + \hook_if_empty:nT { scripture / pilcrow } + { \dim_set:Nn \parindent \l__scripture_para_indent_tl } + \bool_if:NTF \g__scripture_suppress_next_verse_para_bool + { \bool_gset_false:N \g__scripture_suppress_next_verse_para_bool } + { + \legacy_if:nF { @newlist } + { + \mode_if_vertical:F + { + \para_end: + \parshape 1 ~ \@totalleftmargin ~ \linewidth + } + } + } + \__scripture_verse_output:n { #1 } + } +\cs_new_protected:Nn \__scripture_hanging_verse_para:n + { + \mode_if_vertical:T + { \__scripture_set_pilcrow_hook: } + \bool_if:NF \g__scripture_suppress_next_verse_para_bool + { + \legacy_if:nF { @newlist } + { + \mode_if_vertical:F + { + \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool + \hook_gput_next_code:nn { para / begin } + { \parshape 1 ~ \@totalleftmargin ~ \linewidth } + \par + \tex_noindent:D + } + } + } + \bool_gset_false:N \g__scripture_suppress_next_verse_para_bool + \__scripture_hanging_verse:n { #1 } + } +\bool_new:N \g__scripture_suppress_next_pilcrow_bool +\cs_new_protected:Nn \__scripture_set_pilcrow_hook: + { + \hook_if_empty:nT { scripture / pilcrow } + { + \hook_gput_next_code:nn { scripture / pilcrow } { \__scripture_pilcrow_output: } + } + } +\cs_new_protected:Nn \__scripture_pilcrow_output: + { + \bool_gset_false:N \g__scripture_para_mode_vertical_bool + \bool_gset_false:N \g__scripture_mode_vertical_inner_bool + \bool_if:NT \l__scripture_pilcrow_bool + { + \bool_lazy_or:nnT \l__scripture_verse_para_bool \l__scripture_compact_bool + { + \bool_if:NTF \g__scripture_suppress_next_pilcrow_bool + { \bool_gset_false:N \g__scripture_suppress_next_pilcrow_bool } + { + \P + \kern \l__scripture_pilcrow_sep_tl + \nobreak + \skip_horizontal:N \c_zero_skip + } + } + } + } \dim_new:N \g__scripture_final_line_dim \cs_new_protected:Nn \__scripture_calc_final_line_length: { @@ -709,25 +1613,35 @@ \skip_zero:N \belowdisplayshortskip \skip_zero:N \belowdisplayskip $$ - \dim_compare:nNnT \predisplaysize > \c_zero_dim + \hook_use:n { para / after } + \dim_compare:nNnTF \predisplaysize > \c_zero_dim { \dim_gset:Nn \g__scripture_final_line_dim - { \predisplaysize - 2 em } + { \predisplaysize - 2em } + } + { + \bool_if:NT \l__scripture_textdir_change_in_group_bool + { + \str_if_eq:VnT \l__scripture_currenvir_str { scripture } + { \int_set:Nn \prevgraf { \int_use:N \prevgraf - 1 } } + } } \cs_gset_nopar:Nx \__scripture_reset_spacing: { \dim_set:Nn \predisplaysize { \dim_use:N \predisplaysize } \int_set:Nn \prevgraf { \int_use:N \prevgraf } + \int_gset:Nn \g__scripture_chap_par_prevgraf_int { \int_use:N \g__scripture_chap_par_prevgraf_int } } $$ \__scripture_reset_spacing: \dim_compare:nNnT \g__scripture_final_line_dim > \paperwidth { \dim_gset:Nn \g__scripture_final_line_dim { \@totalleftmargin + \linewidth } } - \dim_compare:nNnT \g__scripture_final_line_dim > { \c_zero_dim - 1 sp } + \dim_compare:nNnT \g__scripture_final_line_dim > { \c_zero_dim - 1sp } { \skip_vertical:n { -\baselineskip - \parskip } } } \str_new:N \l__scripture_currenvir_str \skip_new:N \l__scripture_parskip_correction_skip +\tl_new:N \l__scripture_ref_tl \cs_new_protected_nopar:Nn \__scripture_added:n { \group_begin: @@ -735,6 +1649,52 @@ \__scripture_added_format:n { #1 } \group_end: } +\cs_new_protected_nopar:Nn \__scripture_heading:n + { + \str_if_eq:VnTF \l__scripture_currenvir_str { scripture } + { + \bool_if:NTF \l__scripture_heading_show_bool + { + \parshape 1 ~ \@totalleftmargin ~ \linewidth + \group_begin: + \bool_set_false:N \l__scripture_pilcrow_bool + \legacy_if:nTF { @newlist } + { + \skip_horizontal:n { -\parindent } + } + { + \__scripture_list_para_end: + \addvspace { \l__scripture_heading_aboveskip_tl } + \tex_noindent:D + } + \l__scripture_heading_align_tl + \l__scripture_heading_font_tl + \__scripture_heading_format:n { #1 } + \__scripture_list_para_end: + \group_end: + \bool_if:NTF \l__scripture_verse_para_bool + { + \cs_set_eq:NN \noindent \__scripture_para_noindent: + } + { + \cs_set_eq:NN \noindent \tex_noindent:D + } + \legacy_if_set:nn { @afterindent } \l__scripture_heading_afterindent_bool + \bool_if:NF \l__scripture_heading_afterindent_bool + { + \hook_gput_next_code:nn { para / before } + { \para_omit_indent: } + } + \nobreak + \@afterheading + \addvspace { \l__scripture_heading_belowskip_tl } + } + { \ignorespaces } + } + { + \msg_error:nnx { scripture } { heading-error } { \l__scripture_currenvir_str } + } + } \cs_new_protected_nopar:Nn \__scripture_name:n { \group_begin: @@ -753,7 +1713,9 @@ \bool_if:NTF \l__scripture_chap_drop_bool { \__scripture_chap:n { #2 } - \bool_if:nTF { #1 } + \bool_lazy_and:nnTF + { #1 } + { \bool_not_p:n { \l__scripture_compact_bool } } { \hook_gput_next_code:nn { para / after } { @@ -766,11 +1728,19 @@ { \int_gset_eq:NN \g__scripture_mid_para_chap_prevgraf_int \prevgraf } } } + { + \bool_if:NTF \l__scripture_chap_para_bool + { \__scripture_para_chap:n { #2 } } + { \__scripture_nodrop_chap:n { #2 } } + } + } + { + \bool_if:NTF \l__scripture_chap_para_bool + { \__scripture_para_chap:n { #2 } } { \__scripture_nodrop_chap:n { #2 } } } - { \__scripture_nodrop_chap:n { #2 } } } -\cs_new_protected:Nn \__scripture_begin:n +\cs_new_protected:Nn \__scripture_begin:nn { \cs_set_eq:NN \__scripture_noindent_saved: \noindent \bool_if:NT \l__scripture_active_bool @@ -778,11 +1748,14 @@ \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 } + { \tl_set:Nn \l__scripture_ref_tl { #1 } } + \str_set:Nn \l__scripture_currenvir_str { scripture } + \tl_if_novalue:nF { #2 } { - \keys_set:nn { scripture } { #1 } + \keys_set:nn { scripture } { #2 } } + \l__scripture_before_tl \__scripture_select_language: \int_gzero:N \g__scripture_chap_par_prevgraf_int \everydisplay { } @@ -794,10 +1767,25 @@ \cs_set_eq:NN \extraskip \__scripture_extra_skip: \cs_set_eq:NN \redletteron \__scripture_red_letter_on: \cs_set_eq:NN \redletteroff \__scripture_red_letter_off: - \DeclareDocumentCommand { \ch } { sm } - { \__scripture_ch_output:nn { ##1 } { ##2 } } + \cs_set:Npn \nopilcrow { \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool } + \bool_gset_false:N \g__scripture_suppress_next_pilcrow_bool + \bool_gset_false:N \g__scripture_suppress_next_verse_para_bool + \bool_gset_false:N \g__scripture_mode_vertical_inner_bool + \box_gclear:N \g__scripture_post_env_indent_box + \skip_gzero:N \g__scripture_prev_inner_below_skip + \bool_if:NT \l__scripture_chap_para_bool + { \bool_set_false:N \l__scripture_chap_drop_bool } + \DeclareDocumentCommand { \ch } { s o m } + { + \tl_if_novalue:nF { ##2 } + { + \tl_set:Nn \l__scripture_X_char_tl { ##2 } + } + \__scripture_ch_output:nn { ##1 } { ##3 } + } \cs_set_eq:NN \vs \__scripture_verse_output:n \cs_set_eq:NN \added \__scripture_added:n + \cs_set_eq:NN \heading \__scripture_heading:n \cs_set_eq:NN \name \__scripture_name:n \cs_set_protected_nopar:Npn \LORD { \name { Lord } } \cs_set_protected_nopar:Npn \GOD { \name { God } } @@ -805,7 +1793,10 @@ \cs_set_protected_nopar:Npn \textright ##1 { \__scripture_text_right:nn { \l__scripture_text_right_sep_tl } { ##1 } } \hook_gclear_next_code:n { para / before } + \hook_gclear_next_code:n { scripture / pilcow } + \hook_gclear_next_code:n { scripture / poetry / pilcow } \l__scripture_font_tl + \tl_set:Ne \l__scripture_parindent_tl { \dim_eval:n { \l__scripture_parindent_tl } } \exp_args:NnV \color_set:nn { scripture default colour } \l__scripture_colour_tl \str_if_eq:VnF \l__scripture_colour_tl { . } { \color_select:n { scripture default colour } } @@ -831,45 +1822,61 @@ { \hook_gput_next_code:nn { para / begin } { - \bool_lazy_any:nT + \bool_if:NTF \l__scripture_compact_bool + { \para_omit_indent: } { - { \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 } } - } - { - \legacy_if:nTF { @noparlist } - { \noindent } - { \para_omit_indent: } + \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 } } + } + { + \legacy_if:nTF { @noparlist } + { + \bool_lazy_and:nnF + { \str_if_eq_p:Vn \l__scripture_currenvir_str { narrow } } + { \str_if_eq_p:Vn \l__scripture_ref_position_tl { start } } + { \noindent } + } + { \para_omit_indent: } + } } } } } - \dim_set_eq:NN \parindent \l__scripture_parindent_tl + \cs_set_eq:NN \__scripture_list_para_end: \@par \item \relax } } -\cs_new_protected:Nn \__scripture_end:n +\cs_new_protected:Nn \__scripture_end: { + \tl_if_eq:NnT \l__scripture_ref_position_tl { start } + { + \tl_clear:N \l__scripture_ref_tl + \tl_if_eq:NnT \l__scripture_version_position_tl { withref } + { \tl_clear:N \l__scripture_version_tl } + } + \cs_set_eq:NN \noindent \tex_noindent:D \bool_if:NTF \l__scripture_inline_bool { \unskip \__scripture_red_letter_off: \l__scripture_inline_end_tl \bool_lazy_or:nnTF - { \tl_if_novalue_p:n { #1 } } - { \tl_if_empty_p:n { #1 } } + { \tl_if_novalue_p:n \l__scripture_ref_tl } + { \tl_if_empty_p:N \l__scripture_ref_tl } { \tl_if_empty:NF \l__scripture_version_tl { \skip_horizontal:N \l__scripture_ref_sep_tl - \__scripture_format_full_ref:n { } + \__scripture_format_full_ref:nn { } \l__scripture_version_tl } } { \skip_horizontal:N \l__scripture_ref_sep_tl - \__scripture_format_full_ref:n { #1 } + \__scripture_format_full_ref:nn \l__scripture_ref_tl \l__scripture_version_tl } } { @@ -882,23 +1889,85 @@ { \skip_zero:N \@topsepadd } { \skip_set:Nn \@topsepadd { \__scripture_skip_diff:NN \l__scripture_belowskip_tl \@outerparskip } } \int_compare:nNnT \prevgraf = \c_zero_int - { \skip_vertical:n { -\g__scripture_prev_inner_below_skip } } + { + \bool_if:NT \l__scripture_textdir_change_in_group_bool + { \skip_vertical:n { -\baselineskip } } + \skip_vertical:n { -\g__scripture_prev_inner_below_skip } + } \hook_gclear_next_code:n { para / before } - \parshape 1 ~ \@totalleftmargin ~ \linewidth \noindent \bool_lazy_or:nnTF - { \tl_if_novalue_p:n { #1 } } - { \tl_if_empty_p:n { #1 } } + { \tl_if_novalue_p:n \l__scripture_ref_tl } + { \tl_if_empty_p:N \l__scripture_ref_tl } { \tl_if_empty:NTF \l__scripture_version_tl { \hbox:n { } } { \__scripture_reference:n { } } } - { \__scripture_reference:n { #1 } } - \@noparlistfalse + { \__scripture_reference:n \l__scripture_ref_tl } + \parshape 1 ~ \@totalleftmargin ~ \linewidth + \legacy_if_set_false:n { @noparlist } \endlist } \cs_set_eq:NN \noindent \__scripture_noindent_saved: + \l__scripture_after_tl + } +\cs_new_protected:Nn \__scripture_compact_end_inner: + { + \bool_gset_false:N \g__scripture_mode_vertical_inner_bool + \str_if_eq:VnT \l__scripture_ref_position_tl { start } + { + \tl_gclear:N \l__scripture_ref_tl + } + \bool_lazy_and:nnT \l__scripture_verse_para_bool \l__scripture_chap_drop_bool + { + \cs_set_eq:NN \par \para_end: + \__scripture_calc_final_line_length: + \int_gset_eq:NN \g__scripture_mid_para_chap_prevgraf_int \g__scripture_chap_par_prevgraf_int + \tex_noindent:D + \bool_lazy_and:nnTF + { \bool_if_p:N \l__scripture_compact_bool } + { \int_compare_p:nNn \g__scripture_mid_para_chap_prevgraf_int = 1 } + { + \hook_gput_next_code:nn { env / \l__scripture_currenvir_str / after } + { + \parshape 3 ~ + \@totalleftmargin ~ \linewidth ~ + \dim_eval:n + { \@totalleftmargin + \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } ~ + \dim_eval:n + { \linewidth - \g__scripture_chap_width_dim - \l__scripture_chap_sep_tl } ~ + \@totalleftmargin ~ \linewidth + } + \hbox_to_wd:nn { \g__scripture_final_line_dim - \g__scripture_chap_width_dim - \l__scripture_chap_sep_tl } { } + } + { + \hbox_to_wd:nn \g__scripture_final_line_dim { } + } + \c_space_token + \kern 0pt + \cs_set_eq:NN \par \relax + \hook_gput_next_code:nn { para / before } + { + \int_compare:nNnT \g__scripture_mid_para_chap_prevgraf_int = 1 + { + \dim_compare:nNnT \parskip < \baselineskip + { + \dim_compare:nNnT { \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } > \parindent + { + \hook_gput_next_code:nn { para / begin } + { + \para_omit_indent: + \skip_horizontal:n {\g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } + } + } + } + } + \int_gzero:N \g__scripture_chap_par_prevgraf_int + \parshape 1 ~ \@totalleftmargin ~ \linewidth + } + } + \unskip } \cs_new_protected:Nn \__scripture_center_begin:n { @@ -907,7 +1976,7 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l__scripture_active_inner_bool - \tl_set:Nn \l__scripture_currenvir_str { center } + \str_set:Nn \l__scripture_currenvir_str { center } \tl_if_novalue:nF { #1 } { \keys_set:nn @@ -917,8 +1986,13 @@ \legacy_if:nTF { @newlist } { \dim_add:Nn \l__scripture_outer_itemindent_dim \itemindent } { \dim_zero:N \l__scripture_outer_itemindent_dim } + \cs_set_eq:NN \par \para_end: \list { } { + \bool_lazy_or:nnF + { \mode_if_vertical_p: } + { \g__scripture_para_mode_vertical_bool } + { \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool } \dim_zero:N \labelsep \dim_set_eq:NN \leftmargin \l__scripture_center_leftmargin_tl \dim_set_eq:NN \rightmargin \l__scripture_center_rightmargin_tl @@ -935,11 +2009,22 @@ { \addvspace { \baselineskip } } \int_gzero:N \g__scripture_chap_par_prevgraf_int \centering + \bool_if:NT \l__scripture_verse_para_bool + { + \cs_set_eq:NN \par \__scripture_para_par: + \cs_set_protected:Npn \\ + { + \mode_if_horizontal:TF + { \unskip } + { \@nolnerr } + } + } \item \relax } \cs_new_protected:Nn \__scripture_center_end: { + \cs_set_eq:NN \par \para_end: \dim_gset:Nn \g__scripture_final_line_dim { \@totalleftmargin + \linewidth } \dim_compare:nNnTF \@outerparskip > \l__scripture_center_belowskip_tl { \skip_zero:N \@topsepadd } @@ -947,6 +2032,7 @@ \skip_gset_eq:NN \g__scripture_prev_inner_below_skip \@topsepadd \legacy_if_set_false:n { @noparlist } \endlist + \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool } \cs_new_protected:Nn \__scripture_flushright_begin:n { @@ -955,7 +2041,7 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l__scripture_active_inner_bool - \tl_set:Nn \l__scripture_currenvir_str { flushright } + \str_set:Nn \l__scripture_currenvir_str { flushright } \tl_if_novalue:nF { #1 } { \keys_set:nn @@ -965,8 +2051,13 @@ \legacy_if:nTF { @newlist } { \dim_add:Nn \l__scripture_outer_itemindent_dim \itemindent } { \dim_zero:N \l__scripture_outer_itemindent_dim } + \cs_set_eq:NN \par \para_end: \list { } { + \bool_lazy_or:nnF + { \mode_if_vertical_p: } + { \g__scripture_para_mode_vertical_bool } + { \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool } \dim_zero:N \labelsep \dim_set_eq:NN \leftmargin \l__scripture_flushright_leftmargin_tl \dim_set_eq:NN \rightmargin \l__scripture_flushright_rightmargin_tl @@ -983,11 +2074,22 @@ { \addvspace { \baselineskip } } \int_gzero:N \g__scripture_chap_par_prevgraf_int \raggedleft + \bool_if:NT \l__scripture_verse_para_bool + { + \cs_set_eq:NN \par \__scripture_para_par: + \cs_set_protected:Npn \\ + { + \mode_if_horizontal:TF + { \unskip } + { \@nolnerr } + } + } \item \relax } \cs_new_protected:Nn \__scripture_flushright_end: { + \cs_set_eq:NN \par \para_end: \dim_gset:Nn \g__scripture_final_line_dim { \@totalleftmargin + \linewidth } \dim_compare:nNnTF \@outerparskip > \l__scripture_flushright_belowskip_tl { \skip_zero:N \@topsepadd } @@ -995,62 +2097,105 @@ \skip_gset_eq:NN \g__scripture_prev_inner_below_skip \@topsepadd \legacy_if_set_false:n { @noparlist } \endlist + \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool } \dim_new:N \l__scripture_hanging_parindent_saved_dim \cs_new_protected:Nn \__scripture_hanging_ch:n { + \bool_gset_false:N \g__scripture_suppress_next_pilcrow_bool \bool_if:NTF \l__scripture_chap_show_bool { \bool_if:NTF \l__scripture_chap_drop_bool { \__scripture_hanging_chap:n { #1 } } + { + \bool_if:NTF \l__scripture_chap_para_bool + { \__scripture_para_chap:n { #1 } } + { \__scripture_nodrop_chap:n { #1 } } + } + } + { + \bool_if:NTF \l__scripture_chap_para_bool + { \__scripture_para_chap:n { #1 } } { \__scripture_nodrop_chap:n { #1 } } } - { \__scripture_nodrop_chap:n { #1 } } } \cs_new_protected:Nn \__scripture_hanging_chap:n { \__scripture_drop_chap_set_up:n { #1 } \dim_compare:nNnTF - \l__scripture_chap_width_dim < \leftmargin + { \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } < \leftmargin { - \tl_set:Nx \l__scripture_chap_sep_tl + \bool_if:NT \l__scripture_hanging_chapter_indent_bool { - \dim_eval:n { \leftmargin - \l__scripture_chap_width_dim } + \tl_set:Nx \l__scripture_chap_sep_tl + { + \dim_eval:n { \leftmargin - \g__scripture_chap_width_dim } + } } } { \parshape 3 ~ \dim_eval:n { - \@totalleftmargin - \leftmargin + \l__scripture_chap_width_dim + + \@totalleftmargin - \leftmargin + \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } ~ \dim_eval:n { - \linewidth + \leftmargin - \l__scripture_chap_width_dim - + \linewidth + \leftmargin - \g__scripture_chap_width_dim - \l__scripture_chap_sep_tl } ~ \dim_eval:n { - \@totalleftmargin - \leftmargin + \l__scripture_chap_width_dim + + \@totalleftmargin - \leftmargin + \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } ~ \dim_eval:n { - \linewidth + \leftmargin - \l__scripture_chap_width_dim - + \linewidth + \leftmargin - \g__scripture_chap_width_dim - \l__scripture_chap_sep_tl } ~ \@totalleftmargin ~ \linewidth } - \tl_set:Nx \l__scripture_chap_sep_tl + \par + \bool_if:NTF \l__scripture_hanging_chapter_indent_bool { - \dim_eval:n + \tl_set:Nx \l__scripture_chap_sep_tl { - \l__scripture_chap_sep_tl + \l__scripture_hanging_parindent_saved_dim + \dim_eval:n + { + \l__scripture_chap_sep_tl + \l__scripture_hanging_parindent_saved_dim + } + } + \__scripture_nohang: + } + { + \mode_leave_vertical: + \dim_compare:nNnTF + { \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } > \l__scripture_hanging_leftmargin_tl + { + \dim_compare:nNnTF + { \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } > \leftmargin + { + \skip_horizontal:n { \l__scripture_hanging_hang_tl } + } + { + \skip_horizontal:n + { + \l__scripture_chap_sep_tl + + \g__scripture_chap_width_dim - + \l__scripture_hanging_leftmargin_tl + } + } + } + { + \tl_set:Nx \l__scripture_chap_sep_tl + { + \dim_eval:n + { \l__scripture_hanging_leftmargin_tl - \g__scripture_chap_width_dim } + } } } - \par - \__scripture_nohang: \hbox_set:Nn \l__scripture_chap_box { \box_move_down:nn @@ -1074,25 +2219,114 @@ { \__scripture_verse_output:n { 1 } } + \__scripture_pilcrow_output: + \bool_if:NT \l__scripture_verse_para_bool + { + \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 + } + } + } \hook_gput_next_code:nn { para / begin } - { \parshape 1 ~ \@totalleftmargin ~ \linewidth } + { + \int_compare:nNnTF \g__scripture_chap_par_prevgraf_int = \c_one_int + { + \dim_compare:nNnTF + { \l__scripture_hanging_leftmargin_tl } < { \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } + { + \parshape 2 ~ + \dim_eval:n + { + \@totalleftmargin - \leftmargin + \g__scripture_chap_width_dim + + \l__scripture_chap_sep_tl + } ~ + \dim_eval:n + { + \linewidth + \leftmargin - \g__scripture_chap_width_dim - + \l__scripture_chap_sep_tl + } ~ + \@totalleftmargin ~ \linewidth + } + { \parshape 1 ~ \@totalleftmargin ~ \linewidth } + \hook_gput_next_code:nn { para / begin } + { \parshape 1 ~ \@totalleftmargin ~ \linewidth } + } + { \parshape 1 ~ \@totalleftmargin ~ \linewidth } + \int_gzero:N \g__scripture_chap_par_prevgraf_int + } } \cs_new_protected:Nn \__scripture_hanging_verse:n { \mode_if_vertical:TF { - \strut - \hbox_overlap_left:n + \tl_set_eq:NN \l_tmpa_tl \l__scripture_verse_sep_tl + \tl_set_eq:NN \l__scripture_verse_sep_tl \l__scripture_hanging_verse_sep_tl + \bool_lazy_and:nnTF + { \legacy_if_p:n { @newlist } } + { \g__scripture_suppress_next_pilcrow_bool } + { + \strut + \bool_if:NTF \l__scripture_hanging_verse_right_bool + { + \hbox_overlap_left:n + { + \__scripture_verse_output:n { #1 } + } + } + { + \hbox_overlap_left:n + { + \hbox_overlap_right:n + { + \__scripture_verse_output:n { #1 } + } + \skip_horizontal:N \l__scripture_hanging_leftmargin_tl + } + } + } { - \__scripture_verse_output:n { #1 } + \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool + \strut + \bool_if:NTF \l__scripture_hanging_verse_right_bool + { + \hbox_overlap_left:n + { + \__scripture_verse_output:n { #1 } + } + } + { + \hbox_overlap_left:n + { + \hbox_overlap_right:n + { + \__scripture_verse_output:n { #1 } + } + \skip_horizontal:N \l__scripture_hanging_leftmargin_tl + } + } + \__scripture_pilcrow_output: } + \tl_set_eq:NN \l__scripture_verse_sep_tl \l_tmpa_tl } { \__scripture_verse_output:n { #1 } } } \cs_new_protected_nopar:Nn \__scripture_nohang: { - \noindent + \legacy_if:nTF {@newlist} + { \skip_horizontal:n { \l__scripture_hanging_hang_tl } } + { \tex_noindent:D } \hbox_to_wd:nn { \l__scripture_hanging_parindent_saved_dim } { } + \peek_meaning:NT \vs + { + \bool_gset_true:N \g__scripture_suppress_next_verse_para_bool + \__scripture_set_pilcrow_hook: + } } \cs_new_protected:Nn \__scripture_hanging_begin:n { @@ -1101,22 +2335,37 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l__scripture_active_inner_bool - \tl_set:Nn \l__scripture_currenvir_str { hanging } + \str_set:Nn \l__scripture_currenvir_str { hanging } \tl_if_novalue:nF { #1 } { \keys_set:nn { scripture / hanging } { #1 } } - \DeclareDocumentCommand { \ch } { sm } { \__scripture_hanging_ch:n { ##2 } } - \cs_set_eq:NN \vs \__scripture_hanging_verse:n + \DeclareDocumentCommand { \ch } { s o m } + { + \tl_if_novalue:nF { ##2 } + { + \tl_set:Nn \l__scripture_X_char_tl { ##2 } + } + \__scripture_hanging_ch:n { ##3 } + } + \bool_if:NTF \l__scripture_verse_para_bool + { \cs_set_eq:NN \vs \__scripture_hanging_verse_para:n } + { \cs_set_eq:NN \vs \__scripture_hanging_verse:n } \cs_set_eq:NN \nohang \__scripture_nohang: \dim_set_eq:NN \l__scripture_hanging_parindent_saved_dim \parindent \legacy_if:nTF { @newlist } { \dim_add:Nn \l__scripture_outer_itemindent_dim \itemindent } { \dim_zero:N \l__scripture_outer_itemindent_dim } + \cs_set_eq:NN \par \para_end: + \hook_gclear_next_code:n { para/ before } \list { } { + \bool_lazy_or:nnF + { \mode_if_vertical_p: } + { \g__scripture_para_mode_vertical_bool } + { \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool } \dim_zero:N \labelsep \dim_set:Nn \leftmargin { \l__scripture_hanging_leftmargin_tl + \l__scripture_hanging_hang_tl } \dim_set_eq:NN \rightmargin \l__scripture_hanging_rightmargin_tl @@ -1144,6 +2393,7 @@ \skip_gset_eq:NN \g__scripture_prev_inner_below_skip \@topsepadd \legacy_if_set_false:n { @noparlist } \endlist + \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool } \cs_new_protected:Npn \__scripture_vbox_set_top:Nw #1 { @@ -1158,6 +2408,27 @@ \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 +\cs_set_eq:Nc \__scripture_mid_para_chap_end_orig:n { end ~ } +\cs_new_nopar:Nn \__scripture_mid_para_chap_end:n + { + \__scripture_mid_para_chap_end_orig:n { #1 } + \bool_if:NT \l__scripture_compact_bool + { \c_space_token } + \peek_remove_spaces:n + { + \peek_analysis_map_inline:n + { + \bool_case:n + { + { \exp_args:No \token_if_letter_p:N { ##1 } } + { \__scripture_pilcrow_output: } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \vs } + { \__scripture_set_pilcrow_hook: } + } + \peek_analysis_map_break:n { ##1 } + } + } + } \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 @@ -1179,11 +2450,11 @@ \dim_compare:nNnTF { \box_wd:N \l__scripture_mid_para_chap_snap_box + - \l__scripture_chap_width_dim + + \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } < - { \linewidth - \leftskip - \rightskip - 3 em } + { \linewidth - \leftskip - \rightskip - 3em } { \__scripture_drop_chap_output: \hbox_unpack_drop:N \l__scripture_mid_para_chap_snap_box @@ -1208,16 +2479,14 @@ } \cs_new_protected:Nn \__scripture_mid_para_chap_begin:n { - \tl_set:Nn \l__scripture_currenvir_str { midparachap } + \str_set:Nn \l__scripture_currenvir_str { midparachap } \tl_if_novalue:nF { #1 } { \keys_set:nn { scripture / midparachap } { #1 } } - \bool_lazy_and:nnT - { \bool_if_p:n \l__scripture_chap_show_verse_bool } - { \bool_if_p:n \l__scripture_chap_drop_bool } + \bool_lazy_and:nnT \l__scripture_chap_show_verse_bool \l__scripture_chap_drop_bool { \bool_set_true:N \l__scripture_midparachap_show_verse_bool \bool_set_false:N \l__scripture_chap_show_verse_bool @@ -1252,8 +2521,8 @@ \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 } + \skip_horizontal:n { \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } + \dim_gadd:Nn \g__scripture_final_line_dim { \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } } \box_use_drop:N \l__scripture_mid_para_chap_line_box \vbox_set_end: @@ -1293,7 +2562,24 @@ \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 + \legacy_if:nF { @newlist } + { + \int_compare:nNnT \g__scripture_chap_par_prevgraf_int = 1 + { + \dim_compare:nNnT \parskip < \baselineskip + { + \dim_compare:nNnT { \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } > \parindent + { + \hook_gput_next_code:nn { para / begin } + { + \para_omit_indent: + \skip_horizontal:n {\g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } + } + } + } + } + \int_gzero:N \g__scripture_chap_par_prevgraf_int + } \parshape 1 ~ \@totalleftmargin ~ \linewidth } } @@ -1304,7 +2590,7 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l__scripture_active_inner_bool - \tl_set:Nn \l__scripture_currenvir_str { narrow } + \str_set:Nn \l__scripture_currenvir_str { narrow } \tl_if_novalue:nF { #1 } { \keys_set:nn @@ -1314,21 +2600,22 @@ \legacy_if:nTF { @newlist } { \dim_add:Nn \l__scripture_outer_itemindent_dim \itemindent } { \dim_zero:N \l__scripture_outer_itemindent_dim } + \cs_set_eq:NN \par \para_end: \list { } { - %\int_compare:nNnT \g__scripture_chap_par_prevgraf_int = 1 - % { \addvspace { \baselineskip } } - %\int_gzero:N \g__scripture_chap_par_prevgraf_int \dim_zero:N \labelsep \dim_set_eq:NN \leftmargin \l__scripture_narrow_leftmargin_tl \dim_set_eq:NN \rightmargin \l__scripture_narrow_rightmargin_tl \dim_set_eq:NN \listparindent \parindent - \mode_if_vertical:TF + \bool_lazy_or:nnTF + { \mode_if_vertical_p: } + { \g__scripture_para_mode_vertical_bool } { \dim_set:Nn \itemindent { \parindent - \l__scripture_outer_itemindent_dim } \__scripture_setup_list_noindent:n { \parindent } } { + \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool \dim_set:Nn \itemindent { -\l__scripture_outer_itemindent_dim } \__scripture_setup_list_noindent:n { \c_zero_dim } } @@ -1341,11 +2628,14 @@ \int_compare:nNnT \g__scripture_chap_par_prevgraf_int = 1 { \addvspace { \baselineskip } } \int_gzero:N \g__scripture_chap_par_prevgraf_int + \bool_if:NT \l__scripture_verse_para_bool + { \cs_set_eq:NN \par \__scripture_para_par: } \item \relax } \cs_new_protected:Nn \__scripture_narrow_end: { + \cs_set_eq:NN \par \para_end: \__scripture_calc_final_line_length: \dim_compare:nNnTF \@outerparskip > \l__scripture_narrow_belowskip_tl { \skip_zero:N \@topsepadd } @@ -1353,29 +2643,15 @@ \skip_gset_eq:NN \g__scripture_prev_inner_below_skip \@topsepadd \legacy_if_set_false:n { @noparlist } \endlist + \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool } \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 +\bool_new:N \l__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 { { @@ -1406,29 +2682,45 @@ { \bool_if:NTF \l__scripture_chap_drop_bool { \__scripture_poetry_chap:n { #1 } } + { + \bool_if:NTF \l__scripture_chap_para_bool + { \__scripture_para_chap:n { #1 } } + { \__scripture_poetry_nodrop_chap:n { #1 } } + } + } + { + \bool_if:NTF \l__scripture_chap_para_bool + { \__scripture_para_chap:n { #1 } } { \__scripture_poetry_nodrop_chap:n { #1 } } } - { \__scripture_poetry_nodrop_chap:n { #1 } } } \cs_new_protected:Nn \__scripture_poetry_chap:n { \__scripture_drop_chap_set_up:n { #1 } - \mode_if_vertical:TF + \hook_gput_next_code:nn { para / after } + { + \hook_gput_next_code:nn { para / after } + { \int_gzero:N \g__scripture_chap_par_prevgraf_int } + } + \cs_if_eq:NNTF \vs \__scripture_poetry_mode_vertical_verse:n + { + \dim_zero:N \l__scripture_poetry_chap_indent_dim + \noindent + } { \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 } + { \g__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 { \l__scripture_poetry_leftmargin_tl + \l__scripture_poetry_chap_indent_dim - - \l__scripture_chap_width_dim + \g__scripture_chap_width_dim } } \hbox_set:Nn \l__scripture_chap_box @@ -1447,7 +2739,7 @@ \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 - + \g__scripture_chap_width_dim + \l__scripture_poetry_chap_sep_dim - \l__scripture_poetry_leftmargin_tl - \l__scripture_poetry_chap_indent_dim } \parshape 2 ~ @@ -1460,7 +2752,7 @@ \dim_eval:n { \linewidth - \l__scripture_poetry_big_indent_tl } \dim_compare:nNnT - { \l__scripture_chap_width_dim + \l__scripture_poetry_chap_sep_dim } + { \g__scripture_chap_width_dim + \l__scripture_poetry_chap_sep_dim } > \l__scripture_poetry_leftmargin_tl { @@ -1468,43 +2760,44 @@ { \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 } + \cs_if_eq:NNTF \vs \__scripture_poetry_mode_vertical_verse:n { - \dim_set:Nn \l__scripture_poetry_chap_parshape_correction_dim + \dim_compare:nNnTF + { \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } + < + \l__scripture_poetry_leftmargin_tl + { \dim_zero:N \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 + \dim_set:Nn \l__scripture_poetry_chap_parshape_correction_dim + { + \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl - + \l__scripture_poetry_leftmargin_tl + } + } + \int_compare:nNnT \g__scripture_chap_par_prevgraf_int = 1 + { + \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 } } } - \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 } - \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 } + { \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl } < - \l__scripture_poetry_leftmargin_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 + \g__scripture_chap_width_dim + \l__scripture_chap_sep_tl - + \l__scripture_poetry_leftmargin_tl - \l__scripture_poetry_indent_tl } } \parshape 2 ~ @@ -1525,18 +2818,17 @@ \box_use:N \l__scripture_chap_box \hook_use:n { scripture / chap / after } \group_end: - \bool_lazy_or:nnT - { \bool_if_p:n \l__scripture_chap_show_verse_bool } - { \bool_if_p:n \g__scripture_poetry_midparachap_show_verse_bool } - { - \__scripture_verse_output:n { 1 } - } + \bool_lazy_or:nnT \l__scripture_chap_show_verse_bool \l__scripture_poetry_midparachap_show_verse_bool + { \__scripture_verse_output:n { 1 } } + \hook_use:n { scripture / poetry / pilcrow } } \cs_new_protected:Nn \__scripture_poetry_nodrop_chap:n { \cs_gset_nopar:Npn \scripturecurrentchapter { #1 } \cs_gset_nopar:Npn \scripturecurrentverse { 1 } \group_begin: + \cs_if_eq:NNT \vs \__scripture_poetry_mode_vertical_verse:n + { \noindent } \bool_if:NTF \l__scripture_chap_show_bool { \hbox_overlap_left:n @@ -1551,12 +2843,8 @@ \skip_horizontal:N \l__scripture_chap_sep_tl \hook_use:n { scripture / chap / after } } - \bool_lazy_or:nnT - { \bool_if_p:n \l__scripture_chap_show_verse_bool } - { \bool_if_p:n \g__scripture_poetry_midparachap_show_verse_bool } - { - \__scripture_verse_output:n { 1 } - } + \bool_lazy_or:nnT \l__scripture_chap_show_verse_bool \l__scripture_poetry_midparachap_show_verse_bool + { \__scripture_verse_output:n { 1 } } } { \hook_use:n { scripture / chap / before } @@ -1564,52 +2852,60 @@ \vs { 1 } } \group_end: + \hook_use:n { scripture / poetry / pilcrow } } \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 + \hook_gclear_next_code:n { scripture / pilcrow } \strut - \bool_if:NTF \l__scripture_poetry_verse_right_bool + \int_compare:nNnTF \g__scripture_chap_par_prevgraf_int = 1 { - \hbox_overlap_left:n - { - \__scripture_verse_output:n { #1 } - } + \__scripture_verse_output:n { #1 } } { - \hbox_overlap_left:n + \bool_if:NTF \l__scripture_poetry_verse_right_bool { - \hbox_overlap_right:n + \hbox_overlap_left:n { \__scripture_verse_output:n { #1 } } - \skip_horizontal:N \l__scripture_poetry_leftmargin_tl + } + { + \hbox_overlap_left:n + { + \hbox_overlap_right:n + { + \__scripture_verse_output:n { #1 } + } + \skip_horizontal:N \l__scripture_poetry_leftmargin_tl + } } } \group_end: + \bool_if:NF \g__scripture_suppress_next_pilcrow_bool + { \hook_use:n { scripture / poetry / pilcrow } } } \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: - { - \mode_if_vertical:TF + \int_compare:nNnTF \g__scripture_chap_par_prevgraf_int = 1 { - \cs_set_eq:NN \vs \__scripture_poetry_mode_vertical_verse:n - \noindent + \__scripture_poetry_mode_vertical_verse:n { #1 } } { - \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 + \skip_horizontal:n { -\listparindent } + \__scripture_poetry_mode_vertical_verse:n { #1 } + \skip_horizontal:N \listparindent } + \group_end: + } +\cs_new_protected:Nn \__scripture_poetry_par: + { + \para_end: + \int_set:Nn \l__scripture_poetry_prevgraf_int { \int_use:N \prevgraf } \parshape 2 ~ \@totalleftmargin ~ \linewidth ~ @@ -1624,15 +2920,67 @@ \cs_gset_protected_nopar:Nn \__scripture_obeylines: % {% \char_set_catcode_active:N \^^M% - \cs_set_eq:NN ^^M \__scripture_obeylines_end:% + \cs_set_eq:NN ^^M \__scripture_obeylines_eol:% }% \group_end: -\cs_new_protected:Nn \__scripture_obeylines_end: +\cs_new_protected:Nn \__scripture_obeylines_eol: { - \peek_meaning:NF \end + \mode_if_vertical:TF { - \par - \int_set:Nn \l__scripture_poetry_prevgraf_int { \int_use:N \prevgraf } + \cs_set_eq:NN \vs \__scripture_poetry_mode_vertical_verse:n + \hook_gput_next_code:nn { scripture / poetry / para / after } + { \bool_set_false:N \l__scripture_poetry_midparachap_show_verse_bool } + } + { \cs_set_eq:NN \vs \__scripture_poetry_mode_horizontal_verse:n } + \peek_analysis_map_inline:n + { + \bool_case:nF + { + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \ch } + { + \bool_set_eq:NN \l__scripture_poetry_midparachap_show_verse_bool \l__scripture_midparachap_show_verse_bool + \__scripture_poetry_par: + \peek_analysis_map_break:n { ##1 } + } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \end } + { \peek_analysis_map_break:n { ##1 } } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \extraskip } + { \peek_analysis_map_break:n { ##1 } } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \nopilcrow } + { + \__scripture_poetry_par: + \cs_if_eq:NNT \vs \__scripture_poetry_mode_vertical_verse:n + { \noindent } + \peek_analysis_map_break:n + { + \__scripture_fix_protrusion:o { ##1 } + } + } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \vs } + { + \__scripture_poetry_par: + \cs_if_eq:NNT \vs \__scripture_poetry_mode_vertical_verse:n + { \noindent } + \peek_analysis_map_break:n { ##1 } + } + { \exp_args:No \token_if_eq_meaning_p:NN { ##1 } \__scripture_obeylines_eol: } + { \cs_set_eq:NN \vs \__scripture_poetry_mode_vertical_verse:n } + } + { + \__scripture_poetry_par: + \cs_if_eq:NNT \vs \__scripture_poetry_mode_vertical_verse:n + { \noindent } + \bool_if:NT \l__scripture_verse_para_bool + { + \__scripture_pilcrow_output: + \bool_set_false:N \l__scripture_verse_para_bool + \bool_set_false:N \l__scripture_pilcrow_bool + } + \peek_analysis_map_break:n + { + \__scripture_fix_protrusion:o { ##1 } + } + } } } \cs_new_protected:Nn \__scripture_poetry_begin: @@ -1642,19 +2990,37 @@ \msg_error:nn { scripture } { nested-environment } } \bool_set_true:N \l__scripture_active_inner_bool - \tl_set:Nn \l__scripture_currenvir_str { poetry } + \str_set:Nn \l__scripture_currenvir_str { poetry } \bool_gset_false:N \g__scripture_poetry_midparachap_show_verse_bool - \DeclareDocumentCommand { \ch } { sm } { \__scripture_poetry_ch:n { ##2 } } + \DeclareDocumentCommand { \ch } { s o m } + { + \tl_if_novalue:nF { ##2 } + { + \tl_set:Nn \l__scripture_X_char_tl { ##2 } + } + \__scripture_poetry_ch:n { ##3 } + } \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: \cs_set_protected_nopar:Npn \textright ##1 { \__scripture_poetry_text_right:nn { \l__scripture_text_right_sep_tl } { ##1 } } \legacy_if:nTF { @newlist } { \dim_add:Nn \l__scripture_outer_itemindent_dim \itemindent } { \dim_zero:N \l__scripture_outer_itemindent_dim } + \cs_set_eq:NN \par \para_end: + \cs_set_eq:NN \noindent \tex_noindent:D + \hook_gput_next_code:nn { scripture / poetry / pilcrow } + { + \__scripture_pilcrow_output: + \bool_set_false:N \l__scripture_pilcrow_bool + \bool_set_false:N \l__scripture_verse_para_bool + } \list { } { + \bool_lazy_or:nnF + { \mode_if_vertical_p: } + { \g__scripture_para_mode_vertical_bool } + { \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool } \dim_zero:N \labelsep \dim_set_eq:NN \leftmargin \l__scripture_poetry_leftmargin_tl \dim_set_eq:NN \rightmargin \l__scripture_poetry_rightmargin_tl @@ -1674,10 +3040,6 @@ \dim_set_eq:NN \parindent \l__scripture_poetry_indent_tl \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: { @@ -1688,6 +3050,8 @@ \skip_gset_eq:NN \g__scripture_prev_inner_below_skip \@topsepadd \legacy_if_set_false:n { @noparlist } \endlist + \bool_gset_true:N \g__scripture_suppress_next_pilcrow_bool + \hook_gclear_next_code:n { scripture / poetry / pilcrow } \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 } @@ -1716,47 +3080,47 @@ } \NewDocumentEnvironment { scripture } { o o } { - \__scripture_begin:n { #2 } + \__scripture_begin:nn { #1 } { #2 } \DeclareDocumentEnvironment { center } { o } { \__scripture_center_begin:n { ##1 } - \ignorespaces + \__scripture_reference_start_peek: } { \__scripture_center_end: } \DeclareDocumentEnvironment { flushright } { o } { \__scripture_flushright_begin:n { ##1 } - \ignorespaces + \__scripture_reference_start_peek: } { \__scripture_flushright_end: } \DeclareDocumentEnvironment { hanging } { o } { \__scripture_hanging_begin:n { ##1 } - \ignorespaces + \__scripture_reference_start_peek: } { \__scripture_hanging_end: } \DeclareDocumentEnvironment { midparachap } { o } { \__scripture_mid_para_chap_begin:n { ##1 } - \ignorespaces + \__scripture_reference_start_peek: } { \__scripture_mid_para_chap_end: } \DeclareDocumentEnvironment { narrow } { o } { \__scripture_narrow_begin:n { ##1 } - \ignorespaces + \__scripture_reference_start_peek: } { \__scripture_narrow_end: } \DeclareDocumentEnvironment { poetryaux } { o } { \tl_if_novalue:nF { ##1 } - { - \keys_set:nn - { scripture / poetry } - { ##1 } - } + { + \keys_set:nn + { scripture / poetry } + { ##1 } + } \__scripture_poetry_begin: - \ignorespaces + \__scripture_reference_start_peek: } { \__scripture_poetry_end: } \DeclareDocumentEnvironment { poetry } { } @@ -1775,19 +3139,91 @@ \tl_set_eq:NN \l__scripture_ref_sep_tl \l__scripture_inline_ref_sep_tl \cs_set_eq:NN \__scripture_version_format:n \__scripture_inline_version_format:n \tl_set_eq:NN \l__scripture_version_delim_tl \l__scripture_inline_version_delim_tl + \bool_set_false:N \l__scripture_chap_para_bool \bool_set_true:N \l__scripture_compact_bool + \bool_set_false:N \l__scripture_heading_show_bool } - \bool_if:NT \l__scripture_compact_bool + \bool_if:NT \l__scripture_chap_para_bool { - \scripturesetup { chapter / nodrop } - \RenewDocumentEnvironment { center } { o } { \ignorespaces } { \unskip } - \RenewDocumentEnvironment { flushright } { o } { \ignorespaces } { \unskip } - \RenewDocumentEnvironment { hanging } { o } { \ignorespaces } { \unskip } \RenewDocumentEnvironment { midparachap } { o } { \ignorespaces } { \unskip } - \RenewDocumentEnvironment { narrow } { o } { \ignorespaces } { \unskip } - \RenewDocumentEnvironment { poetry } { o } { \ignorespaces } { \unskip } + } + \bool_if:NT \l__scripture_verse_para_bool + { + \cs_set_eq:NN \vs \__scripture_verse_para_output:n + \cs_set_eq:NN \par \__scripture_para_par: + \cs_set_eq:NN \@par \__scripture_para_par: + \cs_set_eq:NN \@doendpe \__scripture_doendpe: + \cs_set_eq:NN \noindent \__scripture_para_noindent: + \cs_set_protected:Npn \\ + { + \mode_if_horizontal:TF + { \unskip } + { \@nolnerr } + } + \RenewDocumentEnvironment { midparachap } { o } + { + \str_set:Nn \l__scripture_currenvir_str { midparachap } + \cs_set_eq:NN \noindent \tex_noindent:D + \cs_set_eq:cN { end ~ } \__scripture_mid_para_chap_end:n + \__scripture_reference_start_peek: + } + { + \para_end: + \bool_gset_false:N \g__scripture_suppress_next_pilcrow_bool + } + } + \bool_if:NT \l__scripture_compact_bool + { + \cs_set_eq:NN \noindent \__scripture_para_noindent: + \bool_if:NF \l__scripture_verse_para_bool + { + \bool_set_false:N \l__scripture_chap_drop_bool + \bool_set_false:N \l__scripture_chap_drop_llap_bool + \bool_set_false:N \l__scripture_chap_drop_smash_bool + \bool_set_false:N \l__scripture_chap_para_bool + \cs_set_eq:NN \vs \__scripture_verse_compact_output:n + } + \bool_gset:Nn \g__scripture_mode_vertical_inner_bool + { \mode_if_vertical_p: } + \RenewDocumentEnvironment { center } { o } + { + \str_set:Nn \l__scripture_currenvir_str { center } + \__scripture_reference_start_peek: + } + { \__scripture_compact_end_inner: } + \RenewDocumentEnvironment { flushright } { o } + { + \str_set:Nn \l__scripture_currenvir_str { flushright } + \__scripture_reference_start_peek: + } + { \__scripture_compact_end_inner: } + \RenewDocumentEnvironment { hanging } { o } + { + \str_set:Nn \l__scripture_currenvir_str { hanging } + \__scripture_reference_start_peek: + } + { \__scripture_compact_end_inner: } + \RenewDocumentEnvironment { midparachap } { o } + { + \str_set:Nn \l__scripture_currenvir_str { midparachap } + \cs_set_eq:cN { end ~ } \__scripture_mid_para_chap_end:n + \__scripture_reference_start_peek: + } + { \__scripture_compact_end_inner: } + \RenewDocumentEnvironment { narrow } { o } + { + \str_set:Nn \l__scripture_currenvir_str { narrow } + \__scripture_reference_start_peek: + } + { \__scripture_compact_end_inner: } + \RenewDocumentEnvironment { poetry } { o } + { + \str_set:Nn \l__scripture_currenvir_str { poetry } + \__scripture_reference_start_peek: + } + { \__scripture_compact_end_inner: } \cs_set_eq:NN \\ \unskip - \cs_set_eq:NN \par \relax + \cs_set_eq:NN \par \__scripture_compact_par: \cs_set_eq:NN \extraskip \relax \cs_set_eq:NN \nohang \relax \cs_set:Npn \selah @@ -1805,14 +3241,13 @@ \c_space_tl ##1 } - \mode_leave_vertical: } - \ignorespaces + \__scripture_reference_start_peek: } { - \bool_if:NT \l__scripture_compact_bool - { \cs_set_eq:NN \par \endgraf } - \__scripture_end:n { #1 } + \bool_lazy_or:nnT \l__scripture_compact_bool \l__scripture_verse_para_bool + { \cs_set_eq:NN \par \para_end: } + \__scripture_end: } %% %% |