texlive[71533] Master/texmf-dist: scontents (15jun24)

commits+karl at tug.org commits+karl at tug.org
Sat Jun 15 21:53:38 CEST 2024


Revision: 71533
          https://tug.org/svn/texlive?view=revision&revision=71533
Author:   karl
Date:     2024-06-15 21:53:38 +0200 (Sat, 15 Jun 2024)
Log Message:
-----------
scontents (15jun24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/scontents/README.md
    trunk/Master/texmf-dist/doc/latex/scontents/scontents.pdf
    trunk/Master/texmf-dist/source/latex/scontents/scontents.dtx
    trunk/Master/texmf-dist/source/latex/scontents/scontents.ins
    trunk/Master/texmf-dist/tex/context/third/scontents/t-scontents.mkiv
    trunk/Master/texmf-dist/tex/generic/scontents/scontents-code.tex
    trunk/Master/texmf-dist/tex/generic/scontents/scontents.tex
    trunk/Master/texmf-dist/tex/latex/scontents/scontents.sty

Modified: trunk/Master/texmf-dist/doc/latex/scontents/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/scontents/README.md	2024-06-15 19:53:25 UTC (rev 71532)
+++ trunk/Master/texmf-dist/doc/latex/scontents/README.md	2024-06-15 19:53:38 UTC (rev 71533)
@@ -1,6 +1,6 @@
 ## scontents — Stores LaTeX contents in memory or files
 
-Release v2.0 \[2022-04-04\]
+Release v2.1 \[2024-06-14\]
 
 ## Description
 
@@ -13,7 +13,7 @@
 
 The package loads and depends on updated versions of:
 - [expl3](https://ctan.org/pkg/expl3)
-- [l3keys2e](https://ctan.org/pkg/l3keys2e)
+- [latex-base](https://www.ctan.org/pkg/latex-base)
 
 ## Installation
 
@@ -68,4 +68,4 @@
 
 ## Author and copyright
 
-Copyright 2019-2022 by Pablo González L.
+Copyright 2019-2023 by Pablo González L.

Modified: trunk/Master/texmf-dist/doc/latex/scontents/scontents.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/scontents/scontents.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/scontents/scontents.dtx	2024-06-15 19:53:25 UTC (rev 71532)
+++ trunk/Master/texmf-dist/source/latex/scontents/scontents.dtx	2024-06-15 19:53:38 UTC (rev 71533)
@@ -1,12 +1,12 @@
 % \iffalse meta-comment
 %
-% Copyright (C) 2019-2022 by Pablo González L <pablgonz at educarchile.cl>
+% Copyright (C) 2019-2024 by Pablo González L <pablgonz at educarchile.cl>
 %
 % This work may be distributed and/or modified under the conditions of the
 % LaTeX Project Public License, either version 1.3c of this license or (at
 % your option) any later version. The latest version of this license is in
 %
-%  http://www.latex-project.org/lppl.txt
+%  https://www.latex-project.org/lppl.txt
 %
 % and version 1.3c or later is part of all distributions of LaTeX version
 % 2005/12/01 or later.
@@ -32,6 +32,7 @@
 % so that entries written to both streams end up in the same file.
 \usepackage[english]{babel}
 \usepackage[top=0.5in,bottom=0.3in,left=2in,right=0.7in,footskip=0.2in,headheight=1cm,headsep=0.27cm]{geometry}
+\usepackage[llscaled=0.95]{libertine} % need by setup-texlive-action at v3
 \usepackage[osf,nomath,mono=false,ScaleSF=0.95,ScaleRM=0.95]{libertinus-otf}
 % Set Monospace font, fix 'quotes' in verbatim
 \usepackage{sourcecodepro}
@@ -64,7 +65,7 @@
 % a letter `j'. The doc package ensures that mathcode and the | actually prints
 % a j inside docstrip guards. This changes the mathcode of | to 07C:
 \makeatletter
-\def\mod at math@codes{\mathcode`\|="207C \mathcode`\&="2026
+\def\mod at math@codes{\mathcode`\|="207C \mathcode`\&="2026 %
                     \mathcode`\-="702D \mathcode`\+="702B
                     \mathcode`\:="703A \mathcode`\=="703D }
 \makeatother
@@ -73,7 +74,7 @@
 \newfontfamily\fetamontotf{ffmw10.otf}[
    Scale             = 0.95,%
    RawFeature        = {+latn,+rand,+kern,+size},%
-   FontFace          = {b}{n}{ffmw10.otf},% fix raplece font
+   FontFace          = {b}{n}{ffmw10.otf},% fix replace font
    ]
 \usepackage[svgnames]{xcolor}
 \usepackage[sf,bf,compact,medium,pagestyles]{titlesec}
@@ -173,7 +174,7 @@
 % User level commands
 \ExplSyntaxOn
 % Logo with fetamont font
-\NewDocumentCommand{\pkglogo}{}
+\NewDocumentCommand \pkglogo {}
   {
     \group_begin:
     \fetamontotf{\textcolor{pkgcolor}{s}\textcolor{OrangeRed}{content}\textcolor{pkgcolor}{s}}
@@ -181,15 +182,15 @@
   }
 
 % Custom \meta[...]{...}, \marg[...]{...} and \oarg[...]{...} with color
-\NewDocumentCommand{\mymeta}{O{}m}
+\NewDocumentCommand \mymeta {O{}m}
   {
     \userdoc_meta_generic:Nnn \userdoc_meta:n { #1 } { #2 }
   }
-\NewDocumentCommand{\mymarg}{O{}m}
+\NewDocumentCommand \mymarg {O{}m}
   {
     \userdoc_meta_generic:Nnn \userdoc_marg:n { #1 } { #2 }
   }
-\NewDocumentCommand{\myoarg}{O{}m}
+\NewDocumentCommand \myoarg {O{}m}
   {
     \userdoc_meta_generic:Nnn \userdoc_oarg:n { #1 } { #2 }
   }
@@ -263,7 +264,7 @@
   }
 % \envexamp{m}
 \newsavebox{\boxexaenv}
-\NewDocumentCommand{\envexamp}{m}
+\NewDocumentCommand \envexamp {m}
   {
    \begin{lrbox}{\boxexaenv}%
     \begin{minipage}[t]{\marginparwidth}%
@@ -276,7 +277,7 @@
    \end{lrbox}%
    \usebox{\boxexaenv}
   }
-\NewDocumentCommand{\envexaplain}{O{} m O{end}}
+\NewDocumentCommand \envexaplain {O{} m O{end}}
   {
    \begin{lrbox}{\boxexaenv}%
     \begin{minipage}[t]{\marginparwidth}%
@@ -291,7 +292,7 @@
   }
 
 % \cmdexamp{s m o m o}
-\DeclareDocumentCommand{\cmdexamp}{o m o m o}
+\DeclareDocumentCommand \cmdexamp {o m o m o}
   {
     \group_begin:
     \small\ttfamily
@@ -309,57 +310,62 @@
     \group_end:
   }
 
-% \keyexamp{mmm}
-\DeclareDocumentCommand{\keyexamp}{ m m m }
+% \keyexamp*{m m m}
+\NewDocumentCommand \keyexamp{s m m m }
   {
-    \par
-    \adjustbox{outer=-\marginparsep}{\textcolor{black}{\small\ttfamily{#1}}}
-    \textcolor{gray}{\,\bfseries\texttt{=}}\,{}
-    \mymarg[type=tt,cbc=gray,ac=lightgray,cf=optcolor]{\small{#2}}
-    \hfill\textcolor{gray}{\small\textsf{default}:~\emph{#3}}
-    \par
-    \MYSortIndex{Keys}{Keys>\texttt{#1}}%
+    \adjustbox{outer=-\marginparsep}{\textcolor{optcolor}{\small\ttfamily{#2}}}
+    \IfBooleanTF{#1}
+      {
+        \hphantom{\textcolor{white}{\,\bfseries\texttt{=}}\,{}}
+        \mymeta[type=tt,cbc=gray,ac=lightgray,cf=lightgray]{\small{#3}}
+      }
+      {
+        \textcolor{gray}{\,\bfseries\texttt{=}}\,{}
+        \mymarg[type=tt,cbc=gray,ac=lightgray,cf=optcolor]{\small{#3}}
+      }
+    \hfill\textcolor{gray}{\small\textsf{default}:~\emph{#4}}\par%
+    \MYSortIndex{Keys}{Keys ~ provide ~ by ~ \pkglogo :>\texttt{#2}}
   }
 
 % \mykey{m}
-\DeclareDocumentCommand{\mykey}{ m }
+\NewDocumentCommand \mykey { m }
   {
     \textcolor{optcolor}{\texttt{#1}}
-    \MYSortIndex{Keys}{Keys>\texttt{#1}}%
+    \MYSortIndex{Keys}{Keys ~ provide ~ by ~\pkglogo :>\texttt{#1}}%
   }
 
 % \mypkg{sm}
-\NewDocumentCommand{\mypkg}{sm}
+\NewDocumentCommand \mypkg {sm}
   {
     \group_begin:
     \IfBooleanTF{#1}
       {
         \pkglogo
-        \MYSortIndex{packages}{Packages>\texttt{#2}}
+        \MYSortIndex{packages}{Packages:>\texttt{#2}}
       }
       {
         \textcolor{darkgray}{\textsf{#2}}
-        \MYSortIndex{packages}{Packages>\texttt{#2}}%
+        \MYSortIndex{packages}{Packages:>\texttt{#2}}%
       }
      \group_end:
   }
 
 % \myenv{sm}
-\DeclareDocumentCommand{\myenv}{sm}
+\NewDocumentCommand \myenv {sm}
   {
     \IfBooleanTF{#1}
       {
         \textcolor{pkgcolor}{\ttfamily{#2}}%
-        \MYSortIndex{environment}{ Environment ~ provide ~ by ~\pkglogo :>\texttt{#2}}
+        \MYSortIndex{environment}{Environments ~ provide ~ by ~\pkglogo :>\texttt{#2}}
       }
       {
         \textcolor{darkgray}{\ttfamily{#2}}%
-        \MYSortIndex{environment}{Environments>\texttt{#2}}
+        \MYSortIndex{environment}{Environments:>\texttt{#2}}
       }
   }
 
 % \ics{sm}
-\DeclareDocumentCommand{\ics}{sm}
+\NewDocumentCommand \ics {sm}
   {
     \IfBooleanTF{#1}
       {
@@ -373,6 +379,27 @@
         \MYSortIndex{#2}{\texttt{\textbackslash#2}}
       }
   }
+% \bomba
+\NewDocumentCommand \bomba { }
+  {
+    \par\hspace*{-0.5\marginparsep}%
+    \makebox[0pt][r]
+      {
+        \makebox[\marginparsep][r]
+          {
+            \footnotesize\textcolor{pkgcolor}{\faIcon{bomb}}
+          }
+      }
+    \hskip 0.5\marginparsep
+  }
+\NewDocumentEnvironment{important}{ s }
+  {
+    \sffamily
+    \bomba%
+    \IfBooleanTF{#1}
+      { \small }
+      { \color{OrangeRed}\Large }
+  }{}
 \ExplSyntaxOff
 
 % email https://tex.stackexchange.com/a/663
@@ -429,7 +456,7 @@
     keywords      = [3]{document,article,setlength,pagestyle,definecolor},%
 % Reserved words 4 (scontents pkg)
     keywordstyle  = [4]{\color{pkgcolor}},%
-    keywords      = [4]{scontents,Scontents,getstored,typestored,verbatimsc,%
+    keywords      = [4]{scontents,Scontents,getstored,typestored,verbatimsc, mergesc, %
                     endverbatimsc,countsc,meaningsc,foreachsc,macros,newenvsc,
                     endscontents,startscontents,stopscontents,scontents.tex},%
 % Reserved words 5 (in red)
@@ -483,7 +510,7 @@
                     {.8}{{\textcolor{MediumOrchid}{.8}}}{2}
                     {.9}{{\textcolor{MediumOrchid}{.9}}}{2}
                     {=}{{\textcolor{gray}{=}}}{1},%
-}[keywords,tex,comments,strings]% end languaje
+}[keywords,tex,comments,strings]% end language
 
 % \begin{examplecode}[key=val]...\end{examplecode}
 \lstnewenvironment{examplecode}[1][]{%
@@ -550,7 +577,7 @@
 }
 \setfoot{\rlap{\hskip\dimexpr-\oddsidemargin-1in\relax%
          \parbox{1.93\paperwidth}{\hfil\thepage\,/\,\pageref{LastPage}}}}%
-        {\parbox{\textwidth}{\raggedright \textcolor{gray}{\raisebox{-1pt}{\textcopyright}{}2019--2022 by Pablo González}}}%
+        {\parbox{\textwidth}{\raggedright \textcolor{gray}{\raisebox{-1pt}{\textcopyright}{}2019--2024 by Pablo González}}}%
         {}%
 \sethead{\llap{\raisebox{0.55cm}{\parbox{\dimexpr\oddsidemargin+1in\relax}{\makebox[0pt][l]{\hspace{15pt}\pkglogo\space\fileversion}}}}}
         {\raisebox{0.55cm}{\parbox{\textwidth}{\hspace*{-\oddsidemargin}\centering\small\S.\thesection\space\sectiontitle}}}%
@@ -605,7 +632,7 @@
 %    \filedate.}\\[25pt]
 %    \author{
 %    \large
-%    \raisebox{-1pt}{\textcopyright}{}2019--2022 by Pablo González\thanks{
+%    \raisebox{-1pt}{\textcopyright}{}2019--2024 by Pablo González\thanks{
 %    E-mail: \textcolor{OrangeRed}{\textsf{\guillemotleft}}\email{pablgonz at educarchile.cl}\textcolor{OrangeRed}{\textsf{\guillemotright}}.
 %       }%
 %    }
@@ -628,6 +655,10 @@
 %
 % \tableofcontents
 %
+% \begin{important}
+% The next update removes compatibility with versions prior to 2024.
+% \end{important}
+%
 % \setlength{\parskip}{3pt}
 %
 % \section{Description of the package}
@@ -681,12 +712,14 @@
 %
 % Permission is granted to copy, distribute and/or modify this software under
 % the terms of the LaTeX Project Public License (lppl), version 1.3 or later
-% (\url{http://www.latex-project.org/lppl.txt}). The software has the status
+% (\url{https://www.latex-project.org/lppl.txt}). The software has the status
 % \enquote{maintained}.
 %
-% The \mypkg*{scontents} package loads \mypkg{expl3} (minimum version 2020-02-08) and
-% \mypkg{l3keys2e}. This package can be used with "plain", "context", "xelatex",
-% "lualatex", "pdflatex" and the classical workflow §latex>dvips>ps2pdf§.
+% The The \mypkg*{scontents} package is written (mostly) using
+% \mypkg{expl3}, it requires an updated version of \LaTeX{} to work
+% (minimum version 2022-06-01). This package can be used with "plain",
+% "context", "xelatex", "lualatex", "pdflatex" and the classical workflow
+% §latex>dvips>ps2pdf§.
 %
 % \section{The \texttt{scontents} package}
 % \label{sec:pkgscontents}
@@ -772,6 +805,10 @@
 %</example>
 % \fi
 %
+% \begin{important}*
+% \hologo{ConTeXt} users should use |-luatex|, the implementation does not support LuaMetaTeX.
+% \end{important}
+%
 % \subsection{The TAB character}
 % \label{sec:tabcharacter}
 %
@@ -984,6 +1021,7 @@
 %   \envexaplain[start]{scontents}[stop]
 %   \end{syntax}
 % \end{function}
+%
 % \subsection*{Options for environment}
 %
 % The environment options can be configured globally using option
@@ -1184,45 +1222,43 @@
 % on the contents stored in \mymarg{seq name}. If you pass without options run
 % §\getstored§ on all contents stored in \mymarg{seq name}.
 %
-% \subsection*{Options for command}
+% \subsubsection*{Options for command}
 % \label{sec:optcmdfor}
 %
 % \keyexamp{sep}{code}{empty}
-% Establishes the separation between each content stored in \mymarg{seq name}.
+% Establishes the separation between each content stored in \mymarg[type=tt]{seq name}.
 % For example, you can use §sep={\\[10pt]}§ for vertical separation of stored
 % contents.
 %
 % \keyexamp{step}{integer}{1}
 % Sets the increment (\mymeta{step}) applied to the value set by key §start§
-% for each element stored in the \mymarg{seq name}. The value must be a
+% for each element stored in the \mymarg[type=tt]{seq name}. The value must be a
 % \mymeta{positive integer}.
 %
 % \keyexamp{start}{integer}{1}
-% Sets the \mymeta{index} number of the \mymarg{seq name} from which execution
+% Sets the \mymeta{index} number of the \mymarg[type=tt]{seq name} from which execution
 % will start. The value must be a \mymeta{positive integer}.
 %
 % \keyexamp{stop}{integer}{total}
-% Sets the \mymeta{index} number of the \mymarg{seq name} from which execution
+% Sets the \mymeta{index} number of the \mymarg[type=tt]{seq name} from which execution
 % it will finish executing. The value must be a \mymeta{positive integer}.
 %
 % \keyexamp{before}{code}{empty}
-% Sets the \mymarg{code} that will be executed \mymeta{before} each content stored
-% in \mymarg{seq name}. The \mymarg{code} must be passed between braces.
+% Sets the \mymarg[type=tt]{code} that will be executed \mymeta{before} each content stored
+% in \mymarg[type=tt]{seq name}. The \mymarg[type=tt]{code} must be passed between braces.
 %
-% \medskip
-%
 % \keyexamp{after}{code}{empty}
-% Sets the \mymarg{code} that will be executed \mymeta{after} each content stored
-% in \mymarg{seq name}. The \mymarg{code} must be passed between braces.
+% Sets the \mymarg[type=tt]{code} that will be executed \mymeta{after} each content stored
+% in \mymarg[type=tt]{seq name}. The \mymarg[type=tt]{code} must be passed between braces.
 %
 % \newsavebox{\hashbox}
 % \begin{lrbox}{\hashbox}
-% \lstinline[language=scontents-doc,basicstyle=\ttfamily]+{#1}+
+% \lstinline[language=scontents-doc,basicstyle=\small\ttfamily]+{#1}+
 % \end{lrbox}
 %
 % \keyexamp{wrapper}{code{} \space\usebox{\hashbox} more code}{empty}
-% Wraps the content stored in \mymarg{seq name} referenced by §{#1}§.
-% The \mymarg{code} must be passed between braces. For example
+% Wraps the content stored in \mymarg[type=tt]{seq name} referenced by §{#1}§.
+% The \mymarg[type=tt]{code} must be passed between braces. For example
 % §\foreachsc[wrapper={\makebox[1em][l]{#1}}]{contents}§.
 %
 %
@@ -1233,17 +1269,51 @@
 %
 % \begin{function}{\typestored}
 %   \begin{syntax}
-%      \cmdexamp{typestored}[index\textnormal{\textcolor{gray}{,}} width-tab \textnormal{\textcolor{gray}{=}} number]{seq name}
+%      \cmdexamp{typestored}[index\textnormal{\textcolor{gray}{,}} 1-end\textnormal{\textcolor{gray}{,}} width-tab \textnormal{\textcolor{gray}{=}} number]{seq name}
 %   \end{syntax}
 % The command \ics*{typestored} internally places the content stored in
-% the \mymarg{seq name} into the \myenv*{verbatimsc} environment. The \mymeta{index}
-% corresponds to the position in which the content is stored in the \mymarg{seq name}.
+% the \mymarg[type=tt]{seq name} into the \myenv*{verbatimsc} environment. The \mymeta{index}
+% corresponds to the position in which the content is stored in the \mymarg[type=tt]{seq name},
+% if \mymeta[type=tt]{1-end} is used \emph{\enquote{all}} content stored in \mymarg[type=tt]{seq name} will be printed.
 % \end{function}
 %
 % If the optional argument is not passed it defaults to the first element
-% stored in the \mymarg{seq name}. The key \mykey{width-tab} is available for
+% stored in the \mymarg[type=tt]{seq name}. The key \mykey{width-tab} is available for
 % this command.
 %
+% \subsection{The command \cs{mergesc}}
+% \label{sec:mergesc}
+%
+% \vspace*{-10pt}
+%
+% \newsavebox{\argmergesc}
+% \begin{lrbox}{\argmergesc}
+% \small\mymarg[type=tt]{seq A}\myoarg[type=tt]{index}\textcolor{gray}{, }\mymarg[type=tt]{seq B}\myoarg[type=tt]{start \textcolor{gray}{-} stop}\textcolor{gray}{, }\mymarg[type=tt]{seq C}\myoarg[type=tt]{1-end}
+% \end{lrbox}
+%
+% \begin{function}{\mergesc}
+%   \begin{syntax}
+%      \cmdexamp{mergesc}[typestored \textnormal{\textcolor{lightgray}{\textbar}} meaningsc\textcolor{lightgray}{, }keys]{\usebox{\argmergesc}}
+%   \end{syntax}
+% The command \ics*{mergesc} internally assembles the content stored in
+% the \mymarg[type=tt]{seq A}§[1]§, \mymarg[type=tt]{seq B}§[2-5]§ and \mymarg[type=tt]{seq C}§[1-end]§ into a temporary internal
+% \mymeta[type=tt]{seq temp}.
+% \end{function}
+%
+% The use of the keys \mykey{typestored} or \mykey{menaingsc} are
+% \emph{\enquote{mandatory}} and disjoint from each other, the rest of the
+% accepted \mymeta{keys} are \mykey{print-cmd}, \mykey{write-out},
+% \mykey{width-tab} and \mykey{overwrite}.
+%
+% The use of the \mykey{write-out} key with this command follows the same
+% rules already described, the main advantage is that it allows to join
+% stored content \emph{without rewriting} the file over and over again,
+% by design \hologo{TeX} does not have an append mode for writing
+% files, this effectively allows you to write chunks of code and then
+% merge them into a single file.
+%
+% \newpage
+%
 % \subsection{The environment \env{verbatimsc}}
 % \label{sec:verbatimsc}
 %
@@ -1537,10 +1607,10 @@
 \usepackage{tikz}
 \setlength{\parindent}{0pt}
 \pagestyle{empty}
-\Scontents*{\matrix{ \node (a) {$a$} ; & \node (b) {$b$} ; \\ } ;}
-\Scontents*{\matrix[ampersand replacement=\&]
+\Scontents{\matrix{ \node (a) {$a$} ; & \node (b) {$b$} ; \\ } ;}
+\Scontents{\matrix[ampersand replacement=\&]
 { \node (a) {$a$} ; \& \node (b) {$b$} ; \\ } ;}
-\Scontents*{\matrix{\node (a) {$a$} ; & \node (b) {$b$} ; \\ } ; }
+\Scontents{\matrix{\node (a) {$a$} ; & \node (b) {$b$} ; \\ } ; }
 \begin{document}
 \section{tikzpicture}
 \begin{tikzpicture}
@@ -1706,9 +1776,9 @@
 %<*example>
 % \fi
 \begin{scontents}[write-out=scexamp7.ltx]
-\documentclass{article}
 % arara: pdflatex
 % arara: clean: { extensions: [ aux, log] }
+\documentclass{article}
 \usepackage{scontents}
 \makeatletter
 \let\verbatimsc\@undefined
@@ -1728,7 +1798,7 @@
 \setlength{\parindent}{0pt}
 \pagestyle{empty}
 \begin{document}
-\section{Test \texttt{\textbackslash begin\{scontents\}} whit \texttt{fancyvrb}}
+\section{Test \texttt{\textbackslash begin\{scontents\}} with \texttt{fancyvrb}}
 Test \verb+{scontents}+ \par
 
 \begin{scontents}
@@ -1735,13 +1805,13 @@
 Using \verb+scontents+ env no \verb+[key=val]+, save in seq \verb+contents+
 with index 1.
 
-Prove new \Verb*{ fancyvrb whit braces } and environment \verb+Verbatim*+
+Prove new \Verb*{ fancyvrb with braces } and environment \verb+Verbatim*+
 \begin{verbatim}
  verbatim  environment
 \end{verbatim}
 \end{scontents}
 
-\section{Test \texttt{\textbackslash Scontents} whit \texttt{fancyvrb}}
+\section{Test \texttt{\textbackslash Scontents} with \texttt{fancyvrb}}
 \Scontents{ We have coded this in \LaTeX: $E=mc^2$.}
 
 \section{Test \texttt{\textbackslash getstored}}
@@ -1798,7 +1868,7 @@
 \setlength{\parindent}{0pt}
 \pagestyle{empty}
 \begin{document}
-\section{Test \texttt{\textbackslash begin\{scontents\}} whit \texttt{listings}}
+\section{Test \texttt{\textbackslash begin\{scontents\}} with \texttt{listings}}
 Test \verb+{scontents}+ \par
 
 \begin{scontents}
@@ -1810,7 +1880,7 @@
 \end{verbatim}
 \end{scontents}
 
-\section{Test \texttt{\textbackslash Scontents*} whit \texttt{listings}}
+\section{Test \texttt{\textbackslash Scontents*} with \texttt{listings}}
 
 \Scontents*+ We have coded this in \lstinline[basicstyle=\ttfamily]|\LaTeX: $E=mc^2$|
 and more.+
@@ -1852,7 +1922,7 @@
 \pagestyle{empty}
 \setlength{\parindent}{0pt}
 \begin{document}
-\section{Test \texttt{\textbackslash begin\{scontents\}} whit \texttt{minted}}
+\section{Test \texttt{\textbackslash begin\{scontents\}} with \texttt{minted}}
 Test \verb+{scontents}+ \par
 
 \begin{scontents}[overwrite,write-env=\jobname.tsc,force-eol=true]
@@ -1859,7 +1929,7 @@
 Using \verb+scontents+ env no \verb+[key=val]+, save in seq \verb+contents+
 with index 1.\par
 
-Prove new \Verb*{ new fvextra whit braces } and environment \verb+Verbatim*+
+Prove new \Verb*{ new fvextra with braces } and environment \verb+Verbatim*+
 \begin{Verbatim}[obeytabs, showtabs, tab=\rightarrowfill, tabcolor=red]
 No tab
 	One real tab
@@ -1871,7 +1941,7 @@
 Read \Verb{\jobname.tsc} (shows TABs as red arrows):
 \VerbatimInput[obeytabs, showtabs, tab=\rightarrowfill, tabcolor=red]{\jobname.tsc}
 
-\section{Test \texttt{\textbackslash Scontents} whit \texttt{minted}}
+\section{Test \texttt{\textbackslash Scontents} with \texttt{minted}}
 
 \Scontents{ We have coded \par this in \LaTeX: $E=mc^2$.}
 
@@ -1892,6 +1962,90 @@
 % \textattachfile[color=linkcolor,print=false]{scexamp9.ltx}{\faFile*[regular]}.
 % \lstinputlisting[language=scontents-doc,numbers=left]{scexamp9.ltx}
 %
+% \subsection{The command \texttt{\textbackslash{}mergesc} in action}
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{scontents}[write-out=scexamp10.ltx]
+% arara: pdflatex
+% arara: clean: { extensions: [ aux, log] }
+\documentclass{article}
+\usepackage{scontents}
+% Fix part of a MCE that should go before babel's loading
+\begin{scontents}[store-env=mce]
+\documentclass[french]{article}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{lmodern}
+\usepackage[a4paper]{geometry}
+\end{scontents}
+% Fix part of a MCE that should go after (>=) babel's loading
+\begin{scontents}[store-env=mce]
+\usepackage{babel}
+\begin{document}
+\end{scontents}
+% Fix part of a MCE that should go after its body
+\begin{scontents}[store-env=mce]
+\end{document}
+\end{scontents}
+\begin{document}
+\section{First annswer}
+% Variable part of a MCE that should added to the fixed preamble, before babel's loading
+\begin{scontents}[store-env=mce-1]
+\usepackage{amsmath}
+\end{scontents}
+% Variable part of a MCE being the code snippet
+\begin{scontents}[store-env=mce-1]
+\begin{align}
+  0 & \neq 1 \\
+  1 & \neq 0
+\end{align}
+\end{scontents}
+\begin{description}
+\item[Preamble's addition]\leavevmode
+  \typestored[1]{mce-1}
+\item[Code snippet]\leavevmode
+  \typestored[2]{mce-1}
+\item[MCE]\leavevmode
+  \mergesc[typestored, print-cmd=true]
+    {
+      {mce}[1], {mce-1}[1], {mce}[2], {mce-1}[2], {mce}[3]
+    }
+\end{description}
+\section{Second annswer}
+% Variable part of a MCE that should added to the fixed preamble, before babel's loading
+\begin{scontents}[store-env=mce-2]
+\usepackage{amsmath}
+\end{scontents}
+% Variable part of a MCE being the code snippet
+\begin{scontents}[store-env=mce-2]
+\begin{flalign}
+  0 & \neq 1 \\
+  1 & \neq 0
+\end{flalign}
+\end{scontents}
+
+\begin{description}
+\item[Preamble's addition]\leavevmode
+  \typestored[1]{mce-2}
+\item[Code snippet]\leavevmode
+  \typestored[2]{mce-2}
+\item[MCE]\leavevmode
+  \mergesc[typestored, print-cmd=true, write-out=mce.txt, overwrite=true]
+    {
+      {mce}[1], {mce-2}[1], {mce}[2], {mce-2}[2], {mce}[3]
+    }
+\end{description}
+\end{document}
+\end{scontents}
+% \iffalse
+%</example>
+% \fi
+% The command §\mergesc§ in action, adapted from Denis Bitouzé request at \url{https://github.com/pablgonz/scontents/issues/2}
+% \textattachfile[color=linkcolor,print=false]{scexamp9.ltx}{\faFile*[regular]}.
+% \lstinputlisting[language=scontents-doc,numbers=left]{scexamp10.ltx}
+%
 % \newpage
 %
 % \section{Change history}
@@ -1910,37 +2064,47 @@
 % \begin{description}[font=\small\sffamily,wide=0pt,style=multiline,leftmargin=\descrwidth,nosep,noitemsep]
 % \item [\fileversion{} (ctan), \filedate]
 %    \begin{itemize}
-%    \item Adapting the |verbatimsc| environment (compatibility |verbatim| package).
-%    \item Removed compatibility layer for older \hologo{LaTeX} releases.
-%    \item Fix loader in \hologo{plainTeX} and \hologo{ConTeXt}.
-%    \item Minor adjustments in the documentation.
+%        \item Fix |\cleansc| command.
+%        \item Add |\mergesc| command.
+%        \item Fix internal definition for seq var.
+%        \item Fix internal code for |\typestored|.
+%        \item Replace |\cs_argument_spec:N| by |\cs_parameter_spec:N|.
+%        \item Detect |l3keys2e| package (obsolete in june 2022 \LaTeX{} release).
+%        \item Minor adjustments in the documentation.
 %    \end{itemize}
+% \item [v2.0 (ctan), 2022-04-04]
+%    \begin{itemize}
+%        \item Adapting the |verbatimsc| environment (compatibility |verbatim| package).
+%        \item Removed compatibility layer for older \hologo{LaTeX} releases.
+%        \item Fix loader in \hologo{plainTeX} and \hologo{ConTeXt}.
+%        \item Minor adjustments in the documentation.
+%    \end{itemize}
 % \item [v1.9 (ctan), 2020-01-21]
 %    \begin{itemize}
-%    \item Update and improvements in the internal code.
-%    \item Updating the generic code for |I/O| verification.
-%    \item Add |write-cmd| and |write-out| keys for |\Scontents*|.
-%    \item Fix |sep| key in |\foreachsc|.
+%        \item Update and improvements in the internal code.
+%        \item Updating the generic code for |I/O| verification.
+%        \item Add |write-cmd| and |write-out| keys for |\Scontents*|.
+%        \item Fix |sep| key in |\foreachsc|.
 %    \end{itemize}
 % \item [v1.8 (ctan), 2019-11-18]
 %    \begin{itemize}
-%    \item Add |\newenvsc| command.
-%    \item Fix nested environment in \hologo{plainTeX} and \hologo{ConTeXt}.
-%    \item Modified default value in |\getstored|.
-%    \item Add |overwrite| key to reduce |I/O| operations.
-%    \item Deleted an unnecessary group in the code.
+%        \item Add |\newenvsc| command.
+%        \item Fix nested environment in \hologo{plainTeX} and \hologo{ConTeXt}.
+%        \item Modified default value in |\getstored|.
+%        \item Add |overwrite| key to reduce |I/O| operations.
+%        \item Deleted an unnecessary group in the code.
 %    \end{itemize}
 % \item [v1.7 (ctan), 2019-10-29]
 %    \begin{itemize}
-%    \item The |verbatimsc| environment was rewritten.
-%    \item Minor adjustments in documentation.
+%        \item The |verbatimsc| environment was rewritten.
+%        \item Minor adjustments in documentation.
 %    \end{itemize}
 % \item [v1.6 (ctan), 2019-10-26]
 %    \begin{itemize}
-%    \item The internal behavior of |\getstored| has been modified.
-%    \item The internal behavior of |\foreachsc| has been modified.
-%    \item Corrected file extension for \hologo{ConTeXt}.
-%    \item Remove spurious warning.
+%        \item The internal behavior of |\getstored| has been modified.
+%        \item The internal behavior of |\foreachsc| has been modified.
+%        \item Corrected file extension for \hologo{ConTeXt}.
+%        \item Remove spurious warning.
 %    \end{itemize}
 % \item [v1.5 (ctan), 2019-10-24]
 %    \begin{itemize}
@@ -1998,15 +2162,15 @@
 % \begin{thebibliography}{9}
 % \bibitem{expl3} The \hologo{LaTeX} Project. \enquote{The \textsf{expl3}
 % package}. Available from
-% \textsc{ctan}, \url{https://www.ctan.org/pkg/expl3}, 2020.
+% \textsc{ctan}, \url{https://www.ctan.org/pkg/expl3}, 2023.
 %
 % \bibitem{xparse} The \hologo{LaTeX} Project. \enquote{The \textsf{xparse}
 % package}. Available from
-% \textsc{ctan}, \url{https://www.ctan.org/pkg/xparse}, 2020.
+% \textsc{ctan}, \url{https://www.ctan.org/pkg/xparse}, 2023.
 %
 % \bibitem{l3keys} The \hologo{LaTeX} Project. \enquote{The \textsf{l3keys2e}
 % package}. Available from
-% \textsc{ctan}, \url{https://www.ctan.org/pkg/l3keys2e}, 2020.
+% \textsc{ctan}, \url{https://www.ctan.org/pkg/l3keys2e}, 2022.
 %
 % \bibitem{keyval} \textsc{Wright, Joseph}. \enquote{Programming
 % \textsf{key–value} in \textsf{expl3}}. Available from
@@ -2053,10 +2217,10 @@
 %
 % Now we define some common macros to hold the package date and version:
 %    \begin{macrocode}
-%<loader>\def\ScontentsFileDate{2022-04-04}%
-%<core>\def\ScontentsCoreFileDate{2022-04-04}%
+%<loader>\def\ScontentsFileDate{2024-06-14}%
+%<core>\def\ScontentsCoreFileDate{2024-06-14}%
 %<*loader>
-\def\ScontentsFileVersion{2.0}%
+\def\ScontentsFileVersion{2.1}%
 \def\ScontentsFileDescription{Stores LaTeX contents in memory or files}%
 %    \end{macrocode}
 %
@@ -2065,7 +2229,15 @@
 %
 %    \begin{macrocode}
 %<*latex>
-\RequirePackage{l3keys2e}[2020/02/08]
+\IfFormatAtLeastTF { 2022-06-01 }
+  { }
+  {
+    \RequirePackage{l3keys2e}[2020/02/08]
+    \PackageWarning { scontents }
+      {
+        The next update removes compatibility with versions prior to 2024.
+      }
+  }
 \ProvidesExplPackage
   {scontents} {\ScontentsFileDate} {\ScontentsFileVersion} {\ScontentsFileDescription}
 %</latex>
@@ -2229,6 +2401,13 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\l_@@_keys_tl}
+%   Stores unused keys to be frwarded to other commands.
+%    \begin{macrocode}
+\tl_new:N \l_@@_keys_tl
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{Compatibility layer with \hologo{plainTeX} and \hologo{ConTeXt}}
 %
 % When loading the package outside of \LaTeX{} we can't usually use
@@ -2292,9 +2471,14 @@
 % In \LaTeX{} mode we load \mypkg{l3keys2e} process the \mymeta{keys}
 % as options passed on to the package, the package \pkg{l3keys2e} will
 % verify the \mymeta{keys} and will return an error when they are
-% \emph{unknown}.
 %    \begin{macrocode}
-%<latex>\ProcessKeysOptions { scontents }
+%<*latex>
+\IfFormatAtLeastTF { 2022-06-01 }
+  {
+    \ProcessKeyOptions [ scontents ]
+  }
+  { \ProcessKeysOptions { scontents } }
+%</latex>
 %<*core>
 %    \end{macrocode}
 %
@@ -2333,8 +2517,8 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\l_@@_seq_item_int,\l_@@_env_nesting_int,\l_@@_foreach_stop_int}
-%   \cs{l_@@_seq_item_int} stores the index in the sequence of the item
+% \begin{macro}{\l_@@_env_nesting_int,\l_@@_foreach_stop_int}
+%   \cs{l_@@_seq_item_seq} stores the indexes in the sequence of the items
 %   requested to §\typestored§ or §\meaningsc§. \cs{l_@@_env_nesting_int}
 %   stores the current nesting level of the \env{scontents} environment.
 %   \cs{l_@@_foreach_stop_int} will save the value at which the §\foreachsc§
@@ -2342,7 +2526,7 @@
 %
 %    \begin{macrocode}
 \int_new:N \l_@@_foreach_stop_int
-\int_new:N \l_@@_seq_item_int
+\seq_new:N \l_@@_seq_item_seq
 \int_new:N \l_@@_env_nesting_int
 %    \end{macrocode}
 % \end{macro}
@@ -2382,6 +2566,7 @@
 %
 %    \begin{macrocode}
 \seq_new:N \l_@@_foreach_print_seq
+\seq_new:c { g_@@_name_sc!internal_seq }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2407,6 +2592,27 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\s_@@_stop,\s_@@_mark}
+%    \begin{macrocode}
+\scan_new:N \s_@@_stop
+\scan_new:N \s_@@_mark
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\l_@@_cur_seq_name_str}
+%    \begin{macrocode}
+\str_new:N \l_@@_cur_seq_name_str
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_use_i_delimit_by_s_stop:nw,\@@_use_none_delimit_by_s_stop:w}
+%    \begin{macrocode}
+\cs_new:Npn \@@_use_delimit_by_s_stop:nw #1 \s_@@_stop {#1}
+\cs_new:Npn \@@_use_i_delimit_by_s_stop:nw #1 #2 \s_@@_stop {#1}
+\cs_new:Npn \@@_use_none_delimit_by_s_stop:w #1 \s_@@_stop { }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\l_@@_save_sf_int,\l_@@_save_skip}
 %   Internal variables used by functions \cs{@@_bsphack:} and \cs{@@_esphack:}.
 %
@@ -2450,7 +2656,7 @@
 \cs_generate_variant:Nn \tl_remove_once:Nn { NV }
 \cs_generate_variant:Nn \tl_replace_all:Nnn { Nx, Nxx, Nnx }
 \cs_generate_variant:Nn \msg_error:nnnn { nnx }
-\prg_generate_conditional_variant:Nnn \tl_if_empty:n { f } { TF }
+\prg_generate_conditional_variant:Nnn \tl_if_empty:n { f } { p, TF }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -2566,16 +2772,25 @@
 % a common \mymeta{key}.
 %
 %    \begin{macrocode}
+\bool_new:N \l_@@_print_aux_bool
+\bool_set_true:N  \l_@@_print_aux_bool
 \keys_define:nn { scontents / typemeaning }
   {
-    width-tab .meta:nn = { scontents } { width-tab = #1 },
-    unknown   .code:n  = { \@@_parse_type_meaning_key:n {#1} }
+    width-tab .meta:nn   = { scontents } { width-tab = #1 },
+    write-out .code:n    = {
+                             \bool_set_false:N \l_@@_storing_bool
+                             \bool_set_true:N  \l_@@_writing_bool
+                             \tl_set:Nn \l_@@_fname_out_tl {#1}
+                           },
+    overwrite .meta:nn   = { scontents } { overwrite = #1 },
+    overwrite .default:n = true,
+    unknown   .code:n    = { \@@_parse_type_meaning_key:n {#1} }
   }
 %    \end{macrocode}
 %
 % \subsection{Handling undefined keys}
 %
-% The \mymeta{keys} are stored in the token list variable \cs{l_keys_key_str},
+% The \mymeta{keys} are stored in the string variable \cs{l_keys_key_str},
 % and the value (if any) is passed as an argument to each \mymeta{function}.
 %
 % \subsubsection{Undefined keys for environment \env{scontents}}
@@ -2666,16 +2881,42 @@
   { \exp_args:NV \@@_parse_type_meaning_key:nn \l_keys_key_str {#1} }
 \cs_new_protected:Npn \@@_parse_type_meaning_key:nn #1#2
   {
-    \tl_if_empty:fTF { \int_to_roman:n { -0 #1 } }
+    \tl_if_blank:nTF {#2}
+      { \@@_parse_type_meaning_range:w #1 - \q_@@_mark - \s_@@_mark }
+      { \msg_error:nnnn { scontents } { type-key-value-unknown } {#1} {#2} }
+  }
+\cs_new_protected:Npn \@@_parse_type_meaning_range:w #1 - #2 - #3 \s_@@_mark
+  {
+    \@@_range_parser:nnxn {#1} {#2}
+      { \seq_count:c { g_@@_name_\l_@@_cur_seq_name_str _seq } }
+      { \msg_error:nnn { scontents } { type-key-unknown } }
+  }
+\cs_generate_variant:Nn \@@_range_parser:nnnn { nnx }
+\cs_new_protected:Npn \@@_range_parser:nnnn #1 #2 #3
+  {
+    \exp_args:Nxx \@@_range_parser_aux:nnn
+      { \str_if_eq:nnTF {#1} { end } {#3} { \exp_not:n {#1} } }
+      { \str_if_eq:nnTF {#2} { end } {#3} { \exp_not:n {#2} } }
+  }
+\cs_new_protected:Npn \@@_range_parser_aux:nnn #1 #2 #3
+  {
+    \@@_tl_if_head_is_q_mark:nTF {#2}
       {
-        \tl_if_blank:nTF {#2}
-          { \int_set:Nn \l_@@_seq_item_int {#1} }
-          { \msg_error:nnnn { scontents } { type-key-value-unknown } {#1} {#2} }
+        \tl_if_empty:fTF { \int_to_roman:n { -0 #1 } }
+          { \seq_put_right:Nx \l_@@_seq_item_seq { \int_eval:n {#1} } }
+          { #3 {#1} }
       }
       {
-        \tl_if_blank:nTF {#2}
-          { \msg_error:nnn { scontents } { type-key-unknown } {#1} }
-          { \msg_error:nnnn { scontents } { type-key-value-unknown } {#1} {#2} }
+        \bool_lazy_and:nnTF
+            { \tl_if_empty_p:f { \int_to_roman:n { -0 #1 } } }
+            { \tl_if_empty_p:f { \int_to_roman:n { -0 #2 } } }
+          {
+            \int_compare:nNnTF {#2} > {#1}
+              { \int_step_inline:nnnn {#1} { 1 } {#2} }
+              { \int_step_inline:nnnn {#1} { -1 } {#2} }
+                { \seq_put_right:Nn \l_@@_seq_item_seq {##1} }
+          }
+          { #3 { #1-#2 } }
       }
   }
 %    \end{macrocode}
@@ -2704,11 +2945,24 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\@@_getfrom_seq:nn,\@@_getfrom_seq:nnn}
+% \begin{macro}{\@@_getfrom_seq:nn,\@@_getfrom_seq:Nn,\@@_getfrom_seq:nnn}
 %   The function \cs{@@_getfrom_seq:nn} retrieves the saved item from the
 %   sequence.
 %
 %    \begin{macrocode}
+\cs_new:Npn \@@_getfrom_seq:Nn #1#2
+  {
+    \seq_if_exist:cTF { g_@@_name_#2_seq }
+      {
+        \exp_args:Nf \@@_getfrom_seq:nNn
+          { \seq_count:c { g_@@_name_#2_seq } } #1 {#2}
+      }
+      { \msg_expandable_error:nnn { scontents } { undefined-storage } {#2} }
+  }
+\cs_new:Npn \@@_getfrom_seq:nNn #1 #2 #3
+  { \seq_map_tokens:Nn #2 { \@@_getfrom_seq_aux:nnn {#1} {#3} } }
+\cs_new:Npn \@@_getfrom_seq_aux:nnn #1 #2 #3
+  { \exp_args:Nnf \use:n { \@@_getfrom_seq:nnn {#1} } { \int_eval:n {#3} } {#2} }
 \cs_new:Npn \@@_getfrom_seq:nn #1#2
   {
     \seq_if_exist:cTF { g_@@_name_#2_seq }
@@ -2765,7 +3019,7 @@
 %
 % In order to be able to define environments that behave similarly to
 % \myenv{scontents}, we define a generic environment and make all other
-% environment as wappers around that one.
+% environment as wrappers around that one.
 %
 % \subsubsection{The command \cs{newenvsc}}
 %
@@ -2853,7 +3107,7 @@
 %     \startscontents,
 %     \stopscontents,
 %   }
-%   Finaly defining the \myenv{scontents} environment should be easy :)
+%   Finally defining the \myenv{scontents} environment should be easy :)
 %    \begin{macrocode}
 %</core>
 %<loader>\newenvsc{scontents}
@@ -2910,7 +3164,7 @@
 %   The function \cs{@@_start_after_option:w} also checks for trailing
 %   tokens after the optional argument and issues an error if any.
 %
-%   In all cases, the function \cs{@@_check_line_process:xn} ckecks that
+%   In all cases, the function \cs{@@_check_line_process:xn} checks that
 %   everything past §\begin{scontents}§ is empty and then process
 %   the environment.
 %
@@ -3407,7 +3661,7 @@
 %    \end{macrocode}
 %
 %   The function \cs{@@_norm_arg:n} grabs a normal argument, adds it to
-%   the |seq| varaible and optionally prints it.
+%   the |seq| variable and optionally prints it.
 %
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_norm_arg:n #1
@@ -3438,7 +3692,7 @@
 %   }
 %
 %   The function \cs{@@_verb_arg_internal:n} replace all §\^^M§ by
-%   §\^^J§ then adds it to the |seq| varaible.
+%   §\^^J§ then adds it to the |seq| variable.
 %
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_verb_arg_internal:n #1
@@ -3593,21 +3847,36 @@
 %<*core>
 \cs_new_protected:Npn \@@_typestored_internal:nn #1 #2
   {
+    \@@_bsphack:
     \group_begin:
-      \int_set:Nn \l_@@_seq_item_int { 1 }
+      \seq_clear:N \l_@@_seq_item_seq
+      \str_set:Nx \l_@@_cur_seq_name_str {#2}
       \tl_if_novalue:nF {#1} { \keys_set:nn { scontents / typemeaning } {#1} }
+      \seq_if_empty:NT \l_@@_seq_item_seq
+        { \seq_set_from_clist:Nn \l_@@_seq_item_seq { 1 } }
       \tl_set:Nx \l_@@_temp_tl
-        { \exp_args:NV \@@_getfrom_seq:nn \l_@@_seq_item_int {#2} }
-      \tl_remove_once:NV \l_@@_temp_tl \c_@@_hidden_space_str
+        { \@@_getfrom_seq:Nn \l_@@_seq_item_seq {#2} }
+      \@@_remove_trailing_eol:N \l_@@_temp_tl
+      \tl_replace_all:Nxn \l_@@_temp_tl \c_@@_hidden_space_str { ^^J }
       \tl_log:N \l_@@_temp_tl
       \tl_if_empty:NF \l_@@_temp_tl
-        { \@@_verb_print:N \l_@@_temp_tl }
+        {
+          \bool_if:NT \l_@@_print_aux_bool
+            {
+              \@@_verb_print:N \l_@@_temp_tl
+            }
+        }
+      \@@_file_write_cmd:VV \l_@@_fname_out_tl \l_@@_temp_tl
+      \use:x
+        {
     \group_end:
+    \bool_if:NF \l_@@_print_aux_bool { \@@_esphack: }
+        }
   }
 %    \end{macrocode}
 %
 %   The \cs{@@_verb_print:N} macro is defined with active carriage return
-%   (\textsc{ascii} 13) characters to mimick an actual verbatim environment
+%   (\textsc{ascii} 13) characters to mimic an actual verbatim environment
 %   \enquote{on the loose}. The contents of the environment are placed in a
 %   §verbatimsc§ environment and rescanned using \cs{@@_rescan_tokens:x}.
 %
@@ -3645,6 +3914,109 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \subsection{The command \cs{mergesc}}
+%
+% \begin{macro}{\mergesc}
+%   The §\mergesc§ command parses a list given as argument, and just assembles
+%   it as a temporary internal sequence, then passes it to the requested command.
+%    \begin{macrocode}
+%<*loader>
+\NewDocumentCommand \mergesc { o m }
+  { \@@_mergesc_internal:nn {#1} {#2} }
+%</loader>
+%<*core>
+\keys_define:nn { scontents / mergesc }
+  {
+    , typestored .code:n =
+        { \cs_set_eq:NN \@@_mergesc_output_cmd:nn \@@_typestored_internal:nn }
+    , meaningsc .code:n =
+        { \cs_set_eq:NN \@@_mergesc_output_cmd:nn \@@_meaningsc_internal:nn }
+  }
+\cs_new_protected:Npn \@@_mergesc_output_cmd:nn #1 #2
+  { \msg_error:nn { scontents } { mergesc-missing-cmd } }
+\msg_new:nnn { scontents } { mergesc-missing-cmd }
+  { Missing~output~command~for~\iow_char:N\\mergesc~\msg_line_context:. }
+\cs_new_protected:Npn \@@_mergesc_internal:nn #1 #2
+  {
+    \group_begin:
+      \tl_clear:N \l_@@_keys_tl
+      \tl_if_novalue:nF {#1}
+        {
+          % Add print-cmd here :D
+          \keys_define:nn { scontents / typemeaning }
+            {
+              print-cmd .bool_set:N = \l_@@_print_aux_bool,
+              print-cmd .initial:n = false,
+              print-cmd .default:n = true,
+            }
+          \keys_set_known:nnN { scontents / mergesc } {#1} \l_@@_keys_tl
+         }
+      \seq_gclear:c { g_@@_name_sc!internal_seq }
+      \@@_mergesc_parse_list:n {#2}
+      \exp_args:Nx \@@_mergesc_output_cmd:nn
+        { 1-end, \exp_not:V \l_@@_keys_tl } { sc!internal }
+    \group_end:
+  }
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_mergesc_parse_list:n #1
+  {
+    \clist_map_inline:nn {#1} { \@@_parse_mergesc:nw ##1 \s_@@_stop }
+    \seq_gpop_right:cN { g_@@_name_sc!internal_seq } \l_@@_temp_tl
+    \@@_remove_trailing_eol:N \l_@@_temp_tl
+    \seq_gput_right:cV { g_@@_name_sc!internal_seq } \l_@@_temp_tl
+  }
+\cs_new_protected:Npx \@@_remove_trailing_eol:N #1
+  {
+    \exp_not:N \exp_after:wN \exp_not:N \@@_remove_trailing_eol:w
+      #1 \s_@@_stop \c_@@_hidden_space_str \s_@@_stop \s_@@_mark #1
+  }
+\use:e
+  {
+    \cs_new_protected:Npn \exp_not:N \@@_remove_trailing_eol:w #1
+        \c_@@_hidden_space_str \s_@@_stop #2 \s_@@_mark #3
+  }   {
+        \tl_set:Nx #3
+          {
+            \tl_if_empty:nTF {#2}
+              { \exp_not:o { \@@_use_delimit_by_s_stop:nw #1 } }
+              { \exp_not:n {#1} }
+          }
+      }
+\cs_new_protected:Npn \@@_parse_mergesc:nw #1
+  {
+    \peek_charcode_ignore_spaces:NTF [ % ]
+      { \@@_parse_mergesc_aux:nw {#1} }
+      { \@@_parse_mergesc_aux:nw {#1} [ 1-\seq_count:c { g_@@_name_#1_seq } ] }
+  }
+\cs_new_protected:Npn \@@_parse_mergesc_aux:nw #1 [#2]
+  {
+    \seq_clear:N \l_@@_seq_item_seq
+    \clist_map_inline:nn {#2}
+      { \@@_parse_mergesc_range:nw {#1} ##1 - \q_@@_mark - \s_@@_mark }
+    \seq_map_inline:Nn \l_@@_seq_item_seq
+      {
+        \seq_gput_right:cx { g_@@_name_sc!internal_seq }
+          { \seq_item:cn { g_@@_name_#1_seq } {##1} }
+      }
+    \@@_use_none_delimit_by_s_stop:w
+  }
+\cs_new_protected:Npn \@@_parse_mergesc_range:nw #1 #2 - #3 - #4 \s_@@_mark
+  {
+    \cs_set_protected:Npn \@@_tmp:w ##1
+      {
+        \msg_error:nnxxx { scontents } { index-out-of-range }
+          {##1} {#1} { \seq_count:c { g_@@_name_#1_seq } }
+      }
+    \@@_range_parser:nnxn {#2} {#3}
+      { \seq_count:c { g_@@_name_#1_seq } }
+      { \@@_tmp:w }
+  }
+%</core>
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{verbatimsc,\startverbatimsc,\stopverbatimsc}
 %   Finally the \hologo{LaTeX} and \hologo{ConTeXt} version of
 %   §verbatimsc§ environment is defined.
@@ -3697,20 +4069,20 @@
 %   §\do at noligs§ which makes sure to not consume following space
 %   tokens. The \LaTeXe{} version ends with §\char`#1§, which
 %   leaves \TeX{} still looking for an \mymeta{optional~space}.
-%   This version uses \cs{char_generate:nn} to ensure that doesn't
-%   happen.
-%
+%^^A   This version uses \cs{char_generate:nn} to ensure that doesn't
+%^^A   happen.
+%^^A   Maintain documentation at this point.
 %    \begin{macrocode}
-\cs_new:Npn \@@_do_noligs:N #1
+\cs_new_protected:Npn \@@_do_noligs:N #1
   {
     \char_set_catcode_active:N #1
-    \char_set_active_eq:Nc #1 { @@_active_char_ \token_to_str:N #1 : }
     \cs_set:cpx { @@_active_char_ \token_to_str:N #1 : }
       {
         \mode_leave_vertical:
         \tex_kern:D \c_zero_dim
-        \char_generate:nn { `#1 } { 12 }
+        \tex_char:D `\exp_not:N #1
       }
+    \char_set_active_eq:Nc #1 { @@_active_char_ \token_to_str:N #1 : }
   }
 %    \end{macrocode}
 % \end{macro}
@@ -3721,7 +4093,8 @@
 \prg_new_protected_conditional:Npnn \@@_tl_if_head_is_q_mark:n #1
   { T, F, TF }
   {
-    \if_meaning:w \q_@@_mark #1 \scan_stop:
+    \exp_after:wN \if_meaning:w
+      \exp_after:wN \q_@@_mark \@@_use_i_delimit_by_s_stop:nw #1 ? \s_@@_stop
       \prg_return_true:
     \else:
       \prg_return_false:
@@ -3805,8 +4178,11 @@
 \cs_new_protected:Npn \@@_meaningsc_internal:nn #1 #2
   {
     \group_begin:
-      \int_set:Nn \l_@@_seq_item_int { 1 }
+      \seq_clear:N \l_@@_seq_item_seq
+      \str_set:Nx \l_@@_cur_seq_name_str {#2}
       \tl_if_novalue:nF {#1} { \keys_set:nn { scontents / typemeaning } {#1} }
+      \seq_if_empty:NT \l_@@_seq_item_seq
+        { \seq_set_from_clist:Nn \l_@@_seq_item_seq { 1 } }
       \@@_meaningsc:n {#2}
     \group_end:
   }
@@ -3815,9 +4191,9 @@
   \cs_new_protected:Npn \@@_meaningsc:n #1
     {
       \tl_set:Nx \l_@@_temp_tl
-        { \exp_args:NV \@@_getfrom_seq:nn \l_@@_seq_item_int {#1} }
+        { \@@_getfrom_seq:Nn \l_@@_seq_item_seq {#1} }
       \tl_replace_all:Nxn \l_@@_temp_tl { \iow_char:N \^^J } { ~ }
-      \tl_remove_once:NV  \l_@@_temp_tl \c_@@_hidden_space_str
+      \tl_replace_all:Nxn \l_@@_temp_tl \c_@@_hidden_space_str { ~ }
       \tl_log:N \l_@@_temp_tl
       \tl_use:N \l_@@_verb_font_tl
       \tl_replace_all:Nnx \l_@@_temp_tl { ^^I } { \@@_tabs_to_spaces: }
@@ -3852,7 +4228,7 @@
 %</core>
 %<*loader>
 \NewDocumentCommand \cleanseqsc { m }
-  { \seq_clear_new:c { g_@@_name_#1_seq } }
+  { \seq_gclear_new:c { g_@@_name_#1_seq } }
 %</loader>
 %<*core>
 %    \end{macrocode}

Modified: trunk/Master/texmf-dist/source/latex/scontents/scontents.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/scontents/scontents.ins	2024-06-15 19:53:25 UTC (rev 71532)
+++ trunk/Master/texmf-dist/source/latex/scontents/scontents.ins	2024-06-15 19:53:38 UTC (rev 71533)
@@ -3,13 +3,13 @@
 \askforoverwritefalse
 \declarepreamble\standard
 
-Copyright (C) 2019-2022 by Pablo González L <pablgonz at educarchile.cl>
+Copyright (C) 2019-2024 by Pablo González L <pablgonz at educarchile.cl>
 
 This work may be distributed and/or modified under the conditions of the
 LaTeX Project Public License, either version 1.3c of this license or (at
 your option) any later version. The latest version of this license is in
 
- http://www.latex-project.org/lppl.txt
+ https://www.latex-project.org/lppl.txt
 
 and version 1.3c or later is part of all distributions of LaTeX version
 2005/12/01 or later.
@@ -33,11 +33,11 @@
 \declarepreamble\context
  \string\module
    [     file=t-scontents,
-      version=2.0,
+      version=2.1,
         title=\string\CONTEXT\ User Module,
      subtitle=Storing Contents,
        author=Pablo González,
-         date=2022-04-04,
+         date=2024-06-14,
     copyright=Pablo González,
         email=pablgonz at educarchile.cl,
       license=LPPL]

Modified: trunk/Master/texmf-dist/tex/context/third/scontents/t-scontents.mkiv
===================================================================
--- trunk/Master/texmf-dist/tex/context/third/scontents/t-scontents.mkiv	2024-06-15 19:53:25 UTC (rev 71532)
+++ trunk/Master/texmf-dist/tex/context/third/scontents/t-scontents.mkiv	2024-06-15 19:53:38 UTC (rev 71533)
@@ -6,13 +6,13 @@
 %%
 %% scontents.dtx  (with options: `loader,context')
 %% 
-%% Copyright (C) 2019-2022 by Pablo González L <pablgonz at educarchile.cl>
+%% Copyright (C) 2019-2024 by Pablo González L <pablgonz at educarchile.cl>
 %% 
 %% This work may be distributed and/or modified under the conditions of the
 %% LaTeX Project Public License, either version 1.3c of this license or (at
 %% your option) any later version. The latest version of this license is in
 %% 
-%%  http://www.latex-project.org/lppl.txt
+%%  https://www.latex-project.org/lppl.txt
 %% 
 %% and version 1.3c or later is part of all distributions of LaTeX version
 %% 2005/12/01 or later.
@@ -33,16 +33,16 @@
 %% scontents.dtx  (with options: `loader,context')
 %D  \module
 %D    [     file=t-scontents,
-%D       version=2.0,
+%D       version=2.1,
 %D         title=\CONTEXT\ User Module,
 %D      subtitle=Storing Contents,
 %D        author=Pablo González,
-%D          date=2022-04-04,
+%D          date=2024-06-14,
 %D     copyright=Pablo González,
 %D         email=pablgonz at educarchile.cl,
 %D       license=LPPL]
-\def\ScontentsFileDate{2022-04-04}%
-\def\ScontentsFileVersion{2.0}%
+\def\ScontentsFileDate{2024-06-14}%
+\def\ScontentsFileVersion{2.1}%
 \def\ScontentsFileDescription{Stores LaTeX contents in memory or files}%
 \writestatus{loading}{User Module scontents v\ScontentsFileVersion}
 \unprotect
@@ -112,6 +112,8 @@
   { \__scontents_foreachsc_internal:nn {#1} {#2} }
 \NewDocumentCommand \typestored { o m }
   { \__scontents_typestored_internal:nn {#1} {#2} }
+\NewDocumentCommand \mergesc { o m }
+  { \__scontents_mergesc_internal:nn {#1} {#2} }
 \definetyping[verbatimsc]
 \group_begin:
   \cs_new_protected:Npn \__scontents_plain_disable_outer_par:
@@ -124,7 +126,7 @@
 \NewExpandableDocumentCommand \countsc { m }
   { \seq_count:c { g__scontents_name_#1_seq } }
 \NewDocumentCommand \cleanseqsc { m }
-  { \seq_clear_new:c { g__scontents_name_#1_seq } }
+  { \seq_gclear_new:c { g__scontents_name_#1_seq } }
 \ExplSyntaxOff
 \endinput
 %%

Modified: trunk/Master/texmf-dist/tex/generic/scontents/scontents-code.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/scontents/scontents-code.tex	2024-06-15 19:53:25 UTC (rev 71532)
+++ trunk/Master/texmf-dist/tex/generic/scontents/scontents-code.tex	2024-06-15 19:53:38 UTC (rev 71533)
@@ -6,13 +6,13 @@
 %%
 %% scontents.dtx  (with options: `core')
 %% 
-%% Copyright (C) 2019-2022 by Pablo González L <pablgonz at educarchile.cl>
+%% Copyright (C) 2019-2024 by Pablo González L <pablgonz at educarchile.cl>
 %% 
 %% This work may be distributed and/or modified under the conditions of the
 %% LaTeX Project Public License, either version 1.3c of this license or (at
 %% your option) any later version. The latest version of this license is in
 %% 
-%%  http://www.latex-project.org/lppl.txt
+%%  https://www.latex-project.org/lppl.txt
 %% 
 %% and version 1.3c or later is part of all distributions of LaTeX version
 %% 2005/12/01 or later.
@@ -27,7 +27,7 @@
 %%                                 t-scontents.mkiv and
 %%                                 scontents-code.tex.
 %% 
-\def\ScontentsCoreFileDate{2022-04-04}%
+\def\ScontentsCoreFileDate{2024-06-14}%
 \begingroup
   \catcode32=10
   \endlinechar=32
@@ -75,6 +75,7 @@
 \tl_new:N \g__scontents_temp_tl
 \int_new:N \l__scontents_tmpa_int
 \bool_new:N \l__scontents_temp_bool
+\tl_new:N \l__scontents_keys_tl
 \keys_define:nn { scontents }
   {
     store-env .tl_set:N         = \l__scontents_name_seq_env_tl,
@@ -112,7 +113,7 @@
 \tl_new:N \l__scontents_foreach_before_tl
 \tl_new:N \l__scontents_foreach_after_tl
 \int_new:N \l__scontents_foreach_stop_int
-\int_new:N \l__scontents_seq_item_int
+\seq_new:N \l__scontents_seq_item_seq
 \int_new:N \l__scontents_env_nesting_int
 \bool_new:N \l__scontents_writing_bool
 \bool_set_false:N \l__scontents_writing_bool
@@ -128,10 +129,17 @@
 \bool_new:N \l__scontents_foreach_wrapper_bool
 \bool_set_false:N \l__scontents_foreach_wrapper_bool
 \seq_new:N \l__scontents_foreach_print_seq
+\seq_new:c { g__scontents_name_sc!internal_seq }
 \str_const:Nx \c__scontents_hidden_space_str
   { \c_percent_str \c_circumflex_str \c_circumflex_str A scheol \c_percent_str }
 \quark_new:N \q__scontents_stop
 \quark_new:N \q__scontents_mark
+\scan_new:N \s__scontents_stop
+\scan_new:N \s__scontents_mark
+\str_new:N \l__scontents_cur_seq_name_str
+\cs_new:Npn \__scontents_use_delimit_by_s_stop:nw #1 \s__scontents_stop {#1}
+\cs_new:Npn \__scontents_use_i_delimit_by_s_stop:nw #1 #2 \s__scontents_stop {#1}
+\cs_new:Npn \__scontents_use_none_delimit_by_s_stop:w #1 \s__scontents_stop { }
 \int_new:N \l__scontents_save_sf_int
 \skip_new:N \l__scontents_save_skip
 \cs_new_protected:Npn \__scontents_rescan_tokens:n #1 { \tex_scantokens:D {#1} }
@@ -141,7 +149,7 @@
 \cs_generate_variant:Nn \tl_remove_once:Nn { NV }
 \cs_generate_variant:Nn \tl_replace_all:Nnn { Nx, Nxx, Nnx }
 \cs_generate_variant:Nn \msg_error:nnnn { nnx }
-\prg_generate_conditional_variant:Nnn \tl_if_empty:n { f } { TF }
+\prg_generate_conditional_variant:Nnn \tl_if_empty:n { f } { p, TF }
 \keys_define:nn { scontents / scontents }
   {
     write-env .code:n           = {
@@ -220,10 +228,19 @@
     sep     .value_required:n = true,
     unknown .code:n           = { \__scontents_parse_foreach_keys:n {#1} }
   }
+\bool_new:N \l__scontents_print_aux_bool
+\bool_set_true:N  \l__scontents_print_aux_bool
 \keys_define:nn { scontents / typemeaning }
   {
-    width-tab .meta:nn = { scontents } { width-tab = #1 },
-    unknown   .code:n  = { \__scontents_parse_type_meaning_key:n {#1} }
+    width-tab .meta:nn   = { scontents } { width-tab = #1 },
+    write-out .code:n    = {
+                             \bool_set_false:N \l__scontents_storing_bool
+                             \bool_set_true:N  \l__scontents_writing_bool
+                             \tl_set:Nn \l__scontents_fname_out_tl {#1}
+                           },
+    overwrite .meta:nn   = { scontents } { overwrite = #1 },
+    overwrite .default:n = true,
+    unknown   .code:n    = { \__scontents_parse_type_meaning_key:n {#1} }
   }
 \cs_new_protected:Npn \__scontents_parse_environment_keys:n #1
   { \exp_args:NV \__scontents_parse_environment_keys:nn \l_keys_key_str {#1} }
@@ -253,16 +270,42 @@
   { \exp_args:NV \__scontents_parse_type_meaning_key:nn \l_keys_key_str {#1} }
 \cs_new_protected:Npn \__scontents_parse_type_meaning_key:nn #1#2
   {
-    \tl_if_empty:fTF { \int_to_roman:n { -0 #1 } }
+    \tl_if_blank:nTF {#2}
+      { \__scontents_parse_type_meaning_range:w #1 - \q__scontents_mark - \s__scontents_mark }
+      { \msg_error:nnnn { scontents } { type-key-value-unknown } {#1} {#2} }
+  }
+\cs_new_protected:Npn \__scontents_parse_type_meaning_range:w #1 - #2 - #3 \s__scontents_mark
+  {
+    \__scontents_range_parser:nnxn {#1} {#2}
+      { \seq_count:c { g__scontents_name_\l__scontents_cur_seq_name_str _seq } }
+      { \msg_error:nnn { scontents } { type-key-unknown } }
+  }
+\cs_generate_variant:Nn \__scontents_range_parser:nnnn { nnx }
+\cs_new_protected:Npn \__scontents_range_parser:nnnn #1 #2 #3
+  {
+    \exp_args:Nxx \__scontents_range_parser_aux:nnn
+      { \str_if_eq:nnTF {#1} { end } {#3} { \exp_not:n {#1} } }
+      { \str_if_eq:nnTF {#2} { end } {#3} { \exp_not:n {#2} } }
+  }
+\cs_new_protected:Npn \__scontents_range_parser_aux:nnn #1 #2 #3
+  {
+    \__scontents_tl_if_head_is_q_mark:nTF {#2}
       {
-        \tl_if_blank:nTF {#2}
-          { \int_set:Nn \l__scontents_seq_item_int {#1} }
-          { \msg_error:nnnn { scontents } { type-key-value-unknown } {#1} {#2} }
+        \tl_if_empty:fTF { \int_to_roman:n { -0 #1 } }
+          { \seq_put_right:Nx \l__scontents_seq_item_seq { \int_eval:n {#1} } }
+          { #3 {#1} }
       }
       {
-        \tl_if_blank:nTF {#2}
-          { \msg_error:nnn { scontents } { type-key-unknown } {#1} }
-          { \msg_error:nnnn { scontents } { type-key-value-unknown } {#1} {#2} }
+        \bool_lazy_and:nnTF
+            { \tl_if_empty_p:f { \int_to_roman:n { -0 #1 } } }
+            { \tl_if_empty_p:f { \int_to_roman:n { -0 #2 } } }
+          {
+            \int_compare:nNnTF {#2} > {#1}
+              { \int_step_inline:nnnn {#1} { 1 } {#2} }
+              { \int_step_inline:nnnn {#1} { -1 } {#2} }
+                { \seq_put_right:Nn \l__scontents_seq_item_seq {##1} }
+          }
+          { #3 { #1-#2 } }
       }
   }
 \cs_new_protected:Npn \__scontents_append_contents:nn #1#2
@@ -274,6 +317,19 @@
     \seq_gput_right:cn { g__scontents_name_#1_seq } {#2}
   }
 \cs_generate_variant:Nn \__scontents_append_contents:nn { Vx }
+\cs_new:Npn \__scontents_getfrom_seq:Nn #1#2
+  {
+    \seq_if_exist:cTF { g__scontents_name_#2_seq }
+      {
+        \exp_args:Nf \__scontents_getfrom_seq:nNn
+          { \seq_count:c { g__scontents_name_#2_seq } } #1 {#2}
+      }
+      { \msg_expandable_error:nnn { scontents } { undefined-storage } {#2} }
+  }
+\cs_new:Npn \__scontents_getfrom_seq:nNn #1 #2 #3
+  { \seq_map_tokens:Nn #2 { \__scontents_getfrom_seq_aux:nnn {#1} {#3} } }
+\cs_new:Npn \__scontents_getfrom_seq_aux:nnn #1 #2 #3
+  { \exp_args:Nnf \use:n { \__scontents_getfrom_seq:nnn {#1} } { \int_eval:n {#3} } {#2} }
 \cs_new:Npn \__scontents_getfrom_seq:nn #1#2
   {
     \seq_if_exist:cTF { g__scontents_name_#2_seq }
@@ -736,16 +792,31 @@
   }
 \cs_new_protected:Npn \__scontents_typestored_internal:nn #1 #2
   {
+    \__scontents_bsphack:
     \group_begin:
-      \int_set:Nn \l__scontents_seq_item_int { 1 }
+      \seq_clear:N \l__scontents_seq_item_seq
+      \str_set:Nx \l__scontents_cur_seq_name_str {#2}
       \tl_if_novalue:nF {#1} { \keys_set:nn { scontents / typemeaning } {#1} }
+      \seq_if_empty:NT \l__scontents_seq_item_seq
+        { \seq_set_from_clist:Nn \l__scontents_seq_item_seq { 1 } }
       \tl_set:Nx \l__scontents_temp_tl
-        { \exp_args:NV \__scontents_getfrom_seq:nn \l__scontents_seq_item_int {#2} }
-      \tl_remove_once:NV \l__scontents_temp_tl \c__scontents_hidden_space_str
+        { \__scontents_getfrom_seq:Nn \l__scontents_seq_item_seq {#2} }
+      \__scontents_remove_trailing_eol:N \l__scontents_temp_tl
+      \tl_replace_all:Nxn \l__scontents_temp_tl \c__scontents_hidden_space_str { ^^J }
       \tl_log:N \l__scontents_temp_tl
       \tl_if_empty:NF \l__scontents_temp_tl
-        { \__scontents_verb_print:N \l__scontents_temp_tl }
+        {
+          \bool_if:NT \l__scontents_print_aux_bool
+            {
+              \__scontents_verb_print:N \l__scontents_temp_tl
+            }
+        }
+      \__scontents_file_write_cmd:VV \l__scontents_fname_out_tl \l__scontents_temp_tl
+      \use:x
+        {
     \group_end:
+    \bool_if:NF \l__scontents_print_aux_bool { \__scontents_esphack: }
+        }
   }
 \group_begin:
   \char_set_catcode_active:N \^^M
@@ -776,23 +847,109 @@
     \char_set_active_eq:nN { 9 } \__scontents_tabs_to_spaces:
     \__scontents_xverb:w
   }
+\keys_define:nn { scontents / mergesc }
+  {
+    , typestored .code:n =
+        { \cs_set_eq:NN \__scontents_mergesc_output_cmd:nn \__scontents_typestored_internal:nn }
+    , meaningsc .code:n =
+        { \cs_set_eq:NN \__scontents_mergesc_output_cmd:nn \__scontents_meaningsc_internal:nn }
+  }
+\cs_new_protected:Npn \__scontents_mergesc_output_cmd:nn #1 #2
+  { \msg_error:nn { scontents } { mergesc-missing-cmd } }
+\msg_new:nnn { scontents } { mergesc-missing-cmd }
+  { Missing~output~command~for~\iow_char:N\\mergesc~\msg_line_context:. }
+\cs_new_protected:Npn \__scontents_mergesc_internal:nn #1 #2
+  {
+    \group_begin:
+      \tl_clear:N \l__scontents_keys_tl
+      \tl_if_novalue:nF {#1}
+        {
+          % Add print-cmd here :D
+          \keys_define:nn { scontents / typemeaning }
+            {
+              print-cmd .bool_set:N = \l__scontents_print_aux_bool,
+              print-cmd .initial:n = false,
+              print-cmd .default:n = true,
+            }
+          \keys_set_known:nnN { scontents / mergesc } {#1} \l__scontents_keys_tl
+         }
+      \seq_gclear:c { g__scontents_name_sc!internal_seq }
+      \__scontents_mergesc_parse_list:n {#2}
+      \exp_args:Nx \__scontents_mergesc_output_cmd:nn
+        { 1-end, \exp_not:V \l__scontents_keys_tl } { sc!internal }
+    \group_end:
+  }
+\cs_new_protected:Npn \__scontents_mergesc_parse_list:n #1
+  {
+    \clist_map_inline:nn {#1} { \__scontents_parse_mergesc:nw ##1 \s__scontents_stop }
+    \seq_gpop_right:cN { g__scontents_name_sc!internal_seq } \l__scontents_temp_tl
+    \__scontents_remove_trailing_eol:N \l__scontents_temp_tl
+    \seq_gput_right:cV { g__scontents_name_sc!internal_seq } \l__scontents_temp_tl
+  }
+\cs_new_protected:Npx \__scontents_remove_trailing_eol:N #1
+  {
+    \exp_not:N \exp_after:wN \exp_not:N \__scontents_remove_trailing_eol:w
+      #1 \s__scontents_stop \c__scontents_hidden_space_str \s__scontents_stop \s__scontents_mark #1
+  }
+\use:e
+  {
+    \cs_new_protected:Npn \exp_not:N \__scontents_remove_trailing_eol:w #1
+        \c__scontents_hidden_space_str \s__scontents_stop #2 \s__scontents_mark #3
+  }   {
+        \tl_set:Nx #3
+          {
+            \tl_if_empty:nTF {#2}
+              { \exp_not:o { \__scontents_use_delimit_by_s_stop:nw #1 } }
+              { \exp_not:n {#1} }
+          }
+      }
+\cs_new_protected:Npn \__scontents_parse_mergesc:nw #1
+  {
+    \peek_charcode_ignore_spaces:NTF [ % ]
+      { \__scontents_parse_mergesc_aux:nw {#1} }
+      { \__scontents_parse_mergesc_aux:nw {#1} [ 1-\seq_count:c { g__scontents_name_#1_seq } ] }
+  }
+\cs_new_protected:Npn \__scontents_parse_mergesc_aux:nw #1 [#2]
+  {
+    \seq_clear:N \l__scontents_seq_item_seq
+    \clist_map_inline:nn {#2}
+      { \__scontents_parse_mergesc_range:nw {#1} ##1 - \q__scontents_mark - \s__scontents_mark }
+    \seq_map_inline:Nn \l__scontents_seq_item_seq
+      {
+        \seq_gput_right:cx { g__scontents_name_sc!internal_seq }
+          { \seq_item:cn { g__scontents_name_#1_seq } {##1} }
+      }
+    \__scontents_use_none_delimit_by_s_stop:w
+  }
+\cs_new_protected:Npn \__scontents_parse_mergesc_range:nw #1 #2 - #3 - #4 \s__scontents_mark
+  {
+    \cs_set_protected:Npn \__scontents_tmp:w ##1
+      {
+        \msg_error:nnxxx { scontents } { index-out-of-range }
+          {##1} {#1} { \seq_count:c { g__scontents_name_#1_seq } }
+      }
+    \__scontents_range_parser:nnxn {#2} {#3}
+      { \seq_count:c { g__scontents_name_#1_seq } }
+      { \__scontents_tmp:w }
+  }
 \cs_new:Npn \__scontents_tabs_to_spaces:
   { \prg_replicate:nn { \l__scontents_tab_width_int } { ~ } }
-\cs_new:Npn \__scontents_do_noligs:N #1
+\cs_new_protected:Npn \__scontents_do_noligs:N #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 : }
       {
         \mode_leave_vertical:
         \tex_kern:D \c_zero_dim
-        \char_generate:nn { `#1 } { 12 }
+        \tex_char:D `\exp_not:N #1
       }
+    \char_set_active_eq:Nc #1 { __scontents_active_char_ \token_to_str:N #1 : }
   }
 \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:
+    \exp_after:wN \if_meaning:w
+      \exp_after:wN \q__scontents_mark \__scontents_use_i_delimit_by_s_stop:nw #1 ? \s__scontents_stop
       \prg_return_true:
     \else:
       \prg_return_false:
@@ -816,8 +973,11 @@
 \cs_new_protected:Npn \__scontents_meaningsc_internal:nn #1 #2
   {
     \group_begin:
-      \int_set:Nn \l__scontents_seq_item_int { 1 }
+      \seq_clear:N \l__scontents_seq_item_seq
+      \str_set:Nx \l__scontents_cur_seq_name_str {#2}
       \tl_if_novalue:nF {#1} { \keys_set:nn { scontents / typemeaning } {#1} }
+      \seq_if_empty:NT \l__scontents_seq_item_seq
+        { \seq_set_from_clist:Nn \l__scontents_seq_item_seq { 1 } }
       \__scontents_meaningsc:n {#2}
     \group_end:
   }
@@ -826,9 +986,9 @@
   \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} }
+        { \__scontents_getfrom_seq:Nn \l__scontents_seq_item_seq {#1} }
       \tl_replace_all:Nxn \l__scontents_temp_tl { \iow_char:N \^^J } { ~ }
-      \tl_remove_once:NV  \l__scontents_temp_tl \c__scontents_hidden_space_str
+      \tl_replace_all:Nxn \l__scontents_temp_tl \c__scontents_hidden_space_str { ~ }
       \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: }

Modified: trunk/Master/texmf-dist/tex/generic/scontents/scontents.tex
===================================================================
--- trunk/Master/texmf-dist/tex/generic/scontents/scontents.tex	2024-06-15 19:53:25 UTC (rev 71532)
+++ trunk/Master/texmf-dist/tex/generic/scontents/scontents.tex	2024-06-15 19:53:38 UTC (rev 71533)
@@ -6,13 +6,13 @@
 %%
 %% scontents.dtx  (with options: `loader,plain')
 %% 
-%% Copyright (C) 2019-2022 by Pablo González L <pablgonz at educarchile.cl>
+%% Copyright (C) 2019-2024 by Pablo González L <pablgonz at educarchile.cl>
 %% 
 %% This work may be distributed and/or modified under the conditions of the
 %% LaTeX Project Public License, either version 1.3c of this license or (at
 %% your option) any later version. The latest version of this license is in
 %% 
-%%  http://www.latex-project.org/lppl.txt
+%%  https://www.latex-project.org/lppl.txt
 %% 
 %% and version 1.3c or later is part of all distributions of LaTeX version
 %% 2005/12/01 or later.
@@ -27,8 +27,8 @@
 %%                                 t-scontents.mkiv and
 %%                                 scontents-code.tex.
 %% 
-\def\ScontentsFileDate{2022-04-04}%
-\def\ScontentsFileVersion{2.0}%
+\def\ScontentsFileDate{2024-06-14}%
+\def\ScontentsFileVersion{2.1}%
 \def\ScontentsFileDescription{Stores LaTeX contents in memory or files}%
 \input expl3-generic.tex
 \ExplSyntaxOn
@@ -148,6 +148,8 @@
   { \__scontents_foreachsc_internal:nn {#1} {#2} }
 \NewDocumentCommand \typestored { o m }
   { \__scontents_typestored_internal:nn {#1} {#2} }
+\NewDocumentCommand \mergesc { o m }
+  { \__scontents_mergesc_internal:nn {#1} {#2} }
 \use:x
   {
     \cs_new_protected:Npn \exp_not:N \__scontents_xverb:w
@@ -172,7 +174,7 @@
 \NewExpandableDocumentCommand \countsc { m }
   { \seq_count:c { g__scontents_name_#1_seq } }
 \NewDocumentCommand \cleanseqsc { m }
-  { \seq_clear_new:c { g__scontents_name_#1_seq } }
+  { \seq_gclear_new:c { g__scontents_name_#1_seq } }
 \ExplSyntaxOff
 \endinput
 %%

Modified: trunk/Master/texmf-dist/tex/latex/scontents/scontents.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/scontents/scontents.sty	2024-06-15 19:53:25 UTC (rev 71532)
+++ trunk/Master/texmf-dist/tex/latex/scontents/scontents.sty	2024-06-15 19:53:38 UTC (rev 71533)
@@ -6,13 +6,13 @@
 %%
 %% scontents.dtx  (with options: `loader,latex')
 %% 
-%% Copyright (C) 2019-2022 by Pablo González L <pablgonz at educarchile.cl>
+%% Copyright (C) 2019-2024 by Pablo González L <pablgonz at educarchile.cl>
 %% 
 %% This work may be distributed and/or modified under the conditions of the
 %% LaTeX Project Public License, either version 1.3c of this license or (at
 %% your option) any later version. The latest version of this license is in
 %% 
-%%  http://www.latex-project.org/lppl.txt
+%%  https://www.latex-project.org/lppl.txt
 %% 
 %% and version 1.3c or later is part of all distributions of LaTeX version
 %% 2005/12/01 or later.
@@ -27,10 +27,18 @@
 %%                                 t-scontents.mkiv and
 %%                                 scontents-code.tex.
 %% 
-\def\ScontentsFileDate{2022-04-04}%
-\def\ScontentsFileVersion{2.0}%
+\def\ScontentsFileDate{2024-06-14}%
+\def\ScontentsFileVersion{2.1}%
 \def\ScontentsFileDescription{Stores LaTeX contents in memory or files}%
-\RequirePackage{l3keys2e}[2020/02/08]
+\IfFormatAtLeastTF { 2022-06-01 }
+  { }
+  {
+    \RequirePackage{l3keys2e}[2020/02/08]
+    \PackageWarning { scontents }
+      {
+        The next update removes compatibility with versions prior to 2024.
+      }
+  }
 \ProvidesExplPackage
   {scontents} {\ScontentsFileDate} {\ScontentsFileVersion} {\ScontentsFileDescription}
 \tl_new:N \g__scontents_end_verbatimsc_tl
@@ -55,7 +63,11 @@
   {#1} % LaTeX
 \keys_define:nn { scontents }
   { verb-font .initial:n = \ttfamily }
-\ProcessKeysOptions { scontents }
+\IfFormatAtLeastTF { 2022-06-01 }
+  {
+    \ProcessKeyOptions [ scontents ]
+  }
+  { \ProcessKeysOptions { scontents } }
 \NewDocumentCommand \newenvsc { m O{} }
   {
     \cs_if_exist:cTF { #1 }
@@ -89,6 +101,8 @@
   { \__scontents_foreachsc_internal:nn {#1} {#2} }
 \NewDocumentCommand \typestored { o m }
   { \__scontents_typestored_internal:nn {#1} {#2} }
+\NewDocumentCommand \mergesc { o m }
+  { \__scontents_mergesc_internal:nn {#1} {#2} }
 \use:x
   {
     \cs_new_protected:Npn \exp_not:N \__scontents_xverb:w
@@ -112,7 +126,7 @@
 \NewExpandableDocumentCommand \countsc { m }
   { \seq_count:c { g__scontents_name_#1_seq } }
 \NewDocumentCommand \cleanseqsc { m }
-  { \seq_clear_new:c { g__scontents_name_#1_seq } }
+  { \seq_gclear_new:c { g__scontents_name_#1_seq } }
 \endinput
 %%
 %% End of file `scontents.sty'.



More information about the tex-live-commits mailing list.