summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/scontents
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-11-18 03:01:03 +0000
committerNorbert Preining <norbert@preining.info>2019-11-18 03:01:03 +0000
commit96f9362fc3e3bb70fa2411c62418c42d9acda4d7 (patch)
tree0a5b5a1a0eb542f5e4a01241ff22837cc0e86835 /macros/latex/contrib/scontents
parentee7abbf3326590ad80cbd11ae7756c9238f7dab8 (diff)
CTAN sync 201911180301
Diffstat (limited to 'macros/latex/contrib/scontents')
-rw-r--r--macros/latex/contrib/scontents/README.md21
-rw-r--r--macros/latex/contrib/scontents/scontents.dtx1328
-rw-r--r--macros/latex/contrib/scontents/scontents.ins4
-rw-r--r--macros/latex/contrib/scontents/scontents.pdfbin336246 -> 341895 bytes
4 files changed, 844 insertions, 509 deletions
diff --git a/macros/latex/contrib/scontents/README.md b/macros/latex/contrib/scontents/README.md
index bd42d3ab4f..9cb1056924 100644
--- a/macros/latex/contrib/scontents/README.md
+++ b/macros/latex/contrib/scontents/README.md
@@ -1,13 +1,13 @@
## scontents — Stores LaTeX contents in memory or files
-- Version: 1.7
-- Date: 2019-10-29
+- Version: 1.8
+- Date: 2019-11-18
- Author: Pablo González
## Description
-The `scontents` package stores valid `LaTeX` code in memory (sequences) using the
-`l3seq` module of `expl3`. The stored content, including `verbatim` material, can be
-used as many times as desired in the document, additionally can be written
-to external files.
+This package allows to store `LaTeX` code, including _"verbatim"_, in <code>&lt;sequences&gt;</code>
+using the `l3seq` module of `expl3`. The <code>&lt;stored content&gt;</code> can be used
+as many times as desired in the document, additionally you can write to <code>&lt;external files&gt;</code>
+or show it in <code>&lt;verbatim style&gt;</code>.
## Requirements
The package loads and depends on updated versions of:
@@ -35,8 +35,13 @@ the files to appropriate locations:
then run `mktexlsr`.
## Examples
-The file `scontents.pdf` contains attached examples, which can be extracted
-from the PDF viewer or using `pdfdetach -saveall scontents.pdf` from command line.
+The file <code>&lt;scontents.pdf&gt;</code> contains attached examples, which can be extracted
+from the PDF viewer or from the command line by running:
+
+```
+$ pdfdetach -saveall scontents.pdf
+```
+and then you can use the excellent `arara` tool to compile them.
## License
The scontents package may be modified and distributed under the terms and
diff --git a/macros/latex/contrib/scontents/scontents.dtx b/macros/latex/contrib/scontents/scontents.dtx
index c2316fb999..3f362eea95 100644
--- a/macros/latex/contrib/scontents/scontents.dtx
+++ b/macros/latex/contrib/scontents/scontents.dtx
@@ -31,10 +31,10 @@
% 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[english]{babel}
-\usepackage[top=0.5in,bottom=0.5in,left=2in,right=0.7in,footskip=0.2in,headsep=10pt]{geometry}
+\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,
+ %Ligatures = TeX,
Numbers = OldStyle,
Scale = 0.80,
UprightFont = *-Regular,
@@ -42,11 +42,15 @@
BoldFont = *-Semibold,
BoldItalicFont = *-SemiboldIt,
RawFeature = {+zero,+ss06},
- FontFace = {m}{sc}{*-ExtraLight},
+ FontFace = {m}{sc}{LinBiolinum_R.otf},
Extension = .otf]{SourceCodePro}
-\newfontfamily\sourcecodeprolight{SourceCodePro-Regular.otf}[Scale = 0.80,FakeStretch =0.75]
+\newfontfamily\sourcecodeprolight{SourceCodePro-Regular.otf}[
+ Scale = 0.80,FakeStretch =0.75,
+ FontFace = {m}{it}{Font =SourceCodePro-RegularIt.otf,Color=FF0000}]
\RenewDocumentCommand{\MacroLongFont}{}
- { \sourcecodeprolight\small }
+ {
+ \sourcecodeprolight\small
+ }
% The character of visible space is now taken from Latin Modern Mono
% to prevent fonts in T1. The original definition for xetex/luatex is
% \def\verbvisiblespace{\usefont{OT1}{cmtt}{m}{n}\asciispace}
@@ -64,11 +68,6 @@
\setmathfont[Scale = 0.95]{latinmodern-math.otf}
\usepackage{fontawesome5}
-\newfontfamily\lmmitalic{lmmono10-italic.otf}[
- Scale = 0.95,%
- Extension = .otf,%
- ItalicFont = lmmono10-italic,%
- ]
\newfontfamily\fetamontotf{ffmw10.otf}[
Scale = 0.95,%
RawFeature = {+latn,+rand,+kern,+size},%
@@ -76,10 +75,11 @@
]
\usepackage[svgnames]{xcolor}
\usepackage[sf,bf,compact,medium,pagestyles]{titlesec}
-\usepackage{hyperxmp,lastpage,imakeidx,microtype,attachfile2}
+\usepackage{lastpage,imakeidx,microtype,attachfile2}
\usepackage{adjustbox,multicol,listings,accsupp,titletoc}
\usepackage{scontents} % main
\usepackage[contents]{colordoc}
+% \show\docCodelineNo
\def\textnew#1{\color{color-def}#1\/}
\def\AltMacroFont{\fontencoding\encodingdefault
\fontfamily\ttdefault
@@ -104,6 +104,15 @@
|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
@@ -117,9 +126,19 @@
\expandafter\DoNotIndex\expandafter{\string\}}
\expandafter\DoNotIndex\expandafter{\string\begin}
\newcommand{\HP}[1]{\emph{\hyperpage{#1}}\normalsize}
-\def\MYSortIndex#1#2{\index[userdoc]{#1\actualchar#2|HP}}
+\ExplSyntaxOn
+\cs_new_protected:Npn \StartImplementation
+ { \bool_set_true:N \l__codedoc_in_implementation_bool }
+\bool_set_false:N \l__codedoc_in_implementation_bool
+\cs_new_protected:Npn \MYSortIndex #1 #2
+ {
+ \bool_if:NTF \l__codedoc_in_implementation_bool
+ { \index{#1\actualchar#2|HP} }
+ { \index[userdoc]{#1\actualchar#2|HP} }
+ }
+\ExplSyntaxOff
-\indexsetup{level=\section,firstpagestyle=myheader}
+\indexsetup{level=\section,firstpagestyle=myheader,othercode=\pagestyle{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
@@ -130,104 +149,108 @@
\setlength{\parindent}{0pt}
-%%-------------------- ONLY FOR DOCUMENTATION ------------------------%%
-% Colors for options
+% Colors
\definecolor{optcolor}{rgb}{0.281,0.275,0.485}
-\definecolor{mypkgcolor}{RGB}{0,128,128}%
+\definecolor{pkgcolor}{rgb}{0,0.5,0.5}
+\definecolor{araracolor}{rgb}{0, 0.72, 0.28}
+\definecolor{linkcolor}{rgb}{0.04,0.38,0.04}
+\definecolor{rulecolor}{rgb}{0.96,0.96,0.96}
-% Logo with fetamont font for title
-\makeatletter
-\newsavebox{\logobox}
-\savebox{\logobox}{%
- \normalsize\fetamontotf{\textcolor{mypkgcolor}{s}\textcolor{OrangeRed}{content}\textcolor{mypkgcolor}{s}}}
-\newcommand{\mylogo}{%
- \settoheight{\@tempdima}{L}%
- \resizebox{!}{\@tempdima}{\usebox{\logobox}}%
- }
-\makeatother
+% Only for arara... I like arara :)
+\usepackage[scale=0.85]{comfortaa}
+\newcommand{\araratext}[1]{{\small\normalfont\comfortaa\color{araracolor}\bfseries#1}}
+\newcommand*\arara{\araratext{ar\kern-.03emar\kern-.03ema}}
-% Custom \meta[...]{...}, \marg[...]{...} and \oarg[...]{...} with color
-\ExplSyntaxOn
% User level commands
+\ExplSyntaxOn
+% Logo with fetamont font
+\NewDocumentCommand{\pkglogo}{}
+ {
+ \group_begin:
+ \fetamontotf{\textcolor{pkgcolor}{s}\textcolor{OrangeRed}{content}\textcolor{pkgcolor}{s}}
+ \group_end:
+ }
+
+% Custom \meta[...]{...}, \marg[...]{...} and \oarg[...]{...} with color
\NewDocumentCommand{\mymeta}{O{}m}
{
- \userdoc_meta_generic:Nnn \userdoc_meta:n { #1 } { #2 }
+ \userdoc_meta_generic:Nnn \userdoc_meta:n { #1 } { #2 }
}
\NewDocumentCommand{\mymarg}{O{}m}
{
- \userdoc_meta_generic:Nnn \userdoc_marg:n { #1 } { #2 }
+ \userdoc_meta_generic:Nnn \userdoc_marg:n { #1 } { #2 }
}
\NewDocumentCommand{\myoarg}{O{}m}
{
- \userdoc_meta_generic:Nnn \userdoc_oarg:n { #1 } { #2 }
+ \userdoc_meta_generic:Nnn \userdoc_oarg:n { #1 } { #2 }
}
% Variables and keys
\tl_new:N \l_userdoc_meta_font_tl
\keys_define:nn { userdoc / mymeta }
{
- type .choice:,
- type / tt .code:n = \tl_set:Nn \l_userdoc_meta_font_tl { \ttfamily },
- type / rm .code:n = \tl_set:Nn \l_userdoc_meta_font_tl { \rmfamily },
- type .initial:n = rm,
- cf .tl_set:N = \l_userdoc_meta_color_tl,
- cf .initial:n = optcolor,
- ac .tl_set:N = \l_userdoc_meta_anglecolor_tl,
- ac .initial:n = lightgray,
- sbc .tl_set:N = \l_userdoc_meta_brackcolor_tl,
- sbc .initial:n = gray,
- cbc .tl_set:N = \l_userdoc_meta_bracecolor_tl,
- cbc .initial:n = gray,
+ type .choice:,
+ type / tt .code:n = \tl_set:Nn \l_userdoc_meta_font_tl { \ttfamily },
+ type / rm .code:n = \tl_set:Nn \l_userdoc_meta_font_tl { \rmfamily },
+ type .initial:n = rm,
+ cf .tl_set:N = \l_userdoc_meta_color_tl,
+ cf .initial:n = optcolor,
+ ac .tl_set:N = \l_userdoc_meta_anglecolor_tl,
+ ac .initial:n = lightgray,
+ sbc .tl_set:N = \l_userdoc_meta_brackcolor_tl,
+ sbc .initial:n = gray,
+ cbc .tl_set:N = \l_userdoc_meta_bracecolor_tl,
+ cbc .initial:n = gray,
}
% Internal commands
\cs_new_protected:Npn \userdoc_meta_generic:Nnn #1 #2 #3
{
- \group_begin:
- \keys_set:nn { userdoc / mymeta } { #2 }
- \color{ \l_userdoc_meta_color_tl }
- \l_userdoc_meta_font_tl
- #1 { #3 } % #1 is \userdoc_meta:n, \userdoc_marg:n or \userdoc_oarg:n
- \group_end:
+ \group_begin:
+ \keys_set:nn { userdoc / mymeta } { #2 }
+ \color{ \l_userdoc_meta_color_tl }
+ \l_userdoc_meta_font_tl
+ #1 { #3 } % #1 is \userdoc_meta:n, \userdoc_marg:n or \userdoc_oarg:n
+ \group_end:
}
\cs_new_protected:Npn \userdoc_meta:n #1
{
- \userdoc_meta_angle:n { \textlangle }
- \userdoc_meta_meta:n { #1 }
- \userdoc_meta_angle:n { \textrangle }
+ \userdoc_meta_angle:n { \textlangle }
+ \userdoc_meta_meta:n { #1 }
+ \userdoc_meta_angle:n { \textrangle }
}
\cs_new_protected:Npn \userdoc_marg:n #1
{
- \userdoc_meta_brace:n { \textbraceleft }
- \userdoc_meta:n { #1 }
- \userdoc_meta_brace:n { \textbraceright }
+ \userdoc_meta_brace:n { \textbraceleft }
+ \userdoc_meta:n { #1 }
+ \userdoc_meta_brace:n { \textbraceright }
}
\cs_new_protected:Npn \userdoc_oarg:n #1
{
- \userdoc_meta_brack:n { [ }
- \userdoc_meta:n { #1 }
- \userdoc_meta_brack:n { ] }
+ \userdoc_meta_brack:n { [ }
+ \userdoc_meta:n { #1 }
+ \userdoc_meta_brack:n { ] }
}
\cs_new_protected:Npn \userdoc_meta_meta:n #1
{
- \textnormal{\textit{#1}}
+ \textnormal{\textit{#1}}
}
\cs_new_protected:Npn \userdoc_meta_angle:n #1
{
- \group_begin:
- \fontfamily{lmr}\selectfont
- \textcolor{\l_userdoc_meta_anglecolor_tl}{#1}
- \group_end:
+ \group_begin:
+ \fontfamily{lmr}\selectfont
+ \textcolor{\l_userdoc_meta_anglecolor_tl}{#1}
+ \group_end:
}
\cs_new_protected:Npn \userdoc_meta_brace:n #1
{
- \group_begin:
- \color{\l_userdoc_meta_bracecolor_tl}
+ \group_begin:
+ \color{\l_userdoc_meta_bracecolor_tl}
#1
- \group_end:
+ \group_end:
}
\cs_new_protected:Npn \userdoc_meta_brack:n #1
{
- \textcolor{\l_userdoc_meta_brackcolor_tl}{#1}
+ \textcolor{\l_userdoc_meta_brackcolor_tl}{#1}
}
% \envexamp{m}
\newsavebox{\boxexaenv}
@@ -236,10 +259,10 @@
\begin{lrbox}{\boxexaenv}%
\begin{minipage}[t]{\marginparwidth}%
\raggedright\ttfamily\small
- \textcolor{gray}{\textbackslash begin\{\textcolor{mypkgcolor}{{#1}}\}\myoarg
+ \textcolor{gray}{\textbackslash begin\{\textcolor{pkgcolor}{{#1}}\}\myoarg
[type=tt,sbc=gray,ac=lightgray,cf=optcolor]{keyval ~ list}}\par%
\hspace{0.5cm}\mymeta[type=tt,ac=lightgray,cf=gray]{env ~ contents}\par%
- \textcolor{gray}{\textbackslash end\{{\textcolor{mypkgcolor}{{#1}}}\}}\par
+ \textcolor{gray}{\textbackslash end\{{\textcolor{pkgcolor}{{#1}}}\}}\par
\end{minipage}%
\end{lrbox}%
\usebox{\boxexaenv}
@@ -249,10 +272,10 @@
\begin{lrbox}{\boxexaenv}%
\begin{minipage}[t]{\marginparwidth}%
\raggedright\ttfamily\small
- \textcolor{mypkgcolor}{{\textbackslash#1#2}}\myoarg
+ \textcolor{pkgcolor}{{\textbackslash#1#2}}\myoarg
[type=tt,sbc=gray,ac=lightgray,cf=optcolor]{keyval ~ list}\par%
\hspace{0.5cm}\mymeta[type=tt,ac=lightgray,cf=gray]{env ~ contents}\par%
- \textcolor{mypkgcolor}{{\textbackslash #3#2}}\par
+ \textcolor{pkgcolor}{{\textbackslash #3#2}}\par
\end{minipage}%
\end{lrbox}%
\usebox{\boxexaenv}
@@ -261,22 +284,20 @@
% \cmdexamp{s m o m o}
\DeclareDocumentCommand{\cmdexamp}{o m o m o}
{
- \group_begin:
- \small\ttfamily
- \textcolor{mypkgcolor}{\textbackslash#2}
- \IfValueT{#1}{ \textcolor{MediumOrchid}{#1} }
- \IfValueT{#3}{ \myoarg[type=tt,sbc=gray,ac=lightgray,cf=optcolor]{#3} }
- \IfValueTF{#5}
- {
- \mymeta[ac=gray,type=tt,cf=MediumOrchid]{#5}%
- \mymeta[type=tt,ac=gray,cf=optcolor]{#4}
- \mymeta[ac=gray,type=tt,cf=MediumOrchid]{#5}%
- }
- { \mymarg[type=tt,cbc=gray,ac=lightgray,cf=optcolor]{#4} }
- \par
- \group_end:
- \MYSortIndex{Commands}{Commands ~ provide ~ by ~
- {\fetamontotf{\textcolor{mypkgcolor}{s}\textcolor{OrangeRed}{content}\textcolor{mypkgcolor}{s}}}:}%
+ \group_begin:
+ \small\ttfamily
+ \textcolor{pkgcolor}{\textbackslash#2}
+ \IfValueT{#1}{ \textcolor{MediumOrchid}{#1} }
+ \IfValueT{#3}{ \myoarg[type=tt,sbc=gray,ac=lightgray,cf=optcolor]{#3} }
+ \IfValueTF{#5}
+ {
+ \mymeta[ac=gray,type=tt,cf=MediumOrchid]{#5}%
+ \mymeta[type=tt,ac=gray,cf=optcolor]{#4}
+ \mymeta[ac=gray,type=tt,cf=MediumOrchid]{#5}%
+ }
+ { \mymarg[type=tt,cbc=gray,ac=lightgray,cf=optcolor]{#4} }
+ \par
+ \group_end:
}
% \keyexamp{mmm}
@@ -286,19 +307,25 @@
\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})}
+ \hfill\textcolor{gray}{\small\textsf{default}:~\emph{#3}}
\par
\MYSortIndex{Keys}{Keys>\texttt{#1}}%
}
+% \mykey{m}
+\DeclareDocumentCommand{\mykey}{ m }
+ {
+ \textcolor{optcolor}{\texttt{#1}}
+ \MYSortIndex{Keys}{Keys>\texttt{#1}}%
+ }
+
% \mypkg{sm}
\NewDocumentCommand{\mypkg}{sm}
{
\group_begin:
\IfBooleanTF{#1}
{
- %\textsf{\textcolor{mypkgcolor}{s}\textcolor{OrangeRed}{content}\textcolor{mypkgcolor}{s}}
- \fetamontotf{\textcolor{mypkgcolor}{s}\textcolor{OrangeRed}{content}\textcolor{mypkgcolor}{s}}
+ \pkglogo
\MYSortIndex{packages}{Packages>\texttt{#2}}
}
{
@@ -313,13 +340,12 @@
{
\IfBooleanTF{#1}
{
- \textcolor{mypkgcolor}{\ttfamily{#2}}%
- \MYSortIndex{environment}{ Environment ~ provide ~ by ~
- {\fetamontotf{\textcolor{mypkgcolor}{s}\textcolor{OrangeRed}{content}\textcolor{mypkgcolor}{s}}}:>\texttt{#2}}
+ \textcolor{pkgcolor}{\ttfamily{#2}}%
+ \MYSortIndex{environment}{ Environment ~ provide ~ by ~\pkglogo :>\texttt{#2}}
}
{
- \textcolor{darkgray}{\ttfamily{#2}}%
- \MYSortIndex{environment}{Environments>\texttt{#2}}
+ \textcolor{darkgray}{\ttfamily{#2}}%
+ \MYSortIndex{environment}{Environments>\texttt{#2}}
}
}
@@ -330,12 +356,8 @@
{
\tl_set:Nn \l_tmpa_tl { #2 }
\regex_replace_once:nnN { (\*) } { \c{textcolor}\cB\{MediumOrchid\cE\}\cB\{\1\cE\} } \l_tmpa_tl
- \textcolor{mypkgcolor}{\ttfamily\textbackslash{\tl_use:N \l_tmpa_tl}}
- \MYSortIndex{Commands}{ Commands ~ provide ~ by ~
- {
- \fetamontotf{
- \textcolor{mypkgcolor}{s}\textcolor{OrangeRed}{content}\textcolor{mypkgcolor}{s}}
- }:>\texttt{\textbackslash#2}}
+ \textcolor{pkgcolor}{\ttfamily\textbackslash{\tl_use:N \l_tmpa_tl}}
+ \MYSortIndex{Commands}{ Commands ~ provide ~ by ~ \pkglogo :>\texttt{\textbackslash#2}}
}
{
\textcolor{darkgray}{\ttfamily\textbackslash{#2}}
@@ -363,10 +385,9 @@
\lstnewenvironment{verbatimsc}
{
\lstset{
- language=,%
- basicstyle= \ttfamily,
- columns = fullflexible,
- gobble = 2,%
+ language =,%
+ basicstyle = \ttfamily\small,
+ gobble = 2,%
}
}{}
\makeatother
@@ -376,100 +397,100 @@
% Create a language for documentation
\lstdefinelanguage{scontents-doc}{
- texcsstyle=*,%
- escapechar=`,%
- extendedchars=true,%
- breakatwhitespace=true,%
- breaklines=true,%
- keepspaces=true,%
- columns=fullflexible,%
- stringstyle= {\color{red}},%
- basicstyle=\ttfamily\small,%
- alsoletter={-,@,.},%
+ texcsstyle = *,%
+ escapechar = Ç,%
+ extendedchars = true,%
+ keepspaces = true,%
+ stringstyle = {\color{red}},%
+ basicstyle = \ttfamily\small,%
+ alsoletter = {-,@,.},%
% comments
- morecomment=[l]{\%},%
- commentstyle=\lmmitalic\small\itshape\color{lightgray},%
+ morecomment = [l]{\%},%
+ commentstyle = \ttfamily\small\color{lightgray},%
% Important words 1
- keywordstyle=[1]{\color{gray}},%
- keywords=[1]{begin,end,Verbatim},%
+ keywordstyle = [1]{\color{gray}},%
+ keywords = [1]{begin,end,Verbatim,env,myseq,false},%
% Other words 2
- keywordstyle=[2]{\color{blue!75}},%
- keywords=[2]{usepackage,section,documentclass,input,usemodule,
- subsection,ExplSyntaxOff,ExplSyntaxOn,RequirePackage,
- ProvidesExplPackage},%
+ keywordstyle = [2]{\color{blue!75}},%
+ keywords = [2]{usepackage,section,documentclass,input,usemodule,
+ subsection,ExplSyntaxOff,ExplSyntaxOn,RequirePackage,
+ ProvidesExplPackage},%
% Other words 3
- keywordstyle=[3]{\color{optcolor!85}},%
- keywords=[3]{document,article,setlength,pagestyle,definecolor},%
+ keywordstyle = [3]{\color{optcolor!85}},%
+ keywords = [3]{document,article,setlength,pagestyle,definecolor},%
% Reserved words 4 (scontents pkg)
- keywordstyle=[4]{\color{mypkgcolor}},%
- keywords=[4]{scontents,Scontents,getstored,typestored,verbatimsc,%
- endverbatimsc,countsc,meaningsc,foreachsc,macros
- endscontents,startscontents,stopscontents,scontents.tex},%
-% Reserved in red
- keywordstyle=[5]{\color{red}},%
- keywords=[5]{makeatletter,makeatother,let,verb,@undefined,makebox,def,%
- par,item,parindent,lstinline,@ifpackagelater,ver@xparse.sty,%
- dospecials,do@noligs,char,outer},%
-% Reserved in orange
- keywordstyle=[6]{\color{optcolor}},%
- keywords=[6]{store-cmd,store-env,print-env,print-cmd,write-env,%
- start,stopt,wrapper,sep,step,before,after,write-out,%
- width-tab,force-eol,inner,outer,I,J,M,L,Ascheol},%
-% Reserved in orange
- keywordstyle=[7]{\color{OrangeRed}},%
- keywords=[7]{DefineVerbatimEnvironment,lstnewenvironment,newminted,%
- newtheorem,newenvironment,VerbatimEnvironment},%
+ keywordstyle = [4]{\color{pkgcolor}},%
+ keywords = [4]{scontents,Scontents,getstored,typestored,verbatimsc,%
+ endverbatimsc,countsc,meaningsc,foreachsc,macros,newenvsc,
+ endscontents,startscontents,stopscontents,scontents.tex},%
+% Reserved words 5 (in red)
+ keywordstyle = [5]{\color{red}},%
+ keywords = [5]{makeatletter,makeatother,let,verb,@undefined,makebox,def,%
+ par,item,parindent,lstinline,@ifpackagelater,ver@xparse.sty,%
+ ver@scontents.sty,dospecials,do@noligs,char,outer,jobname,inner},%
+% Reserved words 6 (optcolor)
+ keywordstyle = [6]{\color{optcolor}},%
+ keywords = [6]{store-cmd,store-env,print-env,print-cmd,write-env,%
+ start,stopt,wrapper,sep,step,before,after,write-out,%
+ overwrite,width-tab,force-eol,inner,outer,I,J,M,L,Ascheol},%
+% Reserved words 7 (OrangeRed)
+ keywordstyle = [7]{\color{OrangeRed}},%
+ keywords = [7]{DefineVerbatimEnvironment,lstnewenvironment,newminted,%
+ newtheorem,newenvironment,VerbatimEnvironment,myenvstore},%
% literate
- literate=*{\{}{{{\color{gray}{\char`\{}}}}{1}
- {\}}{{{\color{gray}{\char`\}}}}}{1}
- {\|}{{{\color{gray}{\char`\|}}}}{1}
- {\$}{{{\color{gray}{\char`\$}}}}{1}
- {\#}{{{\color{optcolor}{\char`\#}}}}{1}
- {[}{{\textcolor{gray}{[}}}{1}
- {]}{{\textcolor{gray}{]}}}{1}
- {,}{{\textcolor{gray}{,}}}{1}
- {;}{{\textcolor{gray}{;}}}{1}
- {\&}{{\textcolor{gray}{\&}}}{1}
- {>}{{\textcolor{OrangeRed}{\guillemotright}}}{1}
- {*}{{\textcolor{MediumOrchid}{*}}}{1}
- %{@}{{\textcolor{red}{@}}}{1}
- {\^}{{\textcolor{optcolor}{\textasciicircum}}}{1}
- {0}{{\textcolor{MediumOrchid}{0}}}{1}
- {1}{{\textcolor{MediumOrchid}{1}}}{1}
- {2}{{\textcolor{MediumOrchid}{2}}}{1}
- %{3}{{\textcolor{MediumOrchid}{3}}}{1}% expl3
- {4}{{\textcolor{MediumOrchid}{4}}}{1}
- {5}{{\textcolor{MediumOrchid}{5}}}{1}
- {6}{{\textcolor{MediumOrchid}{6}}}{1}
- {7}{{\textcolor{MediumOrchid}{7}}}{1}
- {8}{{\textcolor{MediumOrchid}{8}}}{1}
- {9}{{\textcolor{MediumOrchid}{9}}}{1}
- {.0}{{\textcolor{MediumOrchid}{.0}}}{2}% Following is to ensure that only periods
- {.1}{{\textcolor{MediumOrchid}{.1}}}{2}% followed by a digit are changed.
- {.2}{{\textcolor{MediumOrchid}{.2}}}{2}
- {.3}{{\textcolor{MediumOrchid}{.3}}}{2}
- {.4}{{\textcolor{MediumOrchid}{.4}}}{2}
- {.5}{{\textcolor{MediumOrchid}{.5}}}{2}
- {.6}{{\textcolor{MediumOrchid}{.6}}}{2}
- {.7}{{\textcolor{MediumOrchid}{.7}}}{2}
- {.8}{{\textcolor{MediumOrchid}{.8}}}{2}
- {.9}{{\textcolor{MediumOrchid}{.9}}}{2}
- {=}{{\textcolor{gray}{=}}}{1},%
+ literate =*{\{}{{{\color{gray}{\char`\{}}}}{1}
+ {\}}{{{\color{gray}{\char`\}}}}}{1}
+ {\|}{{{\color{gray}{\char`\|}}}}{1}
+ {\$}{{{\color{gray}{\char`\$}}}}{1}
+ {\#}{{{\color{optcolor}{\char`\#}}}}{1}
+ {[}{{\textcolor{gray}{[}}}{1}
+ {]}{{\textcolor{gray}{]}}}{1}
+ {,}{{\textcolor{gray}{,}}}{1}
+ {;}{{\textcolor{gray}{;}}}{1}
+ {`}{{\textcolor{gray}{\textasciigrave}}}{1}
+ {\&}{{\textcolor{gray}{\&}}}{1}
+ {>}{{\textcolor{OrangeRed}{\guillemotright}}}{1}
+ {<}{{\textcolor{OrangeRed}{\guillemotleft}}}{1}
+ {*}{{\textcolor{MediumOrchid}{*}}}{1}
+ {\^}{{\textcolor{optcolor}{\textasciicircum}}}{1}
+ {0}{{\textcolor{MediumOrchid}{0}}}{1}
+ {1}{{\textcolor{MediumOrchid}{1}}}{1}
+ {2}{{\textcolor{MediumOrchid}{2}}}{1}
+ {3}{{\textcolor{MediumOrchid}{3}}}{1}
+ {4}{{\textcolor{MediumOrchid}{4}}}{1}
+ {5}{{\textcolor{MediumOrchid}{5}}}{1}
+ {6}{{\textcolor{MediumOrchid}{6}}}{1}
+ {7}{{\textcolor{MediumOrchid}{7}}}{1}
+ {8}{{\textcolor{MediumOrchid}{8}}}{1}
+ {9}{{\textcolor{MediumOrchid}{9}}}{1}
+ {.0}{{\textcolor{MediumOrchid}{.0}}}{2}% Following is to ensure that only periods
+ {.1}{{\textcolor{MediumOrchid}{.1}}}{2}% followed by a digit are changed.
+ {.2}{{\textcolor{MediumOrchid}{.2}}}{2}
+ {.3}{{\textcolor{MediumOrchid}{.3}}}{2}
+ {.4}{{\textcolor{MediumOrchid}{.4}}}{2}
+ {.5}{{\textcolor{MediumOrchid}{.5}}}{2}
+ {.6}{{\textcolor{MediumOrchid}{.6}}}{2}
+ {.7}{{\textcolor{MediumOrchid}{.7}}}{2}
+ {.8}{{\textcolor{MediumOrchid}{.8}}}{2}
+ {.9}{{\textcolor{MediumOrchid}{.9}}}{2}
+ {=}{{\textcolor{gray}{=}}}{1},%
}[keywords,tex,comments,strings]% end languaje
% \begin{examplecode}[key=val]...\end{examplecode}
\lstnewenvironment{examplecode}[1][]{%
\lstset{
- language=scontents-doc,%
- stringstyle= {\color{red}},%
- basicstyle=\ttfamily\small,%
- numbersep=1em,%
- numberstyle=\tiny\color{lightgray}\noaccsupp,%
- rulecolor=\color{gray!50},%
- framesep=\fboxsep,%
- framerule=\fboxrule,%
- xleftmargin=\dimexpr\fboxsep+\fboxrule\relax,%
- xrightmargin=\dimexpr\fboxsep+\fboxrule\relax,%
+ language = scontents-doc,%
+ stringstyle = {\color{red}},%
+ basicstyle = \ttfamily\small,%
+ columns = fullflexible,%
+ fontadjust = true,%
+ aboveskip = 8pt,%
+ belowskip = 5pt,%
+ rulecolor = \color{gray!50},%
+ framesep = \fboxsep,%
+ framerule = \fboxrule,%
+ xleftmargin = \dimexpr\fboxsep+\fboxrule\relax,%
+ xrightmargin= \dimexpr\fboxsep+\fboxrule\relax,%
#1,%
}% close lstset
}{}% close examplecode
@@ -477,56 +498,55 @@
% \lstinline[style=inline]|...|
\lstdefinestyle{inline}
{
- language=scontents-doc,%
- escapechar=`,%
- upquote=true,%
- numbersep=1em,%
- columns=fullflexible,%
- numberstyle=\tiny\color{lightgray}\noaccsupp,%
- literate=*{\%}{{\bfseries\textcolor{gray}{\%}}}{1}
+ language = scontents-doc,%
+ upquote = true,%
+ numbersep = 1em,%
+ numberstyle = \tiny\color{lightgray}\noaccsupp,%
+ literate =*{\%}{{\textcolor{gray}{\%}}}{1}
}
% Set default \lstinline style
\lstset{style=inline}
+
+% Set short §...§
\lstMakeShortInline[language=scontents-doc,basicstyle=\ttfamily]§
% Get file info
\GetFileInfo{\jobname.sty}
% Config hyperref
-\definecolor{linkcolour}{cmyk}{0.64,0,0.95,0.40}% <-Olive Green
\hypersetup{
- linkcolor = linkcolour,%
- citecolor = linkcolour,%
- urlcolor = linkcolour,%
+ allcolors = linkcolor,
colorlinks = true,%
linktoc = all,%
pdftitle = {.:: The scontents package --- \fileinfo{} ::.},%
pdfauthor = {Pablo González L},
pdfsubject = {Documentation for \fileversion{} [\filedate] },%
- pdfcopyright = {\textcopyright 2019 by Pablo González},
- pdfcontacturl = {https://github.com/pablgonz/scontents},
pdfkeywords = {sequences, contents, external files, expl3, xparse, l3seq, store contents},
- pdfstartview = {FitH},%
bookmarksopenlevel = 1,%
}
% Configuration titleps and titlesec
\settitlemarks{section}
-\renewpagestyle{plain}[\color{gray}\small\sffamily]{
-\setfoot{}{}{\thepage/\pageref{LastPage}}}
-
-\newpagestyle{myheader}[\color{gray}\small\sffamily]{
-\renewcommand\makeheadrule{\color{gray}\rule[0.45\baselineskip]{\linewidth}{0.4pt}}
-\setfoot{\scalebox{0.8}{\mylogo}\space\textcopyright\space 2019 by Pablo González}
- {}
- {\thepage/\pageref{LastPage}}
-\sethead{\raisebox{0.75\baselineskip}{Documentation for \fileversion\space[\filedate]}}
- {}
- {\raisebox{0.75\baselineskip}{\scshape\small\S.\thesection\space\sectiontitle}}
+\renewpagestyle{plain}[\color{optcolor}\small\sffamily]{%
+\setfoot{\rlap{\hskip\dimexpr-\oddsidemargin-1in\relax%
+ \parbox{1.93\paperwidth\relax}{\hfil\thepage\,/\,\pageref{LastPage}}}}%
+ {}%
+ {}%
+}
+\newpagestyle{myheader}[\color{optcolor}\small\sffamily]{%
+\renewcommand\makeheadrule{%
+\rlap{\hskip\dimexpr-\oddsidemargin-1in\relax
+ \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}}}%
+ {}%
+\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}}}%
+ {}%
}
-
-\setlength{\headheight}{21pt}%
\titlecontents{section}[0mm]{}%
{\bfseries\contentspush{\makebox[5mm][l]{\thecontentslabel\hfill}}}%
@@ -541,7 +561,7 @@
\makeatletter
\renewcommand\tableofcontents{%
\begingroup%
-\section*{\contentsname\quad{\color{optcolor}\leaders\hrule height 5pt depth -4.4pt\hfill}%
+\section*{\contentsname\quad{\color{gray}\leaders\hrule height 5pt depth -4.4pt\hfill}%
\@mkboth{%
\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
\vspace*{-14pt}
@@ -549,11 +569,18 @@
\begin{multicols}{2}%
\@starttoc{toc}%
\end{multicols}%
-\vspace*{-3pt}{\color{optcolor}\hrule height 0.6pt}%
+\vspace*{-3pt}{\color{gray}\hrule height 0.6pt}%
\vspace*{5pt}
\endgroup
}
\makeatother
+% thanks
+\makeatletter
+\renewcommand*{\@fnsymbol}[1]{\ensuremath{\ifcase#1\or \textcolor{pkgcolor}{*}
+\or \textcolor{pkgcolor}{\dagger} \or \ddagger\or \mathsection
+\or \mathparagraph\or \|\or **\or \dagger\dagger
+\or \ddagger\ddagger \else\@ctrerr\fi}}
+\makeatother
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
@@ -561,7 +588,7 @@
% \fi
%
% \title{
-% \scalebox{1.025}{\mylogo}\\[2pt]
+% \scalebox{1.57}{\pkglogo}\\[2pt]
% \Large
% \textsf{Stores \hologo{LaTeX}}{ \fetamontotf{contents} }\\[3pt]
% \fileversion{} --- \filedate\thanks{
@@ -569,24 +596,24 @@
% \filedate.}\\[25pt]
% \author{
% \large
-% \raisebox{-1pt}{\textcopyright}{}2019 by Pablo González
-% \thanks{E-mail: \textsf{\guillemotleft}\email{pablgonz@educarchile.cl}\textsf{\guillemotright}}%
+% \raisebox{-1pt}{\textcopyright}{}2019 by Pablo González\thanks{
+% E-mail: \textcolor{OrangeRed}{\textsf{\guillemotleft}}\email{pablgonz@educarchile.cl}\textcolor{OrangeRed}{\textsf{\guillemotright}}.
+% }%
% }
% \small
-% \textsc{ctan}: \url{http://www.ctan.org/pkg/scontents}\\
-% \textsc{git}: \url{https://github.com/pablgonz/scontents}
+% \textsc{ctan}: \url{https://www.ctan.org/pkg/scontents}\\
+% \textcolor{gray}{\scriptsize\faIcon[regular]{github}}\,\,\,\url{https://github.com/pablgonz/scontents}
% \vspace*{-2cm}
% }
% \date{}
% \maketitle
%
-% \begin{scontents}[store-env=abstract,print-env=true]
+% \begin{scontents}[store-env=abstract, print-env=true]
% \begin{abstract}
-% The \mypkg*{scontents} package stores valid \hologo{LaTeX} code in
-% \mymeta{sequences} using the \mypkg{l3seq} module of \mypkg{expl3}.
-% The \mymeta{stored content}, including \emph{verbatim}, can be used
-% as many times as desired in the document, additionally can be written
-% to \mymeta{external files}.
+% This package allows to store \hologo{LaTeX} code, including \enquote{\emph{verbatim}},
+% in \mymeta{sequences} using the \mypkg{l3seq} module of \mypkg{expl3}. The \mymeta{stored
+% content} can be used as many times as desired in the document, additionally you can write
+% to \mymeta{external files} or show it in \mymeta{verbatim style}.
% \end{abstract}
% \end{scontents}
%
@@ -597,10 +624,10 @@
% \section{Motivation and Acknowledgments}
%
% In \hologo{LaTeX} there is no direct way to record content for later use, although
-% you can do this using §\macros§, recording \mymeta{verbatim content} is a
+% you can do this using §\macros§, recording \mymeta[type=rm]{verbatim content} is a
% problem, usually you can avoid this by creating external files or boxes. The
% general idea of this package is to try to imitate this implementation
-% \emph{buffers} that has \hologo{ConTeXt} which allows you to save content in
+% \enquote{\emph{buffers}} that has \hologo{ConTeXt} which allows you to save content in
% memory, including \emph{verbatim}, to be used later. The package
% \mypkg{filecontentsdef} solves this problem and since \mypkg{expl3} has an
% excellent way to manage data, ideas were combined giving rise to this package.
@@ -613,7 +640,7 @@
% of the \href{https://tex.stackexchange.com}{TeX-SX} community who have provided
% great answers and ideas. Here a note of the main ones:
%
-% \begin{enumerate}[nosep]
+% \begin{enumerate}[left=0pt, labelsep=5pt, noitemsep, nosep, label=\small\arabic*.]
% \item \href{https://tex.stackexchange.com/q/45946/7832}{Stack datastructure using LaTeX}
%
% \item \href{https://tex.stackexchange.com/q/5338/7832}{LaTeX equivalent of ConTeXt buffers}
@@ -651,12 +678,11 @@
% \subsection{Description of the package and load}
%
% \begin{scontents}[store-env=description, print-env=true]
-% The \mypkg*{scontents} package allows to \mymeta{store contents} in
-% \mymeta{sequences} or \mymeta{external files}. In some ways it is
-% similar to the \mypkg{filecontentsdef} package, with the difference
-% in which the \mymeta{content} is stored. The idea behind this package
-% is to get an approach to \hologo{ConTeXt} \enquote{\emph{buffers}}
-% by making use \mymeta{sequences}.
+% The \mypkg*{scontents} package allows to \mymeta{store contents} in \mymeta{sequences}
+% or \mymeta{external files}. In some ways it is similar to the \mypkg{filecontentsdef}
+% package, with the difference in which the \mymeta{content} is stored. The idea behind
+% this package is to get an approach to \hologo{ConTeXt} \enquote{\emph{buffers}} by
+% making use \mymeta{sequences}.
% \end{scontents}
%
% The package is loaded in the usual way:
@@ -671,13 +697,14 @@
% \iffalse
%</example>
% \fi
-% \vspace*{-5pt}
+%
% or
+%
% \iffalse
%<*example>
% \fi
\begin{examplecode}[frame=single]
-\usepackage`\small\myoarg[type=tt]{key \textnormal{\textcolor{gray}{=}} val}`{scontents}
+\usepackageÇ\small\myoarg[type=tt]{key \textnormal{\textcolor{gray}{=}} val}Ç{scontents}
\end{examplecode}
% \iffalse
%</example>
@@ -715,8 +742,8 @@
%
% Some users use horizontal "TAB"s \enquote{\LKeyTab} from keyboard to indented the source
% code of the document and depending on the text editor used, some will use real "TAB"s
-% (\enquote{hard tabs}), others with \enquote{soft tabs}(\verbvisiblespace\verbvisiblespace{}
-% or \verbvisiblespace\verbvisiblespace\verbvisiblespace\verbvisiblespace) or both.
+% (\enquote{hard tabs}), others with \enquote{soft tabs}(\verb*| | or \verb*| |)
+% or both.
%
% At first glance it may seem the same, but the way in which "TAB"s (\enquote{hard tabs})
% are processed according to the context in which they are found within
@@ -745,7 +772,7 @@
%
% Most of the options can be passed directly to the package or using the
% command \ics*{setupsc}. All boolean keys can be passed using the
-% equal sign \enquote{\textnormal{\textcolor{optcolor}{=}}} or just the
+% equal sign \enquote{\textnormal{\textcolor{gray}{=}}} or just the
% name of the key, all unknown keys will return an error. In this section
% are described some of the options, a summary of all options is shown in
% section \ref{sec:optover}.
@@ -764,32 +791,37 @@
%
% \keyexamp{verb-font}{font family}{\textnormal{\ttfamily\textbackslash{}ttfamily}}
% Sets the \mymeta{font family} used to display the \mymeta{stored content} for the
-% commands \ics*{typestored} and \ics*{meaningsc}. This key is only available
+% \ics*{typestored} and \ics*{meaningsc} commands. This key is only available
% as a package option or using \ics*{setupsc}.
%
% \medskip
%
% \keyexamp{store-all}{seq name}{not used}
-% It is a \mymeta{meta-key} that sets the §store-env§ key of the \myenv*{scontents}
-% environment and the §store-cmd§ key of the \ics*{Scontents} command. This key is
+% It is a \mymeta{meta-key} that sets the \mykey{store-env} key of the \myenv*{scontents}
+% 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
%
+% \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.
+% \medskip
+%
% \keyexamp{print-all}{true \textnormal{\textcolor{lightgray}{\textbar}} false}{false}
-% It is a \mymeta{meta-key} that sets the §print-env§ key of the \myenv*{scontents}
-% environment and the §print-cmd§ key of the \ics*{Scontents} command. This key is
+% It is a \mymeta{meta-key} that sets the \mykey{print-env} key of the \myenv*{scontents}
+% environment and the \mykey{print-cmd} key of the \ics*{Scontents} command. This key is
% only available as a package option or using \ics*{setupsc}.
%
-% \medskip
-%
% \keyexamp{force-eol}{true \textnormal{\textcolor{lightgray}{\textbar}} false}{false}
% Sets if the end of line for the \mymeta{stored content} is hidden or not.
% 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{\textcolor{gray}{\%}}
-% after closing §\end{§\textcolor{gray}{...}§}%§. This key is available for the \myenv*{scontents}
-% environment and the \ics*{Scontents} command.
+% 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.
%
% \keyexamp{width-tab}{integer}{1}
% Sets the equivalence in \mymeta{spaces} for the character "TAB"
@@ -800,29 +832,30 @@
% \subsection{Options Overview}
% \label{sec:optover}
%
-% \newcommand*{\xmark}{\textcolor{red}{✘}}%
-% \newcommand*{\cmark}{\textcolor{green}{✔}}%
+% \newcommand*{\xmark}{\textcolor{OrangeRed}{✘}}%
+% \newcommand*{\cmark}{\textcolor{linkcolor}{✔}}%
%
-% Summary of available options.
+% Summary of available options:
%
% \setlength{\tabcolsep}{0.25em}
% \begin{center}
% \small
% \begin{tabular}{cccccccc}
% \toprule
-% \texttt{key} &package &\ics{setupsc} &\myenv*{scontents} &\ics*{Scontents} &\ics*{Scontents*} &\ics*{typestored} &\ics*{meaningsc}\\
+% \texttt{key} &package &\ics*{setupsc} &\myenv*{scontents} &\ics*{Scontents} &\ics*{Scontents*} &\ics*{typestored} &\ics*{meaningsc}\\
% \midrule
-% \texttt{store-env} & \cmark & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark \\
-% \texttt{store-cmd} & \cmark & \cmark & \xmark & \cmark & \cmark & \xmark & \xmark \\
-% \texttt{print-env} & \cmark & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark \\
-% \texttt{print-cmd} & \cmark & \cmark & \xmark & \cmark & \cmark & \xmark & \xmark \\
-% \texttt{print-all} & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark \\
-% \texttt{store-all} & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark \\
-% \texttt{write-env} & \xmark & \xmark & \cmark & \xmark & \xmark & \xmark & \xmark \\
-% \texttt{write-out} & \xmark & \xmark & \cmark & \xmark & \xmark & \xmark & \xmark \\
-% \texttt{width-tab} & \cmark & \cmark & \xmark & \xmark & \xmark & \cmark & \cmark \\
-% \texttt{force-eol} & \cmark & \cmark & \cmark & \xmark & \cmark & \xmark & \xmark \\
-% \texttt{verb-font} & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark \\
+% \mykey{store-env} & \cmark & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark \\
+% \mykey{store-cmd} & \cmark & \cmark & \xmark & \cmark & \cmark & \xmark & \xmark \\
+% \mykey{print-env} & \cmark & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark \\
+% \mykey{print-cmd} & \cmark & \cmark & \xmark & \cmark & \cmark & \xmark & \xmark \\
+% \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{width-tab} & \cmark & \cmark & \xmark & \xmark & \xmark & \cmark & \cmark \\
+% \mykey{force-eol} & \cmark & \cmark & \cmark & \xmark & \cmark & \xmark & \xmark \\
+% \mykey{verb-font} & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark \\
% \bottomrule
% \end{tabular}
% \end{center}
@@ -870,14 +903,11 @@
% \fi
\begin{examplecode}[frame=single]
\begin{scontents}[store-env=outer]
-This text is in the outer environment
-(before nested).
+This text is in the outer environment (before nested).
\begin{scontents}[store-env=inner]
-This text is found in the inner environment
-(inside of nested).
+This text is found in the inner environment (inside of nested).
\end{scontents}
-This text is in the outer environment
-(after nested).
+This text is in the outer environment (after nested).
\end{scontents}
\end{examplecode}
% \iffalse
@@ -886,13 +916,11 @@ This text is in the outer environment
%
% Of course, content stored in the \mymeta{inner} sequence is only available
% after content stored in the \mymeta{outer} sequence one has been retrieved,
-% either by using the key §print-env§ or §\getstored§ command.
+% either by using the key \mykey{print-env} or \ics*{getstored} command.
%
% It is advisable to store content within sequences with different names,
% so as not to get lost in the order in which content is stored.
%
-% \newpage
-%
% \subsection*{Notes for \hologo{plainTeX} and \hologo{ConTeXt} users}
%
% In \hologo{plainTeX} there is not environments as in \hologo{LaTeX}.
@@ -918,7 +946,7 @@ This text is in the outer environment
% The environment options can be configured globally using option
% in package or the \ics*{setupsc} command and locally using
% \myoarg{key \textnormal{\textcolor{gray}{=}} val} in the environment.
-% The key §force-eol§ is available for this environment.
+% The key \mykey{force-eol} is available for this environment.
%
% \keyexamp{store-env}{seq name}{contents}
% Sets the name of the \mymeta{sequence} in which the contents will be
@@ -957,6 +985,43 @@ This text is in the outer environment
% must add \texttt{\textcolor{optcolor}{-8bit}} at the command line,
% otherwise you will get \hologo{TeX}-"TAB" (§^^I§) in \mymeta{file.ext}.
%
+%
+% \subsection{The command \cs{newenvsc}}
+% \label{sec:newenvsc}
+%
+% \newsavebox{\exaboxtmp}
+% \begin{lrbox}{\exaboxtmp}
+% \small\ttfamily
+% \textcolor{pkgcolor}{\textbackslash newenvsc}\mymarg[type=tt]{env name}\myoarg[type=tt]{initial keys}
+% \end{lrbox}
+%
+% \vspace*{-10pt}
+%
+% \begin{function}{\newenvsc}
+% \begin{syntax}
+% \usebox{\exaboxtmp}
+% \end{syntax}
+% \end{function}
+%
+% 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:
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{examplecode}[frame=single]
+\newenvsc{myenvstore}[store-env=myseq,print-env=false]
+\end{examplecode}
+% \iffalse
+%</example>
+% \fi
+%
+% created the §myenvstore§ environment that stored the content in the §myseq§
+% sequence and will not display the content when it is executed.
+%
% \subsection{The command \cs{Scontents}}
% \label{sec:Scontents}
%
@@ -987,6 +1052,8 @@ This text is in the outer environment
% \enquote{\texttt{\textcolor{gray}{\textbackslash\}}}} must also be
% balanced if the argument is used with braces and "TAB"s characters typed
% from the keyboard are converted into spaces.
+% The starred argument (§*§) and \myoarg{key \textnormal{\textcolor{gray}{=}} val}
+% must not be separated by horizontal spaces between them and the command.
%
% Both versions can be used anywhere in the document and cannot be used
% as an \mymeta{argument} for other command.
@@ -996,7 +1063,7 @@ This text is in the outer environment
%
% The command options can be configured globally using option in package
% or the \ics*{setupsc} command and locally using \myoarg{key \textnormal{\textcolor{gray}{=}} val}.
-% The key §force-eol§ is available for this command.
+% The key \mykey{force-eol} is available for this command.
%
% \keyexamp{store-cmd}{seq name}{contents}
% Sets the name of the \mymeta{sequence} in which the contents will be stored.
@@ -1022,9 +1089,9 @@ This text is in the outer environment
%
% The command \ics*{getstored} gets the content stored in \mymarg{seq name}
% according to the \mymeta{index} in which it was stored. The command is
-% robust and can be used as an \mymeta{argument} for another command. If the
-% optional argument is not passed it defaults to the first element stored
-% in the \mymarg{seq name}.
+% robust and can be used as an \mymeta{argument} for another command. If
+% the optional argument is not passed, the default value is the \enquote{last
+% element} stored in \mymarg{seq name}.
%
% \subsection{The command \cs{foreachsc}}
% \label{sec:foreachsc}
@@ -1072,8 +1139,13 @@ This text is in the outer environment
% 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.
%
-% \keyexamp{wrapper}{code \textnormal{\textcolor{gray}{\{\#1\}}} more code}{empty}
-% Wraps the content stored in \mymarg{seq name} referenced by \mymarg{\#1}.
+% \newsavebox{\hashbox}
+% \begin{lrbox}{\hashbox}
+% \lstinline[language=scontents-doc,basicstyle=\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
% §\foreachsc[wrapper={\makebox[1em][l]{#1}}]{contents}§.
%
@@ -1093,9 +1165,10 @@ This text is in the outer environment
% \end{function}
%
% If the optional argument is not passed it defaults to the first element
-% stored in the \mymarg{seq name}. The key §width-tab§ is available for
+% stored in the \mymarg{seq name}. The key \mykey{width-tab} is available for
% this command.
%
+%
% \subsection{The environment \env{verbatimsc}}
% \label{sec:verbatimsc}
%
@@ -1111,9 +1184,9 @@ This text is in the outer environment
% a real \emph{verbatim} environment. The \mypkg{verbatim} package is not
% compatible with the implementation of the \myenv*{verbatimsc} environment.
%
-% The \myenv*{verbatimsc} environment can be customized in the following ways:
+%^^A \newpage
%
-% \newpage
+% The \myenv*{verbatimsc} environment can be customized in the following ways:
%
% Using the package \mypkg{fancyvrb}:
% \iffalse
@@ -1188,7 +1261,7 @@ This text is in the outer environment
% \end{function}
%
% If the optional argument is not passed it defaults to the first element
-% stored in the \mymarg{seq name}. The key §width-tab§ is available for
+% stored in the \mymarg{seq name}. The key \mykey{width-tab} is available for
% this command.
%
% \subsection{The command \cs{countsc}}
@@ -1243,11 +1316,10 @@ This text is in the outer environment
\begin{examplecode}[numbers=left]
\begin{scontents}[store-env=abstract,print-env=true]
\begin{abstract}
-The \mypkg*{scontents} package stores valid \hologo{(La)TeX} code in
-\mymeta{sequences} using the \mypkg{l3seq} module of \mypkg{expl3}.
-The \mymeta{stored content}, including \emph{verbatim}, can be used
-as many times as desired in the document, additionally can be written
-to \mymeta{external files}.
+This package allows to store \hologo{LaTeX} code, including \enquote{\emph{verbatim}},
+in \mymeta{sequences} using the \mypkg{l3seq} module of \mypkg{expl3}. The \mymeta{stored
+content} can be used as many times as desired in the document, additionally you can write
+to \mymeta{external files} or show it in \mymeta{verbatim style}.
\end{abstract}
\end{scontents}
\end{examplecode}
@@ -1262,12 +1334,11 @@ to \mymeta{external files}.
% \fi
\begin{examplecode}[numbers=left]
\begin{scontents}[store-env=description, print-env=true]
-The \mypkg*{scontents} package allows to \mymeta{store contents} in
-\mymeta{sequences} or \mymeta{external files}. In some ways it is
-similar to the \mypkg{filecontentsdef} package, with the difference
-in which the \mymeta{content} is stored. The idea behind this package
-is to get an approach to \hologo{ConTeXt} \enquote{\emph{buffers}}
-by making use \mymeta{sequences}.
+The \mypkg*{scontents} package allows to \mymeta{store contents} in \mymeta{sequences}
+or \mymeta{external files}. In some ways it is similar to the \mypkg{filecontentsdef}
+package, with the difference in which the \mymeta{content} is stored. The idea behind
+this package is to get an approach to \hologo{ConTeXt} \enquote{\emph{buffers}} by
+making use \mymeta{sequences}.
\end{scontents}
\end{examplecode}
% \iffalse
@@ -1280,7 +1351,19 @@ by making use \mymeta{sequences}.
% \section{Examples}
%
% These are some adapted examples that have served as inspiration for
-% the creation of this package.
+% the creation of this package. The examples are attached to this documentation
+% and can be extracted from your PDF viewer or from the command line by running:
+% \iffalse
+%<*example>
+% \fi
+\begin{examplecode}[frame=single]
+$ pdfdetach -saveall scontents.pdf
+\end{examplecode}
+% \iffalse
+%</example>
+% \fi
+% and then you can use the excellent \arara\footnote{The cool \TeX\ automation tool:
+% \url{https://www.ctan.org/pkg/arara}} tool to compile them.
%
% \subsection{From \texttt{answers} package}
%
@@ -1290,6 +1373,8 @@ by making use \mymeta{sequences}.
%<*example>
% \fi
\begin{scontents}[write-out=scexamp1.ltx]
+% arara: pdflatex
+% arara: clean: { extensions: [ aux, log] }
\documentclass{article}
\usepackage[store-cmd=solutions]{scontents}
\newtheorem{ex}{Exercise}
@@ -1314,7 +1399,7 @@ Second exercise
% \fi
%
% Adaptation of example 1 of the package \mypkg{answers}
-% \textattachfile[color=0 0 1]{scexamp1.ltx}{\faFile*[regular]}.
+% \textattachfile[color=linkcolor,print=false]{scexamp1.ltx}{\faFile*[regular]}.
% \lstinputlisting[language=scontents-doc,numbers=left]{scexamp1.ltx}
%
% \subsection{From \texttt{filecontentsdef} package}
@@ -1325,6 +1410,8 @@ Second exercise
%<*example>
% \fi
\begin{scontents}[write-out=scexamp2.ltx]
+% arara: pdflatex
+% arara: clean: { extensions: [ aux, log] }
\documentclass{article}
\usepackage[store-env=defexercise,store-cmd=defexercise]{scontents}
\pagestyle{empty}
@@ -1356,7 +1443,7 @@ seventies that the \NSA\ has known that for 40 years.\par
% \fi
%
% Adaptation of example from package \mypkg{filecontentsdef}
-% \textattachfile[color=0 0 1]{scexamp2.ltx}{\faFile*[regular]}.
+% \textattachfile[color=linkcolor,print=false]{scexamp2.ltx}{\faFile*[regular]}.
% \lstinputlisting[language=scontents-doc,numbers=left]{scexamp2.ltx}
%
% \subsection{From TeX-SX}
@@ -1367,6 +1454,8 @@ seventies that the \NSA\ has known that for 40 years.\par
%<*example>
% \fi
\begin{scontents}[write-out=scexamp3.ltx]
+% arara: pdflatex
+% arara: clean: { extensions: [ aux, log] }
\documentclass{article}
\usepackage[store-cmd=tikz]{scontents}
\usepackage{tikz}
@@ -1418,7 +1507,7 @@ This is a \verb*|fake poor man's buffer :)|.
% \fi
%
% Adapted from \href{https://tex.stackexchange.com/q/5338/7832}{LaTeX equivalent of ConTeXt buffers}
-% \textattachfile[color=0 0 1]{scexamp3.ltx}{\faFile*[regular]}.
+% \textattachfile[color=linkcolor,print=false]{scexamp3.ltx}{\faFile*[regular]}.
% \lstinputlisting[language=scontents-doc,numbers=left]{scexamp3.ltx}
%
% \subsubsection*{Example 4}
@@ -1427,6 +1516,8 @@ This is a \verb*|fake poor man's buffer :)|.
%<*example>
% \fi
\begin{scontents}[write-out=scexamp4.ltx]
+% arara: pdflatex
+% arara: clean: { extensions: [ aux, log] }
\documentclass{article}
\usepackage{scontents}
\pagestyle{empty}
@@ -1458,7 +1549,7 @@ This is stored in other: \getstored[1]{other}
% \fi
%
% Adapted from \href{https://tex.stackexchange.com/q/184503/7832}{Collecting contents of environment and store them for later retrieval}
-% \textattachfile[color=0 0 1]{scexamp4.ltx}{\faFile*[regular]}.
+% \textattachfile[color=linkcolor,print=false]{scexamp4.ltx}{\faFile*[regular]}.
% \lstinputlisting[language=scontents-doc,numbers=left]{scexamp4.ltx}
%
% \subsubsection*{Example 5}
@@ -1467,6 +1558,8 @@ This is stored in other: \getstored[1]{other}
%<*example>
% \fi
\begin{scontents}[write-out=scexamp5.ltx]
+% arara: pdflatex
+% arara: clean: { extensions: [ aux, log] }
\documentclass{article}
\usepackage{scontents}
\pagestyle{empty}
@@ -1494,10 +1587,9 @@ This is from the verbatim environment:
% \fi
%
% Adapted from \href{https://tex.stackexchange.com/q/373647/7832}{Collect contents of an environment (that contains verbatim content)}
-% \textattachfile[color=0 0 1]{scexamp5.ltx}{\faFile*[regular]}.
+% \textattachfile[color=linkcolor,print=false]{scexamp5.ltx}{\faFile*[regular]}.
% \lstinputlisting[language=scontents-doc,numbers=left]{scexamp5.ltx}
%
-% \subsection{Customization of \texttt{verbatimsc}}
%
% \subsubsection*{Example 6}
%
@@ -1505,7 +1597,40 @@ This is from the verbatim environment:
%<*example>
% \fi
\begin{scontents}[write-out=scexamp6.ltx]
+% arara: pdflatex
+% arara: clean: { extensions: [ aux, log] }
+\documentclass[10pt]{article}
+\usepackage{scontents}
+\newenvsc{forshort}[store-env=forshort,print-env=false]
+\begin{document}
+
+Something in the whole course.
+
+\begin{forshort}
+ Just a summary...
+\end{forshort}
+
+\end{document}
+\end{scontents}
+% \iffalse
+%</example>
+% \fi
+%
+% Adapted from \href{https://tex.stackexchange.com/q/509595/7832}{Environment hiding its content}
+% \textattachfile[color=linkcolor,print=false]{scexamp6.ltx}{\faFile*[regular]}.
+% \lstinputlisting[language=scontents-doc,numbers=left]{scexamp6.ltx}
+%
+% \subsection{Customization of \texttt{verbatimsc}}
+%
+% \subsubsection*{Example 7}
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{scontents}[write-out=scexamp7.ltx]
\documentclass{article}
+% arara: pdflatex
+% arara: clean: { extensions: [ aux, log] }
\usepackage{scontents}
\makeatletter
\let\verbatimsc\@undefined
@@ -1560,15 +1685,17 @@ Prove new \Verb*{ fancyvrb whit braces } and environment \verb+Verbatim*+
%
% Customization of \myenv*{verbatimsc} using the \mypkg{fancyvrb} and
% \mypkg{tcolorbox} package
-% \textattachfile[color=0 0 1]{scexamp6.ltx}{\faFile*[regular]}.
-% \lstinputlisting[language=scontents-doc,numbers=left]{scexamp6.ltx}
+% \textattachfile[color=linkcolor,print=false]{scexamp7.ltx}{\faFile*[regular]}.
+% \lstinputlisting[language=scontents-doc,numbers=left]{scexamp7.ltx}
%
-% \subsubsection*{Example 7}
+% \subsubsection*{Example 8}
%
% \iffalse
%<*example>
% \fi
-\begin{scontents}[write-out=scexamp7.ltx]
+\begin{scontents}[write-out=scexamp8.ltx]
+% arara: pdflatex
+% arara: clean: { extensions: [ aux, log] }
\documentclass{article}
\usepackage{scontents}
\makeatletter
@@ -1624,16 +1751,17 @@ and more.+
% \fi
%
% Customization of \myenv*{verbatimsc} using the \mypkg{listings} package
-% \textattachfile[color=0 0 1]{scexamp7.ltx}{\faFile*[regular]}.
-% \lstinputlisting[language=scontents-doc,numbers=left]{scexamp7.ltx}
+% \textattachfile[color=linkcolor,print=false]{scexamp8.ltx}{\faFile*[regular]}.
+% \lstinputlisting[language=scontents-doc,numbers=left]{scexamp8.ltx}
%
-% \subsubsection*{Example 8}
+% \subsubsection*{Example 9}
%
% \iffalse
%<*example>
% \fi
-\begin{scontents}[write-out=scexamp8.ltx]
-% need -shell-escape
+\begin{scontents}[write-out=scexamp9.ltx]
+% arara: xelatex : {shell: true, options: [-8bit]}
+% arara: clean: { extensions: [ aux, log] }
\documentclass{article}
\usepackage{scontents}
\makeatletter
@@ -1648,19 +1776,22 @@ and more.+
\section{Test \texttt{\textbackslash begin\{scontents\}} whit \texttt{minted}}
Test \verb+{scontents}+ \par
-\begin{scontents}[write-env=usingtab.tex,force-eol=true]
+\begin{scontents}[overwrite,write-env=\jobname.tsc,force-eol=true]
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*+
-% Real TABs here :)
-\begin{Verbatim}[obeytabs, showtabs, tab=\rightarrowfill, tabcolor=red,showspaces, spacecolor=blue]
+\begin{Verbatim}[obeytabs, showtabs, tab=\rightarrowfill, tabcolor=red]
No tab
One real tab
Two real Tab plus one tab
\end{Verbatim}
\end{scontents}
+\section{See \Verb{\jobname.tsc}}
+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}}
\Scontents{ We have coded \par this in \LaTeX: $E=mc^2$.}
@@ -1679,8 +1810,10 @@ No tab
% \fi
%
% Customization of \myenv*{verbatimsc} using the \mypkg{minted} package
-% \textattachfile[color=0 0 1]{scexamp8.ltx}{\faFile*[regular]}.
-% \lstinputlisting[language=scontents-doc,numbers=left]{scexamp8.ltx}
+% \textattachfile[color=linkcolor,print=false]{scexamp9.ltx}{\faFile*[regular]}.
+% \lstinputlisting[language=scontents-doc,numbers=left]{scexamp9.ltx}
+%
+% \newpage
%
% \section{Change history}
% \label{sec:changes}
@@ -1689,6 +1822,8 @@ No tab
% development, from the first public implementation using the \mypkg{filecontentsdef}
% package to the current version with only \mypkg{expl3}.
%
+% \medskip
+%
% \setlist[itemize,1]{label=\textendash,wide=0.5em,nosep,noitemsep,leftmargin=10pt}
% \newlength\descrwidth
% \settowidth{\descrwidth}{\textsf{v1.0, (ctan), 2019-07-30} }
@@ -1696,6 +1831,14 @@ No tab
% \begin{description}[font=\small\sffamily,wide=0pt,style=multiline,leftmargin=\descrwidth,nosep,noitemsep]
% \item [\fileversion{} (ctan), \filedate]
% \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.
+% \end{itemize}
+% \item [v1.7 (ctan), 2019-10-29]
+% \begin{itemize}
% \item The |verbatimsc| environment was rewritten.
% \item Minor adjustments in documentation.
% \end{itemize}
@@ -1744,18 +1887,24 @@ No tab
% \end{itemize}
% \item [v1.0 (ctan), 2019-07-30]
% \begin{itemize}
-% \item First public release,
+% \item First public release.
% \end{itemize}
% \end{description}
%
% \newpage
%
+% \indexprologue{
+% The italic numbers denote the pages where the corresponding entry is
+% described.}
+%
% \printindex[userdoc]
%
% \newpage
%
+% \StartImplementation
+%
% \StopEventually{^^A
-% \newgeometry{top=0.5in,bottom=0.5in,left=1.0in,right=0.5in,footskip=0.2in,headsep=10pt}
+% \newgeometry{top=0.5in,bottom=0.3in,left=1.0in,right=0.5in,footskip=0.2in,headheight=1cm,headsep=0.27cm}
% \addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
% \cleardoublepage
% \phantomsection
@@ -1767,10 +1916,18 @@ No tab
% \printindex
% }
%
+%
% \section{Implementation}
% \label{sec:Implementation}
% \addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
%
+% The most recent publicly released version of \mypkg*{scontents} is available at
+% \textsc{ctan}: \url{https://www.ctan.org/pkg/scontents}. Historical and
+% developmental versions are available at \textcolor{gray}{\scriptsize\faIcon[regular]{github}}
+% \url{https://github.com/pablgonz/scontents}. While general feedback via email is
+% welcomed, specific bugs or feature requests should be reported through the issue
+% tracker: \url{https://github.com/pablgonz/scontents/issues}.
+%
% \subsection{Declaration of the package}
%
% First we set up the module name for \pkg{l3doc}:
@@ -1780,10 +1937,10 @@ No tab
%
% Now we define some common macros to hold the package date and version:
% \begin{macrocode}
-%<loader>\def\ScontentsFileDate{2019-10-29}%
-%<core>\def\ScontentsCoreFileDate{2019-10-29}%
+%<loader>\def\ScontentsFileDate{2019-11-18}%
+%<core>\def\ScontentsCoreFileDate{2019-11-18}%
%<*loader>
-\def\ScontentsFileVersion{1.7}%
+\def\ScontentsFileVersion{1.8}%
\def\ScontentsFileDescription{Stores LaTeX contents in memory or files}%
% \end{macrocode}
%
@@ -1799,13 +1956,13 @@ No tab
{scontents} {\ScontentsFileDate} {\ScontentsFileVersion} {\ScontentsFileDescription}
\@ifpackageloaded { verbatim }
{
- \iow_term:n
+ \msg_set:nnn { scontents } { unsupported-verbatim }
{
- The~implementation~of~the~'verbatimsc'~environment~\\
- used~by~\tl_to_str:n{\typestored}~is~not~compatible~with~package\\
- 'verbatim'.~Review~the~documentation~and~redefine~\\
- the~'verbatimsc'~environment.
+ The~implementation~of~the~'verbatimsc'~environment~used~by~
+ \iow_char:N \\typestored~is~not~compatible~with~package~'verbatim'.~
+ Review~the~documentation~and~redefine~the~'verbatimsc'~environment.
}
+ \msg_warning:nn { scontents } { unsupported-verbatim }
} { }
%</latex>
% \end{macrocode}
@@ -1829,7 +1986,7 @@ No tab
% \begin{macrocode}
%<*plain>
\msg_gset:nnn { scontents } { already-loaded }
- { The~`scontents'~package~is~already~loaded.~Aborting~input~\msg_line_context:. }
+ { The~'scontents'~package~is~already~loaded.~Aborting~input~\msg_line_context:. }
\cs_if_exist:NT \@@_rescan_tokens:n
{
\msg_warning:nn { scontents } { already-loaded }
@@ -1863,7 +2020,7 @@ No tab
%<latex|plain> end
%<context> stop
%<latex> \c_left_brace_str
- scontents
+ \exp_not:N \l_@@_env_name_tl
%<latex> \c_right_brace_str
}
% \end{macrocode}
@@ -1954,6 +2111,9 @@ No tab
force-eol .bool_set:N = \l_@@_forced_eol_bool,
force-eol .initial:n = false,
force-eol .default:n = true,
+ overwrite .bool_set:N = \l_@@_overwrite_bool,
+ overwrite .initial:n = false,
+ overwrite .default:n = true,
width-tab .int_set:N = \l_@@_tab_width_int,
width-tab .initial:n = 1,
width-tab .value_required:n = true,
@@ -2036,7 +2196,7 @@ No tab
% \end{macro}
%
%
-% \begin{macro}{\l_@@_foreach_before_bool,\l_@@_foreach_after_bool
+% \begin{macro}{\l_@@_foreach_before_bool,\l_@@_foreach_after_bool,
% \l_@@_foreach_stop_bool,\l_@@_foreach_wrapper_bool}
% Boolean variables used by the §\foreachsc§ loop.
%
@@ -2152,6 +2312,8 @@ No tab
store-env .meta:nn = { scontents } { store-env = #1 },
force-eol .meta:nn = { scontents } { force-eol = #1 },
force-eol .default:n = true,
+ overwrite .meta:nn = { scontents } { overwrite = #1 },
+ overwrite .default:n = true,
unknown .code:n = { \@@_parse_environment_keys:n {#1} }
}
% \end{macrocode}
@@ -2203,7 +2365,8 @@ No tab
step .initial:n = 1,
wrapper .code:n = {
\bool_set_true:N \l_@@_foreach_wrapper_bool
- \cs_set_protected:Npn \@@_foreach_wrapper:n ##1 {#1}
+ \cs_set_protected:Npn
+ \@@_foreach_wrapper:n ##1 {#1}
},
wrapper .value_required:n = true,
sep .tl_set:N = \l_@@_foreach_sep_tl,
@@ -2343,7 +2506,7 @@ No tab
% in \pkg{miniltx}) so that \pkg{xparse} is loadable in any format.
%
% The bunch of macros below is adapted from the \LaTeX{} kernel (greatly simplified).
-% \begin{macrocode}
+% \begin{macrocode}
%</core>
%<*loader&!latex>
\seq_new:N \l_@@_compat_seq
@@ -2383,9 +2546,12 @@ No tab
\clist_map_function:NN \l_@@_temp_tl \@@_require_auxiii:n
}
\cs_new_protected:Npn \@@_require_auxiii:n #1
- { \str_if_eq:eeF {expl3} {#1} { \msg_error:nnn { scontents } { invalid-package } {#1} } }
+ {
+ \str_if_eq:eeF {expl3} {#1}
+ { \msg_error:nnn { scontents } { invalid-package } {#1} }
+ }
\msg_new:nnn { scontents } { invalid-package }
- { Package~`#1'~invalid~in~scontents.~This~is~an~error~in~scontents. }
+ { Package~'#1'~invalid~in~scontents.~This~is~an~error~in~scontents. }
\@@_compat_redefine:cpn { @ifpackagelater } #1
{ \exp_args:Nc \@@_package_later_aux:Nn { ver@#1.sty } }
\cs_new_protected:Npn \@@_package_later_aux:Nn #1 #2
@@ -2400,7 +2566,7 @@ No tab
\cs_new:Npn \@@_parse_version_auxii:w #1-#2-#3#4#5 \q_mark
{ \tl_if_blank:nF {#2} {#1} #2 #3 #4 }
\@@_compat_redefine:Npn \ProvidesExplPackage #1 #2 #3 #4
- { \@@_provides_aux:nn {#1} { #2 \ifx\relax#3\relax\else v#3\space\fi #4 } }
+ { \@@_provides_aux:nn {#1} { #2 \tl_if_empty:nF {#3} {#3~} #4 } }
\cs_new_protected:Npn \@@_provides_aux:nn #1 #2
{
\tl_gset:cx { ver@#1.sty } {#2}
@@ -2521,43 +2687,77 @@ No tab
%
% \subsection{Construction of environment \env{scontents}}
%
-% We define the environment \env{scontents}, next to the system
-% \myoarg{key \textnormal{\textcolor{gray}{=}} val}. The environment
-% is divided into two parts.
+% 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.
%
-% \begin{macro}{
-% scontents,
-% \scontents,
-% \startscontents,
-% \endscontents,
-% \stopscontents,
-% \@@_scontents_env_begin:,
-% \@@_scontents_env_end:,
-% }
-% This is the main environment used in the document.
+% \subsubsection{The command \cs{newenvsc}}
%
+% \begin{macro}{\newenvsc,\l_@@_env_name_tl,\@@_scontents_setenv:nn}
+% The \cs{newenvsc} command defines two functions \cs[no-index]{@@_\#1_env_begin:}
+% and \cs[no-index]{@@_\#1_env_end:}, which set the current environment's
+% default properties and then call the generic \cs{@@_env_generic_begin:} and
+% \cs{@@_env_generic_end:}.
% \begin{macrocode}
+\tl_new:N \l_@@_env_name_tl
+\cs_new_protected:Npn \@@_scontents_setenv:nn #1 #2
+ {
+ \cs_new_protected:cpn { @@_#1_env_begin: }
+ {
+ \tl_set:Nn \l_@@_env_name_tl {#1}
+ \keys_set:nn { scontents } {#2}
+ \@@_setup_verb_processor:
+ \@@_env_generic_begin:
+ }
+ \cs_new_protected:cpn { @@_#1_env_end: }
+ { \@@_env_generic_end: }
+ \exp_args:Nooo % http://nooooooooooooooo.com :) jeje
+ \@@_env_define:nnn { \tl_to_str:n {#1} }
+ { \cs:w @@_#1_env_begin: \cs_end: }
+ { \cs:w @@_#1_env_end: \cs_end: }
+ }
%</core>
%<*loader>
-%<!context>\NewDocumentEnvironment { scontents } { }
-%<context>\cs_new_protected:Npn \startscontents
+\NewDocumentCommand { \newenvsc } { m O{} }
{
-%<plain|context> \group_begin:
- \@@_scontents_env_begin:
+%<latex|plain> \cs_if_exist:cTF { #1 }
+%<context> \cs_if_exist:cTF { start #1 }
+ { \msg_error:nnn { scontents } { env-already-defined } {#1} }
+ { \@@_scontents_setenv:nn {#1} {#2} }
}
-%<context>\cs_new_protected:Npn \stopscontents
+\cs_new_protected:Npn \@@_env_define:nnn #1 #2 #3
{
- \@@_scontents_env_end:
-%<plain|context> \group_end:
+%<latex|plain> \NewDocumentEnvironment {#1} { }
+%<context> \cs_new_protected:cpn { start #1 }
+ {
+%<!latex> \group_begin:
+ #2
+ }
+%<context> \cs_new_protected:cpn { stop #1 }
+ {
+ #3
+%<!latex> \group_end:
+ }
}
%</loader>
%<*core>
-\cs_new_protected:Npn \@@_scontents_env_begin:
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Generic definition of the environment}
+%
+% \begin{macro}{
+% \@@_env_generic_begin:,
+% \@@_env_generic_begin:,
+% }
+% Now we define the generic environment \cs{@@_env_generic_begin:}
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_env_generic_begin:
{
\char_set_catcode_active:N \^^M
\@@_start_environment:w
}
-\cs_new_protected:Npn \@@_scontents_env_end:
+\cs_new_protected:Npn \@@_env_generic_end:
{
\@@_stop_environment:
\@@_atend_environment:
@@ -2565,6 +2765,23 @@ No tab
% \end{macrocode}
% \end{macro}
%
+% \subsubsection{Definition of the environment \env{scontents}}
+%
+% \begin{macro}{
+% scontents,
+% \scontents,
+% \endscontents,
+% \startscontents,
+% \stopscontents,
+% }
+% Now defining the \myenv{scontents} environment should be easy:
+% \begin{macrocode}
+%</core>
+%<loader>\newenvsc{scontents}
+%<*core>
+% \end{macrocode}
+% \end{macro}
+%
% \subsubsection{key val for environment}
%
% Define a \myoarg{key \textnormal{\textcolor{gray}{=}} val} for
@@ -2603,7 +2820,7 @@ No tab
% \subsubsection{The environment itself}
%
% \begin{macro}{\@@_start_environment:w,\@@_start_after_option:w,
-% \@@_check_line_and_process:xn,\@@_stop_environment:}
+% \@@_check_line_process:xn,\@@_stop_environment:}
% Here we make §^^I§, §^^L§ and §^^M§ active characters so that the end of
% line can be \enquote{seen} to be used as a delimiter, and \hologo{TeX} doesn't try to
% eliminate space-like characters.
@@ -2616,22 +2833,17 @@ No tab
% \cs{@@_start_after_option:w} also checks for trailing tokens after
% the optional argument and issues an error if any.
%
-% In all cases \cs{@@_check_line_and_process:xn} is called to check that
-% the rest of the §\begin{scontents}§ is empty and then process
-% the environment. \cs{@@_check_line_and_process:xn} calls the
+% In all cases, \cs{@@_check_line_process:xn} ckecks that
+% everything past §\begin{scontents}§ is empty and then process
+% the environment. \cs{@@_check_line_process:xn} calls the
% \cs{@@_file_tl_write_start:V} function, which will then read the contents
% of the environment and optionally store them in a token list or write to
% an external file.
%
-% When that's done, \cs{@@_file_write_stop:N} does the cleanup and the
-% read token list is smuggled out of the verbatim group. This part of
+% When that's done, \cs{@@_file_write_stop:N} does the cleanup. This part of
% the code is inspired and adapted from the code of the package \pkg{xsimverb}
% by Clemens Niederberger.
%
-%^^A Hm... Apparently this is not the verbatim group, but one level above. Is
-%^^A this group really necessary?
-%^^A Reply : I've checked it several times, it seems to be correct.
-%
% \begin{macrocode}
\group_begin:
\char_set_catcode_active:N \^^I
@@ -2645,31 +2857,32 @@ No tab
{
\str_if_eq:eeTF { \tl_head:n {#1} } { [ }
{ \@@_grab_optional:w #1 ^^M }
- { \@@_check_line_and_process:xn { } {#1} }
+ { \@@_check_line_process:xn { } {#1} }
}
- { \@@_check_line_and_process:xn { } {#1} }
+ { \@@_check_line_process:xn { } {#1} }
}
\cs_new_protected:Npn \@@_start_after_option:w #1 ^^M
- { \@@_check_line_and_process:xn { [...] } {#1} }
- \cs_new_protected:Npn \@@_check_line_and_process:xn #1 #2
+ { \@@_check_line_process:xn { [...] } {#1} }
+ \cs_new_protected:Npn \@@_check_line_process:xn #1 #2
{
\tl_if_blank:nF {#2}
{
\msg_error:nnxn { scontents } { junk-after-begin }
- { after~\c_backslash_str begin{scontents} #1 } {#2}
+ { after~\c_backslash_str begin { \l_@@_env_name_tl } #1 } {#2}
}
\@@_make_control_chars_active:
- \group_begin:
- \@@_file_tl_write_start:V \l_@@_fname_out_tl
+ \@@_file_tl_write_start:V \l_@@_fname_out_tl
}
\cs_new_protected:Npn \@@_stop_environment:
{
- \@@_file_write_stop:N \l_@@_macro_tmp_tl
- \exp_args:NNNV
- \group_end:
- \tl_set:Nn \l_@@_macro_tmp_tl \l_@@_macro_tmp_tl
- \tl_if_empty:NT \l_@@_macro_tmp_tl
- { \msg_warning:nnn { scontents } { empty-environment } }
+ \@@_file_write_stop:N \l_@@_macro_tmp_tl
+ \bool_lazy_and:nnT
+ { \l_@@_storing_bool }
+ { \tl_if_empty_p:N \l_@@_macro_tmp_tl }
+ {
+ \msg_warning:nnx { scontents } { empty-environment }
+ { \l_@@_env_name_tl }
+ }
}
% \end{macrocode}
% \end{macro}
@@ -2678,6 +2891,8 @@ No tab
% \@@_file_tl_write_start:n,
% \@@_file_tl_write_start:V,
% \@@_verb_processor_iterate:w,
+% \@@_verb_processor_iterate:nnn,
+% \@@_setup_verb_processor:,
% \@@_file_write_stop:N,
% \@@_remove_leading_nl:n,
% \@@_remove_leading_nl:w,
@@ -2698,16 +2913,22 @@ No tab
\cs_new_protected:Npn \@@_file_tl_write_start:n #1
{
\group_begin:
- \bool_if:NT \l_@@_writing_bool
+ \bool_if:nT { \l_@@_writing_bool && \l_@@_overwrite_bool }
{
- \file_if_exist:nTF {#1}
- { \msg_warning:nnx { scontents } { rewriting-file } {#1} }
- { \msg_warning:nnx { scontents } { writing-file } {#1} }
- \iow_open:Nn \l_@@_file_iow {#1}
+ \file_if_exist:nTF {#1}
+ { \msg_warning:nnx { scontents } { overwrite-file } {#1} }
+ { \msg_warning:nnx { scontents } { writing-file } {#1} }
+ \iow_open:Nn \l_@@_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}
}
\tl_clear:N \l_@@_file_tl
\seq_map_function:NN \l_char_special_seq \char_set_catcode_other:N
- \int_step_function:nnN { 128 } { 255 } \char_set_catcode_letter:n
+ \int_step_function:nnnN { 128 } { 1 } { 255 } \char_set_catcode_letter:n
\cs_set_protected:Npx \@@_ret:w ##1 ^^M
{
\exp_not:N \@@_verb_processor_iterate:w
@@ -2718,48 +2939,65 @@ No tab
\@@_make_control_chars_active:
\@@_ret:w
}
- \use:x
+ \cs_new:Npn \@@_setup_verb_processor:
{
- \cs_new:Npn \exp_not:N \@@_verb_processor_iterate:w
- ##1 \c_@@_end_env_tl
- ##2 \c_@@_end_env_tl
- ##3 \exp_not:N \q_@@_stop
- } {
- \tl_if_blank:nTF {#3}
- {
- \@@_analyse_nesting:n {#1}
- \@@_verb_processor_output:n {#1}
- }
- {
- \@@_if_nested:TF
- {
- \@@_nesting_decr:
- \@@_verb_processor_output:x
- { \exp_not:n {#1} \c_@@_end_env_tl \exp_not:n {#2} }
- }
- {
- \tl_if_blank:nF {#1}
- { \@@_verb_processor_output:n {#1} }
- \cs_set_protected:Npx \@@_ret:w
- {
- \@@_format_case:nnn
- { \exp_not:N \end{scontents} } % LaTeX
- { \endscontents } % Plain/Generic
- { \stopscontents } % ConTeXt
- \bool_lazy_or:nnF
- { \tl_if_blank_p:n {#2} }
- { \str_if_eq_p:ee {#2} { \c_percent_str } }
- {
- \str_if_eq:VnF \c_@@_hidden_space_str {#2}
- { \msg_warning:nnn { scontents } { rescanning-text } {#2} }
- \@@_rescan_tokens:n {#2}
- }
- }
- \char_set_active_eq:NN ^^M \@@_ret:w
- }
- }
- ^^M
- }
+ \use:x
+ {
+ \cs_set:Npn \exp_not:N \@@_verb_processor_iterate:w
+ ####1 \c_@@_end_env_tl
+ ####2 \c_@@_end_env_tl
+ ####3 \exp_not:N \q_@@_stop
+ } { \@@_verb_processor_iterate:nnn {##1} {##2} {##3} }
+ }
+ \cs_new:Npn \@@_verb_processor_iterate:nnn #1 #2 #3
+ {
+ \tl_if_blank:nTF {#3}
+ {
+ \@@_analyse_nesting:n {#1}
+ \@@_verb_processor_output:n {#1}
+ }
+ {
+ \@@_if_nested:TF
+ {
+ \@@_nesting_decr:
+ \@@_verb_processor_output:x
+ { \exp_not:n {#1} \c_@@_end_env_tl \exp_not:n {#2} }
+ }
+ {
+ \tl_if_blank:nF {#1}
+ { \@@_verb_processor_output:n {#1} }
+ \cs_set_protected:Npx \@@_ret:w
+ {
+ \@@_env_end_function:
+ \bool_lazy_or:nnF
+ { \tl_if_blank_p:n {#2} }
+ { \str_if_eq_p:ee {#2} { \c_percent_str } }
+ {
+ \str_if_eq:VnF \c_@@_hidden_space_str {#2}
+ {
+ \msg_warning:nnnn { scontents } { rescanning-text }
+ {#2} { \tl_use:N \l_@@_env_name_tl }
+ }
+ \@@_rescan_tokens:n {#2}
+ }
+ }
+ \char_set_active_eq:NN ^^M \@@_ret:w
+ }
+ }
+ ^^M
+ }
+ \cs_new:Npn \@@_env_end_function:
+ {
+ \@@_format_case:nnn
+ { \exp_not:N \end { \if_false: } \fi: }
+ { \exp_after:wN \exp_not:N \cs:w end }
+ { \exp_after:wN \exp_not:N \cs:w stop }
+ \tl_use:N \l_@@_env_name_tl
+ \@@_format_case:nnn
+ { \if_false: { \fi: } }
+ { \cs_end: }
+ { \cs_end: }
+ }
\cs_new_protected:Npn \@@_file_write_stop:N #1
{
\bool_if:NT \l_@@_writing_bool
@@ -2797,23 +3035,10 @@ No tab
% \begin{macro}{
% \@@_verb_processor_output:n,
% \@@_verb_processor_output:x,
-% \@@_analyse_nesting:n,
-% \@@_analyse_nesting:w,
-% \@@_nesting_decr:,
-% \@@_use_none_delimit_by_q_stop:w,
% }
-% \begin{macro}[TF]{\@@_if_nested:}
% \cs{@@_verb_processor_output:n} does the output of each line read,
% to a token list and to a file, depending on the booleans
% \cs{l_@@_writing_bool} and \cs{l_@@_storing_bool}.
-%
-% \cs{@@_analyse_nesting:n} looks for nested §\begin{scontents}§
-% and adds to a \cs{l_@@_env_nesting_int} counter. The \cs{@@_if_nested:}
-% conditional tests if we're in a nested environment, and
-% \cs{@@_nesting_decr:} reduces the nesting level, if an §\end{scontents}§
-% is found.
-%
-% Multiple §\end{scontents}§ in the same line are not supported...
% \begin{macrocode}
\cs_new_protected:Npn \@@_verb_processor_output:n #1
{
@@ -2822,51 +3047,120 @@ No tab
\bool_if:NT \l_@@_storing_bool
{ \tl_put_right:Nn \l_@@_file_tl { ^^J #1 } }
}
- \cs_generate_variant:Nn \@@_verb_processor_output:n { x }
- \cs_new_protected:Npx \@@_analyse_nesting:n #1
- {
- \int_zero:N \l_@@_tmpa_int
- \exp_not:N \@@_analyse_nesting:w #1
- \c_backslash_str begin
- \c_left_brace_str \exp_not:N \q_@@_mark \c_right_brace_str
- \exp_not:N \q_@@_stop
- \int_compare:nNnT { \l_@@_tmpa_int } > { 1 }
- { \msg_warning:nn { scontents } { multiple-begin } }
- }
- \use:x
- {
- \cs_new_protected:Npn \exp_not:N \@@_analyse_nesting:w ##1
- \c_backslash_str begin \c_left_brace_str ##2 \c_right_brace_str
- } {
- \if_meaning:w \q_@@_mark #2
- \exp_after:wN \use_i:nn
- \else:
- \exp_after:wN \use_ii:nn
- \fi:
- { \@@_use_none_delimit_by_q_stop:w }
- {
- \str_if_eq:eeT {#2} {scontents}
- {
- \int_incr:N \l_@@_env_nesting_int
- \int_incr:N \l_@@_tmpa_int
- \@@_analyse_nesting:w
- }
- \@@_analyse_nesting:w
- }
- }
- \cs_new_protected:Npn \@@_nesting_decr:
- { \int_decr:N \l_@@_env_nesting_int }
- \prg_new_protected_conditional:Npnn \@@_if_nested: { TF }
- {
- \int_compare:nNnTF { \l_@@_env_nesting_int } > { \c_zero_int }
- { \prg_return_true: }
- { \prg_return_false: }
- }
- \cs_new:Npn \@@_use_none_delimit_by_q_stop:w #1 \q_@@_stop { }
\group_end:
+\cs_generate_variant:Nn \@@_verb_processor_output:n { x }
\cs_generate_variant:Nn \@@_file_tl_write_start:n { V }
% \end{macrocode}
% \end{macro}
+%
+% \begin{macro}{
+% \@@_analyse_nesting:n,
+% \@@_analyse_nesting:w,
+% \@@_nesting_decr:,
+% \@@_use_none_delimit_by_q_stop:w,
+% }
+% \begin{macro}[TF]{\@@_if_nested:}
+% \cs{@@_analyse_nesting:n} scans nested §\begin{scontents}§
+% and steps a \cs{l_@@_env_nesting_int} counter. The \cs{@@_if_nested:}
+% conditional tests if we're in a nested environment, and
+% \cs{@@_nesting_decr:} reduces the nesting level, if an §\end{scontents}§
+% is found.
+%
+% Multiple §\end{scontents}§ in the same line are not supported\dots
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_analyse_nesting:n #1
+ {
+ \int_zero:N \l_@@_tmpa_int
+ \@@_analyse_nesting_format:n {#1}
+ \int_compare:nNnT { \l_@@_tmpa_int } > { 1 }
+ { \msg_warning:nn { scontents } { multiple-begin } }
+ }
+\cs_new_protected:Npn \@@_nesting_incr:
+ {
+ \int_incr:N \l_@@_env_nesting_int
+ \int_incr:N \l_@@_tmpa_int
+ }
+\cs_new_protected:Npn \@@_nesting_decr:
+ { \int_decr:N \l_@@_env_nesting_int }
+\prg_new_protected_conditional:Npnn \@@_if_nested: { TF }
+ {
+ \int_compare:nNnTF { \l_@@_env_nesting_int } > { \c_zero_int }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+\cs_new:Npn \@@_use_none_delimit_by_q_stop:w #1 \q_@@_stop { }
+% \end{macrocode}
+% In \LaTeX{}, environments start with §\begin{<env>}§, so checking if a
+% string contains §\begin{scontents}§ is straightforward. Since no §}§ can
+% appear inside §<env>§, then just a macro delimited by §}§ is enough.
+% \begin{macrocode}
+\use:x
+ {
+ \cs_new_protected:Npn \exp_not:N \@@_analyse_nesting_latex:w ##1
+ \c_backslash_str begin \c_left_brace_str ##2 \c_right_brace_str
+ } {
+ \@@_tl_if_head_is_q_mark:nTF {#2}
+ { \@@_use_none_delimit_by_q_stop:w }
+ {
+ \str_if_eq:VnT \l_@@_env_name_tl {#2}
+ { \@@_nesting_incr: }
+ \@@_analyse_nesting_latex:w
+ }
+ }
+\cs_new_protected:Npx \@@_analyse_nesting_latex:n #1
+ {
+ \@@_analyse_nesting_latex:w #1
+ \c_backslash_str begin
+ \c_left_brace_str \exp_not:N \q_@@_mark \c_right_brace_str
+ \exp_not:N \q_@@_stop
+ }
+% \end{macrocode}
+% In other formats, however, we don't have an \enquote{end anchor} to delimit the
+% environment name, so a delimited macro won't help. We have to search for
+% the entire environment command (usually §\scontents§ and §\startscontents§).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_analyse_nesting_generic_process:nn #1 #2
+ {
+ \tl_if_head_is_N_type:nTF {#2}
+ {
+ \@@_tl_if_head_is_q_mark:nF {#2}
+ {
+ \@@_nesting_incr:
+ \@@_analyse_nesting_generic:w #2 \q_@@_stop
+ }
+ }
+ { \@@_analyse_nesting_generic:w #2 \q_@@_stop }
+ }
+\cs_new_protected:Npn \@@_analyse_nesting_generic:nn #1 #2
+ {
+ \@@_define_generic_nesting_function:n {#1}
+ \use:x
+ {
+ \exp_not:N \@@_analyse_nesting_generic:w #2
+ \c_backslash_str #1 \tl_use:N \l_@@_env_name_tl
+ \exp_not:N \q_@@_mark \exp_not:N \q_@@_stop
+ }
+ }
+\cs_new_protected:Npn \@@_define_generic_nesting_function:n #1
+ {
+ \use:x
+ {
+ \cs_set_protected:Npn \exp_not:N \@@_analyse_nesting_generic:w ####1
+ \c_backslash_str #1 \tl_use:N \l_@@_env_name_tl
+ ####2 \exp_not:N \q_@@_stop
+ } { \@@_analyse_nesting_generic_process:nn {##1} {##2} }
+ }
+%</core>
+%<*loader>
+%<latex>\cs_new_eq:NN \@@_analyse_nesting_format:n
+%<latex> \@@_analyse_nesting_latex:n
+%<!latex>\cs_new_protected:Npn \@@_analyse_nesting_format:n
+%<plain> { \@@_analyse_nesting_generic:nn { } }
+%<context> { \@@_analyse_nesting_generic:nn { start } }
+%</loader>
+%<*core>
+% \end{macrocode}
+% \end{macro}
% \end{macro}
%
% \subsubsection{Recording of the content in the sequence}
@@ -2881,8 +3175,12 @@ No tab
\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
+ {
+ \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 }
}
@@ -2899,7 +3197,8 @@ No tab
\cs_new_protected:Npn \verbatimsc
{
\group_begin:
- \@@_verbatimsc_aux: \frenchspacing \@@_vobeyspaces: \@@_xverb:
+ \@@_verbatimsc_aux: \frenchspacing \@@_vobeyspaces:
+ \@@_xverb:
}
\cs_new_protected:Npn \endverbatimsc
{ \group_end: }
@@ -3036,7 +3335,7 @@ No tab
% \begin{macrocode}
%</core>
%<*loader>
-\NewDocumentCommand { \getstored } { O{1} m }
+\NewDocumentCommand { \getstored } { O{-1} m }
{ \@@_getstored_internal:nn {#1} {#2} }
%</loader>
%<*core>
@@ -3082,7 +3381,10 @@ No tab
{ \l_@@_foreach_stop_int }
\@@_foreach_add_body:n
\tl_gset:Nx \g_@@_temp_tl
- { \seq_use:Nn \l_@@_foreach_print_seq { \tl_use:N \l_@@_foreach_sep_tl } }
+ {
+ \seq_use:Nn \l_@@_foreach_print_seq
+ { \tl_use:N \l_@@_foreach_sep_tl }
+ }
\group_end:
\exp_after:wN \tl_gclear:N
\exp_after:wN \g_@@_temp_tl
@@ -3235,6 +3537,21 @@ No tab
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}[TF]{\@@_tl_if_head_is_q_mark:n}
+% Tests if the head of the token list is \cs{q_@@_mark}.
+% \begin{macrocode}
+\prg_new_protected_conditional:Npnn \@@_tl_if_head_is_q_mark:n #1
+ { T, F, TF }
+ {
+ \if_meaning:w \q_@@_mark #1 \scan_stop:
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{
% \@@_set_active_eq:NN,
% \@@_make_control_chars_active:,
@@ -3335,7 +3652,6 @@ No tab
%
% \subsection{The command \cs{countsc}}
%
-%
% \begin{macro}{\countsc}
% User command §\countsc§ to count number of contents stored in |seq|.
%
@@ -3376,18 +3692,25 @@ No tab
\\ \\
#2
}
+\msg_new:nnnn { scontents } { env-already-defined }
+ { Environment~'#1'~already~defined! }
+ {
+ You~have~used~\newenvsc
+ with~an~environment~that~already~has~a~definition. \\ \\
+ The~existing~definition~of~'#1'~will~not~be~altered.
+ }
\msg_new:nnn { scontents } { empty-stored-content }
{ Empty~value~for~key~'getstored'~\msg_line_context:. }
\msg_new:nnn { scontents } { empty-variable }
{ Variable~'#1'~empty~\msg_line_context:. }
-\msg_new:nnn { scontents } { rewriting-file }
- { Overwriting ~ file ~ '#1' }
+\msg_new:nnn { scontents } { overwrite-file }
+ { Overwriting~file~'#1'. }
\msg_new:nnn { scontents } { writing-file }
- { Writing ~ file ~ '#1' }
+ { Writing~file~'#1'. }
\msg_new:nnn { scontents } { rescanning-text }
- { Rescanning~text~'#1'~after~\c_backslash_str end{scontents}~\msg_line_context:.}
+ { Rescanning~text~'#1'~after~\c_backslash_str end{#2}~\msg_line_context:.}
\msg_new:nnn { scontents } { multiple-begin }
- { Multiple~\c_backslash_str begin{scontents}~\msg_line_context:.}
+ { Multiple~\c_backslash_str begin{ \l_@@_env_name_tl }~\msg_line_context:.}
\msg_new:nnn { scontents } { undefined-storage }
{ Storage~named~'#1'~is~not~defined. }
\msg_new:nnn { scontents } { index-out-of-range }
@@ -3401,15 +3724,21 @@ No tab
}
}
\msg_new:nnnn { scontents } { env-key-unknown }
- { The~key~'#1'~is~unknown~by~environment~'scontents'~and~is~being~ignored.}
{
- The~environment~'scontents'~does~not~have~a~key~called~'#1'.\\
+ The~key~'#1'~is~unknown~by~environment~
+ '\l_@@_env_name_tl'~and~is~being~ignored.
+ }
+ {
+ The~environment~'\l_@@_env_name_tl'~does~not~have~a~key~called~'#1'.\\
Check~that~you~have~spelled~the~key~name~correctly.
}
\msg_new:nnnn { scontents } { env-key-value-unknown }
- { The~key~'#1=#2'~is~unknown~by~environment~'scontents'~and~is~being~ignored. }
{
- The~environment~'scontents'~does~not~have~a~key~called~'#1'.\\
+ The~key~'#1=#2'~is~unknown~by~environment~
+ '\l_@@_env_name_tl'~and~is~being~ignored.
+ }
+ {
+ The~environment~'\l_@@_env_name_tl'~does~not~have~a~key~called~'#1'.\\
Check~that~you~have~spelled~the~key~name~correctly.
}
\msg_new:nnnn { scontents } { cmd-key-unknown }
@@ -3449,7 +3778,7 @@ No tab
This~command~only~accepts~the~key~'width-tab'.
}
\msg_new:nnn { scontents } { empty-environment }
- { scontents~environment~empty~\msg_line_context:. }
+ { environment~'#1'~empty~\msg_line_context:. }
\msg_new:nnnn { scontents } { verbatim-newline }
{ Verbatim~argument~of~#1~ended~by~end~of~line. }
{
@@ -3479,4 +3808,5 @@ No tab
%</core>
%<plain|context>\ExplSyntaxOff
% \end{macrocode}
+%
% \Finale
diff --git a/macros/latex/contrib/scontents/scontents.ins b/macros/latex/contrib/scontents/scontents.ins
index 6c761fe6b0..953dc79bb6 100644
--- a/macros/latex/contrib/scontents/scontents.ins
+++ b/macros/latex/contrib/scontents/scontents.ins
@@ -33,11 +33,11 @@ and the derived files scontents.sty,
\declarepreamble\context
\string\module
[ file=t-scontents,
- version=1.7,
+ version=1.8,
title=\string\CONTEXT\ User Module,
subtitle=Storing Contents,
author=Pablo González,
- date=2019-10-29,
+ date=2019-11-18,
copyright=Pablo González,
email=pablgonz@educarchile.cl,
license=LPPL]
diff --git a/macros/latex/contrib/scontents/scontents.pdf b/macros/latex/contrib/scontents/scontents.pdf
index 958da1dcc6..eea74b0101 100644
--- a/macros/latex/contrib/scontents/scontents.pdf
+++ b/macros/latex/contrib/scontents/scontents.pdf
Binary files differ