summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/newverbs
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-07-25 21:54:21 +0000
committerKarl Berry <karl@freefriends.org>2011-07-25 21:54:21 +0000
commitc8570fd6aff117b8caeec3dcc0039161c6e85049 (patch)
tree6e6f76bdbc01973a88234ba17087b569d51cd2fa /Master/texmf-dist/source/latex/newverbs
parentf1615aae3ec6e6c8333f5c09987e5888bd5cd0c6 (diff)
newverbs (25jul11)
git-svn-id: svn://tug.org/texlive/trunk@23220 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/newverbs')
-rw-r--r--Master/texmf-dist/source/latex/newverbs/newverbs.dtx218
-rw-r--r--Master/texmf-dist/source/latex/newverbs/newverbs.ins2
2 files changed, 204 insertions, 16 deletions
diff --git a/Master/texmf-dist/source/latex/newverbs/newverbs.dtx b/Master/texmf-dist/source/latex/newverbs/newverbs.dtx
index 3308c33784b..51aebe266d8 100644
--- a/Master/texmf-dist/source/latex/newverbs/newverbs.dtx
+++ b/Master/texmf-dist/source/latex/newverbs/newverbs.dtx
@@ -20,26 +20,21 @@
%</copyright>
%<*!copyright>
%
-%% $Id: newverbs.dtx 2161 2011-02-16 16:19:38Z martin $
+%% $Id: newverbs.dtx 2529 2011-07-24 01:15:30Z martin $
%
%<*driver>
\ProvidesFile{newverbs.dtx}
%</driver>
%<package>\ProvidesPackage{newverbs}
%<*package|driver>
- [2011/02/16 v1.2 Define new 'verb' commands and short verb. characters]
+ [2011/07/24 v1.3 Define new 'verb' commands and short verb. characters]
%</package|driver>
%
%<*driver>
\documentclass{ydoc}
-\usepackage{hyperref}
-\usepackage{xcolor}
-
\GetFileInfo{newverbs.dtx}
\usepackage{newverbs}[\filedate]
-\usepackage{shortvrb}
-\MakeSpecialShortVerb{\qverb}{\"}
%\EnableCrossrefs
%\CodelineIndex
%\RecordChanges
@@ -51,7 +46,7 @@
%</driver>
% \fi
%
-% \CheckSum{131}\relax
+% \CheckSum{245}\relax
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -73,15 +68,16 @@
% \changes{v1.0}{2010/04/05}{Initial version}
% \changes{v1.1}{2010/04/13}{Added usage of 'csquotes' macros if loaded.}
% \changes{v1.2}{2011/02/16}{Added support for 'tabularx' environments.}
+% \changes{v1.2a}{2011/03/19}{Removed spurious spaces.}
+% \changes{v1.3}{2011/07/24}{Added macros to collect verbatim arguments.}
%
% \DoNotIndex{\newcommand,\newenvironment,\providecommand}
%
% \GetFileInfo{newverbs.dtx}
-% \title{The \textsf{newverbs} package}
-% \author{Martin Scharrer \\ \texttt{martin@scharrer-online.de}}
-% \date{\fileversion\ from \filedate}
-%
+% \author{Martin Scharrer}
+% \email{martin@scharrer-online.de}
% \maketitle
+%
% \begin{abstract}
% This package allows the definition of \cs{verb} variants which add \TeX\ code before and after the verbatim text.
% When used together with the \pkg{shortvrb} package it allows the definition of short verbatim characters which use this variants
@@ -130,6 +126,7 @@
%
% \subsection{Using \cs{verb} variants with short verbatim character}
%
+% \DescribeMacro\MakeSpecialShortVerb {<\textbackslash macro>}{\textbackslash\meta{char}}
% \DescribeMacro\MakeSpecialShortVerb*{<\textbackslash macro>}{\textbackslash\meta{char}}
% This package also defines a special version of the \cs{MakeShortVerb} macro from the \pkg{shortvrb} package.
% The orignal command \Macro\MakeShortVerb*{\textbackslash\meta{char}} changes the meaning of \meta{char} so that
@@ -150,6 +147,42 @@
% |\DeleteShortVerb{\"}\MakeSpecialShortVerb{\fverb}{\"}| will change it definition to use \cs{fverb}: \fverb+$^&$+.
%
%
+% \DescribeMacro\collectverb{<code>}<char><verbatim material><char>
+% \DescribeMacro\collectverb*{<code>}<char><verbatim material><char>
+% \DescribeMacro\collectverb{<code>}{<verbatim material>}
+% \DescribeMacro\collectverb*{<code>}{<verbatim material>}
+% This macro is supposed to be used with its \marg{code} argument at the end of user or package macro which want to typeset verbatim material.
+% It will collect everything between the following \meta{char} and its next occurrence as verbatim material.
+% An exception is if the following \meta{char} is `|{|', then `|}|' is taken as the end \meta{char} to simulate a normal argument to increase user friendliness.
+% Afterwards \meta{code} is expanded with \marg{verbatim material} direct behind it. The macro ensures proper font settings to typeset the verbatim material.
+% For this, a group is opened before the material is collected and closed directly after the given code is processed. ^^A \MacroArgs<code>{<verbatim material>}\AlsoMacro\endgroup.
+% Therefore all changes done by the \meta{code} are local and the material should be typeset directly.
+% (In special cases when the group is disruptive, \meta{code} can be a macro which reads both the verbatim material and the \Macro\endgroup as two arguments.
+% However, then special care must be taken to use the correct font and some of the special characters may be active but have lost their definition.)
+% The starred version will make spaces appear as `\collectverb*{}: :' instead of displaying them as normal spaces.
+%
+%
+% \DescribeMacro\Collectverb{<code>}<char><verbatim material><char>
+% \DescribeMacro\Collectverb*{<code>}<char><verbatim material><char>
+% \DescribeMacro\Collectverb{<code>}{<verbatim material>}
+% \DescribeMacro\Collectverb*{<code>}{<verbatim material>}
+% This macro is supposed to be used with its \marg{code} argument at the end of user or package macro which want to collect plain verbatim material suitable to be
+% written in auxiliary files or log messages.
+% It will collect everything between the following \meta{char} and its next occurrence as verbatim material without adjusting the font or defining any characters in a special way (besides being verbatim).
+% The starred version will make spaces appear as `\Collectverb*{}: :' when typeset but still be written to auxiliary files as normal spaces.
+% An exception is if the following \meta{char} is `|{|', then `|}|' is taken as the end \meta{char} to simulate a normal argument to increase user friendliness.
+% Afterwards \meta{code} is expanded with \marg{verbatim material} direct behind it. This macro does not add any group around the code.
+% Should the code be typeset after all a proper font (e.g.\ \Macro\ttfamily or \Macro\verbatim@font) must be enabled manually.
+%
+% \DescribeMacro\Verbdef<\textbackslash macro><char><verbatim material><char>
+% \DescribeMacro\Verbdef*<\textbackslash macro><char><verbatim material><char>
+% \DescribeMacro\Verbdef<\textbackslash macro>{<verbatim material>}
+% \DescribeMacro\Verbdef*<\textbackslash macro>{<verbatim material>}
+% This macro uses \Macro\Collectverb internally to define \meta{\textbackslash macro} as the plain \meta{verbatim material}.
+% This can be used to define macros for special characters, so these can be used in error or warning messages or be written into auxiliary files.
+% A corresponding \Macro\verbdef macro which defines macros with typesetable verbatim material is already provided by the \pkg{verbdef} package.
+%
+%
% \section{Compatibility with other verbatim packages}
% The compatibility with other verbatim packages is not tested yet. This package relies on the normal internal definition of \cs{verb}
% and \cs{MakeShortVerb}. Any package which changes these might break this package.
@@ -163,6 +196,9 @@
% \iffalse
%<*package>
% \fi
+% \begin{macrocode}
+\ProvidesPackage{newverbs}[2011/02/16 v1.2 Define new 'verb' commands and short verb. characters]
+% \end{macrocode}
%
% \subsection{Verb Definition Commands}
%
@@ -188,7 +224,7 @@
\begingroup
\newverbcommand@settings
\def\verb@egroup{\verb@orig@egroup#4\endgroup}%
- \def\newverbs@txend{#4\endgroup}
+ \def\newverbs@txend{#4\endgroup}%
#3\verb
}%
}
@@ -204,12 +240,12 @@
\def\newverbs@tabularxsupport{%
\begingroup
\def\orig@TX@vb##1{\def\@tempa####1##1{\toks@{####1}\edef\@tempa{\the\toks@}%
- \expandafter\TX@v\meaning\@tempa\\ \\\ifnum0=`{\fi}}\@tempa!}
+ \expandafter\TX@v\meaning\@tempa\\\\\ifnum0=`{\fi}}\@tempa!}%
\ifx\TX@vb\orig@TX@vb
\endgroup
\PackageInfo{newverbs}{Patching 'TX@vb' macro of the 'tabularx' package.}%
\def\TX@vb##1{\def\@tempa####1##1{\toks@{####1}\edef\@tempa{\the\toks@}%
- \expandafter\TX@v\meaning\@tempa\\ \\\ifnum0=`{\fi}\newverbs@txend}\@tempa!}
+ \expandafter\TX@v\meaning\@tempa\\\\\ifnum0=`{\fi}\newverbs@txend}\@tempa!}%
\else
\endgroup
\PackageWarning{newverbs}{Couldn't patch 'TX@vb' macro of the 'tabularx' package. Definition unknown.}%
@@ -293,6 +329,158 @@
% \end{macrocode}
% \end{macro}
%
+%
+% \subsection{Collect verbatim argument}
+%
+% \begin{macro}{\collectverb}
+% Collects verbatim text which can be typeset.
+% Checks for an existing star.
+% \begin{macrocode}
+\newcommand*\collectverb{%
+ \begingroup
+ \verbatim@font
+ \@ifstar
+ \@scollectverb
+ \@collectverb
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@collectverb}[1]{<code>}
+% Changes catcodes and ensures that spaces are displayed normally.
+% \begin{macrocode}
+\def\@collectverb#1{%
+ \verb@eol@error
+ \let\do\@makeother
+ \dospecials
+ \@vobeyspaces
+ \frenchspacing
+ \@noligs
+ \@@collectverb{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@scollectverb}[1]{<code>}
+% Changes catcodes.
+% \begin{macrocode}
+\def\@scollectverb#1{%
+ \verb@eol@error
+ \let\do\@makeother
+ \dospecials
+ \@noligs
+ \@@collectverb{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@@collectverb}[2]{<code>}{<char>}
+% Defines \Macro\@@@collectverb to read everything to the next occurrence of \meta{char}
+% and feed it to the given \meta{code}.
+% \begin{macrocode}
+\def\@@collectverb#1#2{%
+ \ifnum`#2=`\{%
+ \catcode`\}\active
+ \else
+ \catcode`#2\active
+ \fi
+ \begingroup
+ \ifnum`#2=`\{%
+ \lccode`\~`\}%
+ \else
+ \lccode`\~`#2%
+ \fi
+ \lowercase{\endgroup
+ \def\@@@collectverb##1~}{#1{##1}\endgroup}%
+ \@@@collectverb
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\Collectverb}
+% Collects argument as plain verbatim and feeds it to the given code.
+% The text is suitable to be printed to auxiliary files.
+% \begin{macrocode}
+\newcommand*\Collectverb{%
+ \begingroup
+ \@ifstar
+ \@sCollectverb
+ \@Collectverb
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@Collectverb}
+% \begin{macrocode}
+\def\@Collectverb#1{%
+ \verb@eol@error
+ \let\do\@makeother
+ \dospecials
+ \obeyspaces
+ \@@Collectverb{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@sCollectverb}
+% \begin{macrocode}
+\def\@sCollectverb#1{%
+ \verb@eol@error
+ \let\do\@makeother
+ \dospecials
+ \@@Collectverb{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@@Collectverb}
+% \begin{macrocode}
+\def\@@Collectverb#1#2{%
+ \ifnum`#2=`\{%
+ \catcode`\}\active
+ \else
+ \catcode`#2\active
+ \fi
+ \begingroup
+ \ifnum`#2=`\{%
+ \lccode`\~`\}%
+ \else
+ \lccode`\~`#2%
+ \fi
+ \lowercase{\endgroup
+ \def\@@@Collectverb##1~}{\endgroup#1{##1}}%
+ \@@@Collectverb
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\Verbdef}
+% \begin{macrocode}
+\newcommand*\Verbdef{%
+ \@ifstar
+ {\@Verbdef*}%
+ {\@Verbdef{}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@Verbdef}
+% \begin{macrocode}
+\newcommand*\@Verbdef[2]{%
+ \Collectverb#1{\def#2}%
+}
+% \end{macrocode}
+% \end{macro}
+%
% \iffalse
%</package>
% \fi
diff --git a/Master/texmf-dist/source/latex/newverbs/newverbs.ins b/Master/texmf-dist/source/latex/newverbs/newverbs.ins
index a0abf99b144..7fb81c14d49 100644
--- a/Master/texmf-dist/source/latex/newverbs/newverbs.ins
+++ b/Master/texmf-dist/source/latex/newverbs/newverbs.ins
@@ -1,4 +1,4 @@
-% $Id: newverbs.ins 1816 2010-04-05 18:03:28Z martin $
+% $Id$
%
% Copyright (c) 2010 by Martin Scharrer <martin@scharrer-online.de>
% WWW: http://latex.scharrer-online.de/