summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/listings/listings.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/listings/listings.dtx')
-rw-r--r--macros/latex/contrib/listings/listings.dtx351
1 files changed, 223 insertions, 128 deletions
diff --git a/macros/latex/contrib/listings/listings.dtx b/macros/latex/contrib/listings/listings.dtx
index 06f881726b..bd1e84342b 100644
--- a/macros/latex/contrib/listings/listings.dtx
+++ b/macros/latex/contrib/listings/listings.dtx
@@ -46,6 +46,7 @@
\usepackage{mdframed} % frames for external files
\usepackage{moreverb} % writing external files
\usepackage{xcolor} % because of coloring the background
+\usepackage{tablefootnote} % because of \tablefootnote
\makeindex
@@ -135,7 +136,7 @@
% Hoffmann became the maintainer of the \packagename{listings}
% package in 2013; see the Preface for details.}~ %
% \textless\lstemail\textgreater}
-% \date{2024/03/11\enspace\enspace Version 1.10a\ \box\abstractbox}
+% \date{2024/09/23\enspace\enspace Version 1.10c\ \box\abstractbox}
% \def\lstemail{\href{mailto:j.hoffmann@fh-aachen.de}{\texttt{j.hoffmann(at)fh-aachen.de}}}
% \ifhyper
% \hypersetup{pdftitle=The Listings Package,
@@ -2723,7 +2724,7 @@
% \texttt{last} continues the numbering of the most recent listing and
% \meta{number} sets it to the (logical) number.
%
-% \item[1.0] \rkeyname{name}|=|\meta{name}
+% \item[1.0,{{}}] \rkeyname{name}|=|\meta{name}
%
% names a listing. Displayed environment-listings with the same name
% share a line counter if |firstnumber=auto| is in effect.
@@ -3561,15 +3562,18 @@
% other & \texttt{!\ " \#\ \%\ \&\ ' ( ) * + , - .\ / :\ ; < = > ?}\\
% & {\catcode`\|=12\texttt{[ \char92\ ] \textasciicircum\ \char123\
% | \char125\ \textasciitilde}}\\
-% space & chr(32)\\
-% tabulator & chr(9)\\
-% form feed & chr(12)\\
+% space & \texttt{chr(32)}\footnotemark{}\\
+% tabulator & \texttt{chr(9)}\\
+% form feed & \texttt{chr(12)}\\
% \noalign{\smallskip}
% \end{tabular}
% \par\noindent
% Note: Extended characters of codes 128--255 (if defined) are \emph{currently}
% letters.
% \end{table}
+% \footnotetext{Here and at other places |chr(|\meta{number}|)| means a
+% Pascal function which returns the character which has ASCII value
+% \meta{number}.}
%
%
% \paragraph{Strings}\label{uStrings}
@@ -4197,20 +4201,25 @@
%
% \subsection{Listings inside arguments}\label{uListingsArguments}
%
-% At the moment it isn't possible to use \verb-\lstinline{...}- in a cell
+% A long time it wasn't possible to use \verb-\lstinline{...}- in a cell
% of a table\makeatletter\@ifundefined{r@uProcessingInline}{}{%
% (see section \ref{uProcessingInline} on page \pageref{uProcessingInline}
% for more information)},%
% \makeatother%
-% but it is possible to define a wrapper macro
-% which can be used instead of \verb-\lstinline{...}-:
+% but there was a recommended workaround. This workaround is still
+% functional, but now one can use \verb-\lstinline{...}- and of course
+% \verb-\lstinline|...|- directly:
% \begin{lstsample}[lstlisting]{}{}
% \newcommand\foo{\lstinline{t}}
% \newcommand\foobar[2][]{\lstinline[#1]{#2}}
%
% \begin{tabular}{ll}
-% \foo & a variable\\
-% \foobar[language=java]{int u;} & a declaration
+% \lstinline|r| & a first variable (standard)\\
+% \lstinline[language=java]|int s;| & a standard declaration \\
+% \foo & a second variable (workaround)\\
+% \foobar[language=java]{int u;} & a (workaraond) declaration \\
+% \lstinline{v} & another variable using braces\\
+% \lstinline[language=java]{int w;} & an additional braced declaration
% \end{tabular}
% \end{lstsample}
%
@@ -4817,22 +4826,29 @@
% Usually you will use |#1| as \meta{value}.
%
% \item[1.0] \cs{lstKV@SwitchCases}\marg{value}\\
-% |{|\meta{string 1}|&|\meta{execute 1}|\\|\\
-% | |\meta{string 2}|&|\meta{execute 2}|\\|\\
+% |{|\meta{string 1}|:|\meta{execute 1}|\\|\\
+% | |\meta{string 2}|:|\meta{execute 2}|\\|\\
% \hbox to 3em{\hfill\vdots}\\
-% | |\meta{string $n$}|&|\meta{execute $n$}|}|\marg{else}
+% | |\meta{string $n$}|;|\meta{execute $n$}|}|\marg{else}
%
% Either execute \meta{else} or the \meta{value} matching part.
%
-% This implementation of C. Heinz has a problem\label{gAmpersand}, if
-% the listing is part of a tabular environment as found out by
-% \lsthelper{Nasser~M.~Abbasi}{2016/05/25}{possible bug in listings
-% package}. \lsthelper{David~Carlisle}{2016/05/25}{%
+% This implementation is based on a hint of \lsthelper{David~Carlisle}{2016/05/25}{%
% http://tex.stackexchange.com/questions/311383/^^A
% adding-frame-none-to-lstlisting-options-in-lstdefinestyle^^A
-% -gives-error-with-tabu}
-% gave a hint how to avoid this problem and so the separator |&| is
-% replaced by |:|.
+% -gives-error-with-tabu} to avoid the problem of the original
+% implementation of C. Heinz\label{gAmpersand}:
+% \begin{quote}
+% \cs{lstKV@SwitchCases}\marg{value}\\
+% |{|\meta{string 1}|&|\meta{execute 1}|\\|\\
+% | |\meta{string 2}|&|\meta{execute 2}|\\|\\
+% \hbox to 3em{\hfill\vdots}\\
+% | |\meta{string $n$}|&|\meta{execute $n$}|}|\marg{else}
+% \end{quote}
+% The problem arose when the listing was part of a tabular
+% environment, as found out by
+% \lsthelper{Nasser~M.~Abbasi}{2016/05/25}{possible bug in listings
+% package}.
%
% \item[0.20] |\lstKV@TwoArg|\marg{value}\marg{subdefinition}
% \item[0.20] |\lstKV@ThreeArg|\marg{value}\marg{subdefinition}
@@ -4959,8 +4975,13 @@
% \lsttabspace |\lst@KCSmode| &
% \ldots~a keyword comment which can be terminated by a semicolon only.
% \\
-% \aspectname{html}\lsttabspace |\lst@insidemode| &
+% \aspectname{html}\lsttabspace |\lst@htmlmode| &
% Active if we are between \texttt{<} and \texttt{>}.
+%
+% Previous documentations used the mode name |\lst@insidemode| at this
+% place, but the name |\lst@insidemode| isn't referenced in any documentation
+% and so it is now (from v1.10c on) assumed as an overseen
+% documentation error.
% \\
% \aspectname{make}\lsttabspace |\lst@makemode| &
% Used to indicate a keyword.
@@ -5744,7 +5765,7 @@
% \item |\lst@Init\relax|
% \item |\lst@Def{`#1}{\lst@DeInit\egroup}| installs the `end inline'
% detection, where |#1| is the next character after |\lstinline|.
-% Moreover chr(13) is redefined to end the fragment in the same way but
+% Moreover |chr(13)| is redefined to end the fragment in the same way but
% also issues an error message.
% \item Now comes the source code and \ldots
% \item \ldots\ |\lst@DeInit| (from |\lst@Def| above) ends the code snippet
@@ -5978,7 +5999,7 @@
% \part{Implementation}
%
%
-% \CheckSum{12409}
+% \CheckSum{12443}
%^^A
%^^A Don't index TeX-primitives.
%^^A
@@ -6122,8 +6143,8 @@
% All files will have same date and version.
% \begin{macrocode}
%<*kernel|misc|doc>
-\def\filedate{2024/03/11}
-\def\fileversion{1.10a}
+\def\filedate{2024/09/23}
+\def\fileversion{1.10c}
%</kernel|misc|doc>
% \end{macrocode}
% What we need and who we are.
@@ -6662,11 +6683,11 @@
\ifx#1\relax
\else \lccode`\^^@=`#1%
% \end{macrocode}
-% Otherwise we say that |^^@|=chr(0) is the lower case version of the first
+% Otherwise we say that |^^@|=|chr(0)| is the lower case version of the first
% character.
% Then we test the second character.
% If there is none, we append the lower case |^^@| to |\lst@temp|.
-% Otherwise we say that |^^A|=chr(1) is the lower case version of the second
+% Otherwise we say that |^^A|=|chr(1)| is the lower case version of the second
% character and we test the next argument, and so on.
% \begin{macrocode}
\ifx#2\relax
@@ -6703,7 +6724,7 @@
\lst@next}
\endgroup
% \end{macrocode}
-% This |\endgroup| restores the catcodes of chr(0)--chr(8), but not the
+% This |\endgroup| restores the catcodes of |chr(0)|--|chr(8)|, but not the
% catcodes of the characters inside |\lst@MakeActive@| since they are already
% read.
%
@@ -8910,9 +8931,16 @@
% \begin{macrocode}
\def\lst@UM#1{\csname\@lst @um#1@\endcsname}
% \end{macrocode}
-% And all remaining standard characters.
+% And all remaining standard characters. \lsthelper{Peter
+% Cock}{2024/09/18}{Upright double-quotes in LaTeX listings}
+% pointed to the discussion in
+% \url{https://tex.stackexchange.com/questions/166790/how-can-i-get-straight-double-quotes-in-listings}
+% about the lack of support for upright double quotes which are now
+% implemented by the lines below.
% \begin{macrocode}
\lst@CCPutMacro
+ \lst@ProcessOther {"22}{\lst@ifupquote \textquotedbl
+ \else \char34\relax \fi}
\lst@ProcessOther {"23}\#
\lst@ProcessLetter{"24}\textdollar
\lst@ProcessOther {"25}\%
@@ -12646,7 +12674,9 @@
% \subsection{Line numbers}
%
% \begin{aspect}{labels}
-% \lsthelper{Rolf~Niepraschk}{1997/04/24}{line numbers} asked for line numbers.
+% \lsthelper{Rolf~Niepraschk}{1997/04/24}{line numbers} asked for line
+% number, the relevant keys and `\textit{data}' commands are described in
+% section \ref{rLineNumbers}, here is their implementation.
% \begin{macrocode}
%<*misc>
\lst@BeginAspect{labels}
@@ -12665,26 +12695,31 @@
right:\def\lst@PlaceNumber{\rlap{\normalfont
\kern\linewidth \kern\lst@numbersep
\lst@numberstyle{\thelstnumber}}}%
- }{\PackageError{Listings}{Numbers #1 unknown}\@ehc}}
+ }{\PackageError{Listings}{value `#1' for keyword `numbers' not supported}\@ehc}}
% \end{macrocode}
% \end{lstkey}
%
+% \begin{lstkey}{stepnumber}
+% \begin{lstkey}{numberfirstline}
% \begin{lstkey}{numberstyle}
% \begin{lstkey}{numbersep}
-% \begin{lstkey}{stepnumber}
% \begin{lstkey}{numberblanklines}
-% \begin{lstkey}{numberfirstline}
% Definition of the keys.
% \begin{macrocode}
+\lst@Key{stepnumber}{1}{\def\lst@stepnumber{#1\relax}}
+\lst@Key{numberfirstline}{f}[t]{\lstKV@SetIf{#1}\lst@ifnumberfirstline}
\lst@Key{numberstyle}{}{\def\lst@numberstyle{#1}}
\lst@Key{numbersep}{10pt}{\def\lst@numbersep{#1}}
-\lst@Key{stepnumber}{1}{\def\lst@stepnumber{#1\relax}}
+\lst@Key{numberblanklines}{true}[t]
+ {\lstKV@SetIf{#1}\lst@ifnumberblanklines}
+% \end{macrocode}
+% If we use the `empty' style, the listing must start at line 1, so:
+% \begin{macrocode}
\lst@AddToHook{EmptyStyle}{\let\lst@stepnumber\@ne}
% \end{macrocode}
+% Later on we use this to prevent numbering of the first line for a second
+% time.
% \begin{macrocode}
-\lst@Key{numberblanklines}{true}[t]
- {\lstKV@SetIf{#1}\lst@ifnumberblanklines}
-\lst@Key{numberfirstline}{f}[t]{\lstKV@SetIf{#1}\lst@ifnumberfirstline}
\gdef\lst@numberfirstlinefalse{\let\lst@ifnumberfirstline\iffalse}
% \end{macrocode}
% \end{lstkey}
@@ -12713,6 +12748,9 @@
% \end{macrocode}
% \end{lstkey}
%
+% The key |name| is defined in section \ref{sec:list-listings}, the data
+% command |\thelstnumber| below on page \pageref{iTheLstNumber}.
+%
% \begin{macro}{\lst@SetFirstNumber}
% \begin{macro}{\lst@SaveFirstNumber}
% \lsthelper{Boris~Veytsman}{1998/03/25}{continue line numbering: a.c b.c a.c}
@@ -12741,7 +12779,9 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}{\thelstnumber}
% \begin{macro}{\c@lstnumber}
+% \label{iTheLstNumber}%
% This counter keeps the current label number. We use it as current label to
% make line numbers referenced by |\ref|. This was proposed by
% \lsthelper{Boris~Veytsman}{1998/03/25}{make line numbers referenced via
@@ -12797,6 +12837,7 @@
.\thelstnumber}}
% \end{macrocode}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\lst@skipnumbers}
% There are more things to do. We calculate how many lines must skip their
@@ -13871,12 +13912,21 @@
% \end{macrocode}
% Further parsing is done by |lst@GLI@|, the argument is |#1--\@nil| that
% is the first element of the list augmented by a sentinel. This
-% argument is parsed with the template |#1-#2-#3\@nil|. A linerange given
-% as e.\,g. `|12-21|' leads to the argument |12-21--\@nil|, so it is parsed
-% as \#1\(\leftarrow\) |12|, \#2\(\leftarrow\)|21|, and \#3\(\leftarrow\)|-|.
+% argument is parsed with the template |#1-#2-#3\@nil|.
+%
% \begin{macrocode}
\def\lst@GLI@#1-#2-#3\@nil{%
% \end{macrocode}
+% A linerange given as e.\,g. `|12-21|' leads to the argument
+% |12-21--\@nil|, so it is parsed as \#1\(\leftarrow\) |12|,
+% \#2\(\leftarrow\)|21|, and \#3\(\leftarrow\)|-|.
+%
+% Otherwise it is possible to define a range by arbitrary linerange markers
+% like `|start-end|' which leads to the argument
+% |12-21--\@nil|, so it is parsed as \#1\(\leftarrow\) |12|,
+% \#2\(\leftarrow\)|21|, and \#3\(\leftarrow\)|-|.
+
+
% First we test, if the linerange starts with a number (consisting of -, 1,
% 2, 3, \ldots) or an arbitrary linerange marker. If a linerange starts
% erroneously with a `|-|' character, the argument \#1 isn't set and so the
@@ -13889,23 +13939,23 @@
\ifx\@empty#1\@empty
\let\lst@firstline\@ne
\else
- \def\lst@firstline{#1\relax}%
+ \def\lst@firstline{#1\relax}
\fi
% \end{macrocode}
% Now we know the starting number of the linerange. \#3 isn't set with a
% linerange consisting of a single number, in all other cases \#2 defines
% the last line (explicitly or implicitly).
% \begin{macrocode}
- \ifx\@empty#3\@empty%
- \def\lst@lastline{9999999\relax}%
+ \ifx\@empty#3\@empty
+ \def\lst@lastline{9999999\relax}
\ifx\@empty#2\@empty
- \let\lst@lastline\lst@firstline%
+ \let\lst@lastline\lst@firstline
\fi
\else%
\ifx\@empty#2\@empty
\def\lst@lastline{9999999\relax}
\else % doesn't happen(?)
- \def\lst@lastline{#2\relax}%
+ \def\lst@lastline{#2\relax}
\fi
\fi
}%
@@ -13914,7 +13964,7 @@
% 9999999. This prevents (almost) anything from being printed for now.
% \begin{macrocode}
{%
- \def\lst@firstline{9999999\relax}%
+ \def\lst@firstline{9999999\relax}
\let\lst@lastline\lst@firstline
% \end{macrocode}
% We add the prefixes and suffixes to the markers.
@@ -14009,10 +14059,10 @@
\ifnum\@tempcnta=\z@ \else
\lst@nololtrue
\advance\@tempcnta\lst@advancenumber
- \edef\lst@firstnumber{\the\@tempcnta\relax}%
- \fi%
- \fi%
- }%
+ \edef\lst@firstnumber{\the\@tempcnta\relax}
+ \fi
+ \fi
+ }
}
\def\lst@InitLstNumber{%
\global\c@lstnumber\lst@firstnumber
@@ -14358,7 +14408,8 @@
% \begin{macro}{\lst@HRefStepCounter}
% This macro sets the listing number to a negative value since the user
% shouldn't refer to such a listing. If the \packagename{hyperref} package
-% is present, we use `lstlisting' (argument from above) to hyperref to.
+% is present, we use `lstlisting.' (argument from above) concatenated with
+% the current (negative) number to hyperref to.
% The groups have been added to prevent other packages (namely
% \packagename{tabularx}) from reading the locally changed counter
% and writing it back globally. Thanks to \lsthelper{Michael~Niedermair}
@@ -14366,14 +14417,17 @@
% this localization led to another bug, see |\theHlstnumber|.
% \begin{macrocode}
\def\lst@HRefStepCounter#1{%
- \begingroup
- \c@lstlisting\lst@neglisting
- \advance\c@lstlisting\m@ne \xdef\lst@neglisting{\the\c@lstlisting}%
- \ifx\hyper@refstepcounter\@undefined\else
- \hyper@refstepcounter{#1}%
- \fi
- \endgroup}
-\gdef\lst@neglisting{\z@}% init
+ \begingroup
+ \c@lstlisting\lst@neglisting
+ \advance\c@lstlisting\m@ne \xdef\lst@neglisting{\the\c@lstlisting}%
+ \ifx\hyper@refstepcounter\@undefined\else
+ \hyper@refstepcounter{#1}%
+ \fi
+ \endgroup
+}
+\gdef\lst@neglisting{\z@}% init, \z@ can be used both for 0pt and 0,
+ % remember: _neg_ative number, but no
+ % counter!
% \end{macrocode}
% \end{macro}
%
@@ -14552,7 +14606,7 @@
\fi
\lsthk@InitVars \lsthk@InitVarsBOL
% \end{macrocode}
-% The end of line character chr(13)=|^^M| controls the processing, see the
+% The end of line character |chr(13)|=|^^M| controls the processing, see the
% definition of |\lst@MProcessListing| below.
% The argument |#1| is either |\relax| or |\lstenv@backslash|.
% \begin{macrocode}
@@ -14768,7 +14822,8 @@
% \end{macro}
%
%
-% \subsection{List of listings}
+% \subsection{List of listings}%
+% \label{sec:list-listings}
%
% \begin{lstkey}{name}
% \begin{macro}{\lstname}
@@ -14904,36 +14959,35 @@
% \subsubsection{Processing inline listings}\label{uProcessingInline}
%
% \begin{macro}{\lstinline}
-% In addition to |\lsthk@PreSet|, we use |boxpos=b| and flexiblecolumns.
-% I've inserted |\leavevmode| after bug report from \lsthelper{Michael~Weber}
-% {1999/12/16}{wrong spacing in list environments}. \lsthelper{Olivier~Lecarme}
-% {2001/07/30}{inconsistent `break' when \lstinline is used inside caption}
-% reported a problem which has gone after removing |\let| |\lst@newlines|
-% |\@empty| (now |\lst@newlines| is a counter!). Unfortunately I don't know
-% the reason for inserting this code some time ago! At the end of the macro we
-% check the delimiter.
-% \begin{macrocode}
-\newcommand\lstinline[1][]{%
- \leavevmode\bgroup % \hbox\bgroup --> \bgroup
- \def\lst@boxpos{b}%
- \lsthk@PreSet\lstset{flexiblecolumns,#1}%
- \lsthk@TextStyle
- \@ifnextchar\bgroup{%
-% \end{macrocode}
-% \lsthelper{Luc~Van~Eycken}{2014/01/22}{\rcmdname\lstinline{} in alignments}
-% reported, that the experimental implementation of |\lstinline| with
-% braces instead of characters surrounding the source code resulted in an
-% error if used in a tabular environment. He found that this error comes
-% from the master counter (cf. appendix D (Dirty Tricks), item 5. (Brace
-% hacks), of the TeXbook (p. 385-386)). Adding the following line at this
-% point
+% In addition to |\lsthk@PreSet|, we use |boxpos=b| and
+% flexiblecolumns. I've inserted |\leavevmode| after bug report from
+% \lsthelper{Michael~Weber} {1999/12/16}{wrong spacing in list
+% environments}. \lsthelper{Olivier~Lecarme} {2001/07/30}{inconsistent
+% `break' when \lstinline is used inside caption} reported a problem
+% which has gone after removing |\let| |\lst@newlines| |\@empty| (now
+% |\lst@newlines| is a counter!). Unfortunately I don't know the reason
+% for inserting this code some time ago! At the end of the macro we
+% check the delimiter.\footnote{This is text of the original author
+% Carsten Heinz.}
+%
+% Then came an experimental version which allowed braces, but
+% \lsthelper{Luc~Van~Eycken}{2014/01/22}{\rcmdname\lstinline{} in
+% alignments} reported, that the experimental implementation of
+% |\lstinline| with braces instead of characters surrounding the source
+% code resulted in an error if used in a tabular environment.
+%
+% He found that this error comes from the master counter (cf. appendix
+% D (Dirty Tricks), item 5. (Brace hacks), of the TeXbook
+% (p. 385-386)). Adding the following line after testing the next
+% character (line no. 7 in the following outcommented snippet)
%\begin{verbatim}
-% \ifnum`{=0}\fi%
+%\ifnum`{=0}\fi%
%\end{verbatim}
-% remedies the wrong behaviour. But \lsthelper{Qing~Lee}{2014/06/28}{-}
-% pointed out, that this breaks code like the one showed in
-% \ref{uListingsArguments} on \pageref{uListingsArguments} and proposed
-% another solution which in turn broke the code needed by Luc:
+% remedies the wrong behaviour. But \lsthelper{Qing~Lee}{2014/06/28}{-}
+% pointed out, that this breaks code like the one shown in section
+% \ref{uListingsArguments} on page \pageref{uListingsArguments} and
+% proposed another solution which in turn broke the code provided by
+% Luc:
%\begin{verbatim}
% \renewcommand\lstinline[1][]{%
% \leavevmode\bgroup % \hbox\bgroup --> \bgroup
@@ -14944,20 +14998,45 @@
% \@ifnextchar\bgroup{%
% \ifnum`{=\z@}\fi%
% \afterassignment\lst@InlineG \let\@let@token}{%
-% \ifnum`{=\z@}\fi\lstinline@}}
+% \ifnum`{=\z@}\fi\lstinline@}%
+%}
%\end{verbatim}
-% So finally the old code comes back and the people, who need a
-% |\lstinline| with braces, should use the workaround from section
-% \ref{uListingsArguments} on page \pageref{uListingsArguments}.
+% So finally the old code came back and the people, who needed a
+% |\lstinline| with braces, should use the workaround from section
+% \ref{uListingsArguments} on page \pageref{uListingsArguments}.
+%
+% This long outstanding deficiency is now repaired by
+% \lsthelper{user5028841}{2024/05/05}{Regarding the Listings package}
+% who provided a solution by using special characters as begin and end
+% of a group:
+% \begin{macrocode}
+\edef\lst@temp{\the\catcode`\^^@}
+\catcode`\^^@=1
+\newcommand\lstinline[1][]{%
+ \leavevmode\bgroup % \hbox\bgroup --> \bgroup
+ \def\lst@boxpos{b}%
+ \lsthk@PreSet\lstset{flexiblecolumns,#1}%
+ \lsthk@TextStyle
+ \@ifnextchar\bgroup{%
+ \afterassignment\lst@InlineG \romannumeral`^^@\iffalse}\fi
+ \let\@let@token}%
+ \lstinline@}
+% \end{macrocode}
+% Here we restore the previous catcode of |\^^@|:
+% \begin{macrocode}
+\catcode`\^^@=\lst@temp
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\lst@inline@}
+% This is the standard method after processing the optional arguments
+% of |\lstinline|.
% \begin{macrocode}
- \afterassignment\lst@InlineG \let\@let@token}%
- \lstinline@}
\def\lstinline@#1{%
- \lst@Init\relax
- \lst@IfNextCharActive{\lst@InlineM#1}{\lst@InlineJ#1}}
-\lst@AddToHook{TextStyle}{}% init
+ \lst@Init\relax
+ \lst@IfNextCharActive{\lst@InlineM#1}{\lst@InlineJ#1}}
% \end{macrocode}
% \begin{macrocode}
+\lst@AddToHook{TextStyle}{}% init
\lst@AddToHook{SelectCharTable}{\lst@inlinechars}
\global\let\lst@inlinechars\@empty
% \end{macrocode}
@@ -14965,56 +15044,68 @@
%
% \begin{macro}{\lst@InlineM}
% \begin{macro}{\lst@InlineJ}
-% treat the cases of `normal' inlines and inline listings inside an argument.
-% In the first case the given character ends the inline listing and EOL within
-% such a listing immediately ends it and produces an error message.
+% treat the cases of `normal' inlines and inline listings inside an
+% argument. In the first case the given character ends the inline
+% listing and EOL within such a listing immediately ends it and
+% produces an error message.
% \begin{macrocode}
-\def\lst@InlineM#1{\gdef\lst@inlinechars{%
+\def\lst@InlineM#1{%
+ \gdef\lst@inlinechars{%
\lst@Def{`#1}{\lst@DeInit\egroup\global\let\lst@inlinechars\@empty}%
\lst@Def{13}{\lst@DeInit\egroup \global\let\lst@inlinechars\@empty
- \PackageError{Listings}{lstinline ended by EOL}\@ehc}}%
- \lst@inlinechars}
+ \PackageError{Listings}{lstinline ended by EOL}\@ehc}}%
+ \lst@inlinechars}
% \end{macrocode}
% In the other case we get all characters up to |#1|, make these characters
% active, execute (typeset) them and end the listing (all via temporary macro).
% That's all about it.
% \begin{macrocode}
\def\lst@InlineJ#1{%
- \def\lst@temp##1#1{%
- \let\lst@arg\@empty \lst@InsideConvert{##1}\lst@arg
- \lst@DeInit\egroup}%
- \lst@temp}
+ \def\lst@temp##1#1{%
+ \let\lst@arg\@empty \lst@InsideConvert{##1}\lst@arg
+ \lst@DeInit\egroup}%
+ \lst@temp}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\lst@InlineG}
-% is experimental.
+% is experimental.
% \begin{macrocode}
\def\lst@InlineG{%
- \lst@Init\relax
- \lst@IfNextCharActive{\lst@InlineM\}}%
- {\let\lst@arg\@empty \lst@InlineGJ}}
+ \lst@Init\relax
+ \lst@IfNextCharActive{\lst@InlineM\}}{%
+ \let\lst@arg\@empty \lst@InlineGJ}}
+% \end{macrocode}
+% This is the point for closing the group:
+% \begin{macrocode}
+\edef\lst@temp{\the\catcode`\^^@}
+\catcode`\^^@=2
\def\lst@InlineGJ{\futurelet\@let@token\lst@InlineGJTest}
\def\lst@InlineGJTest{%
- \ifx\@let@token\egroup
- \afterassignment\lst@InlineGJEnd
- \expandafter\let\expandafter\@let@token
+ \ifx\@let@token\egroup
+ \iffalse{\fi\romannumeral`^^@
+ \afterassignment\lst@InlineGJEnd
+ \expandafter\let\expandafter\@let@token
+ \else
+ \ifx\@let@token\@sptoken
+ \let\lst@next\lst@InlineGJReadSp
\else
- \ifx\@let@token\@sptoken
- \let\lst@next\lst@InlineGJReadSp
- \else
- \let\lst@next\lst@InlineGJRead
- \fi
- \expandafter\lst@next
+ \let\lst@next\lst@InlineGJRead
+ \fi
+ \expandafter\lst@next
\fi}
+% \end{macrocode}
+% As before: restore the previous catcode of |\^^@|:
+% \begin{macrocode}
+\catcode`\^^@=\lst@temp
\def\lst@InlineGJEnd{\lst@arg\lst@DeInit\egroup}
\def\lst@InlineGJRead#1{%
- \lccode`\~=`#1\lowercase{\lst@lAddTo\lst@arg~}%
- \lst@InlineGJ}
+ \lccode`\~=`#1\lowercase{\lst@lAddTo\lst@arg~}%
+ \lst@InlineGJ}
\def\lst@InlineGJReadSp#1{%
- \lccode`\~=`\ \lowercase{\lst@lAddTo\lst@arg~}%
- \lst@InlineGJ#1}
+ \lccode`\~=`\ \lowercase{\lst@lAddTo\lst@arg~}%
+ \lst@InlineGJ#1}
% \end{macrocode}
% \end{macro}
%
@@ -15313,7 +15404,7 @@
%
% \begin{macro}{\lst@MSkipToFirst}
% We just look whether to drop more lines or to leave the mode which restores
-% the definition of chr(13) and chr(10).
+% the definition of |chr(13)| and |chr(10)|.
% \begin{macrocode}
\def\lst@MSkipToFirst{%
\global\advance\lst@lineno\@ne
@@ -15391,7 +15482,7 @@
% \end{macrocode}
% We must append an active backslash and the `end string' to |\lst@arg|. So all
% (in fact most) other processing won't notice that the code has been inside
-% an argument. But the EOL character is chr(10)=|^^J| now and not chr(13).
+% an argument. But the EOL character is |chr(10)|=|^^J| now and not |chr(13)|.
% \begin{macrocode}
\begingroup \lccode`\~=`\\\lowercase{%
\gdef\lstenv@ProcessJ@{%
@@ -15737,7 +15828,7 @@
\ifalgorithmicpkg \RequirePackage{algorithmic}\fi
\iflgrind \RequirePackage{lgrind}\fi
\RequirePackage{nameref}
-\RequirePackage{url}
+\RequirePackage{xurl} % allow URL breaks
\renewcommand\ref{\protect\T@ref}
\renewcommand\pageref{\protect\T@pageref}
% \end{macrocode}
@@ -17292,6 +17383,10 @@
% \item[1.10] from 2024/02/15 on
% \item usage of |tocbasic| if loaded to improve compatibility with
% KOMA-Script and also enhance functionality.
+% \item differentiate between Python 2 and Python 3
+% \item add initial support for Scala 3.0
+% \item made |\lstinline{...}| work in tabular cells
+% \item implemented upright double-quotes
% \end{itemize}
% \endgroup
%