From 1f2fdb31c172bba8a03b6b1a359b86650b7a738b Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 28 Aug 2019 23:41:40 +0000 Subject: scontents (29aug19) git-svn-id: svn://tug.org/texlive/trunk@51975 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/scontents/README.md | 4 +- .../texmf-dist/doc/latex/scontents/scontents.pdf | Bin 193183 -> 198211 bytes .../source/latex/scontents/scontents.dtx | 383 +++++++++++---------- .../source/latex/scontents/scontents.ins | 6 +- .../texmf-dist/tex/latex/scontents/scontents.sty | 33 +- 5 files changed, 229 insertions(+), 197 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/latex/scontents/README.md b/Master/texmf-dist/doc/latex/scontents/README.md index ddcb6524ede..c446c1bf8db 100644 --- a/Master/texmf-dist/doc/latex/scontents/README.md +++ b/Master/texmf-dist/doc/latex/scontents/README.md @@ -1,6 +1,6 @@ ## scontents — Stores LaTeX contents in memory or files -- Version: 1.1 -- Date: 2019/08/12 +- Version: 1.2 +- Date: 2019/08/28 - Author: Pablo González ## Description diff --git a/Master/texmf-dist/doc/latex/scontents/scontents.pdf b/Master/texmf-dist/doc/latex/scontents/scontents.pdf index 81229e496b2..6e78f883be3 100644 Binary files a/Master/texmf-dist/doc/latex/scontents/scontents.pdf and b/Master/texmf-dist/doc/latex/scontents/scontents.pdf differ diff --git a/Master/texmf-dist/source/latex/scontents/scontents.dtx b/Master/texmf-dist/source/latex/scontents/scontents.dtx index 6787d4e4880..9084a7ea356 100644 --- a/Master/texmf-dist/source/latex/scontents/scontents.dtx +++ b/Master/texmf-dist/source/latex/scontents/scontents.dtx @@ -11,9 +11,9 @@ \askforoverwritefalse \nopreamble\nopostamble \usedir{tex/latex/scontents} -\generate{ - \file{\jobname.sty}{\from{\jobname.dtx}{package}} -} +\generate{% + \file{\jobname.sty}{\from{\jobname.dtx}{package}}% +}% % %\endbatchfile %<*internal> @@ -21,7 +21,6 @@ \generate{ \file{\jobname.ins}{\from{\jobname.dtx}{install}} } - \ifx\fmtname\nameofplainTeX \expandafter\endbatchfile \else @@ -30,6 +29,13 @@ % %<*driver> \documentclass[full]{l3doc} +% imakeidx also opens a write stream for the .idx file, and that conflicts +% with the one opened by l3doc. Here we close that write stream: +\makeatletter +\immediate\closeout\@indexfile +\makeatother +% and later we will copy the write stream opened by imakeidx into \@indexfile +% so that entries written to both streams end up in the same file. \usepackage[top=0.5in,bottom=0.5in,left=2.0in,right=1in,footskip=0.2in,headsep=10pt]{geometry} \usepackage[osf,mono=false,scale=0.95,llscaled=0.95]{libertine} \usepackage{unicode-math} @@ -52,9 +58,9 @@ \usepackage{hyperxmp,lastpage,imakeidx,microtype,attachfile2} \usepackage{adjustbox,multicol,listings,accsupp,titletoc} \usepackage{scontents} % main - \usepackage[contents]{colordoc} + % Patching colordoc.sty to work with l3doc.cls \ExplSyntaxOn \cs_new_eq:cN { liii@xmacro@code } \__codedoc_xmacro_code:n @@ -72,8 +78,13 @@ |endgroup \EnableCrossrefs -\PageIndex +% \PageIndex % \CodelineIndex undoes what \PageIndex does +% \CodelineIndex tries to open another write stream for the index file. We don't +% want that, so we temporarily make \makeindex a no-op: +\let\ORGmakeindex\makeindex +\def\makeindex{} \CodelineIndex +\let\makeindex\ORGmakeindex \DoNotIndex{\ , \1,\^} \expandafter\DoNotIndex\expandafter{\string\{} \expandafter\DoNotIndex\expandafter{\string\}} @@ -84,6 +95,12 @@ \indexsetup{level=\section,firstpagestyle=myheader} \makeindex[name=userdoc,options=-s gind.ist,columnsep=15pt,title={Index of Documentation}] \makeindex[options=-s gind.ist,columnsep=15pt,title={Index of Implementation}] +% Now, after imakeidx opens the write stream for the index file, we copy +% the reference to \@indexfile: +\makeatletter +\let\@indexfile\scontents@idxfile +\makeatother + \setlength{\parindent}{0pt} %^^A------------------- ONLY FOR DOCUMENTATION ------------------------%% @@ -175,21 +192,19 @@ } %^^A \envexamp{m} -\newsavebox{\marginexa} +\newsavebox{\boxexaenv} \NewDocumentCommand{\envexamp}{m} { - \begin{lrbox}{\marginexa}% + \begin{lrbox}{\boxexaenv}% \begin{minipage}[t]{\marginparwidth}% - \raggedleft\ttfamily\small + \raggedright\ttfamily\small \textcolor{gray}{\textbackslash begin\{\textcolor{mypkgcolor}{\bfseries{#1}}\}\myoarg [type=tt,sbc=gray,ac=NavyBlue,cf=optcolor]{key=val}}\par% - \mymeta[ac=gray,cf=gray]{env ~ contents}\par% + \hspace{0.5cm}\mymeta[ac=gray,cf=gray]{env ~ contents}\par% \textcolor{gray}{\textbackslash end\{{\textcolor{mypkgcolor}{\bfseries{#1}}}\}}\par \end{minipage}% \end{lrbox}% - \leavevmode% - \marginpar{\usebox{\marginexa}}% - \ignorespaces% + \usebox{\boxexaenv} } %^^A \cmdexamp{s m o m o} @@ -197,7 +212,7 @@ { \group_begin: \small\ttfamily - \adjustbox{outer=-0.5\marginparsep}{\textcolor{mypkgcolor}{\textbackslash#2}} + \textcolor{mypkgcolor}{\textbackslash#2} \IfBooleanTF{#1}{ \textcolor{red}{*} }{ \hphantom{*} } \IfValueT{#3}{ \myoarg[type=tt,sbc=gray,ac=NavyBlue,cf=optcolor]{#3} } \IfValueTF{#5} @@ -442,7 +457,7 @@ % \filedate.}\\[25pt] % \author{ % \large -% \raisebox{-1pt}{\textcopyright}{}2019 by Pablo González +% \raisebox{-1pt}{\textcopyright}{}2019 by Pablo González % \thanks{E-mail: \textsf{\guillemotleft}\email{pablgonz@educarchile.cl}\textsf{\guillemotright}}% % } % \small @@ -464,15 +479,7 @@ % % \setlength{\parskip}{3pt} % -% \section*{Description} -% -% The \mypkg*{scontents} package encapsulates the \mypkg{filecontentsdef} -% package of \textsc{Jean Fran\c{c}ois Burnol} which allows you to save the -% content in a |\macro| and save it in external files, adding a user interface -% style \myoarg{key = val} along with the ability to save content in sequences -% for later use in different parts of the document. -% -% \section*{Motivation and Acknowledgments} +% \section{Motivation and Acknowledgments} % % In \hologo{LaTeX} there is no direct way to record content for later use, although % you can do this using \verb|\macros|, recording \meta{verbatim content} is a @@ -486,7 +493,7 @@ % This package would not be possible without the great work of \textsc{Jean % Fran\c{c}ois Burnol} who was kind enough to take my requirements into account % and add the \myenv{filecontentsdefmacro} environment. Also a special thanks to -% Phelype Oleinik who has collaborated and adapted a large part of the code and +% Phelype Oleinik who has collaborated and adapted a large part of the code and % all \hologo{LaTeX3} team for their great work and to the different members % of the \href{https://tex.stackexchange.com}{TeX-SX} community who have provided % great answers and ideas. Here a note of the main ones: @@ -503,7 +510,7 @@ % \item \href{https://tex.stackexchange.com/q/373647/7832}{Collect contents of an environment (that contains verbatim content)} % \end{enumerate} % -% \section*{License and Requirements} +% \section{License and Requirements} % \label{sec:licence} % % Permission is granted to copy, distribute and/or modify this software under @@ -523,16 +530,21 @@ % \pagestyle{myheader} % % \section{The \texttt{scontents} package} +% \label{sec:pkgscontents} % -% The \mypkg*{scontents} package provides the \myenv*{scontents} environment, -% \ics*{Scontents} and \ics*{Scontents*} command to stored contents and \ics*{getstored} -% command to get the \meta{stored content} along with other utilities described in this -% documentation. +% \subsection{Description} +% +% The \mypkg*{scontents} package encapsulates the \mypkg{filecontentsdef} +% package of \textsc{Jean Fran\c{c}ois Burnol} which allows you to save the +% content in a |\macro| and save it in external files, adding a user interface +% style \myoarg{key = val} along with the ability to save content in sequences +% for later use in different parts of the document. % % \subsection{Loading package} % \label{sec:loadoptpkg} % % The package is loaded in the usual way: +% % \iffalse %<*example> % \fi @@ -542,7 +554,7 @@ % \iffalse % % \fi -% Or +% or % \iffalse %<*example> % \fi @@ -552,27 +564,71 @@ % \iffalse % % \fi +% % \subsection{Configuration of the options} % \label{sec:confopt} % % Most of the options can be passed directly to the package or can be % configured by means of the command \ics*{setupsc}. % -% \cmdexamp{setupsc}{key=val} +% \vspace*{-10pt} +% +% \begin{function}{\setupsc} +% \begin{syntax} +% \cmdexamp{setupsc}{key=val} +% \end{syntax} +% % The command \ics*{setupsc} configures the options in a global way, +% for \ics*{Scontents}, \ics*{Scontents*} and environment \myenv*{scontents}. % it can be used both in the preamble and in the body of the document % as many times as desired. +% \end{function} +% +% \subsection{Options Overview} +% \label{sec:optover} +% +% \newcommand*{\xmark}{\textcolor{red}{✘}}% +% \newcommand*{\cmark}{\textcolor{green}{✔}}% +% +% Summary table of available options. +% +% \begin{tabular}{cccccc} +% \toprule +% \texttt{key} & package & \ics{setupsc} & \myenv*{scontents} & \ics*{Scontents} & \ics*{Scontents*}\\ +% \midrule +% \texttt{store-env} & \cmark & \cmark & \cmark & \xmark & \xmark \\ +% \texttt{store-cmd} & \cmark & \cmark & \xmark & \cmark & \cmark \\ +% \texttt{print-env} & \cmark & \cmark & \cmark & \xmark & \xmark \\ +% \texttt{print-cmd} & \cmark & \cmark & \xmark & \cmark & \cmark \\ +% \texttt{print-all} & \cmark & \cmark & \cmark & \xmark & \xmark \\ +% \texttt{write-env} & \xmark & \xmark & \cmark & \xmark & \xmark \\ +% \texttt{write-out} & \xmark & \xmark & \cmark & \xmark & \xmark \\ +% \bottomrule +% \end{tabular} % -% The summary with all possible options can be found in \ref{sec:optover}. +% \section{User interface} +% \label{sec:interface} % -% \section{The environment \env{scontents}} -% \label{sec:envscontents} +% The \emph{user interface} provided by this package consists in \myenv*{scontents} environment, +% \ics*{Scontents} and \ics*{Scontents*} commands to stored contents and \ics*{getstored} command +% to get the \meta{stored content} along with other utilities described in this documentation. % -% \envexamp{scontents} -% The \myenv*{scontents} environment encapsulates the \ics{filecontentsdef*} and % -% \ics{filecontentsdefmacro} environments provided by the \mypkg{filecontentsdef} -% package. This allows you to record content including verbatim for later -% reuse. Some considerations to keep in mind: +% \subsection{The environment \env{scontents}} +% \label{sec:scontents} +% +% \vspace*{-10pt} +% +% \begin{function}{scontents} +% \begin{syntax} +% \envexamp{scontents} +% \end{syntax} +% +% The \myenv*{scontents} environment encapsulates the \myenv{filecontentsdef*} and +% \myenv{filecontentsdefmacro} environments provided by the \mypkg{filecontentsdef} +% package. This allows you to record content including verbatim for later reuse. +% \end{function} +% +% Some considerations to keep in mind: % % \begin{enumerate}[nosep] % \item The environment cannot be nested. @@ -619,10 +675,22 @@ % it will not store the contents of this one. It is analogous to the % \myenv{filecontents*} environment. % -% \section{The command \cs{Scontents}} +% \subsection{The command \cs{Scontents}} % \label{sec:Scontents} % -% \cmdexamp{Scontents}[key=val]{argument} +% The command to store content directly in memory, the star version allows to save +% \meta{verbatim} contents. +% +% \vspace*{-10pt} +% +% \begin{function}{\Scontents} +% \begin{syntax} +% \cmdexamp{Scontents}[key=val]{argument} +% \cmdexamp*{Scontents}[key=val]{argument} +% \cmdexamp*{Scontents}[key=val]{argument}[del] +% \end{syntax} +% \end{function} +% % The \ics*{Scontents} command reads the \meta{argument} in standard mode. % It is not possible to pass environments such as \meta{verbatim}, but it is % possible to use the implementation of \ics{Verb} provided by the @@ -632,8 +700,6 @@ % It can be used anywhere in the document and cannot be used as an \meta{argument} % for another command. % -% \cmdexamp*{Scontents}[key=val]{argument} -% \cmdexamp*{Scontents}[key=val]{argument}[del] % The \ics*{Scontents*} command reads the \meta{argument} under verbatim % category code regimen. If its first delimiter is a brace, it will be assumed that % the \meta{argument} is nested into braces. Otherwise it will be assumed that @@ -648,6 +714,7 @@ % \end{enumerate} % % \subsection*{Options for command} +% \label{sec:optcmdsc} % % The command options (including star version) can be configured globally % using option in package or the \ics*{setupsc} command and locally @@ -663,29 +730,53 @@ % \keyexamp{print-cmd}{true\textbar false}{false} % It will show the current content of \ics*{Scontents}. % -% \section{The command \cs{getstored}} +% \subsection{The command \cs{getstored}} % \label{sec:getstored} % -% \cmdexamp{getstored}[index]{seq name} +% \vspace*{-10pt} +% +% \begin{function}{\getstored} +% \begin{syntax} +% \cmdexamp{getstored}[index]{seq name} +% \end{syntax} +% \end{function} +% % The command \ics*{getstored} gets the content stored in \meta{seq name} -% according to the index in which it was stored. The command is robust and expandable +% according to the index in which it was stored. The command is robust % and can be used as an \meta{argument} for another command. If the optional argument % is not passed it defaults to the last element saved in the \meta{seq name}. % -% \section{The command \cs{typestored}} +% \subsection{The command \cs{typestored}} % \label{sec:typestored} % -% \cmdexamp{typestored}[index]{seq name} +% \vspace*{-10pt} +% +% \begin{function}{\typestored} +% \begin{syntax} +% \cmdexamp{typestored}[index]{seq name} +% \cmdexamp*{typestored}[index]{seq name} +% \end{syntax} +% \end{function} +% % The command \ics*{typestored} shows the content stored in \meta{seq name} in % \emph{verbatim} mode. Internally places the content into the \myenv*{verbatimsc} environment. % -% \cmdexamp*{typestored}[index]{seq name} % The command \ics*{typestored*} must be used for content stored by \ics*{Scontents*} command. % Internally places the content into the \myenv*{verbatimsc} environment. % % If the optional argument is not passed it defaults to the % last element saved in the \meta{seq name}. % +% \subsection{The environment \env{verbatimsc}} +% \label{sec:verbatimsc} +% +% \vspace*{-10pt} +% +% \begin{function}{verbatimsc} +% Internal environment used by \cs{typestored} and \cs{typestored*} to display +% \meta{verbatim style} contents. +% \end{function} +% % One consideration to keep in mind is that this is a \emph{representation} of the content % in a \meta{verbatim} environment and not a real \meta{verbatim} environment, the line ends % are not respected. The \myenv*{verbatimsc} environment can be in the following ways: @@ -748,50 +839,46 @@ % % \section{Other commands provided} % -% \subsection*{The command \cs{meaningsc}} +% \subsection{The command \cs{meaningsc}} % \label{sec:meaningsc} % -% \cmdexamp{meaningsc}[index]{seq name} +% \vspace*{-10pt} +% +% \begin{function}{\meaningsc} +% \begin{syntax} +% \cmdexamp{meaningsc}[index]{seq name} +% \end{syntax} % The command \ics*{meaningsc} executes \ics{meaning} on the content stored % in \meta{seq name}. If the optional argument is not passed it defaults to the % last element saved in the \meta{seq name}. +% \end{function} % -% \subsection*{The command \cs{countsc}} +% \subsection{The command \cs{countsc}} % \label{sec:countsc} % -% \cmdexamp{countsc}{seq name} +% \vspace*{-10pt} +% +% \begin{function}{\countsc} +% \begin{syntax} +% \cmdexamp{countsc}{seq name} +% \end{syntax} % The command \ics*{countsc} count a number of contents stored in \meta{seq name}. +% \end{function} % -% \subsection*{The command \cs{cleansc}} +% \subsection{The command \cs{cleansc}} % \label{sec:cleansc} % -% \cmdexamp{cleansc}{seq name} -% The command \ics*{cleansc} remove all contents stored in \meta{seq name}. -% -% \section{Options Overview} -% \label{sec:optover} -% -% \newcommand*{\xmark}{\textcolor{red}{✘}}% -% \newcommand*{\cmark}{\textcolor{green}{✔}}% -% -% Summary table of available options -% +% \vspace*{-10pt} % -% \begin{tabular}{cccccc} -% \toprule -% \texttt{key} & package & \ics{setupsc} & \myenv*{scontents} & \ics*{Scontents} & \ics*{Scontents*}\\ -% \midrule -% \texttt{store-env} & \cmark & \cmark & \cmark & \xmark & \xmark \\ -% \texttt{store-cmd} & \cmark & \cmark & \xmark & \cmark & \cmark \\ -% \texttt{print-env} & \cmark & \cmark & \cmark & \xmark & \xmark \\ -% \texttt{print-cmd} & \cmark & \cmark & \xmark & \cmark & \cmark \\ -% \texttt{print-all} & \cmark & \cmark & \cmark & \xmark & \xmark \\ -% \texttt{write-env} & \xmark & \xmark & \cmark & \xmark & \xmark \\ -% \texttt{write-out} & \xmark & \xmark & \cmark & \xmark & \xmark \\ -% \bottomrule -% \end{tabular} +% \begin{function}{\cleanseqsc} +% \begin{syntax} +% \cmdexamp{cleansc}{seq name} +% \end{syntax} +% The command \ics*{cleansc} remove all contents stored in \meta{seq name}. +% \end{function} % % \section{Examples} +% % These are some (adapted) examples that have served as inspiration for % the creation of this package. % @@ -1131,15 +1218,20 @@ % \lstinputlisting[language=scontents-doc,numbers=left]{scexamp8.ltx} % % \section{Change history} -% % \label{sec:changes} -% +% % \setlist[itemize,1]{label=\textendash, wide=0.5em, nosep, noitemsep, leftmargin=10pt} % \newlength\descrwidth % \settowidth{\descrwidth}{\textsf{v1.0, (ctan), 2019/07/30} } +% % \begin{description}[font=\small\sffamily, wide=0pt, style=multiline, leftmargin=\descrwidth, nosep, noitemsep] % \item [\fileversion{} (ctan), \filedate] % \begin{itemize} +% \item Restructuring of documentation. +% \item Added copy of \verb+\tex_scantokens:D+. +% \end{itemize} +% \item [v1.1 (ctan), 2019/08/12] +% \begin{itemize} % \item Extension of documentation. % \item Replace \verb+\tex_endinput:D+ by \verb+\file_input_stop:+. % \end{itemize} @@ -1148,10 +1240,13 @@ % \item First public release, % \end{itemize} % \end{description} +% % \newpage % % \printindex[userdoc] +% % \newpage +% % \StopEventually{^^A % \newgeometry{top=0.5in,bottom=0.5in,left=1.0in,right=1in,footskip=0.2in,headsep=10pt} % \addtocontents{toc}{\protect\setcounter{tocdepth}{2}} @@ -1160,86 +1255,10 @@ % \printindex % } % -% \section{scontents implementation} +% \section{Implementation} % \label{sec:Implementation} % \addtocontents{toc}{\protect\setcounter{tocdepth}{0}} % -% \begin{documentation} -% \subsection{User interface} -% -% The \emph{user interface} provided by this package consists of a couple of environments -% and a series of commands described below. -% -% \begin{function}{\setupsc} -% \begin{syntax} -% \cs{setupsc} \Arg{key=val} -% \end{syntax} -% The command to set options for \cs{Scontents}, \cs{Scontents*} and the -% environment \env{scontents}. -% \end{function} -% -% \begin{function}{scontents} -% \begin{syntax} -% \oarg{key=val} -% \end{syntax} -% The environment encapsulating \env{filecontentsdef*} and -% \env{filecontentsdefmacro} from \pkg{filecontentsdef} package. -% \end{function} -% -% \begin{function}{\Scontents} -% \begin{syntax} -% \cs{Scontents}~ \oarg{key=val} \Arg{argument} -% \cs{Scontents*} \oarg{key=val} \Arg{argument} -% \cs{Scontents*} \oarg{key=val} \meta{del}\Arg{argument}\meta{del} -% \end{syntax} -% The command to store content directly in memory, the star version allows to save -% \meta{verbatim} content. -% \end{function} -% -% \begin{function}{\getstored} -% \begin{syntax} -% \cs{getstored}~\oarg{index} \Arg{seq name} -% \end{syntax} -% The command to receive content stored in memory. -% \end{function} -% -% \begin{function}{\typestored} -% \begin{syntax} -% \cs{typestored}~\oarg{index} \Arg{seq name} -% \cs{typestored*}\oarg{index} \Arg{seq name} -% \end{syntax} -% The command to display the content stored in memory within the \env{verbatimsc}, -% the starred version displays the content stored by \cs{Scontents*}. -% \end{function} -% -% \begin{function}{verbatimsc} -% Internal environment used by \cs{typestored} and \cs{typestored*} to display -% \meta{verbatim style} content. -% \end{function} -% -% \begin{function}{\countsc} -% \begin{syntax} -% \cs{countsc} \Arg{seq name} -% \end{syntax} -% The command to count the number of elements stored. -% \end{function} -% -% \begin{function}{\meaningsc} -% \begin{syntax} -% \cs{meaningsc}~\oarg{index} \Arg{seq name} -% \end{syntax} -% The command to display the \cs{meaning} of the stored content. -% \end{function} -% -% \begin{function}{\cleanseqsc} -% \begin{syntax} -% \cs{meaningsc} \Arg{seq name} -% \end{syntax} -% The command to erase the memory sequence at the point at which it is executed. -% \end{function} -% -% \end{documentation} -% % \iffalse %<*package> % \fi @@ -1257,7 +1276,7 @@ \RequirePackage{filecontentsdef}[2019/04/20] \RequirePackage{l3keys2e} \RequirePackage{xparse}[2019/05/28] -\ProvidesExplPackage{scontents}{2019/08/12}{1.1} +\ProvidesExplPackage{scontents}{2019/08/28}{1.2} {Stores LaTeX contents in memory or files} % \end{macrocode} % A check to make sure that \pkg{xparse} is not too old @@ -1349,6 +1368,18 @@ % \end{macrocode} % \end{macro} % +%%^^A Internal quarks +% \begin{macro}{\@@_rescan_tokens:w} +% \cs{tl_rescan:nn} doesn't fit the needs of this package because +% it does not allow catcode changes inside the argument, so verbatim +% commands used inside one of \mypkg*{scontents}'s commands/environments +% will not work. Here we create a private copy of \cs{tex_scantokens:D} +% which will serve our purposes: +% \begin{macrocode} +\cs_new_eq:NN \@@_rescan_tokens:w \tex_scantokens:D +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\g_@@_end_verbatimsc_tl} % A token list to match when ending verbatim environments. % \begin{macrocode} @@ -1356,7 +1387,6 @@ \tl_gset_rescan:Nnn \g_@@_end_verbatimsc_tl { - \char_set_catcode_escape:N \| \char_set_catcode_other:N \\ \char_set_catcode_other:N \{ \char_set_catcode_other:N \} @@ -1435,7 +1465,7 @@ % \begin{macro}{scontents} % This is the main environment used in the document. % \begin{macrocode} -\ProvideDocumentEnvironment { scontents } { } +\NewDocumentEnvironment { scontents } { } { \char_set_catcode_active:N \^^M \@@_start_environment:w @@ -1548,12 +1578,12 @@ } \tl_clear:N \l_@@_macro_tmp_tl } -\cs_gset_protected:Npn \@@_stored_to_seq: +\cs_new_protected:Npn \@@_stored_to_seq: { \regex_replace_all:nnN { \^^M } { \^^J } \l_@@_macro_tmp_tl \tl_log:N \l_@@_macro_tmp_tl \@@_append_contents:Vx \l_@@_name_seq_env_tl - { \exp_not:N \tex_scantokens:D { \tl_use:N \l_@@_macro_tmp_tl } } + { \exp_not:N \@@_rescan_tokens:w { \tl_use:N \l_@@_macro_tmp_tl } } } % \end{macrocode} % \end{macro} @@ -1564,7 +1594,7 @@ % \url{https://tex.stackexchange.com/a/500281/7832}. % %%^^A User command to stored content -% +% % \begin{macro}{\Scontents,\@@_norm:n,\@@_verb:w} % The \cs{Scontents} macro starts by parsing an optional argument and % then delegates to \cs{@@_verb:w} or \cs{@@_norm:n} depending whether @@ -1581,7 +1611,7 @@ %^^A Reply: The redirection of error messages has never worked well for me %^^A perhaps it would be better to implement it. % \begin{macrocode} -\ProvideDocumentCommand { \Scontents }{ !s !O{} } +\NewDocumentCommand { \Scontents }{ !s !O{} } { \group_begin: \IfNoValueF {#2} @@ -1603,7 +1633,7 @@ \regex_replace_all:nnN { \^^M } { \^^J } \l_@@_temp_tl \tl_log:N \l_@@_temp_tl \exp_args:NVx \@@_append_contents:nn \l_@@_name_seq_cmd_tl - { \exp_not:N \tex_scantokens:D { \tl_use:N \l_@@_temp_tl } } + { \exp_not:N \@@_rescan_tokens:w { \tl_use:N \l_@@_temp_tl } } \bool_if:NT \l_@@_print_cmd_bool { \@@_getfrom_seq:nn { -1 } { \l_@@_name_seq_cmd_tl } } \group_end: @@ -1618,7 +1648,7 @@ % User command \cs{getstored} to extract stored content in |seq| % (robust). % \begin{macrocode} -\ProvideDocumentCommand { \getstored } { O{1} m } +\NewDocumentCommand { \getstored } { O{1} m } { \@@_getfrom_seq:nn {#1} {#2} } % \end{macrocode} % \end{macro} @@ -1638,7 +1668,7 @@ % to read the contents of the token list and pass them to % \cs{@@_fcdef_print:N}. % \begin{macrocode} -\ProvideDocumentCommand { \typestored } { s O{1} m } +\NewDocumentCommand { \typestored } { s O{1} m } { \group_begin: \tl_set:Nx \l_@@_temp_tl { \@@_getfrom_seq:nn {#2} {#3} } @@ -1665,7 +1695,7 @@ \cs_set_eq:NN ^^M \scan_stop: \use:x { - \exp_not:N \tex_scantokens:D + \exp_not:N \@@_rescan_tokens:w { \exp_not:N \begin{verbatimsc} ^^M \@@_strip_scantokens:N #1 @@ -1683,7 +1713,7 @@ \use:x { \cs_gset_protected:Npn \exp_not:N \@@_xverb:w ##1 \g_@@_end_verbatimsc_tl } { #1 \end{verbatimsc} } -\ProvideDocumentEnvironment { verbatimsc } { } +\NewDocumentEnvironment { verbatimsc } { } { \cs_set_eq:cN { @xverbatim } \@@_xverb:w \verbatim @@ -1722,7 +1752,7 @@ } \prg_new_conditional:Npnn \@@_if_scantokens:Nw #1#2 \q_@@_mark { TF } { - \token_if_eq_meaning:NNTF \tex_scantokens:D #1 + \token_if_eq_meaning:NNTF \@@_rescan_tokens:w #1 { \prg_return_true: } { \prg_return_false: } } @@ -1736,20 +1766,20 @@ % \begin{macro}{\setupsc} % A user-level wrapper for \cs{keys_set:nn}|{ scontents }| % \begin{macrocode} -\ProvideDocumentCommand { \setupsc } { m } +\NewDocumentCommand { \setupsc } { m } { \keys_set:nn { scontents } {#1} } % \end{macrocode} % \end{macro} % % \subsection{The command meaningsc} % -% \begin{macro}{\meaningsc} +% \begin{macro}[do-not-index=\v]{\meaningsc} % User command \cs{meaningsc} to see content stored in seq. %^^A NOTE: Perhaps replace \cs{regex_replace_all:nnN} by something more %^^A efficient... %^^A Reply: I've only used it to avoid ΩΩ ... % \begin{macrocode} -\ProvideDocumentCommand { \meaningsc } { O{1} m } +\NewDocumentCommand { \meaningsc } { O{1} m } { \group_begin: \tl_set:Nx \l_@@_temp_tl { \@@_getfrom_seq:nn {#1} {#2} } @@ -1768,7 +1798,7 @@ % \begin{macro}{\countsc} % User command \cs{countsc} to count number of contents stored in seq. % \begin{macrocode} -\ProvideExpandableDocumentCommand { \countsc } { m } +\NewExpandableDocumentCommand { \countsc } { m } { \seq_count:c { g_@@_seq_name_#1_seq } } % \end{macrocode} % \end{macro} @@ -1778,7 +1808,7 @@ % \begin{macro}{\cleanseqsc} % A user command \cs{cleanseqsc} to clear (remove) a defined seq % \begin{macrocode} -\ProvideExpandableDocumentCommand { \cleanseqsc } { m } +\NewDocumentCommand { \cleanseqsc } { m } { \seq_clear_new:c { g_@@_seq_name_#1_seq } } % \end{macrocode} % \end{macro} @@ -1810,4 +1840,5 @@ % \iffalse % % \fi +% % \Finale diff --git a/Master/texmf-dist/source/latex/scontents/scontents.ins b/Master/texmf-dist/source/latex/scontents/scontents.ins index 2b0d3865154..ee59a97dcf3 100644 --- a/Master/texmf-dist/source/latex/scontents/scontents.ins +++ b/Master/texmf-dist/source/latex/scontents/scontents.ins @@ -3,7 +3,7 @@ \askforoverwritefalse \nopreamble\nopostamble \usedir{tex/latex/scontents} -\generate{ - \file{\jobname.sty}{\from{\jobname.dtx}{package}} -} +\generate{% + \file{\jobname.sty}{\from{\jobname.dtx}{package}}% +}% \endbatchfile diff --git a/Master/texmf-dist/tex/latex/scontents/scontents.sty b/Master/texmf-dist/tex/latex/scontents/scontents.sty index 5b26bcc19a0..35771c8f982 100644 --- a/Master/texmf-dist/tex/latex/scontents/scontents.sty +++ b/Master/texmf-dist/tex/latex/scontents/scontents.sty @@ -1,7 +1,7 @@ \RequirePackage{filecontentsdef}[2019/04/20] \RequirePackage{l3keys2e} \RequirePackage{xparse}[2019/05/28] -\ProvidesExplPackage{scontents}{2019/08/12}{1.1} +\ProvidesExplPackage{scontents}{2019/08/28}{1.2} {Stores LaTeX contents in memory or files} \@ifpackagelater { xparse } { 2019/05/03 } { } @@ -47,11 +47,12 @@ %%^^A Internal quarks \quark_new:N \q__scontents_stop \quark_new:N \q__scontents_mark +%%^^A Internal quarks +\cs_new_eq:NN \__scontents_rescan_tokens:w \tex_scantokens:D \tl_new:N \g__scontents_end_verbatimsc_tl \tl_gset_rescan:Nnn \g__scontents_end_verbatimsc_tl { - \char_set_catcode_escape:N \| \char_set_catcode_other:N \\ \char_set_catcode_other:N \{ \char_set_catcode_other:N \} @@ -91,7 +92,7 @@ \cs_new:Npn \__scontents_getfrom_seq:nn #1#2 { \seq_item:cn { g__scontents_seq_name_#2_seq } {#1} } %%^^A Define |scontents| whit [key=val] (delaying) -\ProvideDocumentEnvironment { scontents } { } +\NewDocumentEnvironment { scontents } { } { \char_set_catcode_active:N \^^M \__scontents_start_environment:w @@ -154,15 +155,15 @@ } \tl_clear:N \l__scontents_macro_tmp_tl } -\cs_gset_protected:Npn \__scontents_stored_to_seq: +\cs_new_protected:Npn \__scontents_stored_to_seq: { \regex_replace_all:nnN { \^^M } { \^^J } \l__scontents_macro_tmp_tl \tl_log:N \l__scontents_macro_tmp_tl \__scontents_append_contents:Vx \l__scontents_name_seq_env_tl - { \exp_not:N \tex_scantokens:D { \tl_use:N \l__scontents_macro_tmp_tl } } + { \exp_not:N \__scontents_rescan_tokens:w { \tl_use:N \l__scontents_macro_tmp_tl } } } %%^^A User command to stored content -\ProvideDocumentCommand { \Scontents }{ !s !O{} } +\NewDocumentCommand { \Scontents }{ !s !O{} } { \group_begin: \IfNoValueF {#2} @@ -184,14 +185,14 @@ \regex_replace_all:nnN { \^^M } { \^^J } \l__scontents_temp_tl \tl_log:N \l__scontents_temp_tl \exp_args:NVx \__scontents_append_contents:nn \l__scontents_name_seq_cmd_tl - { \exp_not:N \tex_scantokens:D { \tl_use:N \l__scontents_temp_tl } } + { \exp_not:N \__scontents_rescan_tokens:w { \tl_use:N \l__scontents_temp_tl } } \bool_if:NT \l__scontents_print_cmd_bool { \__scontents_getfrom_seq:nn { -1 } { \l__scontents_name_seq_cmd_tl } } \group_end: } -\ProvideDocumentCommand { \getstored } { O{1} m } +\NewDocumentCommand { \getstored } { O{1} m } { \__scontents_getfrom_seq:nn {#1} {#2} } -\ProvideDocumentCommand { \typestored } { s O{1} m } +\NewDocumentCommand { \typestored } { s O{1} m } { \group_begin: \tl_set:Nx \l__scontents_temp_tl { \__scontents_getfrom_seq:nn {#2} {#3} } @@ -212,7 +213,7 @@ \cs_set_eq:NN ^^M \scan_stop: \use:x { - \exp_not:N \tex_scantokens:D + \exp_not:N \__scontents_rescan_tokens:w { \exp_not:N \begin{verbatimsc} ^^M \__scontents_strip_scantokens:N #1 @@ -226,7 +227,7 @@ \use:x { \cs_gset_protected:Npn \exp_not:N \__scontents_xverb:w ##1 \g__scontents_end_verbatimsc_tl } { #1 \end{verbatimsc} } -\ProvideDocumentEnvironment { verbatimsc } { } +\NewDocumentEnvironment { verbatimsc } { } { \cs_set_eq:cN { @xverbatim } \__scontents_xverb:w \verbatim @@ -250,14 +251,14 @@ } \prg_new_conditional:Npnn \__scontents_if_scantokens:Nw #1#2 \q__scontents_mark { TF } { - \token_if_eq_meaning:NNTF \tex_scantokens:D #1 + \token_if_eq_meaning:NNTF \__scontents_rescan_tokens:w #1 { \prg_return_true: } { \prg_return_false: } } %%^^A User command to setup module -\ProvideDocumentCommand { \setupsc } { m } +\NewDocumentCommand { \setupsc } { m } { \keys_set:nn { scontents } {#1} } -\ProvideDocumentCommand { \meaningsc } { O{1} m } +\NewDocumentCommand { \meaningsc } { O{1} m } { \group_begin: \tl_set:Nx \l__scontents_temp_tl { \__scontents_getfrom_seq:nn {#1} {#2} } @@ -268,9 +269,9 @@ \cs_replacement_spec:N \l__scontents_temp_tl \group_end: } -\ProvideExpandableDocumentCommand { \countsc } { m } +\NewExpandableDocumentCommand { \countsc } { m } { \seq_count:c { g__scontents_seq_name_#1_seq } } -\ProvideExpandableDocumentCommand { \cleanseqsc } { m } +\NewDocumentCommand { \cleanseqsc } { m } { \seq_clear_new:c { g__scontents_seq_name_#1_seq } } %%^^A Messages \msg_new:nnn { scontents } { junk-after-begin } -- cgit v1.2.3