diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/scontents/scontents.sty | 512 |
1 files changed, 391 insertions, 121 deletions
diff --git a/Master/texmf-dist/tex/latex/scontents/scontents.sty b/Master/texmf-dist/tex/latex/scontents/scontents.sty index 35771c8f982..6983b4517d5 100644 --- a/Master/texmf-dist/tex/latex/scontents/scontents.sty +++ b/Master/texmf-dist/tex/latex/scontents/scontents.sty @@ -1,8 +1,9 @@ -\RequirePackage{filecontentsdef}[2019/04/20] +%%^^A Initial declaration of the package \RequirePackage{l3keys2e} \RequirePackage{xparse}[2019/05/28] -\ProvidesExplPackage{scontents}{2019/08/28}{1.2} +\ProvidesExplPackage{scontents}{2019/09/24}{1.3} {Stores LaTeX contents in memory or files} +%%^^A Checking the version of xparse \@ifpackagelater { xparse } { 2019/05/03 } { } { @@ -14,41 +15,52 @@ } \file_input_stop: } +%%^^A Common keys available as package options \keys_define:nn { scontents } { store-env .tl_set:N = \l__scontents_name_seq_env_tl, store-env .initial:n = contents, - print-env .bool_set:N = \l__scontents_print_env_bool, - print-env .initial:n = false, + store-env .value_required:n = true, store-cmd .tl_set:N = \l__scontents_name_seq_cmd_tl, store-cmd .initial:n = contents, + store-cmd .value_required:n = true, + verb-font .tl_set:N = \l__scontents_verb_font_tl, + verb-font .initial:n = \ttfamily, + verb-font .value_required:n = true, + print-env .bool_set:N = \l__scontents_print_env_bool, + print-env .initial:n = false, + print-env .default:n = true, print-cmd .bool_set:N = \l__scontents_print_cmd_bool, print-cmd .initial:n = false, - print-all .meta:n = { print-env = true , print-cmd = true }, - store-env .value_required:n = true, - store-cmd .value_required:n = true, - print-env .value_required:n = true, - print-cmd .value_required:n = true, - print-all .value_required:n = true + print-cmd .default:n = true, + force-eol .bool_set:N = \l__scontents_forced_eol_bool, + force-eol .initial:n = false, + force-eol .default:n = true, + width-tab .int_set:N = \l__scontents_tab_width_int, + width-tab .initial:n = 1, + width-tab .value_required:n = true, + print-all .meta:n = { print-env = #1 , print-cmd = #1 }, + print-all .default:n = true, + unknown .code:n = { \__scontents_parse_unknown_key:n {#1} } } -%%^^A Process options for pkg +%%^^A Process options for package \ProcessKeysOptions { scontents } -%%^^A Internal tl vars +%%^^A Internal token list vars \tl_new:N \l__scontents_macro_tmp_tl \tl_new:N \l__scontents_fname_out_tl \tl_new:N \l__scontents_temp_tl +\tl_new:N \l__scontents_file_tl +\tl_new:N \g__scontents_temp_tl +%%^^A Internal int vars +\int_new:N \l__scontents_seq_item_int +\int_new:N \l__scontents_env_nesting_int +\int_new:N \l__scontents_tmpa_int %%^^A Internal bool vars -\bool_new:N \l__scontents_typeverb_env_bool -\bool_set_true:N \l__scontents_typevrb_env_bool \bool_new:N \l__scontents_writing_bool \bool_set_false:N \l__scontents_writing_bool \bool_new:N \l__scontents_storing_bool \bool_set_true:N \l__scontents_storing_bool -%%^^A Internal quarks -\quark_new:N \q__scontents_stop -\quark_new:N \q__scontents_mark -%%^^A Internal quarks -\cs_new_eq:NN \__scontents_rescan_tokens:w \tex_scantokens:D +%%^^A A token list to match \env{verbatimsc} and \env{scontents} \tl_new:N \g__scontents_end_verbatimsc_tl \tl_gset_rescan:Nnn \g__scontents_end_verbatimsc_tl @@ -58,6 +70,23 @@ \char_set_catcode_other:N \} } { \end{verbatimsc} } +\tl_const:Nx \c__scontents_end_env_tl + { \c_backslash_str end \c_left_brace_str scontents \c_right_brace_str } +%%^^A Internal quarks +\quark_new:N \q__scontents_stop +\quark_new:N \q__scontents_mark +%%^^A Stream for saving the contents +\iow_new:N \l__scontents_file_iow +%%^^A Copy of scantokens in expl3 +\cs_new_protected:Npn \__scontents_rescan_tokens:n #1 { \tex_scantokens:D {#1} } +\cs_generate_variant:Nn \__scontents_rescan_tokens:n { V, x } +%%^^A Internal \tab and \par +\cs_new:Npx \__scontents_tab: { \c_space_tl } +\cs_new:Npn \__scontents_par: { ^^J ^^J } +%%^^A Some nonstandard variants +\cs_generate_variant:Nn \tl_remove_once:Nn { NV } +\cs_generate_variant:Nn \tl_replace_all:Nnn { Nx, Nxx, Nnx } +\prg_generate_conditional_variant:Nnn \tl_if_empty:n { f } { TF } %%^^A Add keys to scontents environnment \keys_define:nn { scontents } { @@ -73,13 +102,31 @@ write-env .value_required:n = true, write-out .value_required:n = true } -%%^^A A sub/keys for command |\Scontents| +%%^^A A sub/keys for command \Scontents \keys_define:nn { scontents / Scontents } { print-cmd .meta:nn = { scontents } { print-cmd = #1 }, - store-cmd .meta:nn = { scontents } { store-cmd = #1 } + store-cmd .meta:nn = { scontents } { store-cmd = #1 }, + force-eol .meta:nn = { scontents } { force-eol = #1 } } -%%^^A Append content to seq +%%^^A Parse unknown keys +\cs_new_protected:Npn \__scontents_parse_unknown_key:n #1 + { \exp_args:NV \__scontents_parse_unknown_key:nn \l_keys_key_tl {#1} } +\cs_new_protected:Npn \__scontents_parse_unknown_key:nn #1 #2 + { + \tl_if_empty:fTF { \int_to_roman:n { -0 #1 } } + { + \tl_if_blank:nTF {#2} + { \int_set:Nn \l__scontents_seq_item_int {#1} } + { \msg_error:nnnn { scontents } { key-value-unknown } {#1} {#2} } + } + { + \tl_if_blank:nTF {#2} + { \msg_error:nnn { scontents } { key-unknown } {#1} } + { \msg_error:nnnn { scontents } { key-value-unknown } {#1} {#2} } + } + } +%%^^A Programming of the sequences \cs_new_protected:Npn \__scontents_append_contents:nn #1#2 { \tl_if_blank:nT {#1} @@ -90,8 +137,30 @@ } \cs_generate_variant:Nn \__scontents_append_contents:nn { Vx } \cs_new:Npn \__scontents_getfrom_seq:nn #1#2 - { \seq_item:cn { g__scontents_seq_name_#2_seq } {#1} } -%%^^A Define |scontents| whit [key=val] (delaying) + { + \seq_if_exist:cTF { g__scontents_seq_name_#2_seq } + { + \exp_args:Nf \__scontents_getfrom_seq:nnn + { \seq_count:c { g__scontents_seq_name_#2_seq } } + {#1} {#2} + } + { \msg_expandable_error:nnn { scontents } { undefined-storage } {#2} } + } +\cs_new:Npn \__scontents_getfrom_seq:nnn #1 #2 #3 + { + \bool_lazy_or:nnTF + { \int_compare_p:nNn {#2} = { 0 } } + { \int_compare_p:nNn { \int_abs:n {#2} } > {#1} } + { \msg_expandable_error:nnnnn { scontents } { index-out-of-range } {#2} {#3} {#1} } + { \seq_item:cn { g__scontents_seq_name_#3_seq } {#2} } + } +%%^^A Storing content in sequences +\cs_new_protected:Npn \__scontents_store_to_seq:NN #1 #2 + { + \tl_log:N #1 + \__scontents_append_contents:Vx #2 { \exp_not:V #1 } + } +%%^^A Definition of {scontents}[key=val] env \NewDocumentEnvironment { scontents } { } { \char_set_catcode_active:N \^^M @@ -101,29 +170,7 @@ \__scontents_stop_environment: \__scontents_atend_environment: } -%%^^A First \cs{@@_start_environment:w} -\group_begin: - \char_set_catcode_active:N \^^M - \cs_new_protected:Npn \__scontents_start_environment:w #1 ^^M - { - \__scontents_environment_inline:w #1 \q__scontents_mark - \group_begin: - \bool_if:NTF \l__scontents_writing_bool - { - \use:c { filecontentsdef* } { \l__scontents_fname_out_tl } - { \l__scontents_macro_tmp_tl } ^^M - } - { \filecontentsdefmacro { \l__scontents_macro_tmp_tl } ^^M } - } - \cs_new_protected:Npn \__scontents_stop_environment: - { - \bool_if:NTF \l__scontents_writing_bool - { \endfilecontentsdef } - { \endfilecontentsdefmacro } - \group_end: - } -\group_end: -%%^^A key val for environment scontents +%%^^A Test [key=val] for environment scontents \cs_new_protected:Npn \__scontents_environment_inline:w { \peek_charcode_ignore_spaces:NTF [ % ] @@ -145,135 +192,322 @@ { \msg_error:nnnn { scontents } { junk-after-begin } {#1} {#2} } } \cs_generate_variant:Nn \__scontents_environment_junk:nw { x } +%%^^A First start_environment/stop_environment +\group_begin: + \char_set_catcode_active:N \^^I + \char_set_catcode_active:N \^^L + \char_set_catcode_active:N \^^M + \cs_new_protected:Npn \__scontents_start_environment:w #1 ^^M + { + \__scontents_environment_inline:w #1 \q__scontents_mark + \__scontents_make_control_chars_active: + \group_begin: + \__scontents_file_tl_write_start:V \l__scontents_fname_out_tl + } + \cs_new_protected:Npn \__scontents_stop_environment: + { + \__scontents_file_write_stop:N \l__scontents_macro_tmp_tl + \exp_args:NNNV + \group_end: + \tl_set:Nn \l__scontents_macro_tmp_tl \l__scontents_macro_tmp_tl + } +%%^^A File write start/File write stop + \cs_new_protected:Npn \__scontents_file_tl_write_start:n #1 + { + \group_begin: + \bool_if:NT \l__scontents_writing_bool + { + \file_if_exist:nTF {#1} + { \msg_warning:nnx { scontents } { rewriting-file } {#1} } + { \msg_warning:nnx { scontents } { writing-file } {#1} } + \iow_open:Nn \l__scontents_file_iow {#1} + } + \tl_clear:N \l__scontents_file_tl + \seq_map_function:NN \l_char_special_seq \char_set_catcode_other:N + \int_step_function:nnN { 128 } { 255 } \char_set_catcode_letter:n + \cs_set_protected:Npx \__scontents_ret:w ##1 ^^M + { + \exp_not:N \__scontents_verb_processor_iterate:w + ##1 \c__scontents_end_env_tl + \c__scontents_end_env_tl + \exp_not:N \q__scontents_stop + } + \__scontents_make_control_chars_active: + \__scontents_ret:w + } + \use:x + { + \cs_new:Npn \exp_not:N \__scontents_verb_processor_iterate:w + ##1 \c__scontents_end_env_tl + ##2 \c__scontents_end_env_tl + ##3 \exp_not:N \q__scontents_stop + } { + \tl_if_blank:nTF {#3} + { + \__scontents_analyse_nesting:n {#1} + \__scontents_verb_processor_output:n {#1} + } + { + \__scontents_if_nested:TF + { + \__scontents_nesting_decr: + \__scontents_verb_processor_output:x + { \exp_not:n {#1} \c__scontents_end_env_tl \exp_not:n {#2} } + } + { + \tl_if_blank:nF {#1} + { \__scontents_verb_processor_output:n {#1} } + \cs_set_protected:Npx \__scontents_ret:w + { + \exp_not:N \end{scontents} + \bool_lazy_or:nnF + { \tl_if_blank_p:n {#2} } + { \str_if_eq_p:ee {#2} { \c_percent_str } } + { + \msg_warning:nnn { scontents } { rescanning-text } {#2} + \__scontents_rescan_tokens:n {#2} + } + } + \char_set_active_eq:NN ^^M \__scontents_ret:w + } + } + ^^M + } + \cs_new_protected:Npn \__scontents_file_write_stop:N #1 + { + \bool_if:NT \l__scontents_writing_bool + { \iow_close:N \l__scontents_file_iow } + \use:x + { + \group_end: + \bool_if:NT \l__scontents_storing_bool + { + \tl_set:Nn \exp_not:N #1 + { + \exp_args:NV \__scontents_remove_leading_nl:n \l__scontents_file_tl + \bool_if:NT \l__scontents_forced_eol_bool { \exp_not:N ^^J } + } + } + } + } + \cs_new:Npn \__scontents_remove_leading_nl:n #1 + { \exp_not:o { \__scontents_remove_leading_nl:w #1 } } + \cs_new:Npn \__scontents_remove_leading_nl:w ^^J { } + \cs_new_protected:Npn \__scontents_verb_processor_output:n #1 + { + \bool_if:NT \l__scontents_writing_bool + { \iow_now:Nn \l__scontents_file_iow {#1} } + \bool_if:NT \l__scontents_storing_bool + { \tl_put_right:Nn \l__scontents_file_tl { ^^J #1 } } + } + \cs_generate_variant:Nn \__scontents_verb_processor_output:n { x } + \cs_new_protected:Npx \__scontents_analyse_nesting:n #1 + { + \int_zero:N \l__scontents_tmpa_int + \exp_not:N \__scontents_analyse_nesting:w #1 + \c_backslash_str begin + \c_left_brace_str \exp_not:N \q__scontents_mark \c_right_brace_str + \exp_not:N \q__scontents_stop + \int_compare:nNnT { \l__scontents_tmpa_int } > { 1 } + { \msg_warning:nn { scontents } { multiple-begin } } + } + \use:x + { + \cs_new_protected:Npn \exp_not:N \__scontents_analyse_nesting:w ##1 + \c_backslash_str begin \c_left_brace_str ##2 \c_right_brace_str + } { + \if_meaning:w \q__scontents_mark #2 + \exp_after:wN \use_i:nn + \else: + \exp_after:wN \use_ii:nn + \fi: + { \__scontents_use_none_delimit_by_q_stop:w } + { + \str_if_eq:eeT {#2} {scontents} + { + \int_incr:N \l__scontents_env_nesting_int + \int_incr:N \l__scontents_tmpa_int + \__scontents_analyse_nesting:w + } + \__scontents_analyse_nesting:w + } + } + \cs_new_protected:Npn \__scontents_nesting_decr: + { \int_decr:N \l__scontents_env_nesting_int } + \prg_new_protected_conditional:Npnn \__scontents_if_nested: { TF } + { + \int_compare:nNnTF { \l__scontents_env_nesting_int } > { \c_zero_int } + { \prg_return_true: } + { \prg_return_false: } + } + \cs_new:Npn \__scontents_use_none_delimit_by_q_stop:w #1 \q__scontents_stop { } +\group_end: +\cs_generate_variant:Nn \__scontents_file_tl_write_start:n { V } +%%^^A Second atend_environment/stored_to_seq \cs_new_protected:Npn \__scontents_atend_environment: { \bool_if:NT \l__scontents_storing_bool { - \__scontents_stored_to_seq: - \bool_if:NT \l__scontents_print_env_bool - { \__scontents_getfrom_seq:nn { -1 } { \l__scontents_name_seq_env_tl } } + \__scontents_store_to_seq:NN \l__scontents_macro_tmp_tl \l__scontents_name_seq_env_tl + } + \bool_if:NT \l__scontents_print_env_bool + { + \tl_gset_eq:NN \g__scontents_temp_tl \l__scontents_macro_tmp_tl + \tl_gput_right:NV \g__scontents_temp_tl \c_percent_str + \group_insert_after:N \__scontents_rescan_tokens:V + \group_insert_after:N \g__scontents_temp_tl } \tl_clear:N \l__scontents_macro_tmp_tl } -\cs_new_protected:Npn \__scontents_stored_to_seq: - { - \regex_replace_all:nnN { \^^M } { \^^J } \l__scontents_macro_tmp_tl - \tl_log:N \l__scontents_macro_tmp_tl - \__scontents_append_contents:Vx \l__scontents_name_seq_env_tl - { \exp_not:N \__scontents_rescan_tokens:w { \tl_use:N \l__scontents_macro_tmp_tl } } - } -%%^^A User command to stored content +%%^^A User command \Scontents to stored content \NewDocumentCommand { \Scontents }{ !s !O{} } { \group_begin: \IfNoValueF {#2} { \keys_set_known:nn { scontents / Scontents } {#2} } - \IfBooleanTF{#1} - { \__scontents_verb:w } - { \__scontents_norm:n } + \char_set_catcode_active:n { 9 } + \IfBooleanTF {#1} + { \__scontents_verb_arg:w } + { \__scontents_norm_arg:n } } -\cs_new_protected:Npn \__scontents_norm:n #1 +\cs_new_protected:Npn \__scontents_norm_arg:n #1 { - \exp_args:NV \__scontents_append_contents:nn \l__scontents_name_seq_cmd_tl {#1} - \bool_if:NT \l__scontents_print_cmd_bool - { \__scontents_getfrom_seq:nn { -1 } { \l__scontents_name_seq_cmd_tl } } - \group_end: + \exp_args:NV \__scontents_append_contents:nn \l__scontents_name_seq_cmd_tl {#1} + \bool_if:NT \l__scontents_print_cmd_bool { \__scontents_rescan_tokens:n {#1} } + \group_end: } -\NewDocumentCommand { \__scontents_verb:w } { +v } +\NewDocumentCommand { \__scontents_verb_arg:w } { +v } { - \tl_set:Nn \l__scontents_temp_tl {#1} - \regex_replace_all:nnN { \^^M } { \^^J } \l__scontents_temp_tl - \tl_log:N \l__scontents_temp_tl - \exp_args:NVx \__scontents_append_contents:nn \l__scontents_name_seq_cmd_tl - { \exp_not:N \__scontents_rescan_tokens:w { \tl_use:N \l__scontents_temp_tl } } + \tl_set:Nx \l__scontents_temp_tl + { + \exp_not:n {#1} + \bool_if:NT \l__scontents_forced_eol_bool { \exp_not:N ^^J } + } + \tl_replace_all:Nxx \l__scontents_temp_tl { \iow_char:N \^^M } { \iow_char:N \^^J } + \__scontents_store_to_seq:NN \l__scontents_temp_tl \l__scontents_name_seq_cmd_tl \bool_if:NT \l__scontents_print_cmd_bool - { \__scontents_getfrom_seq:nn { -1 } { \l__scontents_name_seq_cmd_tl } } + { \__scontents_rescan_tokens:V \l__scontents_temp_tl } \group_end: } +%%^^A User command \getstored to get content \NewDocumentCommand { \getstored } { O{1} m } - { \__scontents_getfrom_seq:nn {#1} {#2} } -\NewDocumentCommand { \typestored } { s O{1} m } { \group_begin: - \tl_set:Nx \l__scontents_temp_tl { \__scontents_getfrom_seq:nn {#2} {#3} } + \__scontents_rescan_tokens:x + { + \__scontents_getfrom_seq:nn {#1} {#2} + \c_percent_str + } + \group_end: + } +%%^^A User command \typestored to verbatimized content +\NewDocumentCommand { \typestored } { o m } + { + \group_begin: + \int_set:Nn \l__scontents_seq_item_int { 1 } + \IfValueT {#1} { \keys_set:nn { scontents } {#1} } + \tl_set:Nx \l__scontents_temp_tl { \exp_args:NV \__scontents_getfrom_seq:nn \l__scontents_seq_item_int {#2} } \tl_log:N \l__scontents_temp_tl - \IfBooleanTF {#1} - { \bool_set_false:N \l__scontents_typeverb_env_bool } - { \bool_set_true:N \l__scontents_typeverb_env_bool } - \use:c { filecontentsdef@get } \__scontents_fcdef_print:N \l__scontents_temp_tl + \tl_if_empty:NF \l__scontents_temp_tl + { \__scontents_verb_print:N \l__scontents_temp_tl } \group_end: } +%%^^A Internal verb_print:N, need to verbatimized content \group_begin: - \char_set_catcode_active:N \^^M - \cs_new_protected:Npn \__scontents_fcdef_print:N #1 + \char_set_catcode_active:N \^^M + \cs_new_protected:Npn \__scontents_verb_print:N #1 { \tl_if_blank:VT #1 { \msg_error:nnn { scontents } { empty-variable } {#1} } - \cs_set_eq:NN \__scontents_fcdef_saved_EOL: ^^M + \cs_set_eq:NN \__scontents_verb_print_EOL: ^^M \cs_set_eq:NN ^^M \scan_stop: - \use:x + \cs_set_eq:cN { do@noligs } \__scontents_do_noligs:N + \__scontents_rescan_tokens:x { - \exp_not:N \__scontents_rescan_tokens:w - { - \exp_not:N \begin{verbatimsc} ^^M - \__scontents_strip_scantokens:N #1 - \bool_if:NF \l__scontents_typeverb_env_bool { ^^M } - \g__scontents_end_verbatimsc_tl - } + \exp_not:N \begin{verbatimsc} ^^M + \exp_not:V #1 ^^M + \g__scontents_end_verbatimsc_tl } - \cs_set_eq:NN ^^M \__scontents_fcdef_saved_EOL: + \cs_set_eq:NN ^^M \__scontents_verb_print_EOL: } \group_end: +%%^^A Definition of verbatimsc environment +\cs_new_protected:Npn \__scontents_xverb: + { + \char_set_catcode_active:n { 9 } + \char_set_active_eq:nN { 9 } \__scontents_tabs_to_spaces: + \__scontents_xverb:w + } \use:x - { \cs_gset_protected:Npn \exp_not:N \__scontents_xverb:w ##1 \g__scontents_end_verbatimsc_tl } + { + \cs_new_protected:Npn \exp_not:N \__scontents_xverb:w + ##1 \g__scontents_end_verbatimsc_tl + } { #1 \end{verbatimsc} } \NewDocumentEnvironment { verbatimsc } { } { - \cs_set_eq:cN { @xverbatim } \__scontents_xverb:w + \cs_set_eq:cN { @xverbatim } \__scontents_xverb: \verbatim } { } -\cs_new:Npn \__scontents_strip_scantokens:N #1 - { \exp_args:NV \__scontents_strip_scantokens:n #1 } -\cs_new:Npn \__scontents_strip_scantokens:n #1 +%%^^A Tab to space +\cs_new:Npn \__scontents_tabs_to_spaces: + { \prg_replicate:nn { \l__scontents_tab_width_int } { ~ } } +%%^^A Patch do_noligs for ligatures +\cs_new:Npn \__scontents_do_noligs:N #1 { - \tl_if_head_is_N_type:nTF {#1} + \char_set_catcode_active:N #1 + \char_set_active_eq:Nc #1 { __scontents_active_char_ \token_to_str:N #1 : } + \cs_set:cpx { __scontents_active_char_ \token_to_str:N #1 : } { - \__scontents_if_scantokens:NwTF #1 \q__scontents_mark - { - \exp_args:No \tl_if_single_token:nTF { \use_none:nn #1 ? } - { \exp_not:o { \use_ii:nn #1 } } - { \exp_not:n {#1} } - } - { \exp_not:n {#1} } + \mode_leave_vertical: + \tex_kern:D \c_zero_dim + \char_generate:nn { `#1 } { 12 } } - { \exp_not:n {#1} } } -\prg_new_conditional:Npnn \__scontents_if_scantokens:Nw #1#2 \q__scontents_mark { TF } +%%^^A Common catcode changes +\cs_new_protected:Npn \__scontents_set_active_eq:NN #1 + { + \char_set_catcode_active:N #1 + \char_set_active_eq:NN #1 + } +\cs_new_protected:Npn \__scontents_make_control_chars_active: { - \token_if_eq_meaning:NNTF \__scontents_rescan_tokens:w #1 - { \prg_return_true: } - { \prg_return_false: } + \__scontents_set_active_eq:NN \^^I \__scontents_tab: + \__scontents_set_active_eq:NN \^^L \__scontents_par: + \__scontents_set_active_eq:NN \^^M \__scontents_ret:w } -%%^^A User command to setup module +%%^^A User command \setupsc \NewDocumentCommand { \setupsc } { m } { \keys_set:nn { scontents } {#1} } -\NewDocumentCommand { \meaningsc } { O{1} m } +%%^^A User command \meaningsc +\NewDocumentCommand { \meaningsc } { o m } { \group_begin: - \tl_set:Nx \l__scontents_temp_tl { \__scontents_getfrom_seq:nn {#1} {#2} } - \tl_log:N \l__scontents_temp_tl - \tl_set:Nx \l__scontents_temp_tl { \__scontents_strip_scantokens:N \l__scontents_temp_tl } - \regex_replace_all:nnN { \v{1,} } { } \l__scontents_temp_tl - \ttfamily - \cs_replacement_spec:N \l__scontents_temp_tl + \int_set:Nn \l__scontents_seq_item_int { 1 } + \IfValueT {#1} { \keys_set:nn { scontents } {#1} } + \__scontents_meaningsc:n {#2} \group_end: } +\group_begin: + \char_set_catcode_active:N \^^I + \cs_new_protected:Npn \__scontents_meaningsc:n #1 + { + \tl_set:Nx \l__scontents_temp_tl { \exp_args:NV \__scontents_getfrom_seq:nn \l__scontents_seq_item_int {#1} } + \tl_replace_all:Nxn \l__scontents_temp_tl { \iow_char:N \^^J } { ~ } + \tl_log:N \l__scontents_temp_tl + \tl_use:N \l__scontents_verb_font_tl + \tl_replace_all:Nnx \l__scontents_temp_tl { ^^I } { \__scontents_tabs_to_spaces: } + \cs_replacement_spec:N \l__scontents_temp_tl + } +\group_end: +%%^^A User command \countsc \NewExpandableDocumentCommand { \countsc } { m } { \seq_count:c { g__scontents_seq_name_#1_seq } } +%%^^A User command \cleanseqsc \NewDocumentCommand { \cleanseqsc } { m } { \seq_clear_new:c { g__scontents_seq_name_#1_seq } } -%%^^A Messages +%%^^A Messages used throughout the package \msg_new:nnn { scontents } { junk-after-begin } { Junk~characters~#1~\msg_line_context: : @@ -283,6 +517,42 @@ \msg_new:nnn { scontents } { empty-stored-content } { Empty~value~for~key~`getstored'~\msg_line_context:. } \msg_new:nnn { scontents } { empty-variable } - { Variable~`#1'~empty~\msg_line_context:. } -%%^^A Finish package + { Variable~`#1'~empty~\msg_line_context:. } +\msg_new:nnn { scontents } { rewriting-file } + { Overwriting ~ file ~ `#1' } +\msg_new:nnn { scontents } { writing-file } + { Writing ~ file ~ `#1' } +\msg_new:nnn { scontents } { rescanning-text } + { Rescanning~text~`#1'~after~\c_backslash_str end{scontents}~\msg_line_context:.} +\msg_new:nnn { scontents } { multiple-begin } + { Multiple~\c_backslash_str begin{scontents}~\msg_line_context:.} +\msg_new:nnn { scontents } { tab-to-space } + { Tab~has~been~converted~to~Blank~Space } +\msg_new:nnn { scontents } { feed-to-space } + { Form~Feed~has~been~converted~to~Blank~Space } +\msg_new:nnnn { scontents } { key-unknown } + { The~key~'#1'~is~unknown~and~is~being~ignored. } + { + The~module~'scontents'~does~not~have~a~key~called~'#1'.\\ + Check~that~you~have~spelled~the~key~name~correctly. + } +\msg_new:nnnn { scontents } { key-value-unknown } + { The~key~'#1'~to~which~you~passed~'#2'~is~unknown~and~is~being~ignored. } + { + The~module~'scontents'~does~not~have~a~key~called~'#1'.\\ + Check~that~you~have~spelled~the~key~name~correctly. + } +\msg_new:nnn { scontents } { undefined-storage } + { Storage~named~'#1'~is~not~defined. } +\msg_new:nnn { scontents } { index-out-of-range } + { + \int_compare:nNnTF {#1} = { 0 } + { Index~of~sequence~cannot~be~zero. } + { + Index~'#1'~out~of~range~for~'#2'.~ + \int_compare:nNnTF {#1} > { 0 } + { Max = } { Min = -} #3. + } + } +%%^^A Finish package :) \file_input_stop: |