summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-11-17 22:34:27 +0000
committerKarl Berry <karl@freefriends.org>2019-11-17 22:34:27 +0000
commit23ef0a47d81811188819422f09392e5220e96b59 (patch)
tree17a6d6fc7d95bd2889038db33bb55b1b8c920bd8 /Master/texmf-dist/tex
parent59dc3a32912329f9a44b04a5bd4df8bde04e383e (diff)
scontents (17nov19)
git-svn-id: svn://tug.org/texlive/trunk@52841 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/context/third/scontents/t-scontents.mkiv45
-rw-r--r--Master/texmf-dist/tex/generic/scontents/scontents-code.tex344
-rw-r--r--Master/texmf-dist/tex/generic/scontents/scontents.tex44
-rw-r--r--Master/texmf-dist/tex/latex/scontents/scontents.sty36
4 files changed, 310 insertions, 159 deletions
diff --git a/Master/texmf-dist/tex/context/third/scontents/t-scontents.mkiv b/Master/texmf-dist/tex/context/third/scontents/t-scontents.mkiv
index 8f336482dad..944ff08225a 100644
--- a/Master/texmf-dist/tex/context/third/scontents/t-scontents.mkiv
+++ b/Master/texmf-dist/tex/context/third/scontents/t-scontents.mkiv
@@ -33,16 +33,16 @@
%% scontents.dtx (with options: `loader,context')
%D \module
%D [ file=t-scontents,
-%D version=1.7,
+%D version=1.8,
%D title=\CONTEXT\ User Module,
%D subtitle=Storing Contents,
%D author=Pablo González,
-%D date=2019-10-29,
+%D date=2019-11-18,
%D copyright=Pablo González,
%D email=pablgonz@educarchile.cl,
%D license=LPPL]
-\def\ScontentsFileDate{2019-10-29}%
-\def\ScontentsFileVersion{1.7}%
+\def\ScontentsFileDate{2019-11-18}%
+\def\ScontentsFileVersion{1.8}%
\def\ScontentsFileDescription{Stores LaTeX contents in memory or files}%
\writestatus{loading}{User Module scontents v\ScontentsFileVersion}
\unprotect
@@ -62,7 +62,7 @@
{
\c_backslash_str
stop
- scontents
+ \exp_not:N \l__scontents_env_name_tl
}
\file_input:n { scontents-code.tex }
\cs_new:Npn \__scontents_format_case:nnn #1 #2 #3
@@ -106,9 +106,12 @@
\clist_map_function:NN \l__scontents_temp_tl \__scontents_require_auxiii:n
}
\cs_new_protected:Npn \__scontents_require_auxiii:n #1
- { \str_if_eq:eeF {expl3} {#1} { \msg_error:nnn { scontents } { invalid-package } {#1} } }
+ {
+ \str_if_eq:eeF {expl3} {#1}
+ { \msg_error:nnn { scontents } { invalid-package } {#1} }
+ }
\msg_new:nnn { scontents } { invalid-package }
- { Package~`#1'~invalid~in~scontents.~This~is~an~error~in~scontents. }
+ { Package~'#1'~invalid~in~scontents.~This~is~an~error~in~scontents. }
\__scontents_compat_redefine:cpn { @ifpackagelater } #1
{ \exp_args:Nc \__scontents_package_later_aux:Nn { ver@#1.sty } }
\cs_new_protected:Npn \__scontents_package_later_aux:Nn #1 #2
@@ -123,7 +126,7 @@
\cs_new:Npn \__scontents_parse_version_auxii:w #1-#2-#3#4#5 \q_mark
{ \tl_if_blank:nF {#2} {#1} #2 #3 #4 }
\__scontents_compat_redefine:Npn \ProvidesExplPackage #1 #2 #3 #4
- { \__scontents_provides_aux:nn {#1} { #2 \ifx\relax#3\relax\else v#3\space\fi #4 } }
+ { \__scontents_provides_aux:nn {#1} { #2 \tl_if_empty:nF {#3} {#3~} #4 } }
\cs_new_protected:Npn \__scontents_provides_aux:nn #1 #2
{
\tl_gset:cx { ver@#1.sty } {#2}
@@ -142,18 +145,30 @@
\ExplSyntaxOn
\char_set_catcode:nn { `\@ } { \l__scontents_tmpa_int }
\__scontents_compat_restore:
-\cs_new_protected:Npn \startscontents
+\NewDocumentCommand { \newenvsc } { m O{} }
{
- \group_begin:
- \__scontents_scontents_env_begin:
+ \cs_if_exist:cTF { start #1 }
+ { \msg_error:nnn { scontents } { env-already-defined } {#1} }
+ { \__scontents_scontents_setenv:nn {#1} {#2} }
}
-\cs_new_protected:Npn \stopscontents
+\cs_new_protected:Npn \__scontents_env_define:nnn #1 #2 #3
{
- \__scontents_scontents_env_end:
- \group_end:
+ \cs_new_protected:cpn { start #1 }
+ {
+ \group_begin:
+ #2
+ }
+ \cs_new_protected:cpn { stop #1 }
+ {
+ #3
+ \group_end:
+ }
}
+\newenvsc{scontents}
\NewDocumentCommand \__scontents_grab_optional:w { r[] }
{ \__scontents_grab_optional:n {#1} }
+\cs_new_protected:Npn \__scontents_analyse_nesting_format:n
+ { \__scontents_analyse_nesting_generic:nn { start } }
\cs_if_exist:NF \dospecials
{
\cs_new:Npn \dospecials
@@ -163,7 +178,7 @@
{ \__scontents_Scontents_internal:nn {#1} {#2} }
\NewDocumentCommand { \__scontents_verb_arg:w } { +v }
{ \__scontents_verb_arg_internal:n {#1} }
-\NewDocumentCommand { \getstored } { O{1} m }
+\NewDocumentCommand { \getstored } { O{-1} m }
{ \__scontents_getstored_internal:nn {#1} {#2} }
\NewDocumentCommand { \foreachsc } { o m }
{ \__scontents_foreachsc_internal:nn {#1} {#2} }
diff --git a/Master/texmf-dist/tex/generic/scontents/scontents-code.tex b/Master/texmf-dist/tex/generic/scontents/scontents-code.tex
index 49e87eba3e0..f417191f680 100644
--- a/Master/texmf-dist/tex/generic/scontents/scontents-code.tex
+++ b/Master/texmf-dist/tex/generic/scontents/scontents-code.tex
@@ -27,7 +27,7 @@
%% t-scontents.mkiv and
%% scontents-code.tex.
%%
-\def\ScontentsCoreFileDate{2019-10-29}%
+\def\ScontentsCoreFileDate{2019-11-18}%
\begingroup
\def\next{\endgroup}%
\expandafter\ifx\csname PackageError\endcsname\relax
@@ -87,6 +87,9 @@
force-eol .bool_set:N = \l__scontents_forced_eol_bool,
force-eol .initial:n = false,
force-eol .default:n = true,
+ overwrite .bool_set:N = \l__scontents_overwrite_bool,
+ overwrite .initial:n = false,
+ overwrite .default:n = true,
width-tab .int_set:N = \l__scontents_tab_width_int,
width-tab .initial:n = 1,
width-tab .value_required:n = true,
@@ -151,6 +154,8 @@
store-env .meta:nn = { scontents } { store-env = #1 },
force-eol .meta:nn = { scontents } { force-eol = #1 },
force-eol .default:n = true,
+ overwrite .meta:nn = { scontents } { overwrite = #1 },
+ overwrite .default:n = true,
unknown .code:n = { \__scontents_parse_environment_keys:n {#1} }
}
\keys_define:nn { scontents / Scontents }
@@ -187,7 +192,8 @@
step .initial:n = 1,
wrapper .code:n = {
\bool_set_true:N \l__scontents_foreach_wrapper_bool
- \cs_set_protected:Npn \__scontents_foreach_wrapper:n ##1 {#1}
+ \cs_set_protected:Npn
+ \__scontents_foreach_wrapper:n ##1 {#1}
},
wrapper .value_required:n = true,
sep .tl_set:N = \l__scontents_foreach_sep_tl,
@@ -280,12 +286,29 @@
\tl_log:N #1
\__scontents_append_contents:Vx #2 { \exp_not:V #1 }
}
-\cs_new_protected:Npn \__scontents_scontents_env_begin:
+\tl_new:N \l__scontents_env_name_tl
+\cs_new_protected:Npn \__scontents_scontents_setenv:nn #1 #2
+ {
+ \cs_new_protected:cpn { __scontents_#1_env_begin: }
+ {
+ \tl_set:Nn \l__scontents_env_name_tl {#1}
+ \keys_set:nn { scontents } {#2}
+ \__scontents_setup_verb_processor:
+ \__scontents_env_generic_begin:
+ }
+ \cs_new_protected:cpn { __scontents_#1_env_end: }
+ { \__scontents_env_generic_end: }
+ \exp_args:Nooo % http://nooooooooooooooo.com :) jeje
+ \__scontents_env_define:nnn { \tl_to_str:n {#1} }
+ { \cs:w __scontents_#1_env_begin: \cs_end: }
+ { \cs:w __scontents_#1_env_end: \cs_end: }
+ }
+\cs_new_protected:Npn \__scontents_env_generic_begin:
{
\char_set_catcode_active:N \^^M
\__scontents_start_environment:w
}
-\cs_new_protected:Npn \__scontents_scontents_env_end:
+\cs_new_protected:Npn \__scontents_env_generic_end:
{
\__scontents_stop_environment:
\__scontents_atend_environment:
@@ -312,45 +335,52 @@
{
\str_if_eq:eeTF { \tl_head:n {#1} } { [ }
{ \__scontents_grab_optional:w #1 ^^M }
- { \__scontents_check_line_and_process:xn { } {#1} }
+ { \__scontents_check_line_process:xn { } {#1} }
}
- { \__scontents_check_line_and_process:xn { } {#1} }
+ { \__scontents_check_line_process:xn { } {#1} }
}
\cs_new_protected:Npn \__scontents_start_after_option:w #1 ^^M
- { \__scontents_check_line_and_process:xn { [...] } {#1} }
- \cs_new_protected:Npn \__scontents_check_line_and_process:xn #1 #2
+ { \__scontents_check_line_process:xn { [...] } {#1} }
+ \cs_new_protected:Npn \__scontents_check_line_process:xn #1 #2
{
\tl_if_blank:nF {#2}
{
\msg_error:nnxn { scontents } { junk-after-begin }
- { after~\c_backslash_str begin{scontents} #1 } {#2}
+ { after~\c_backslash_str begin { \l__scontents_env_name_tl } #1 } {#2}
}
\__scontents_make_control_chars_active:
- \group_begin:
- \__scontents_file_tl_write_start:V \l__scontents_fname_out_tl
+ \__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
- \tl_if_empty:NT \l__scontents_macro_tmp_tl
- { \msg_warning:nnn { scontents } { empty-environment } }
+ \__scontents_file_write_stop:N \l__scontents_macro_tmp_tl
+ \bool_lazy_and:nnT
+ { \l__scontents_storing_bool }
+ { \tl_if_empty_p:N \l__scontents_macro_tmp_tl }
+ {
+ \msg_warning:nnx { scontents } { empty-environment }
+ { \l__scontents_env_name_tl }
+ }
}
\cs_new_protected:Npn \__scontents_file_tl_write_start:n #1
{
\group_begin:
- \bool_if:NT \l__scontents_writing_bool
+ \bool_if:nT { \l__scontents_writing_bool && \l__scontents_overwrite_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}
+ \file_if_exist:nTF {#1}
+ { \msg_warning:nnx { scontents } { overwrite-file } {#1} }
+ { \msg_warning:nnx { scontents } { writing-file } {#1} }
+ \iow_open:Nn \l__scontents_file_iow {#1}
+ }
+ \bool_if:nT { \l__scontents_writing_bool && !\l__scontents_overwrite_bool }
+ {
+ \file_if_exist:nF {#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
+ \int_step_function:nnnN { 128 } { 1 } { 255 } \char_set_catcode_letter:n
\cs_set_protected:Npx \__scontents_ret:w ##1 ^^M
{
\exp_not:N \__scontents_verb_processor_iterate:w
@@ -361,48 +391,65 @@
\__scontents_make_control_chars_active:
\__scontents_ret:w
}
- \use:x
+ \cs_new:Npn \__scontents_setup_verb_processor:
{
- \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
- {
- \__scontents_format_case:nnn
- { \exp_not:N \end{scontents} } % LaTeX
- { \endscontents } % Plain/Generic
- { \stopscontents } % ConTeXt
- \bool_lazy_or:nnF
- { \tl_if_blank_p:n {#2} }
- { \str_if_eq_p:ee {#2} { \c_percent_str } }
- {
- \str_if_eq:VnF \c__scontents_hidden_space_str {#2}
- { \msg_warning:nnn { scontents } { rescanning-text } {#2} }
- \__scontents_rescan_tokens:n {#2}
- }
- }
- \char_set_active_eq:NN ^^M \__scontents_ret:w
- }
- }
- ^^M
- }
+ \use:x
+ {
+ \cs_set: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
+ } { \__scontents_verb_processor_iterate:nnn {##1} {##2} {##3} }
+ }
+ \cs_new:Npn \__scontents_verb_processor_iterate:nnn #1 #2 #3
+ {
+ \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
+ {
+ \__scontents_env_end_function:
+ \bool_lazy_or:nnF
+ { \tl_if_blank_p:n {#2} }
+ { \str_if_eq_p:ee {#2} { \c_percent_str } }
+ {
+ \str_if_eq:VnF \c__scontents_hidden_space_str {#2}
+ {
+ \msg_warning:nnnn { scontents } { rescanning-text }
+ {#2} { \tl_use:N \l__scontents_env_name_tl }
+ }
+ \__scontents_rescan_tokens:n {#2}
+ }
+ }
+ \char_set_active_eq:NN ^^M \__scontents_ret:w
+ }
+ }
+ ^^M
+ }
+ \cs_new:Npn \__scontents_env_end_function:
+ {
+ \__scontents_format_case:nnn
+ { \exp_not:N \end { \if_false: } \fi: }
+ { \exp_after:wN \exp_not:N \cs:w end }
+ { \exp_after:wN \exp_not:N \cs:w stop }
+ \tl_use:N \l__scontents_env_name_tl
+ \__scontents_format_case:nnn
+ { \if_false: { \fi: } }
+ { \cs_end: }
+ { \cs_end: }
+ }
\cs_new_protected:Npn \__scontents_file_write_stop:N #1
{
\bool_if:NT \l__scontents_writing_bool
@@ -441,56 +488,92 @@
\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_verb_processor_output:n { x }
\cs_generate_variant:Nn \__scontents_file_tl_write_start:n { V }
+\cs_new_protected:Npn \__scontents_analyse_nesting:n #1
+ {
+ \int_zero:N \l__scontents_tmpa_int
+ \__scontents_analyse_nesting_format:n {#1}
+ \int_compare:nNnT { \l__scontents_tmpa_int } > { 1 }
+ { \msg_warning:nn { scontents } { multiple-begin } }
+ }
+\cs_new_protected:Npn \__scontents_nesting_incr:
+ {
+ \int_incr:N \l__scontents_env_nesting_int
+ \int_incr:N \l__scontents_tmpa_int
+ }
+\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 { }
+\use:x
+ {
+ \cs_new_protected:Npn \exp_not:N \__scontents_analyse_nesting_latex:w ##1
+ \c_backslash_str begin \c_left_brace_str ##2 \c_right_brace_str
+ } {
+ \__scontents_tl_if_head_is_q_mark:nTF {#2}
+ { \__scontents_use_none_delimit_by_q_stop:w }
+ {
+ \str_if_eq:VnT \l__scontents_env_name_tl {#2}
+ { \__scontents_nesting_incr: }
+ \__scontents_analyse_nesting_latex:w
+ }
+ }
+\cs_new_protected:Npx \__scontents_analyse_nesting_latex:n #1
+ {
+ \__scontents_analyse_nesting_latex: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
+ }
+\cs_new_protected:Npn \__scontents_analyse_nesting_generic_process:nn #1 #2
+ {
+ \tl_if_head_is_N_type:nTF {#2}
+ {
+ \__scontents_tl_if_head_is_q_mark:nF {#2}
+ {
+ \__scontents_nesting_incr:
+ \__scontents_analyse_nesting_generic:w #2 \q__scontents_stop
+ }
+ }
+ { \__scontents_analyse_nesting_generic:w #2 \q__scontents_stop }
+ }
+\cs_new_protected:Npn \__scontents_analyse_nesting_generic:nn #1 #2
+ {
+ \__scontents_define_generic_nesting_function:n {#1}
+ \use:x
+ {
+ \exp_not:N \__scontents_analyse_nesting_generic:w #2
+ \c_backslash_str #1 \tl_use:N \l__scontents_env_name_tl
+ \exp_not:N \q__scontents_mark \exp_not:N \q__scontents_stop
+ }
+ }
+\cs_new_protected:Npn \__scontents_define_generic_nesting_function:n #1
+ {
+ \use:x
+ {
+ \cs_set_protected:Npn \exp_not:N \__scontents_analyse_nesting_generic:w ####1
+ \c_backslash_str #1 \tl_use:N \l__scontents_env_name_tl
+ ####2 \exp_not:N \q__scontents_stop
+ } { \__scontents_analyse_nesting_generic_process:nn {##1} {##2} }
+ }
\cs_new_protected:Npn \__scontents_atend_environment:
{
\bool_if:NT \l__scontents_storing_bool
{
\bool_if:NF \l__scontents_forced_eol_bool
- { \tl_put_right:Nx \l__scontents_macro_tmp_tl { \c__scontents_hidden_space_str } }
- \__scontents_store_to_seq:NN \l__scontents_macro_tmp_tl \l__scontents_name_seq_env_tl
+ {
+ \tl_put_right:Nx \l__scontents_macro_tmp_tl
+ { \c__scontents_hidden_space_str }
+ }
+ \__scontents_store_to_seq:NN \l__scontents_macro_tmp_tl
+ \l__scontents_name_seq_env_tl
\bool_if:NT \l__scontents_print_env_bool
{ \__scontents_lastfrom_seq:n \l__scontents_name_seq_env_tl }
}
@@ -557,7 +640,10 @@
{ \l__scontents_foreach_stop_int }
\__scontents_foreach_add_body:n
\tl_gset:Nx \g__scontents_temp_tl
- { \seq_use:Nn \l__scontents_foreach_print_seq { \tl_use:N \l__scontents_foreach_sep_tl } }
+ {
+ \seq_use:Nn \l__scontents_foreach_print_seq
+ { \tl_use:N \l__scontents_foreach_sep_tl }
+ }
\group_end:
\exp_after:wN \tl_gclear:N
\exp_after:wN \g__scontents_temp_tl
@@ -632,6 +718,15 @@
\char_generate:nn { `#1 } { 12 }
}
}
+\prg_new_protected_conditional:Npnn \__scontents_tl_if_head_is_q_mark:n #1
+ { T, F, TF }
+ {
+ \if_meaning:w \q__scontents_mark #1 \scan_stop:
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
\cs_new_protected:Npn \__scontents_set_active_eq:NN #1
{
\char_set_catcode_active:N #1
@@ -675,18 +770,25 @@
\\ \\
#2
}
+\msg_new:nnnn { scontents } { env-already-defined }
+ { Environment~'#1'~already~defined! }
+ {
+ You~have~used~\newenvsc
+ with~an~environment~that~already~has~a~definition. \\ \\
+ The~existing~definition~of~'#1'~will~not~be~altered.
+ }
\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:. }
-\msg_new:nnn { scontents } { rewriting-file }
- { Overwriting ~ file ~ '#1' }
+\msg_new:nnn { scontents } { overwrite-file }
+ { Overwriting~file~'#1'. }
\msg_new:nnn { scontents } { writing-file }
- { Writing ~ file ~ '#1' }
+ { Writing~file~'#1'. }
\msg_new:nnn { scontents } { rescanning-text }
- { Rescanning~text~'#1'~after~\c_backslash_str end{scontents}~\msg_line_context:.}
+ { Rescanning~text~'#1'~after~\c_backslash_str end{#2}~\msg_line_context:.}
\msg_new:nnn { scontents } { multiple-begin }
- { Multiple~\c_backslash_str begin{scontents}~\msg_line_context:.}
+ { Multiple~\c_backslash_str begin{ \l__scontents_env_name_tl }~\msg_line_context:.}
\msg_new:nnn { scontents } { undefined-storage }
{ Storage~named~'#1'~is~not~defined. }
\msg_new:nnn { scontents } { index-out-of-range }
@@ -700,15 +802,21 @@
}
}
\msg_new:nnnn { scontents } { env-key-unknown }
- { The~key~'#1'~is~unknown~by~environment~'scontents'~and~is~being~ignored.}
{
- The~environment~'scontents'~does~not~have~a~key~called~'#1'.\\
+ The~key~'#1'~is~unknown~by~environment~
+ '\l__scontents_env_name_tl'~and~is~being~ignored.
+ }
+ {
+ The~environment~'\l__scontents_env_name_tl'~does~not~have~a~key~called~'#1'.\\
Check~that~you~have~spelled~the~key~name~correctly.
}
\msg_new:nnnn { scontents } { env-key-value-unknown }
- { The~key~'#1=#2'~is~unknown~by~environment~'scontents'~and~is~being~ignored. }
{
- The~environment~'scontents'~does~not~have~a~key~called~'#1'.\\
+ The~key~'#1=#2'~is~unknown~by~environment~
+ '\l__scontents_env_name_tl'~and~is~being~ignored.
+ }
+ {
+ The~environment~'\l__scontents_env_name_tl'~does~not~have~a~key~called~'#1'.\\
Check~that~you~have~spelled~the~key~name~correctly.
}
\msg_new:nnnn { scontents } { cmd-key-unknown }
@@ -748,7 +856,7 @@
This~command~only~accepts~the~key~'width-tab'.
}
\msg_new:nnn { scontents } { empty-environment }
- { scontents~environment~empty~\msg_line_context:. }
+ { environment~'#1'~empty~\msg_line_context:. }
\msg_new:nnnn { scontents } { verbatim-newline }
{ Verbatim~argument~of~#1~ended~by~end~of~line. }
{
diff --git a/Master/texmf-dist/tex/generic/scontents/scontents.tex b/Master/texmf-dist/tex/generic/scontents/scontents.tex
index 24d0ee99dcf..03078a4cc9f 100644
--- a/Master/texmf-dist/tex/generic/scontents/scontents.tex
+++ b/Master/texmf-dist/tex/generic/scontents/scontents.tex
@@ -27,8 +27,8 @@
%% t-scontents.mkiv and
%% scontents-code.tex.
%%
-\def\ScontentsFileDate{2019-10-29}%
-\def\ScontentsFileVersion{1.7}%
+\def\ScontentsFileDate{2019-11-18}%
+\def\ScontentsFileVersion{1.8}%
\def\ScontentsFileDescription{Stores LaTeX contents in memory or files}%
\input expl3-generic.tex
\ExplSyntaxOn
@@ -36,7 +36,7 @@
v\ScontentsFileVersion\space \ScontentsFileDescription }
\iow_log:x { Package: ~ scontents ~ \use:c { ver @ scontents . sty } }
\msg_gset:nnn { scontents } { already-loaded }
- { The~`scontents'~package~is~already~loaded.~Aborting~input~\msg_line_context:. }
+ { The~'scontents'~package~is~already~loaded.~Aborting~input~\msg_line_context:. }
\cs_if_exist:NT \__scontents_rescan_tokens:n
{
\msg_warning:nn { scontents } { already-loaded }
@@ -54,7 +54,7 @@
{
\c_backslash_str
end
- scontents
+ \exp_not:N \l__scontents_env_name_tl
}
\file_input:n { scontents-code.tex }
\cs_new:Npn \__scontents_format_case:nnn #1 #2 #3
@@ -98,9 +98,12 @@
\clist_map_function:NN \l__scontents_temp_tl \__scontents_require_auxiii:n
}
\cs_new_protected:Npn \__scontents_require_auxiii:n #1
- { \str_if_eq:eeF {expl3} {#1} { \msg_error:nnn { scontents } { invalid-package } {#1} } }
+ {
+ \str_if_eq:eeF {expl3} {#1}
+ { \msg_error:nnn { scontents } { invalid-package } {#1} }
+ }
\msg_new:nnn { scontents } { invalid-package }
- { Package~`#1'~invalid~in~scontents.~This~is~an~error~in~scontents. }
+ { Package~'#1'~invalid~in~scontents.~This~is~an~error~in~scontents. }
\__scontents_compat_redefine:cpn { @ifpackagelater } #1
{ \exp_args:Nc \__scontents_package_later_aux:Nn { ver@#1.sty } }
\cs_new_protected:Npn \__scontents_package_later_aux:Nn #1 #2
@@ -115,7 +118,7 @@
\cs_new:Npn \__scontents_parse_version_auxii:w #1-#2-#3#4#5 \q_mark
{ \tl_if_blank:nF {#2} {#1} #2 #3 #4 }
\__scontents_compat_redefine:Npn \ProvidesExplPackage #1 #2 #3 #4
- { \__scontents_provides_aux:nn {#1} { #2 \ifx\relax#3\relax\else v#3\space\fi #4 } }
+ { \__scontents_provides_aux:nn {#1} { #2 \tl_if_empty:nF {#3} {#3~} #4 } }
\cs_new_protected:Npn \__scontents_provides_aux:nn #1 #2
{
\tl_gset:cx { ver@#1.sty } {#2}
@@ -134,22 +137,35 @@
\ExplSyntaxOn
\char_set_catcode:nn { `\@ } { \l__scontents_tmpa_int }
\__scontents_compat_restore:
-\NewDocumentEnvironment { scontents } { }
+\NewDocumentCommand { \newenvsc } { m O{} }
{
- \group_begin:
- \__scontents_scontents_env_begin:
+ \cs_if_exist:cTF { #1 }
+ { \msg_error:nnn { scontents } { env-already-defined } {#1} }
+ { \__scontents_scontents_setenv:nn {#1} {#2} }
}
+\cs_new_protected:Npn \__scontents_env_define:nnn #1 #2 #3
{
- \__scontents_scontents_env_end:
- \group_end:
+ \NewDocumentEnvironment {#1} { }
+ {
+ \group_begin:
+ #2
+ }
+ {
+ #3
+ \group_end:
+ }
}
+\newenvsc{scontents}
\NewDocumentCommand \__scontents_grab_optional:w { r[] }
{ \__scontents_grab_optional:n {#1} }
+\cs_new_protected:Npn \__scontents_analyse_nesting_format:n
+ { \__scontents_analyse_nesting_generic:nn { } }
\bool_new:N \l__scontents_temp_bool
\cs_new_protected:Npn \verbatimsc
{
\group_begin:
- \__scontents_verbatimsc_aux: \frenchspacing \__scontents_vobeyspaces: \__scontents_xverb:
+ \__scontents_verbatimsc_aux: \frenchspacing \__scontents_vobeyspaces:
+ \__scontents_xverb:
}
\cs_new_protected:Npn \endverbatimsc
{ \group_end: }
@@ -199,7 +215,7 @@
{ \__scontents_Scontents_internal:nn {#1} {#2} }
\NewDocumentCommand { \__scontents_verb_arg:w } { +v }
{ \__scontents_verb_arg_internal:n {#1} }
-\NewDocumentCommand { \getstored } { O{1} m }
+\NewDocumentCommand { \getstored } { O{-1} m }
{ \__scontents_getstored_internal:nn {#1} {#2} }
\NewDocumentCommand { \foreachsc } { o m }
{ \__scontents_foreachsc_internal:nn {#1} {#2} }
diff --git a/Master/texmf-dist/tex/latex/scontents/scontents.sty b/Master/texmf-dist/tex/latex/scontents/scontents.sty
index ceb700d4348..77147e8ecf7 100644
--- a/Master/texmf-dist/tex/latex/scontents/scontents.sty
+++ b/Master/texmf-dist/tex/latex/scontents/scontents.sty
@@ -27,21 +27,21 @@
%% t-scontents.mkiv and
%% scontents-code.tex.
%%
-\def\ScontentsFileDate{2019-10-29}%
-\def\ScontentsFileVersion{1.7}%
+\def\ScontentsFileDate{2019-11-18}%
+\def\ScontentsFileVersion{1.8}%
\def\ScontentsFileDescription{Stores LaTeX contents in memory or files}%
\RequirePackage{expl3,xparse,l3keys2e}[2019/05/28]
\ProvidesExplPackage
{scontents} {\ScontentsFileDate} {\ScontentsFileVersion} {\ScontentsFileDescription}
\@ifpackageloaded { verbatim }
{
- \iow_term:n
+ \msg_set:nnn { scontents } { unsupported-verbatim }
{
- The~implementation~of~the~'verbatimsc'~environment~\\
- used~by~\tl_to_str:n{\typestored}~is~not~compatible~with~package\\
- 'verbatim'.~Review~the~documentation~and~redefine~\\
- the~'verbatimsc'~environment.
+ The~implementation~of~the~'verbatimsc'~environment~used~by~
+ \iow_char:N \\typestored~is~not~compatible~with~package~'verbatim'.~
+ Review~the~documentation~and~redefine~the~'verbatimsc'~environment.
}
+ \msg_warning:nn { scontents } { unsupported-verbatim }
} { }
\tl_new:N \g__scontents_end_verbatimsc_tl
\tl_gset_rescan:Nnn
@@ -57,7 +57,7 @@
\c_backslash_str
end
\c_left_brace_str
- scontents
+ \exp_not:N \l__scontents_env_name_tl
\c_right_brace_str
}
\file_input:n { scontents-code.tex }
@@ -66,20 +66,32 @@
\keys_define:nn { scontents }
{ verb-font .initial:n = \ttfamily }
\ProcessKeysOptions { scontents }
-\NewDocumentEnvironment { scontents } { }
+\NewDocumentCommand { \newenvsc } { m O{} }
{
- \__scontents_scontents_env_begin:
+ \cs_if_exist:cTF { #1 }
+ { \msg_error:nnn { scontents } { env-already-defined } {#1} }
+ { \__scontents_scontents_setenv:nn {#1} {#2} }
}
+\cs_new_protected:Npn \__scontents_env_define:nnn #1 #2 #3
{
- \__scontents_scontents_env_end:
+ \NewDocumentEnvironment {#1} { }
+ {
+ #2
+ }
+ {
+ #3
+ }
}
+\newenvsc{scontents}
\NewDocumentCommand \__scontents_grab_optional:w { r[] }
{ \__scontents_grab_optional:n {#1} }
+\cs_new_eq:NN \__scontents_analyse_nesting_format:n
+ \__scontents_analyse_nesting_latex:n
\NewDocumentCommand { \Scontents }{ !s !O{} }
{ \__scontents_Scontents_internal:nn {#1} {#2} }
\NewDocumentCommand { \__scontents_verb_arg:w } { +v }
{ \__scontents_verb_arg_internal:n {#1} }
-\NewDocumentCommand { \getstored } { O{1} m }
+\NewDocumentCommand { \getstored } { O{-1} m }
{ \__scontents_getstored_internal:nn {#1} {#2} }
\NewDocumentCommand { \foreachsc } { o m }
{ \__scontents_foreachsc_internal:nn {#1} {#2} }