diff options
author | Karl Berry <karl@freefriends.org> | 2019-09-10 21:45:21 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-09-10 21:45:21 +0000 |
commit | 36b416e7adb6f58b240f2bbfa14e0000abf5913f (patch) | |
tree | d2712f8d5eabb0b8143c281e099b4aca253d2a6b /Master/texmf-dist | |
parent | a2e36e6098124b767825914adc09449f74ca3e67 (diff) |
newverbs (10sep19)
git-svn-id: svn://tug.org/texlive/trunk@52074 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/newverbs/README | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/newverbs/newverbs.pdf | bin | 181372 -> 220993 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/newverbs/newverbs.dtx | 235 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/newverbs/newverbs.sty | 93 |
4 files changed, 248 insertions, 82 deletions
diff --git a/Master/texmf-dist/doc/latex/newverbs/README b/Master/texmf-dist/doc/latex/newverbs/README index 77e29799834..3012c3c67d9 100644 --- a/Master/texmf-dist/doc/latex/newverbs/README +++ b/Master/texmf-dist/doc/latex/newverbs/README @@ -1,6 +1,6 @@ The 'newverbs' LaTeX package ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Copyright (c) 2010-2012 by Martin Scharrer <martin@scharrer-online.de> +Copyright (c) 2010-2019 by Martin Scharrer <martin@scharrer-online.de> Code repository: https://bitbucket.org/martin_scharrer/newverbs This package allows the definition of \verb variants which add TeX code before diff --git a/Master/texmf-dist/doc/latex/newverbs/newverbs.pdf b/Master/texmf-dist/doc/latex/newverbs/newverbs.pdf Binary files differindex 389f098093b..017a5c7ef61 100644 --- a/Master/texmf-dist/doc/latex/newverbs/newverbs.pdf +++ b/Master/texmf-dist/doc/latex/newverbs/newverbs.pdf diff --git a/Master/texmf-dist/source/latex/newverbs/newverbs.dtx b/Master/texmf-dist/source/latex/newverbs/newverbs.dtx index f7014ef8d91..f2a79d35fde 100644 --- a/Master/texmf-dist/source/latex/newverbs/newverbs.dtx +++ b/Master/texmf-dist/source/latex/newverbs/newverbs.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment %<=*COPYRIGHT> -%% Copyright (C) 2012 by Martin Scharrer <martin@scharrer-online.de> +%% Copyright (C) 2012-2019 by Martin Scharrer <martin@scharrer-online.de> %% -------------------------------------------------------------------- %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -23,10 +23,10 @@ %<*driver> \ProvidesFile{newverbs.dtx}[% %<=*DATE> - 2012/05/08 + 2019/09/09 %<=/DATE> %<=*VERSION> - v1.3a + v1.4 %<=/VERSION> newverbs DTX file] \documentclass{ydoc} @@ -44,7 +44,7 @@ %</driver> % \fi % -% \CheckSum{0} +% \CheckSum{458} % % \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 @@ -68,6 +68,7 @@ % \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.} +% \changes{v1.4}{2019/09/09}{Added several suggested changes.} % % \DoNotIndex{\newcommand,\newenvironment,\providecommand} % @@ -103,9 +104,9 @@ % % \DescribeMacro\qverb<char><verbatim material><char> % This macro adds quote characters around the verbatim material. -% Two macros are used to insert the quotes: \cs{qverbbeginquote} (`) and \cs{qverbendquote} ('). +% Two macros are used to insert the quotes: \cs{qverbbeginquote} (``) and \cs{qverbendquote} (''). % They can be redefined by the user if required. If the \pkg{csquotes} package was loaded beforehand -% the above macros use its macros \cs{openinnerquote} and \cs{closeinnerquote} to take advantage of the language +% the above macros use its macros \cs{openautoquote} and \cs{closeautoquote} to take advantage of the language % dependent quotation marks. See the manual of \pkg{csquotes} for more details. % % Using \Macro\qverb<char><verbatim material><char> is equal to \\ @@ -133,7 +134,7 @@ % % The new macro \Macro\MakeSpecialShortVerb*{\textbackslash\meta{verb variant}}{\textbackslash\meta{char}} does the same, but % instead of \Macro\verb*\relax\relax\ it uses a \MacroArgs'\'<verb variant>*\relax which needs to be defined using \cs{newverbcommand}. -% The package \pkg{shortvrb} must be loaded by the user in order to make this macro work. It is not loaded automatically by \pkg{newverbs}. +% The package \pkg{shortvrb} must be installed in order to make this macro work. It is loaded automatically by \pkg{newverbs}. % % The special meaning of \meta{char} can be removed using \pkg{shortvrb}'s \cs{DeleteShortVerb}, i.e.\ the same way as for % characters defined with the normal \cs{MakeShortVerb}. @@ -170,7 +171,56 @@ % 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. +% Should the material be typeset after all a proper font (e.g.\ \Macro\ttfamily or \Macro\newverbsfont) must be enabled manually. +% +% +% +% \DescribeMacro\collectverbenv{<code>} +% \DescribeMacro\collectverbenv*{<code>} +% This macro is supposed to be used with its \marg{code} argument at the end of the begin-code of an user or package environment definition. +% It then collects the content of the environment as verbatim material and feeds it as an argument to the provided \meta{code} like \Macro\collectverb does +% (see there for further details which also apply here). +% This has the following limitations: +% When used the \Macro\begin of the environment must end with a line break, i.e.\ the source line must not include any other material afterwards. +% If the environment is defined with arguments, which is supported, the line break must be after the arguments. +% The \Macro\end of the macro must be at the beginning of an own source code line. +% If this conditions are not met incorrect results or an error may occur. Currently trailing material on the \Macro\begin line is simply ignored, but this +% behaviour might change in future versions. +% +% The starred version will make the spaces inside the environment appear as `\collectverb*{}: :'. +% +% \noindent Example usage:\\ +% \leavevmode\noindent\bgroup\footnotesize +% |\newenvironment{myenv}{\maybesomeothercode\collectverbenv{\mycmd}}{\someendcode}| \\ +% +% +% \DescribeMacro\Collectverbenv{<code>} +% \DescribeMacro\Collectverbenv*{<code>} +% This macro works like \Macro\collectverbenv but collects the environment content as plain verbatim material suitable to be +% written in auxiliary files or log messages. +% After collecting the environment the \meta{code} is expanded with \marg{verbatim material} direct behind it. This macro does not add any group around the code. +% Should the material be typeset after all a proper font (e.g.\ \Macro\ttfamily or \Macro\newverbsfont) must be enabled manually. +% +% The starred version will make spaces appear as `\Collectverb*{}: :' when typeset but still be written to auxiliary files as normal spaces. +% +% +% \DescribeMacro\newverbsfont +% Macro which activates the font used by the \pkg{newverbs} package for the verbatim text. +% This macro can be used manually if verbatim material collected with \Macro\Collectverb or \Macro\Collectverbenv should be typeset afterall. +% +% \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 defines the \meta{\textbackslash macro} as a robust macro which typesets the \meta{verbatim material} in the usual verbatim font. +% For this the material is placed in a brace group with \Macro\newverbsfont. If a different font is wanted, this macro can be redefined locally. +% +% If the \meta{\textbackslash macro} existed before it will be overwritten silently. If an error should be raced instead use +% \Macro\newcommand{\textbackslash macro}{} just before the \Macro\verbdef. +% +% Note that this macro is also provided by the \pkg{verbdef} package. If that package is loaded as well it definition of this macro is used, +% independent on the order of loading the two packages. +% % % \DescribeMacro\Verbdef<\textbackslash macro><char><verbatim material><char> % \DescribeMacro\Verbdef*<\textbackslash macro><char><verbatim material><char> @@ -178,7 +228,12 @@ % \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. +% +% If the \meta{\textbackslash macro} existed before it will be overwritten silently. If an error should be raced instead use +% \Macro\newcommand{\textbackslash macro}{} just before the \Macro\Verbdef. +% +% Note that for maximum flexibility the such defined macros are not defined as robust macros. Therefore using them inside sectioning commands they should +% be protected using \Macro\protect to avoid syntax issues in the |.aux| file due to verbatim characters. % % % \section{Compatibility with other verbatim packages} @@ -221,17 +276,37 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\new@verbcommand}[4]{underlying definition macro}{macro to define}{code before}{code after} +% \begin{macro}{\new@verbcommand}[2]{underlying definition macro}{macro to be defined} +% Checks for optional argument and calls \cs{new@@verbcommand} accordingly. +% \begin{macrocode} +\def\new@verbcommand#1#2{% + \@ifnextchar[% + {\new@@verbcommand{#1}{#2}}% + {\new@@verbcommand{#1}{#2}[\verb]}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\new@verbcommand}[5]{underlying definition macro}{verb macro to be used}{macro to define}{code before}{code after} % The trailing code is inserted by patching \cs{verb@egroup} which is called by \cs{verb} % after the verbatim content. % \begin{macrocode} -\def\new@verbcommand#1#2#3#4{% +\let\newverbs@end\@empty +\def\new@@verbcommand#1#2[#3]#4#5{% #1*#2{% - \begingroup + \bgroup \newverbcommand@settings - \def\verb@egroup{\verb@orig@egroup#4\endgroup}% - \def\newverbs@txend{#4\endgroup}% - #3\verb + \ifx\newverbs@end\@empty + \expandafter\def\expandafter\verb@egroup\expandafter{\verb@egroup\newverbs@end}% + \fi + \begingroup\def\@tempa{#5}% + \expandafter\expandafter\expandafter\endgroup + \expandafter\expandafter\expandafter\def + \expandafter\expandafter\expandafter\newverbs@end + \expandafter\expandafter\expandafter{\expandafter\@tempa\newverbs@end\egroup}% + \def\newverbs@txend{#5\egroup}% + \verbatim@font\let\verbatim@font\relax + #4#3% }% } % \end{macrocode} @@ -306,11 +381,11 @@ % \changes{v1.1}{2010/04/13}{Added usage of 'csquotes' macros if loaded.} % \begin{macrocode} \@ifundefined{openinnerquote}{% - \def\qverbbeginquote{`}% - \def\qverbendquote{'}% + \def\qverbbeginquote{``}% + \def\qverbendquote{''}% }{% - \def\qverbbeginquote{\openinnerquote}% - \def\qverbendquote{\closeinnerquote}% + \def\qverbbeginquote{\openautoquote}% + \def\qverbendquote{\closeautoquote}% } % \end{macrocode} % \end{macro} @@ -328,20 +403,66 @@ % % \subsection{Make Special Short Verbatim Characters} % -% \begin{macro}{\MakeSpecialShortVerb}[1]{verbatim macro} -% Uses the definition of \cs{MakeShortVerb} from \pkg{shortvrb} except with \cs{verb} replaced with the first argument. -% The second argument is then read by \cs{@MakeShortVerb}. % \begin{macrocode} -\newcommand*\MakeSpecialShortVerb[1]{% +\RequirePackage{shortvrb} +% \end{macrocode} +% +% \begin{macro}{\MakeShortVerb} +% \begin{macrocode} +\def\MakeShortVerb{% \@ifstar - {\def\@shortvrbdef{#1*}\@MakeShortVerb}% - {\def\@shortvrbdef{#1}\@MakeShortVerb}% + {\newverbs@MakeShortVerb*}% + {\newverbs@MakeShortVerb{}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\newverbs@MakeShortVerb}[1]{star or empty} +% \begin{macrocode} +\def\newverbs@MakeShortVerb#1{% + \@ifnextchar[% + {\newverbs@@MakeShortVerb{#1}}% + {\@MakeSpecialShortVerb{#1}{\verb}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\newverbs@@MakeShortVerb}[2]{star or empty}{verbatim macro} +% \begin{macrocode} +\def\newverbs@@MakeShortVerb#1[#2]{% + \@MakeSpecialShortVerb{#1}{#2}% } % \end{macrocode} % \end{macro} % +% \begin{macro}{\@MakeSpecialShortVerb}[3]{star or empty}{verbatim macro}{escaped short verbatim character} +% Uses the definition of \cs{MakeShortVerb} from \pkg{shortvrb} except with \cs{verb} replaced with the first argument. +% The last argument is then read by \cs{@MakeShortVerb}. +% \begin{macrocode} +\def\@MakeSpecialShortVerb#1#2#3{% + %\expandafter\ifx\csname cc\string#3\endcsname\relax + %\else + % \DeleteShortVerb{#3}% + %\fi + \def\@shortvrbdef{#2#1}% + \@MakeShortVerb{#3}% +} +% \end{macrocode} +% \end{macro} % -% \subsection{Collect verbatim argument} +% \begin{macro}{\MakeSpecialShortVerb} +% Checks for the starred version and calls \cs{@MakeSpecialShortVerb} appropriately. The star needs to be added again +% as \cs{@ifstar} removes it. +% \begin{macrocode} +\newcommand*\MakeSpecialShortVerb{% + \@ifstar + {\@MakeSpecialShortVerb{*}}% + {\@MakeSpecialShortVerb{}}% +} +% \end{macrocode} +% \end{macro} +% +%% \subsection{Collect verbatim argument} % % \begin{macro}{\collectverb} % Collects verbatim text which can be typeset. @@ -485,7 +606,7 @@ % \end{macro} % % -% \begin{macro}{\@Collectverb} +% \begin{macro}{\@Collectverb}[1]{<code to be executed afterwards>} % \begin{macrocode} \def\@Collectverb#1{% \verb@eol@error @@ -498,7 +619,7 @@ % \end{macro} % % -% \begin{macro}{\@sCollectverb} +% \begin{macro}{\@sCollectverb}[1]{<code to be executed afterwards>} % \begin{macrocode} \def\@sCollectverb#1{% \verb@eol@error @@ -510,7 +631,7 @@ % \end{macro} % % -% \begin{macro}{\@@Collectverb} +% \begin{macro}{\@@Collectverb}[2]{<code to be executed afterwards>}{<delimiter character>} % \begin{macrocode} \def\@@Collectverb#1#2{% \ifnum`#2=`\{% @@ -546,7 +667,7 @@ % \end{macro} % % -% \begin{macro}{\@Collectverbenv} +% \begin{macro}{\@Collectverbenv}[1]{<code to be executed afterwards>} % \begin{macrocode} \def\@Collectverbenv#1{% \newverb@catcodes @@ -582,7 +703,7 @@ % \end{macro} % % -% \begin{macro}{\@sCollectverbenv} +% \begin{macro}{\@sCollectverbenv}[1]{<code to be executed afterwards>} % \begin{macrocode} \def\@sCollectverbenv#1{% \newverb@catcodes @@ -613,25 +734,6 @@ % \end{macro} % % -% \begin{macro}{\newverbenvironment} -% \begin{macrocode} -\newcommand\newverbenvironment{} -\long\def\newverbenvironment#1#2#{% - \@newverbenvironment{#1}{#2}% -} -\long\def\@newverbenvironment#1#2#3#4{% - \newenvironment{#1}#2{% - \begingroup - \newverb@catcodes - \obeyspaces - #3% - \expandafter\@@Collectverbenv\expandafter{\@currenvir}{\long\def\BODY}% - }{#4}% -} -% \end{macrocode} -% \end{macro} -% -% % \begin{macro}{\newverbsfont} % \begin{macrocode} \newcommand\newverbsfont{% @@ -653,14 +755,43 @@ % \end{macro} % % -% \begin{macro}{\@Verbdef} +% \begin{macro}{\@Verbdef}[2]{<star or empty>}{<macro to be defined>} % \begin{macrocode} -\newcommand*\@Verbdef[2]{% +\def\@Verbdef#1#2{% \Collectverb#1{\def#2}% } % \end{macrocode} % \end{macro} % +% \begin{macro}{\verbdef} +% Provides an own definition of \Macro\verbdef which is also defined by the \pkg{verbdef} package. +% \begin{macrocode} +\providecommand*\verbdef{% + \@ifstar + {\newverbs@verbdef*}% + {\newverbs@verbdef{}}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@Verbdef}[2]{<star or empty>}{<macro to be defined>} +% \begin{macrocode} +\def\newverbs@verbdef#1#2{% + \Collectverb#1{\newverbs@@verbdef{#2}}% +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@Verbdef}[2]{<star or empty>}{<macro to be defined>} +% \begin{macrocode} +\def\newverbs@@verbdef#1#2{% + \DeclareRobustCommand{#1}{{\newverbsfont#2}}% +} +% \end{macrocode} +% \end{macro} +% % \iffalse %</newverbs.sty> % \fi diff --git a/Master/texmf-dist/tex/latex/newverbs/newverbs.sty b/Master/texmf-dist/tex/latex/newverbs/newverbs.sty index d54c720b846..edb060136a6 100644 --- a/Master/texmf-dist/tex/latex/newverbs/newverbs.sty +++ b/Master/texmf-dist/tex/latex/newverbs/newverbs.sty @@ -20,7 +20,7 @@ %% original source files, as listed above, are part of the %% same distribution. (The sources need not necessarily be %% in the same archive or directory.) -%% Copyright (C) 2012 by Martin Scharrer <martin@scharrer-online.de> +%% Copyright (C) 2012-2019 by Martin Scharrer <martin@scharrer-online.de> %% -------------------------------------------------------------------- %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -37,19 +37,33 @@ %% This work consists of the files newverbs.dtx and newverbs.ins %% and the derived file newverbs.sty. \ProvidesPackage{newverbs}[% - 2012/05/08 - v1.3a + 2019/09/09 + v1.4 Define new 'verb' commands and short verb. characters] \newcommand*\newverbcommand{\new@verbcommand\newcommand} \newcommand*\renewverbcommand{\new@verbcommand\renewcommand} \newcommand*\provideverbcommand{\new@verbcommand\providecommand} -\def\new@verbcommand#1#2#3#4{% +\def\new@verbcommand#1#2{% + \@ifnextchar[% + {\new@@verbcommand{#1}{#2}}% + {\new@@verbcommand{#1}{#2}[\verb]}% +} +\let\newverbs@end\@empty +\def\new@@verbcommand#1#2[#3]#4#5{% #1*#2{% - \begingroup + \bgroup \newverbcommand@settings - \def\verb@egroup{\verb@orig@egroup#4\endgroup}% - \def\newverbs@txend{#4\endgroup}% - #3\verb + \ifx\newverbs@end\@empty + \expandafter\def\expandafter\verb@egroup\expandafter{\verb@egroup\newverbs@end}% + \fi + \begingroup\def\@tempa{#5}% + \expandafter\expandafter\expandafter\endgroup + \expandafter\expandafter\expandafter\def + \expandafter\expandafter\expandafter\newverbs@end + \expandafter\expandafter\expandafter{\expandafter\@tempa\newverbs@end\egroup}% + \def\newverbs@txend{#5\egroup}% + \verbatim@font\let\verbatim@font\relax + #4#3% }% } \def\newverbs@tabularxsupport{% @@ -84,20 +98,43 @@ } \provideverbcommand{\qverb}{\qverbbeginquote}{\qverbendquote} \@ifundefined{openinnerquote}{% - \def\qverbbeginquote{`}% - \def\qverbendquote{'}% + \def\qverbbeginquote{``}% + \def\qverbendquote{''}% }{% - \def\qverbbeginquote{\openinnerquote}% - \def\qverbendquote{\closeinnerquote}% + \def\qverbbeginquote{\openautoquote}% + \def\qverbendquote{\closeautoquote}% } \newverbcommand{\fverb} {\setbox\verbbox\hbox\bgroup\color@setgroup} {\color@endgroup\egroup\fbox{\box\verbbox}} -\newcommand*\MakeSpecialShortVerb[1]{% +\RequirePackage{shortvrb} +\def\MakeShortVerb{% \@ifstar - {\def\@shortvrbdef{#1*}\@MakeShortVerb}% - {\def\@shortvrbdef{#1}\@MakeShortVerb}% + {\newverbs@MakeShortVerb*}% + {\newverbs@MakeShortVerb{}}% +} +\def\newverbs@MakeShortVerb#1{% + \@ifnextchar[% + {\newverbs@@MakeShortVerb{#1}}% + {\@MakeSpecialShortVerb{#1}{\verb}}% } +\def\newverbs@@MakeShortVerb#1[#2]{% + \@MakeSpecialShortVerb{#1}{#2}% +} +\def\@MakeSpecialShortVerb#1#2#3{% + %\expandafter\ifx\csname cc\string#3\endcsname\relax + %\else + % \DeleteShortVerb{#3}% + %\fi + \def\@shortvrbdef{#2#1}% + \@MakeShortVerb{#3}% +} +\newcommand*\MakeSpecialShortVerb{% + \@ifstar + {\@MakeSpecialShortVerb{*}}% + {\@MakeSpecialShortVerb{}}% +} +%% \subsection{Collect verbatim argument} \newcommand*\collectverb{% \begingroup \verbatim@font @@ -246,19 +283,6 @@ )% |gdef|misj(|def^^M(^^J))% |endgroup% -\newcommand\newverbenvironment{} -\long\def\newverbenvironment#1#2#{% - \@newverbenvironment{#1}{#2}% -} -\long\def\@newverbenvironment#1#2#3#4{% - \newenvironment{#1}#2{% - \begingroup - \newverb@catcodes - \obeyspaces - #3% - \expandafter\@@Collectverbenv\expandafter{\@currenvir}{\long\def\BODY}% - }{#4}% -} \newcommand\newverbsfont{% \verbatim@font \frenchspacing @@ -268,9 +292,20 @@ {\@Verbdef*}% {\@Verbdef{}}% } -\newcommand*\@Verbdef[2]{% +\def\@Verbdef#1#2{% \Collectverb#1{\def#2}% } +\providecommand*\verbdef{% + \@ifstar + {\newverbs@verbdef*}% + {\newverbs@verbdef{}}% +} +\def\newverbs@verbdef#1#2{% + \Collectverb#1{\newverbs@@verbdef{#2}}% +} +\def\newverbs@@verbdef#1#2{% + \DeclareRobustCommand{#1}{{\newverbsfont#2}}% +} \endinput %% %% End of file `newverbs.sty'. |