summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/codesection
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-06-28 22:28:37 +0000
committerKarl Berry <karl@freefriends.org>2014-06-28 22:28:37 +0000
commita6fa94386add9ed9605b19145be8fa55ca8b8ed7 (patch)
treed6d436ae51c971974edcb879ec6fc56d5cffa401 /Master/texmf-dist/tex/latex/codesection
parentb3de83bfade84ad4e11703492d0250c5ec22edec (diff)
codesection (28jun14)
git-svn-id: svn://tug.org/texlive/trunk@34473 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/codesection')
-rw-r--r--Master/texmf-dist/tex/latex/codesection/codesection.sty159
1 files changed, 159 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/codesection/codesection.sty b/Master/texmf-dist/tex/latex/codesection/codesection.sty
new file mode 100644
index 00000000000..a9cdeb4fa01
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/codesection/codesection.sty
@@ -0,0 +1,159 @@
+%%
+%% This is file `codesection.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% codesection.dtx (with options: `codesection.sty')
+%%
+%% IMPORTANT NOTICE:
+%%
+%% For the copyright see the source file.
+%%
+%% Any modified versions of this file must be renamed
+%% with new filenames distinct from codesection.sty.
+%%
+%% For distribution of the original source see the terms
+%% for copying and modification in the file codesection.dtx.
+%%
+%% This generated file may be distributed as long as the
+%% original source files, as listed above, are part of the
+%% same distribution. (The sources need not necessarily be
+%% in the same archive or directory.)
+ % package defines paired commands and consequently, has no such limitations.
+\NeedsTeXFormat{LaTeX2e}[1994/12/01]
+\ProvidesPackage{codesection}
+ [2014/06/27 v0.1 disableable code sections]
+\RequirePackage{etoolbox}
+%%----------------------------------------------------------------------
+%% provide new if (\ifCodeSection<name>)
+%% with definition \CodeSection<name><true>
+%%
+\newcommand{\DefineCodeSection}[2][true]{%
+ \expandafter\newif\csname ifCodeSection#2\endcsname
+ \csname CodeSection#2#1\endcsname
+}%
+%%----------------------------------------------------------------------
+%% Alternative to \DefineCodeSection
+\newcommand{\SetCodeSection}[2]{%
+ \DefineCodeSection[#2]{#1}
+}%
+%%----------------------------------------------------------------------
+\newcommand\BeginCodeSection[1]{%
+ \ifcsdef{ifCodeSection#1}{}{%
+ \PackageError{codesection}{Section #1 is unknown\MessageBreak}{}%
+ }
+ \csname ifCodeSection#1\endcsname
+ \expandafter\@secondoftwo
+ \else
+ \expandafter\@firstoftwo
+ \fi
+ {% comment all code inside template section
+ \@bsphack
+%% open new group
+ \begingroup
+%% save current template section name
+ \def\@currtemplate{#1}%
+ \let\do\@makeother\dospecials
+ \catcode`\^^M\active
+%% enter main loop
+ \codeSection@
+ }%
+ {% execute all code inside template section
+%% = do nothing except trimming spaces
+ \@bsphack\@esphack%
+ }%
+}
+%%----------------------------------------------------------------------
+%% The macros \@bsphack and \@esphack are internal to LaTeX;
+%% they ensure that an entity like a marginal note or
+%% label definition does not introduce any extra space
+%% into a paragraph, independently of whether or not
+%% it is attached to a word.
+\newcommand\EndCodeSection[1]{\@bsphack\@esphack}
+%%----------------------------------------------------------------------
+%% usage ???
+\@ifundefined{vrb@catcodes}{%
+ \def\vrb@catcodes{%
+ \catcode`\!12\catcode`\[12\catcode`\]12%
+ }%
+}{}%
+%%----------------------------------------------------------------------
+\begingroup
+\vrb@catcodes
+\lccode`\!=`\\
+\lccode`\[=`\{
+\lccode`\]=`\}
+\catcode`\~=\active
+\lccode`\~=`\^^M
+\lccode`\C=`\C
+\lowercase{%
+%%----------------------------------------------------------------------
+ \def\codeSection@#1{%
+ \endgroup
+%% ----
+ \def\codeSection@##1~{\codeSection@@##1!#1\@nil}%
+%% ----
+ \def\codeSection@@##1!#1{\futurelet\next\codeSection@@@}%
+%% ----
+ \def\codeSection@@@##1\@nil{%
+ \ifx\next\@nil
+ \let\next\codeSection@
+ \else
+ \def\@tempa####1!#1\@nil{####1}%
+ \def\next{\expandafter\codeSection@test\@tempa##1\@nil~}%
+ \fi
+ \next
+ }%
+%% ----
+ \def\codeSection@test##1{%
+ \let\next\codeSection@test
+ \if\noexpand##1\noexpand~\let\next\codeSection@
+ \else \if\noexpand##1
+ \else \if\noexpand##1\noexpand[\let\@tempc\@empty
+ \let\next\codeSection@testend
+ \else \def\next{\codeSection@##1}%
+ \fi\fi\fi
+ \next
+ }%
+%% ----
+ \def\codeSection@testend##1{%
+ \if\noexpand##1\noexpand~\let\next\codeSection@
+ \else \if\noexpand##1\noexpand]\let\next\codeSection@@testend
+ \else\if\noexpand##1\noexpand!\def\next{\codeSection@!}%
+ \else \expandafter\def\expandafter\@tempc\expandafter
+ {\@tempc##1}%
+ \fi\fi\fi
+ \next
+ }%
+%% ---- test if end statement belongs to current section
+%% saved in \@currtemplate
+ \def\codeSection@@testend{%
+ \ifx\@tempc\@currtemplate
+%% end group and call rescan
+ \edef\next{\noexpand\endgroup\noexpand\@esphack
+ \noexpand\codeSection@rescan{\@currtemplate}}%
+ \else
+%% start loop gain
+ \let\next\codeSection@
+ \fi
+ \next
+ }%
+%% ---- does what ???
+ \def\codeSection@rescan##1##2~{%
+ \if\noexpand~\noexpand##2~%
+ \else
+ \@warning{%
+ Characters dropped after
+ `\string\EndCodeSection{##1}'%
+ }%
+ \fi
+ }%
+ }%
+%%----------------------------------------------------------------------
+} % lowercase
+\codeSection@{EndCodeSection}%
+%%----------------------------------------------------------------------
+\endinput
+%%
+%% End of file `codesection.sty'.