diff options
author | Karl Berry <karl@freefriends.org> | 2020-01-23 17:54:16 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-01-23 17:54:16 +0000 |
commit | bdd44614e6b6436d84baa1d4ba136ced66ae8e0b (patch) | |
tree | bd4b1668b1e81181c354c53b22eed3344ac0c8df /Master | |
parent | e1db097a0e2f5292da739738fc08b2659c7ceaab (diff) |
scontents (22jan20)
git-svn-id: svn://tug.org/texlive/trunk@53504 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/scontents/README.md | 12 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/scontents/scontents.pdf | bin | 341895 -> 373717 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/scontents/scontents.dtx | 354 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/scontents/scontents.ins | 6 | ||||
-rw-r--r-- | Master/texmf-dist/tex/context/third/scontents/t-scontents.mkiv | 10 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/scontents/scontents-code.tex | 176 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/scontents/scontents.tex | 6 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/scontents/scontents.sty | 8 |
8 files changed, 402 insertions, 170 deletions
diff --git a/Master/texmf-dist/doc/latex/scontents/README.md b/Master/texmf-dist/doc/latex/scontents/README.md index 9cb10569240..fe1c537bf15 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.8 -- Date: 2019-11-18 +- Version: 1.9 +- Date: 2020-01-21 - Author: Pablo González ## Description @@ -20,8 +20,12 @@ The package loads and depends on updated versions of: The package `scontents` is present in `TeXLive` and `MiKTeX`, use the package manager to install. -For manual installation, download `scontents.zip` and unzip it, then move -the files to appropriate locations: +For manual installation, download `scontents.zip` and unzip it, +then run: +``` +$ pdftex scontents.ins +``` +and move all files to appropriate locations: ``` scontents.tex -> TDS:tex/generic/scontents/ scontents-code.tex -> TDS:tex/generic/scontents/ diff --git a/Master/texmf-dist/doc/latex/scontents/scontents.pdf b/Master/texmf-dist/doc/latex/scontents/scontents.pdf Binary files differindex eea74b01014..4b5dfbc9c30 100644 --- a/Master/texmf-dist/doc/latex/scontents/scontents.pdf +++ b/Master/texmf-dist/doc/latex/scontents/scontents.pdf diff --git a/Master/texmf-dist/source/latex/scontents/scontents.dtx b/Master/texmf-dist/source/latex/scontents/scontents.dtx index 3f362eea956..f13db2db83a 100644 --- a/Master/texmf-dist/source/latex/scontents/scontents.dtx +++ b/Master/texmf-dist/source/latex/scontents/scontents.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 2019 by Pablo González L <pablgonz@educarchile.cl> +% Copyright (C) 2019-2020 by Pablo González L <pablgonz@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 @@ -34,7 +34,6 @@ \usepackage[top=0.5in,bottom=0.3in,left=2in,right=0.7in,footskip=0.2in,headheight=1cm,headsep=0.27cm]{geometry} \usepackage[osf,mono=false,scale=0.95,llscaled=0.95]{libertine} \setmonofont[ - %Ligatures = TeX, Numbers = OldStyle, Scale = 0.80, UprightFont = *-Regular, @@ -65,7 +64,6 @@ \mathcode`\-="702D \mathcode`\+="702B \mathcode`\:="703A \mathcode`\=="703D } \makeatother - \setmathfont[Scale = 0.95]{latinmodern-math.otf} \usepackage{fontawesome5} \newfontfamily\fetamontotf{ffmw10.otf}[ @@ -76,7 +74,7 @@ \usepackage[svgnames]{xcolor} \usepackage[sf,bf,compact,medium,pagestyles]{titlesec} \usepackage{lastpage,imakeidx,microtype,attachfile2} -\usepackage{adjustbox,multicol,listings,accsupp,titletoc} +\usepackage{adjustbox,multicol,listings,accsupp,titletoc,hypdestopt} \usepackage{scontents} % main \usepackage[contents]{colordoc} % \show\docCodelineNo @@ -104,15 +102,6 @@ |catcode`| 12|gdef|sxmacro@code#1% \end{macrocode*}[|liii@xmacro@code[#1]|end[macrocode*]] |endgroup -% Other patch for colordoc.sty to work xelatex -\makeatletter -\def\@moddecr#1{% - \global\advance#1\m@ne - \reset@color - \ifnum#1>\z@\else - \global#1\@colorlevels\fi} -\makeatother - \EnableCrossrefs % \PageIndex % \CodelineIndex undoes what \PageIndex does % \CodelineIndex tries to open another write stream for the index file. We don't @@ -530,7 +519,7 @@ \settitlemarks{section} \renewpagestyle{plain}[\color{optcolor}\small\sffamily]{% \setfoot{\rlap{\hskip\dimexpr-\oddsidemargin-1in\relax% - \parbox{1.93\paperwidth\relax}{\hfil\thepage\,/\,\pageref{LastPage}}}}% + \parbox{1.93\paperwidth}{\hfil\thepage\,/\,\pageref{LastPage}}}}% {}% {}% } @@ -540,8 +529,8 @@ \color{rulecolor}\rule[0.3cm]{\paperwidth}{0.7cm}}\hss } \setfoot{\rlap{\hskip\dimexpr-\oddsidemargin-1in\relax% - \parbox{1.93\paperwidth\relax}{\hfil\thepage\,/\,\pageref{LastPage}}}}% - {\parbox{\textwidth}{\raggedright \textcolor{gray}{\raisebox{-1pt}{\textcopyright}{}2019 by Pablo González}}}% + \parbox{1.93\paperwidth}{\hfil\thepage\,/\,\pageref{LastPage}}}}% + {\parbox{\textwidth}{\raggedright \textcolor{gray}{\raisebox{-1pt}{\textcopyright}{}2019--2020 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}}}% @@ -596,7 +585,7 @@ % \filedate.}\\[25pt] % \author{ % \large -% \raisebox{-1pt}{\textcopyright}{}2019 by Pablo González\thanks{ +% \raisebox{-1pt}{\textcopyright}{}2019--2020 by Pablo González\thanks{ % E-mail: \textcolor{OrangeRed}{\textsf{\guillemotleft}}\email{pablgonz@educarchile.cl}\textcolor{OrangeRed}{\textsf{\guillemotright}}. % }% % } @@ -786,7 +775,13 @@ % % The command \ics*{setupsc} sets the \mymeta{keys} in a global way, % it can be used both in the preamble and in the body of the document -% as many times as desired. +% as many times as desired. However, options set in the declaration of +% an environment (with \ics*{newenvsc}) have precedence over options +% set with \ics*{setupsc}. +% +% Options in the optional arguments of environments and +% commands have the highest precedence, overriding both +% options in \ics*{newenvsc}, and in \ics*{setupsc}. % \end{function} % % \keyexamp{verb-font}{font family}{\textnormal{\ttfamily\textbackslash{}ttfamily}} @@ -801,13 +796,14 @@ % environment and the \mykey{store-cmd} key of the \ics*{Scontents} command. This key is % only available as a package option or using \ics*{setupsc}. % -% \medskip +% \newpage % % \keyexamp{overwrite}{true \textnormal{\textcolor{lightgray}{\textbar}} false}{false} % Sets whether the \mymeta{files} generated by \mykey{write-out} and \mykey{write-env} -% from the \myenv*{scontents} environment will be rewritten. This key is -% available as a package option or using \ics*{setupsc} or \myenv*{scontents} -% environment. +% from the \myenv*{scontents} environment will be rewritten. This key is available as +% a package option, for \ics*{setupsc}, for \ics*{Scontents*} and for the environment +% \myenv*{scontents}. +% % \medskip % % \keyexamp{print-all}{true \textnormal{\textcolor{lightgray}{\textbar}} false}{false} @@ -820,8 +816,8 @@ % This key is necessary only if the last line is the closing of some % environment defined by the \mypkg{fancyvrb} package as §\end{Verbatim}§ % or another environment that does not support a comments \enquote{\ttfamily\textcolor{gray}{\%}} -% after closing §\end{<env>}%§. This key is available -% for the \myenv*{scontents} environment and the \ics*{Scontents} command. +% after closing §\end{<env>}%§. This key is available for the \myenv*{scontents} +% environment and the \ics*{Scontents} command. % % \keyexamp{width-tab}{integer}{1} % Sets the equivalence in \mymeta{spaces} for the character "TAB" @@ -851,10 +847,11 @@ % \mykey{print-all} & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark \\ % \mykey{store-all} & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark \\ % \mykey{write-env} & \xmark & \xmark & \cmark & \xmark & \xmark & \xmark & \xmark \\ -% \mykey{write-out} & \xmark & \xmark & \cmark & \xmark & \xmark & \xmark & \xmark \\ -% \mykey{overwrite} & \cmark & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark \\ +% \mykey{write-cmd} & \xmark & \xmark & \xmark & \xmark & \cmark & \xmark & \xmark \\ +% \mykey{write-out} & \xmark & \xmark & \cmark & \xmark & \cmark & \xmark & \xmark \\ +% \mykey{overwrite} & \cmark & \cmark & \cmark & \xmark & \cmark & \xmark & \xmark \\ % \mykey{width-tab} & \cmark & \cmark & \xmark & \xmark & \xmark & \cmark & \cmark \\ -% \mykey{force-eol} & \cmark & \cmark & \cmark & \xmark & \cmark & \xmark & \xmark \\ +% \mykey{force-eol} & \cmark & \cmark & \cmark & \cmark & \cmark & \xmark & \xmark \\ % \mykey{verb-font} & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark \\ % \bottomrule % \end{tabular} @@ -963,11 +960,12 @@ This text is in the outer environment (after nested). % % \keyexamp{write-env}{file.ext}{not used} % Sets the name of the \mymeta{external file} in which the \mymeta{contents} of -% the environment will be written. The \mymeta{file.ext} will be created -% in the working directory, if \mymeta{file.ext} exists it will be overwritten, -% relative or absolute paths are not supported. +% the environment will be written. The \mymeta{file.ext} will be created +% in the working directory, relative or absolute paths are not supported. If \mymeta{file.ext} +% does not exist, it will be created or overwritten if the \mykey{overwrite} key is used. +% % The characters "TAB"s will be written in \mymeta{file.ext} and the \mymeta{contents} -% will be stored in the sequence established at that time. \hologo{XeLaTeX} users +% will be stored in the \mymeta{sequence} established at that time. \hologo{XeLaTeX} users % using the "TAB" character must add \texttt{\textcolor{optcolor}{-8bit}} % at the command line, otherwise you will get \hologo{TeX}-"TAB" (§^^I§) % in \mymeta{file.ext}. @@ -977,11 +975,12 @@ This text is in the outer environment (after nested). % \keyexamp{write-out}{file.ext}{not used} % Sets the name of the \mymeta{external file} in which the \mymeta{contents} of % the environment will be written. The \mymeta{file.ext} will be created -% in the working directory, if \mymeta{file.ext} exists it will be overwritten, -% relative or absolute paths are not supported. +% in the working directory, relative or absolute paths are not supported. If \mymeta{file.ext} +% does not exist, it will be created or overwritten if the \mykey{overwrite} key is used. +% % The characters "TAB"s will be written in \mymeta{file.ext}, the rest of the % \mymeta{keys} will not be available and the \mymeta{contents} will NOT -% be stored in any sequence. \hologo{XeLaTeX} users using the "TAB" character +% be stored in any \mymeta{sequence}. \hologo{XeLaTeX} users using the "TAB" character % must add \texttt{\textcolor{optcolor}{-8bit}} at the command line, % otherwise you will get \hologo{TeX}-"TAB" (§^^I§) in \mymeta{file.ext}. % @@ -1006,8 +1005,8 @@ This text is in the outer environment (after nested). % The command \ics*{newenvsc} allows you to create \mymeta{new environments} % based on the same characteristics of the \myenv*{scontents} environment. % The values entered in \myoarg{initial keys} will be considered as the -% default values for this new environment and the valid \mymeta{keys} are the -% same as those of the \myenv*{scontents} environment. For example: +% default values for this new environment and the valid \mymeta{keys} are +% \mykey{store-env} and \mykey{print-env}. For example: % % \iffalse %<*example> @@ -1039,7 +1038,7 @@ This text is in the outer environment (after nested). % mode. It is not possible to pass environments such as \emph{verbatim}, % but it is possible to use the implementation of \ics{Verb} provided by % the \mypkg{fvextra} package for contents on one line and \ics{lstinline} -% from \mypkg{listings} package, but it is preferable to use the starred +% from \mypkg{listings} package, but it is preferable to use the starred (§*§) % version. % % The \ics*{Scontents*} command reads the \mymarg{argument} under \emph{verbatim} @@ -1076,6 +1075,37 @@ This text is in the outer environment (after nested). % running the command. The content is extracted from the \mymeta{sequence} % in which it is stored. % +% \subsection*{Options only for the starred version} +% \label{sec:onlystarred} +% +% \keyexamp{write-cmd}{file.ext}{not used} +% Sets the name of the \mymeta{external file} in which the \mymeta{contents} of +% the \mymarg{argument} will be written. The \mymeta{file.ext} will be created +% in the working directory, relative or absolute paths are not supported. If \mymeta{file.ext} +% does not exist, it will be created or overwritten if the \mykey{overwrite} key is used. +% +% The characters "TAB"s will be written in \mymeta{file.ext} and the \mymeta{contents} +% will be stored in the \mymeta{sequence} established at that time. \hologo{XeLaTeX} users +% using the "TAB" character must add \texttt{\textcolor{optcolor}{-8bit}} +% at the command line, otherwise you will get \hologo{TeX}-"TAB" (§^^I§) +% in \mymeta{file.ext}. +% +% \medskip +% +% \keyexamp{write-out}{file.ext}{not used} +% Sets the name of the \mymeta{external file} in which the \mymeta{contents} of +% the \mymarg{argument} will be written. The \mymeta{file.ext} will be created +% in the working directory, relative or absolute paths are not supported. If \mymeta{file.ext} +% does not exist, it will be created or overwritten if the \mykey{overwrite} key is used. +% +% The characters "TAB"s will be written in \mymeta{file.ext}, the rest of the +% \mymeta{keys} will not be available and the \mymeta{contents} will NOT +% be stored in any \mymeta{sequence}. \hologo{XeLaTeX} users using the "TAB" character +% must add \texttt{\textcolor{optcolor}{-8bit}} at the command line, +% otherwise you will get \hologo{TeX}-"TAB" (§^^I§) in \mymeta{file.ext}. +% +% The key \mykey{overwrite} is available for this command. +% % \subsection{The command \cs{getstored}} % \label{sec:getstored} % @@ -1378,6 +1408,8 @@ $ pdfdetach -saveall scontents.pdf \documentclass{article} \usepackage[store-cmd=solutions]{scontents} \newtheorem{ex}{Exercise} +\setlength{\parindent}{0pt} +\pagestyle{empty} \begin{document} \section{Problems} \begin{ex} @@ -1414,6 +1446,7 @@ Second exercise % arara: clean: { extensions: [ aux, log] } \documentclass{article} \usepackage[store-env=defexercise,store-cmd=defexercise]{scontents} +\setlength{\parindent}{0pt} \pagestyle{empty} \begin{document} % not starred @@ -1476,7 +1509,7 @@ seventies that the \NSA\ has known that for 40 years.\par \end{tikzpicture} \begin{tikzpicture} -\getstored[3]{tikz} +\getstored{tikz} \end{tikzpicture} \begin{scontents}[store-env=buffer] @@ -1520,6 +1553,7 @@ This is a \verb*|fake poor man's buffer :)|. % arara: clean: { extensions: [ aux, log] } \documentclass{article} \usepackage{scontents} +\setlength{\parindent}{0pt} \pagestyle{empty} \begin{document} \begin{scontents}[store-env=main] @@ -1537,11 +1571,11 @@ Something for \verb|other|. \textbf{Let's print them} This is first stored in main: \getstored[1]{main}\par -This is second stored in main: \getstored[2]{main}\par -This is stored in other: \getstored[1]{other} +This is second stored in main: \getstored{main}\par +This is stored in other: \getstored{other} \textbf{Print all of stored in main}\par -\foreachsc[sep={\\[10pt]}]{a} +\foreachsc[sep={\\[10pt]}]{main} \end{document} \end{scontents} % \iffalse @@ -1562,8 +1596,8 @@ This is stored in other: \getstored[1]{other} % arara: clean: { extensions: [ aux, log] } \documentclass{article} \usepackage{scontents} -\pagestyle{empty} \setlength{\parindent}{0pt} +\pagestyle{empty} \begin{document} \section{Problem stated the first time} \begin{scontents}[print-env=true,store-env=problem] @@ -1602,6 +1636,8 @@ This is from the verbatim environment: \documentclass[10pt]{article} \usepackage{scontents} \newenvsc{forshort}[store-env=forshort,print-env=false] +\setlength{\parindent}{0pt} +\pagestyle{empty} \begin{document} Something in the whole course. @@ -1668,7 +1704,7 @@ Prove new \Verb*{ fancyvrb whit braces } and environment \verb+Verbatim*+ \section{Test \texttt{\textbackslash getstored}} \getstored[1]{contents}\par -\getstored[2]{contents} +\getstored{contents} \section{Test \texttt{\textbackslash meaningsc}} \meaningsc[1]{contents}\par @@ -1738,7 +1774,7 @@ Prove \lstinline[basicstyle=\ttfamily]| lstinline | and environment \verb+Verbat and more.+ \section{Test \texttt{\textbackslash getstored}} -\getstored[2]{contents}\par +\getstored{contents}\par \getstored[1]{contents} \section{Test \texttt{\textbackslash typestored}} @@ -1772,6 +1808,7 @@ and more.+ \newminted{tex}{linenos} \newenvironment{verbatimsc}{\VerbatimEnvironment\begin{texcode}}{\end{texcode}} \pagestyle{empty} +\setlength{\parindent}{0pt} \begin{document} \section{Test \texttt{\textbackslash begin\{scontents\}} whit \texttt{minted}} Test \verb+{scontents}+ \par @@ -1798,7 +1835,7 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): \section{Test \texttt{\textbackslash getstored}} \getstored[1]{contents}\par -\getstored[2]{contents} +\getstored{contents} \section{Test \texttt{\textbackslash typestored}} \typestored[1]{contents} @@ -1815,6 +1852,7 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): % % \newpage % +% % \section{Change history} % \label{sec:changes} % @@ -1831,6 +1869,13 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): % \begin{description}[font=\small\sffamily,wide=0pt,style=multiline,leftmargin=\descrwidth,nosep,noitemsep] % \item [\fileversion{} (ctan), \filedate] % \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|. +% \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|. @@ -1899,6 +1944,30 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): % % \printindex[userdoc] % +% \let\stdsection\section +% \def\section*#1{\stdsection{#1}} +% +% \begin{thebibliography}{9} +% \bibitem{expl3} The \hologo{LaTeX3} Project. \enquote{The \textsf{expl3} +% package}. Available from +% \textsc{ctan}, \url{https://www.ctan.org/pkg/expl3}, 2020. +% +% \bibitem{xparse} The \hologo{LaTeX3} Project. \enquote{The \textsf{xparse} +% package}. Available from +% \textsc{ctan}, \url{https://www.ctan.org/pkg/xparse}, 2020. +% +% \bibitem{l3keys} The \hologo{LaTeX3} Project. \enquote{The \textsf{l3keys2e} +% package}. Available from +% \textsc{ctan}, \url{https://www.ctan.org/pkg/l3keys2e}, 2020. +% +% \bibitem{keyval} \textsc{Wright, Joseph}. \enquote{Programming +% \textsf{key–value} in \textsf{expl3}}. Available from +% \textsc{TUGboat}, +% \url{https://www.tug.org/TUGboat/tb31-1/tb97wright-l3keys.pdf}, 2010. +% \end{thebibliography} +% +% \let\section\stdsection +% % \newpage % % \StartImplementation @@ -1916,7 +1985,6 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): % \printindex % } % -% % \section{Implementation} % \label{sec:Implementation} % \addtocontents{toc}{\protect\setcounter{tocdepth}{0}} @@ -1937,10 +2005,10 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): % % Now we define some common macros to hold the package date and version: % \begin{macrocode} -%<loader>\def\ScontentsFileDate{2019-11-18}% -%<core>\def\ScontentsCoreFileDate{2019-11-18}% +%<loader>\def\ScontentsFileDate{2020-01-21}% +%<core>\def\ScontentsCoreFileDate{2020-01-21}% %<*loader> -\def\ScontentsFileVersion{1.8}% +\def\ScontentsFileVersion{1.9}% \def\ScontentsFileDescription{Stores LaTeX contents in memory or files}% % \end{macrocode} % @@ -2045,6 +2113,8 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): %</loader> %<*core> \begingroup + \catcode32=10 + \endlinechar=32 \def\next{\endgroup}% \expandafter\ifx\csname PackageError\endcsname\relax \begingroup @@ -2066,23 +2136,23 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): }% \endgroup \endinput - } + }% \else \ifx\ScontentsFileDate\ScontentsCoreFileDate \else \def\next {% - \PackageError{scontents}{Mismatched~scontents~files~detected} + \PackageError{scontents}{Mismatched scontents files detected} {% - You~have~attempted~to~load~scontents~with~mismatched~files:~ - probably~you~have~one~or~more~files~'locally~installed'~which~ - are~in~conflict.~Loading~of~scontents~will~abort. + You have attempted to load scontents with mismatched files: + probably you have one or more files 'locally installed' which + are in conflict. Loading of scontents will abort. }% \endgroup \endinput }% \fi -\fi + \fi \next % \end{macrocode} % @@ -2209,6 +2279,7 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): \bool_set_false:N \l_@@_foreach_stop_bool \bool_new:N \l_@@_foreach_wrapper_bool \bool_set_false:N \l_@@_foreach_wrapper_bool +\bool_new:N \l_@@_writable_bool % \end{macrocode} % \end{macro} % @@ -2326,12 +2397,25 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): % \begin{macrocode} \keys_define:nn { scontents / Scontents } { - print-cmd .meta:nn = { scontents } { print-cmd = #1 }, - print-cmd .default:n = true, - store-cmd .meta:nn = { scontents } { store-cmd = #1 }, - force-eol .meta:nn = { scontents } { force-eol = #1 }, - force-eol .default:n = true, - unknown .code:n = { \@@_parse_command_keys:n {#1} } + write-cmd .code:n = { + \bool_set_true:N \l_@@_writing_bool + \tl_set:Nn \l_@@_fname_out_tl {#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} + }, + write-env .value_required:n = true, + write-out .value_required:n = true, + print-cmd .meta:nn = { scontents } { print-cmd = #1 }, + print-cmd .default:n = true, + store-cmd .meta:nn = { scontents } { store-cmd = #1 }, + force-eol .meta:nn = { scontents } { force-eol = #1 }, + force-eol .default:n = true, + overwrite .meta:nn = { scontents } { overwrite = #1 }, + overwrite .default:n = true, + unknown .code:n = { \@@_parse_command_keys:n {#1} } } % \end{macrocode} % @@ -2366,7 +2450,7 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): wrapper .code:n = { \bool_set_true:N \l_@@_foreach_wrapper_bool \cs_set_protected:Npn - \@@_foreach_wrapper:n ##1 {#1} + \@@_foreach_wrapper:n ##1 {#1} }, wrapper .value_required:n = true, sep .tl_set:N = \l_@@_foreach_sep_tl, @@ -2669,6 +2753,7 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): \group_insert_after:N \tl_gclear:N \group_insert_after:N \g_@@_temp_tl } +\cs_generate_variant:Nn \@@_lastfrom_seq:n { V } % \end{macrocode} % \end{macro} % @@ -2760,7 +2845,8 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): \cs_new_protected:Npn \@@_env_generic_end: { \@@_stop_environment: - \@@_atend_environment: + \@@_finish_storing:NNN \l_@@_macro_tmp_tl + \l_@@_name_seq_env_tl \l_@@_print_env_bool } % \end{macrocode} % \end{macro} @@ -2913,19 +2999,12 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): \cs_new_protected:Npn \@@_file_tl_write_start:n #1 { \group_begin: - \bool_if:nT { \l_@@_writing_bool && \l_@@_overwrite_bool } + \@@_file_if_writable:nTF {#1} { - \file_if_exist:nTF {#1} - { \msg_warning:nnx { scontents } { overwrite-file } {#1} } - { \msg_warning:nnx { scontents } { writing-file } {#1} } - \iow_open:Nn \l_@@_file_iow {#1} - } - \bool_if:nT { \l_@@_writing_bool && !\l_@@_overwrite_bool } - { - \file_if_exist:nF {#1} - { \msg_warning:nnx { scontents } { writing-file } {#1} } - \iow_open:Nn \l_@@_file_iow {#1} + \bool_set_true:N \l_@@_writable_bool + \iow_open:Nn \l_@@_file_iow {#1} } + { \bool_set_false:N \l_@@_writable_bool } \tl_clear:N \l_@@_file_tl \seq_map_function:NN \l_char_special_seq \char_set_catcode_other:N \int_step_function:nnnN { 128 } { 1 } { 255 } \char_set_catcode_letter:n @@ -3000,7 +3079,7 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): } \cs_new_protected:Npn \@@_file_write_stop:N #1 { - \bool_if:NT \l_@@_writing_bool + \bool_if:NT \l_@@_writable_bool { \iow_close:N \l_@@_file_iow } \use:x { @@ -3042,7 +3121,7 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): % \begin{macrocode} \cs_new_protected:Npn \@@_verb_processor_output:n #1 { - \bool_if:NT \l_@@_writing_bool + \bool_if:NT \l_@@_writable_bool { \iow_now:Nn \l_@@_file_iow {#1} } \bool_if:NT \l_@@_storing_bool { \tl_put_right:Nn \l_@@_file_tl { ^^J #1 } } @@ -3165,24 +3244,19 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): % % \subsubsection{Recording of the content in the sequence} % -% \begin{macro}{\@@_atend_environment:} +% \begin{macro}{\@@_finish_storing:NNN} % Finishes the environment by optionally calling \cs{@@_store_to_seq:} % and then clearing the temporary token list. % % \begin{macrocode} -\cs_new_protected:Npn \@@_atend_environment: +\cs_new_protected:Npn \@@_finish_storing:NNN #1 #2 #3 { \bool_if:NT \l_@@_storing_bool { \bool_if:NF \l_@@_forced_eol_bool - { - \tl_put_right:Nx \l_@@_macro_tmp_tl - { \c_@@_hidden_space_str } - } - \@@_store_to_seq:NN \l_@@_macro_tmp_tl - \l_@@_name_seq_env_tl - \bool_if:NT \l_@@_print_env_bool - { \@@_lastfrom_seq:n \l_@@_name_seq_env_tl } + { \tl_put_right:Nx #1 { \c_@@_hidden_space_str } } + \@@_store_to_seq:NN #1 #2 + \bool_if:NT #3 { \@@_lastfrom_seq:V #2 } } } %</core> @@ -3258,6 +3332,48 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): % \end{macrocode} % \end{macro} % +% \begin{macro}{\@@_bsphack:,\@@_esphack:} +% \pkg{xparse} also requires \LaTeX's §\dospecials§. In case it doesn't +% exist (at the time \pkg{scontents} is loaded) we define §\dospecials§ +% to use the \cs{l_char_special_seq}. +% \begin{macrocode} +%<*core> +\int_new:N \l_@@_save_sf_int +\dim_new:N \l_@@_save_skip_dim +\cs_new_protected:Npn \@@_bsphack: + { + \scan_stop: + \mode_if_horizontal:T + { + \dim_set_eq:NN \l_@@_save_skip_dim \tex_lastskip:D + \int_set_eq:NN \l_@@_save_sf_int \tex_spacefactor:D + } + } +\cs_new_protected:Npn \@@_esphack: + { + \scan_stop: + \mode_if_horizontal:T + { + \int_set_eq:NN \tex_spacefactor:D \l_@@_save_sf_int + \dim_compare:nNnT { \l_@@_save_skip_dim } > { \c_zero_dim } + { + \dim_compare:nNnT { \tex_lastskip:D } = { \c_zero_dim } + { + \nobreak + \skip_horizontal:n { \c_zero_skip } + } + \tex_ignorespaces:D + } + } + } +%</core> +%<*latex> +\cs_gset_eq:NN \@@_bsphack: \@bsphack +\cs_gset_eq:NN \@@_esphack: \@esphack +%</latex> +% \end{macrocode} +% \end{macro} +% % \subsection{The command \cs{Scontents}} % % User command to \mymeta{stored content}, adapted from @@ -3289,6 +3405,7 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): %<*core> \cs_new_protected:Npn \@@_Scontents_internal:nn #1 #2 { + \@@_bsphack: \group_begin: \tl_if_novalue:nF {#2} { \keys_set:nn { scontents / Scontents } {#2} } @@ -3299,12 +3416,8 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): } \cs_new_protected:Npn \@@_norm_arg:n #1 { - \tl_set:Nx \l_@@_temp_tl { \exp_not:n {#1} } - \tl_put_right:Nx \l_@@_temp_tl { \c_@@_hidden_space_str } - \@@_store_to_seq:NN \l_@@_temp_tl \l_@@_name_seq_cmd_tl - \bool_if:NT \l_@@_print_cmd_bool - { \@@_lastfrom_seq:n \l_@@_name_seq_cmd_tl } - \group_end: + \tl_set:Nn \l_@@_temp_tl {#1} + \@@_Scontents_finish: } %</core> %<*loader> @@ -3314,15 +3427,54 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): %<*core> \cs_new_protected:Npn \@@_verb_arg_internal:n #1 { - \tl_set:Nx \l_@@_temp_tl { \exp_not:n {#1} } + \tl_set:Nn \l_@@_temp_tl {#1} \tl_replace_all:Nxx \l_@@_temp_tl { \iow_char:N \^^M } { \iow_char:N \^^J } - \bool_if:NF \l_@@_forced_eol_bool - { \tl_put_right:Nx \l_@@_temp_tl { \c_@@_hidden_space_str } } - \@@_store_to_seq:NN \l_@@_temp_tl \l_@@_name_seq_cmd_tl - \bool_if:NT \l_@@_print_cmd_bool - { \@@_lastfrom_seq:n \l_@@_name_seq_cmd_tl } + \@@_Scontents_finish: + } +\cs_new_protected:Npn \@@_Scontents_finish: + { + \@@_file_write_cmd:VV \l_@@_fname_out_tl \l_@@_temp_tl + \@@_finish_storing:NNN \l_@@_temp_tl + \l_@@_name_seq_cmd_tl \l_@@_print_cmd_bool + \use:x + { \group_end: + \bool_if:NF \l_@@_print_cmd_bool { \@@_esphack: } + } + } +\cs_new_protected:Npn \@@_file_write_cmd:nn #1#2 + { + \@@_file_if_writable:nT {#1} + { + \iow_open:Nn \l_@@_file_iow {#1} + \iow_now:Nn \l_@@_file_iow {#2} + \iow_close:N \l_@@_file_iow + } + } +\prg_new_protected_conditional:Npnn \@@_file_if_writable:n #1 { T, F, TF } + { + \bool_if:NTF \l_@@_writing_bool + { + \file_if_exist:nTF {#1} + { + \bool_if:NTF \l_@@_overwrite_bool + { + \msg_warning:nnx { scontents } { overwrite-file } {#1} + \prg_return_true: + } + { + \msg_warning:nnx { scontents } { not-writing } {#1} + \prg_return_false: + } + } + { + \msg_warning:nnx { scontents } { writing-file } {#1} + \prg_return_true: + } + } + { \prg_return_false: } } +\cs_generate_variant:Nn \@@_file_write_cmd:nn { VV } % \end{macrocode} % \end{macro} % @@ -3382,8 +3534,8 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): \@@_foreach_add_body:n \tl_gset:Nx \g_@@_temp_tl { - \seq_use:Nn \l_@@_foreach_print_seq - { \tl_use:N \l_@@_foreach_sep_tl } + \exp_args:NNV \seq_use:Nn + \l_@@_foreach_print_seq \l_@@_foreach_sep_tl } \group_end: \exp_after:wN \tl_gclear:N @@ -3707,6 +3859,8 @@ Read \Verb{\jobname.tsc} (shows TABs as red arrows): { Overwriting~file~'#1'. } \msg_new:nnn { scontents } { writing-file } { Writing~file~'#1'. } +\msg_new:nnn { scontents } { not-writing } + { File~`#1'~already~exists.~Not~writing. } \msg_new:nnn { scontents } { rescanning-text } { Rescanning~text~'#1'~after~\c_backslash_str end{#2}~\msg_line_context:.} \msg_new:nnn { scontents } { multiple-begin } diff --git a/Master/texmf-dist/source/latex/scontents/scontents.ins b/Master/texmf-dist/source/latex/scontents/scontents.ins index 953dc79bb69..c5770ae4849 100644 --- a/Master/texmf-dist/source/latex/scontents/scontents.ins +++ b/Master/texmf-dist/source/latex/scontents/scontents.ins @@ -3,7 +3,7 @@ \askforoverwritefalse \declarepreamble\standard -Copyright (C) 2019 by Pablo González L <pablgonz@educarchile.cl> +Copyright (C) 2019-2020 by Pablo González L <pablgonz@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 @@ -33,11 +33,11 @@ and the derived files scontents.sty, \declarepreamble\context \string\module [ file=t-scontents, - version=1.8, + version=1.9, title=\string\CONTEXT\ User Module, subtitle=Storing Contents, author=Pablo González, - date=2019-11-18, + date=2020-01-21, copyright=Pablo González, email=pablgonz@educarchile.cl, license=LPPL] diff --git a/Master/texmf-dist/tex/context/third/scontents/t-scontents.mkiv b/Master/texmf-dist/tex/context/third/scontents/t-scontents.mkiv index 944ff08225a..907c9b63b69 100644 --- a/Master/texmf-dist/tex/context/third/scontents/t-scontents.mkiv +++ b/Master/texmf-dist/tex/context/third/scontents/t-scontents.mkiv @@ -6,7 +6,7 @@ %% %% scontents.dtx (with options: `loader,context') %% -%% Copyright (C) 2019 by Pablo González L <pablgonz@educarchile.cl> +%% Copyright (C) 2019-2020 by Pablo González L <pablgonz@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 @@ -33,16 +33,16 @@ %% scontents.dtx (with options: `loader,context') %D \module %D [ file=t-scontents, -%D version=1.8, +%D version=1.9, %D title=\CONTEXT\ User Module, %D subtitle=Storing Contents, %D author=Pablo González, -%D date=2019-11-18, +%D date=2020-01-21, %D copyright=Pablo González, %D email=pablgonz@educarchile.cl, %D license=LPPL] -\def\ScontentsFileDate{2019-11-18}% -\def\ScontentsFileVersion{1.8}% +\def\ScontentsFileDate{2020-01-21}% +\def\ScontentsFileVersion{1.9}% \def\ScontentsFileDescription{Stores LaTeX contents in memory or files}% \writestatus{loading}{User Module scontents v\ScontentsFileVersion} \unprotect diff --git a/Master/texmf-dist/tex/generic/scontents/scontents-code.tex b/Master/texmf-dist/tex/generic/scontents/scontents-code.tex index f417191f680..2901886b2e0 100644 --- a/Master/texmf-dist/tex/generic/scontents/scontents-code.tex +++ b/Master/texmf-dist/tex/generic/scontents/scontents-code.tex @@ -6,7 +6,7 @@ %% %% scontents.dtx (with options: `core') %% -%% Copyright (C) 2019 by Pablo González L <pablgonz@educarchile.cl> +%% Copyright (C) 2019-2020 by Pablo González L <pablgonz@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 @@ -27,8 +27,10 @@ %% t-scontents.mkiv and %% scontents-code.tex. %% -\def\ScontentsCoreFileDate{2019-11-18}% +\def\ScontentsCoreFileDate{2020-01-21}% \begingroup + \catcode32=10 + \endlinechar=32 \def\next{\endgroup}% \expandafter\ifx\csname PackageError\endcsname\relax \begingroup @@ -50,23 +52,23 @@ }% \endgroup \endinput - } + }% \else \ifx\ScontentsFileDate\ScontentsCoreFileDate \else \def\next {% - \PackageError{scontents}{Mismatched~scontents~files~detected} + \PackageError{scontents}{Mismatched scontents files detected} {% - You~have~attempted~to~load~scontents~with~mismatched~files:~ - probably~you~have~one~or~more~files~'locally~installed'~which~ - are~in~conflict.~Loading~of~scontents~will~abort. + You have attempted to load scontents with mismatched files: + probably you have one or more files 'locally installed' which + are in conflict. Loading of scontents will abort. }% \endgroup \endinput }% \fi -\fi + \fi \next \keys_define:nn { scontents } { @@ -122,6 +124,7 @@ \bool_set_false:N \l__scontents_foreach_stop_bool \bool_new:N \l__scontents_foreach_wrapper_bool \bool_set_false:N \l__scontents_foreach_wrapper_bool +\bool_new:N \l__scontents_writable_bool \seq_new:N \l__scontents_foreach_print_seq \str_const:Nx \c__scontents_hidden_space_str { \c_percent_str \c_circumflex_str \c_circumflex_str A scheol \c_percent_str } @@ -160,12 +163,25 @@ } \keys_define:nn { scontents / Scontents } { - print-cmd .meta:nn = { scontents } { print-cmd = #1 }, - print-cmd .default:n = true, - store-cmd .meta:nn = { scontents } { store-cmd = #1 }, - force-eol .meta:nn = { scontents } { force-eol = #1 }, - force-eol .default:n = true, - unknown .code:n = { \__scontents_parse_command_keys:n {#1} } + write-cmd .code:n = { + \bool_set_true:N \l__scontents_writing_bool + \tl_set:Nn \l__scontents_fname_out_tl {#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} + }, + write-env .value_required:n = true, + write-out .value_required:n = true, + print-cmd .meta:nn = { scontents } { print-cmd = #1 }, + print-cmd .default:n = true, + store-cmd .meta:nn = { scontents } { store-cmd = #1 }, + force-eol .meta:nn = { scontents } { force-eol = #1 }, + force-eol .default:n = true, + overwrite .meta:nn = { scontents } { overwrite = #1 }, + overwrite .default:n = true, + unknown .code:n = { \__scontents_parse_command_keys:n {#1} } } \keys_define:nn { scontents / foreachsc } { @@ -193,7 +209,7 @@ wrapper .code:n = { \bool_set_true:N \l__scontents_foreach_wrapper_bool \cs_set_protected:Npn - \__scontents_foreach_wrapper:n ##1 {#1} + \__scontents_foreach_wrapper:n ##1 {#1} }, wrapper .value_required:n = true, sep .tl_set:N = \l__scontents_foreach_sep_tl, @@ -281,6 +297,7 @@ \group_insert_after:N \tl_gclear:N \group_insert_after:N \g__scontents_temp_tl } +\cs_generate_variant:Nn \__scontents_lastfrom_seq:n { V } \cs_new_protected:Npn \__scontents_store_to_seq:NN #1#2 { \tl_log:N #1 @@ -311,7 +328,8 @@ \cs_new_protected:Npn \__scontents_env_generic_end: { \__scontents_stop_environment: - \__scontents_atend_environment: + \__scontents_finish_storing:NNN \l__scontents_macro_tmp_tl + \l__scontents_name_seq_env_tl \l__scontents_print_env_bool } \cs_new_protected:Npn \__scontents_grab_optional:n #1 { @@ -365,19 +383,12 @@ \cs_new_protected:Npn \__scontents_file_tl_write_start:n #1 { \group_begin: - \bool_if:nT { \l__scontents_writing_bool && \l__scontents_overwrite_bool } - { - \file_if_exist:nTF {#1} - { \msg_warning:nnx { scontents } { overwrite-file } {#1} } - { \msg_warning:nnx { scontents } { writing-file } {#1} } - \iow_open:Nn \l__scontents_file_iow {#1} - } - \bool_if:nT { \l__scontents_writing_bool && !\l__scontents_overwrite_bool } + \__scontents_file_if_writable:nTF {#1} { - \file_if_exist:nF {#1} - { \msg_warning:nnx { scontents } { writing-file } {#1} } - \iow_open:Nn \l__scontents_file_iow {#1} + \bool_set_true:N \l__scontents_writable_bool + \iow_open:Nn \l__scontents_file_iow {#1} } + { \bool_set_false:N \l__scontents_writable_bool } \tl_clear:N \l__scontents_file_tl \seq_map_function:NN \l_char_special_seq \char_set_catcode_other:N \int_step_function:nnnN { 128 } { 1 } { 255 } \char_set_catcode_letter:n @@ -452,7 +463,7 @@ } \cs_new_protected:Npn \__scontents_file_write_stop:N #1 { - \bool_if:NT \l__scontents_writing_bool + \bool_if:NT \l__scontents_writable_bool { \iow_close:N \l__scontents_file_iow } \use:x { @@ -483,7 +494,7 @@ \cs_new:Npn \__scontents_remove_leading_nl:w ^^J { } \cs_new_protected:Npn \__scontents_verb_processor_output:n #1 { - \bool_if:NT \l__scontents_writing_bool + \bool_if:NT \l__scontents_writable_bool { \iow_now:Nn \l__scontents_file_iow {#1} } \bool_if:NT \l__scontents_storing_bool { \tl_put_right:Nn \l__scontents_file_tl { ^^J #1 } } @@ -563,19 +574,14 @@ ####2 \exp_not:N \q__scontents_stop } { \__scontents_analyse_nesting_generic_process:nn {##1} {##2} } } -\cs_new_protected:Npn \__scontents_atend_environment: +\cs_new_protected:Npn \__scontents_finish_storing:NNN #1 #2 #3 { \bool_if:NT \l__scontents_storing_bool { \bool_if:NF \l__scontents_forced_eol_bool - { - \tl_put_right:Nx \l__scontents_macro_tmp_tl - { \c__scontents_hidden_space_str } - } - \__scontents_store_to_seq:NN \l__scontents_macro_tmp_tl - \l__scontents_name_seq_env_tl - \bool_if:NT \l__scontents_print_env_bool - { \__scontents_lastfrom_seq:n \l__scontents_name_seq_env_tl } + { \tl_put_right:Nx #1 { \c__scontents_hidden_space_str } } + \__scontents_store_to_seq:NN #1 #2 + \bool_if:NT #3 { \__scontents_lastfrom_seq:V #2 } } } \cs_if_exist:NF \dospecials @@ -583,8 +589,37 @@ \cs_new:Npn \dospecials { \seq_map_function:NN \l_char_special_seq \do } } +\int_new:N \l__scontents_save_sf_int +\dim_new:N \l__scontents_save_skip_dim +\cs_new_protected:Npn \__scontents_bsphack: + { + \scan_stop: + \mode_if_horizontal:T + { + \dim_set_eq:NN \l__scontents_save_skip_dim \tex_lastskip:D + \int_set_eq:NN \l__scontents_save_sf_int \tex_spacefactor:D + } + } +\cs_new_protected:Npn \__scontents_esphack: + { + \scan_stop: + \mode_if_horizontal:T + { + \int_set_eq:NN \tex_spacefactor:D \l__scontents_save_sf_int + \dim_compare:nNnT { \l__scontents_save_skip_dim } > { \c_zero_dim } + { + \dim_compare:nNnT { \tex_lastskip:D } = { \c_zero_dim } + { + \nobreak + \skip_horizontal:n { \c_zero_skip } + } + \tex_ignorespaces:D + } + } + } \cs_new_protected:Npn \__scontents_Scontents_internal:nn #1 #2 { + \__scontents_bsphack: \group_begin: \tl_if_novalue:nF {#2} { \keys_set:nn { scontents / Scontents } {#2} } @@ -595,24 +630,59 @@ } \cs_new_protected:Npn \__scontents_norm_arg:n #1 { - \tl_set:Nx \l__scontents_temp_tl { \exp_not:n {#1} } - \tl_put_right:Nx \l__scontents_temp_tl { \c__scontents_hidden_space_str } - \__scontents_store_to_seq:NN \l__scontents_temp_tl \l__scontents_name_seq_cmd_tl - \bool_if:NT \l__scontents_print_cmd_bool - { \__scontents_lastfrom_seq:n \l__scontents_name_seq_cmd_tl } - \group_end: + \tl_set:Nn \l__scontents_temp_tl {#1} + \__scontents_Scontents_finish: } \cs_new_protected:Npn \__scontents_verb_arg_internal:n #1 { - \tl_set:Nx \l__scontents_temp_tl { \exp_not:n {#1} } + \tl_set:Nn \l__scontents_temp_tl {#1} \tl_replace_all:Nxx \l__scontents_temp_tl { \iow_char:N \^^M } { \iow_char:N \^^J } - \bool_if:NF \l__scontents_forced_eol_bool - { \tl_put_right:Nx \l__scontents_temp_tl { \c__scontents_hidden_space_str } } - \__scontents_store_to_seq:NN \l__scontents_temp_tl \l__scontents_name_seq_cmd_tl - \bool_if:NT \l__scontents_print_cmd_bool - { \__scontents_lastfrom_seq:n \l__scontents_name_seq_cmd_tl } + \__scontents_Scontents_finish: + } +\cs_new_protected:Npn \__scontents_Scontents_finish: + { + \__scontents_file_write_cmd:VV \l__scontents_fname_out_tl \l__scontents_temp_tl + \__scontents_finish_storing:NNN \l__scontents_temp_tl + \l__scontents_name_seq_cmd_tl \l__scontents_print_cmd_bool + \use:x + { \group_end: + \bool_if:NF \l__scontents_print_cmd_bool { \__scontents_esphack: } + } + } +\cs_new_protected:Npn \__scontents_file_write_cmd:nn #1#2 + { + \__scontents_file_if_writable:nT {#1} + { + \iow_open:Nn \l__scontents_file_iow {#1} + \iow_now:Nn \l__scontents_file_iow {#2} + \iow_close:N \l__scontents_file_iow + } + } +\prg_new_protected_conditional:Npnn \__scontents_file_if_writable:n #1 { T, F, TF } + { + \bool_if:NTF \l__scontents_writing_bool + { + \file_if_exist:nTF {#1} + { + \bool_if:NTF \l__scontents_overwrite_bool + { + \msg_warning:nnx { scontents } { overwrite-file } {#1} + \prg_return_true: + } + { + \msg_warning:nnx { scontents } { not-writing } {#1} + \prg_return_false: + } + } + { + \msg_warning:nnx { scontents } { writing-file } {#1} + \prg_return_true: + } + } + { \prg_return_false: } } +\cs_generate_variant:Nn \__scontents_file_write_cmd:nn { VV } \cs_new_protected:Npn \__scontents_getstored_internal:nn #1 #2 { \group_begin: @@ -641,8 +711,8 @@ \__scontents_foreach_add_body:n \tl_gset:Nx \g__scontents_temp_tl { - \seq_use:Nn \l__scontents_foreach_print_seq - { \tl_use:N \l__scontents_foreach_sep_tl } + \exp_args:NNV \seq_use:Nn + \l__scontents_foreach_print_seq \l__scontents_foreach_sep_tl } \group_end: \exp_after:wN \tl_gclear:N @@ -785,6 +855,8 @@ { Overwriting~file~'#1'. } \msg_new:nnn { scontents } { writing-file } { Writing~file~'#1'. } +\msg_new:nnn { scontents } { not-writing } + { File~`#1'~already~exists.~Not~writing. } \msg_new:nnn { scontents } { rescanning-text } { Rescanning~text~'#1'~after~\c_backslash_str end{#2}~\msg_line_context:.} \msg_new:nnn { scontents } { multiple-begin } diff --git a/Master/texmf-dist/tex/generic/scontents/scontents.tex b/Master/texmf-dist/tex/generic/scontents/scontents.tex index 03078a4cc9f..805c0430047 100644 --- a/Master/texmf-dist/tex/generic/scontents/scontents.tex +++ b/Master/texmf-dist/tex/generic/scontents/scontents.tex @@ -6,7 +6,7 @@ %% %% scontents.dtx (with options: `loader,plain') %% -%% Copyright (C) 2019 by Pablo González L <pablgonz@educarchile.cl> +%% Copyright (C) 2019-2020 by Pablo González L <pablgonz@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 @@ -27,8 +27,8 @@ %% t-scontents.mkiv and %% scontents-code.tex. %% -\def\ScontentsFileDate{2019-11-18}% -\def\ScontentsFileVersion{1.8}% +\def\ScontentsFileDate{2020-01-21}% +\def\ScontentsFileVersion{1.9}% \def\ScontentsFileDescription{Stores LaTeX contents in memory or files}% \input expl3-generic.tex \ExplSyntaxOn diff --git a/Master/texmf-dist/tex/latex/scontents/scontents.sty b/Master/texmf-dist/tex/latex/scontents/scontents.sty index 77147e8ecf7..13ff98bfabb 100644 --- a/Master/texmf-dist/tex/latex/scontents/scontents.sty +++ b/Master/texmf-dist/tex/latex/scontents/scontents.sty @@ -6,7 +6,7 @@ %% %% scontents.dtx (with options: `loader,latex') %% -%% Copyright (C) 2019 by Pablo González L <pablgonz@educarchile.cl> +%% Copyright (C) 2019-2020 by Pablo González L <pablgonz@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 @@ -27,8 +27,8 @@ %% t-scontents.mkiv and %% scontents-code.tex. %% -\def\ScontentsFileDate{2019-11-18}% -\def\ScontentsFileVersion{1.8}% +\def\ScontentsFileDate{2020-01-21}% +\def\ScontentsFileVersion{1.9}% \def\ScontentsFileDescription{Stores LaTeX contents in memory or files}% \RequirePackage{expl3,xparse,l3keys2e}[2019/05/28] \ProvidesExplPackage @@ -87,6 +87,8 @@ { \__scontents_grab_optional:n {#1} } \cs_new_eq:NN \__scontents_analyse_nesting_format:n \__scontents_analyse_nesting_latex:n +\cs_gset_eq:NN \__scontents_bsphack: \@bsphack +\cs_gset_eq:NN \__scontents_esphack: \@esphack \NewDocumentCommand { \Scontents }{ !s !O{} } { \__scontents_Scontents_internal:nn {#1} {#2} } \NewDocumentCommand { \__scontents_verb_arg:w } { +v } |