% \iffalse meta-comment
%
% Copyright (C) 2013-2024 by Geoffrey M. Poore <gpoore@gmail.com>
% Copyright (C) 2010-2011 by Konrad Rudolph <konrad_rudolph@madrat.net>
% --------------------------------------------------------------------------
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%   https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008/05/04 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Geoffrey M. Poore.
%
% This work consists of the files minted.dtx and minted.ins
% and the derived file minted.sty.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{minted.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{minted}
%<*package>
    [2024/09/22 v3.0.0 Yet another Pygments shim for LaTeX]
%</package>
%<*driver>
\documentclass{ltxdoc}
\DisableCrossrefs
^^A\EnableCrossrefs
^^A\CodelineIndex
^^A\RecordChanges
^^A\OnlyDescription
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{fourier}
\usepackage{dingbat}
\usepackage{microtype}

\usepackage[svgnames]{xcolor}
\usepackage{graphicx}
\usepackage[lexerlinenos, highlightmode=immediate]{minted}
\setminted{literatecomment=\%, autogobble}

\usepackage{calc}
\usepackage{multicol}
\usepackage[hyperindex]{hyperref}
\usepackage{cleveref}

\newcommand{\env}[1]{\texttt{#1}}

\makeatletter
% The typesetting for macrocode doesn't use \@noligs, which upquote modifies.
% So apply the upquote fix to \verbatim@nolig@list as well, which is in macrocode.
\begingroup
\catcode`'=\active
\catcode``=\active
\g@addto@macro\verbatim@nolig@list{%
  \let'\textquotesingle
  \let`\textasciigrave
  \ifx\encodingdefault\upquote@OTone
  \ifx\ttdefault\upquote@cmtt
    \def'{\char13 }%
    \def`{\char18 }%
  \fi\fi}
\endgroup

% Create a short verbatim pipe that handles quotation marks properly
\begingroup
\catcode`\|=\active
\gdef\pipe@active@verbatim{%
  \begingroup
  \let\do\@makeother\dospecials
  \catcode`\|=\active
  \catcode`\`=\active
  \catcode`\'=\active
  \catcode`\<=\active
  \catcode`\>=\active
  \catcode`\-=\active
  \catcode`\,=\active
  \catcode`\ =\active
  \pipe@active@verbatim@i}
\gdef\pipe@active@verbatim@i#1|{%
  \endgroup
  \begingroup
  \def\FV@SV@pipe@active@verbatim{%
    \FV@Gobble
    \expandafter\FV@ProcessLine\expandafter{#1}}%
  \BUseVerbatim{pipe@active@verbatim}%
  \endgroup}
\AtBeginDocument{\let|\pipe@active@verbatim}
\endgroup

\def\MacroFont{%
  \fontencoding\encodingdefault%
  \fontfamily\ttdefault%
  \fontseries\mddefault%
  \fontshape\updefault%
  \small}

\definecolor{minted@mint}{HTML}{0B610B}
\colorlet{minted@linkcolor}{minted@mint}

\def\PrintDescribeMacro#1{\strut \MacroFont\textcolor{minted@linkcolor}{\string #1\ }}
\let\PrintDescribeEnv\PrintDescribeMacro
\let\PrintMacroName\PrintDescribeMacro
\let\PrintEnvName\PrintDescribeEnv

\renewenvironment{macro}{\macro@custom@arg}{}
\def\macro@custom@arg{%
  \begingroup\makeatletter\macro@custom@arg@i}
\def\macro@custom@arg@i#1{%
  \makeatother
  \par\noindent
  \ifstrempty{#1}%
   {~\par}%
   {\ttfamily\color{minted@mint}\hspace*{-0.5in}%
    \macro@custom@arg@split#1,\FV@Sentinel\par}%
  \endgroup}
\def\macro@custom@arg@spacegobble#1{#1}
\def\macro@custom@arg@split#1,#2\FV@Sentinel{%
  \expandafter\string\macro@custom@arg@spacegobble#1%
  \if\relax\detokenize{#2}\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {}{\\\hspace*{-0.5in}\macro@custom@arg@split#2\FV@Sentinel}}

\renewenvironment{environment}{\env@custom@arg}{}
\def\env@custom@arg{%
  \begingroup\makeatletter\env@custom@arg@i}
\def\env@custom@arg@i#1{%
  \makeatother
  \ifstrempty{#1}%
   {~\par}%
   {\ttfamily\color{minted@mint}\hspace*{-0.5in}%
    \env@custom@arg@split#1,\FV@Sentinel\par}%
  \endgroup}
\def\env@custom@arg@spacegobble#1{#1}
\def\env@custom@arg@split#1,#2\FV@Sentinel{%
  \env@custom@arg@spacegobble#1{\textrm{ \textit{(env.)}}}%
  \if\relax\detokenize{#2}\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {}{\\\hspace*{-0.5in}\env@custom@arg@split#2\FV@Sentinel}}


\def\theCodelineNo{\textcolor{minted@linkcolor}{\sffamily\footnotesize\oldstylenums{\arabic{CodelineNo}}}}
%
\hypersetup{
  pdftitle=The minted package: Highlighted source code in LaTeX,
  pdfauthor=Geoffrey M. Poore,
  pdfsubject={Minted LaTeX package manual},
  colorlinks=true,
  allcolors=minted@linkcolor,
}

\newenvironment{mintedminted}%
 {\VerbatimEnvironment
  \begin{minted}}%
 {\end{minted}}


\newenvironment{example}
  {\VerbatimEnvironment
   \begin{VerbatimOut}[gobble=1]{example.out}}
  {\end{VerbatimOut}%
   \setlength{\parindent}{0pt}%
   \vspace{1em}%
   \fbox{%
     \vspace{1ex}%
     \begin{minipage}{0.5\linewidth-2em-\fboxsep}%
     \inputminted[resetmargins]{latex}{example.out}%
     \end{minipage}%
     \hspace{2em}\vrule\hspace{2em}%
     \begin{minipage}{0.5\linewidth-2em-\fboxsep}%
     \input{example.out}%
     \end{minipage}%
     \vspace{1ex}}%
   \vspace{1em}}


\begingroup
\catcode`\^^M=\active%
\gdef\longexample@i#1{%
  \def\longexample@arg{#1}%
  \begin{VerbatimOut}[gobble=1]{example.out}^^M}%
\endgroup

\newenvironment{longexample}
 {\VerbatimEnvironment
  \FVExtraReadOArgBeforeVEnv{\longexample@i}}
 {\end{VerbatimOut}%
  \vspace{1em}%
  \setlength{\parindent}{0pt}%
  \fbox{
    \vspace{1ex}%
    \begin{minipage}{\linewidth-2\fboxsep}%
    \inputminted[resetmargins]{latex}{example.out}%
    ~\hrulefill~
    \expandafter\fvset\expandafter{\longexample@arg}%
    \input{example.out}%
    \end{minipage}%
    \vspace{1ex}}%
  \vspace{1em}}


\def\minted@printopt#1(#2) (#3){%
  \vspace{0.1in}%
  \leavevmode%
  \marginpar{\raggedleft\texttt{\textcolor{minted@linkcolor}{\small #1}}\ }%
  \kern-\parindent\textsf{(#2)}\hfill(default: \texttt{#3})\\}

\newenvironment{optionlist}%
 {~\par\vspace{-14pt}%
  \def\pipechar{|}
  \let\|\pipechar
  \newcommand*\mintednext{}%
  \let\item@orig\item
  \renewcommand*\item[1][]{%
    \ifdefstring{\@currenvir}{optionlist}%
     {\mintednext%
      \renewcommand*\mintednext{\par}%
      \minted@printopt##1%
      \ignorespaces}%
     {\ifstrempty{##1}%
      {\vspace{-4pt}\item@orig}
      {\vspace{-4pt}\item@orig[##1]}}}}
 {\par}

\edef\hashchar{\string#}


\renewcommand*\l@subsection{\@dottedtocline{2}{1.5em}{3em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{4.5em}{3.8em}}


\makeatother




\newenvironment{mintedexample}%
 {\VerbatimEnvironment
  \begin{minted}}%
 {\end{minted}}

\begin{document}
\DocInput{minted.dtx}
% ^^A\PrintIndex
\end{document}
%</driver>
% \fi
%
%
% ^^A\DoNotIndex{\newcommand,\newenvironment}
% ^^A\DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ }
% ^^A\DoNotIndex{\@ne}
% ^^A\DoNotIndex{\advance,\begingroup,\catcode,\closein}
% ^^A\DoNotIndex{\closeout,\day,\def,\edef,\else,\empty,\endgroup}
% ^^A\DoNotIndex{\begin,\end,\bgroup,\egroup}
% ^^A\DoNotIndex{\@namedef,\@nameuse,=,\csname,\endcsname}
%
%
% \GetFileInfo{minted.sty}
%
% \newcommand{\texpkg}[1]{\textsf{\detokenize{#1}}}
% \newcommand{\pypkg}[1]{\textsf{\detokenize{#1}}}
% \newcommand{\mintedpkg}{\texpkg{minted}}
% \newcommand{\app}[1]{\textsf{#1}}
%
% \title{The \textcolor{minted@mint}{\mintedpkg} package:\\Highlighted source code in \LaTeX}
% \author{Geoffrey M.\ Poore \\ \url{gpoore@gmail.com} \\ \href{https://github.com/gpoore/minted}{\texttt{github.com/gpoore/minted}} \\ ~\\ Originally created and maintained (2009--2013) by \\ Konrad Rudolph}
% \date{\fileversion~from \filedate}
%
% \maketitle
%
% \begin{abstract}
%   \noindent\mintedpkg\ provides syntax highlighting using the \href{https://pygments.org/}{Pygments} library.  It also provides options for customizing the highlighted source code output, including features implemented in Python such as selecting snippets of code with regular expressions.
%
% \vspace{0.5in}
% \noindent The original development of \mintedpkg\ version 3 was funded by a \href{https://tug.org/tc/devfund/grants.html}{\TeX\ Development Fund grant} from the \href{https://tug.org/}{\TeX\ Users Group} in 2023.
% \end{abstract}
%
% \vspace{0.5in}
%
% \subsection*{License}
% \href{https://www.latex-project.org/lppl.txt}{LaTeX Project Public License (LPPL)} version 1.3c.
%
% \pagebreak
%
%   \tableofcontents
%
% \fvset{
%   codes={\catcode`\%=9}, ^^A Ignore initial |%|
%   numbersep=5pt,
% }
% \setlength{\fboxsep}{1ex}
%
% \mbox{}\newpage
% \section{Introduction}
%
%
%
% \mintedpkg\ provides syntax highlighting using the \href{https://pygments.org/}{Pygments} library.  The general strategy is to wrap code in a command or environment that captures it verbatim, like this:
%\begin{mintedexample}[frame=single]{latex}
%\begin{minted}{<language>}
%<code>
%\end{minted}
%\end{mintedexample}
%
% Then the code is passed to Python, highlighted with Pygments, and passed back to \LaTeX\ for inclusion in the document.  Here is an example with Ruby code, showing the \LaTeX\ source and then the highlighted output:
%
% \begin{example}
% \begin{minted}{ruby}
%   class Foo
%     def init
%       pi = Math::PI
%       @var = "Pi = #{pi}..."
%     end
%   end
% \end{minted}
% \end{example}
%
% Because \mintedpkg\ uses Pygments and other Python software, it can provide more highlighting features than are practical in syntax highlighting packages like \href{ https://ctan.org/pkg/listings}{\texpkg{listings}} that are implemented purely in \LaTeX.  In the past, this reliance on external software brought several disadvantages, including a requirement for separately installing Pygments.  As of \mintedpkg\ version 3, all Python software including Pygments is bundled with the \LaTeX\ package when it is installed with a \TeX\ package manager, and no dependencies must be installed separately.
%
%
% \section{Installation}
%
% \subsection{Package manager}
%
% Installation will typically be simpler and faster using your \TeX\ distribution's package manager.  Start your package manager's graphical user interface, or use the relevant command below:
% \begin{itemize}
% \item TeX Live: |tlmgr install minted|
% \item MiKTeX: |mpm --admin --install=minted|
% \end{itemize}
% When the \mintedpkg\ package is installed, it includes the |latexminted| Python executable and all required Python libraries including Pygments.  For these to function correctly, Python 3.8+ must be installed and on |PATH| when the |latexminted| executable runs.
%
% Note that if you plan to use Pygments plugin packages, you will need to install the \pypkg{latexminted} Python package and dependencies including Pygments within a Python installation.  The Python libraries installed by a \TeX\ package manager within a \TeX\ installation are not compatible with plugin packages.  After installing \pypkg{latexminted} within a Python installation, make sure that its |latexminted| executable has precedence on |PATH|.
%
% The \mintedpkg\ package has the \LaTeX\ package dependencies listed below.  Depending on your \TeX\ distribution and configuration, these may be installed automatically when \mintedpkg\ is installed.
% \begin{multicols}{4}
% \begin{itemize}
% \setlength{\itemsep}{0pt}
% \setlength{\parskip}{0pt}
% \setlength{\parsep}{0pt}
% \item \texpkg{catchfile}
% \item \texpkg{etoolbox}
% \item \texpkg{float}
% \item \texpkg{fvextra}
% \item \texpkg{latex2pydata}
% \item \texpkg{newfloat}
% \item \texpkg{pdftexcmds}
% \item \texpkg{pgfkeys}
% \item \texpkg{pgfopts}
% \item \texpkg{shellesc}
% \item \texpkg{xcolor}
% \end{itemize}
% \end{multicols}
%
%
% \subsection{Manual installation}
%
% \mintedpkg\ source files are available at  \href{https://github.com/gpoore/minted}{|github.com/gpoore/minted|}.  There is also \href{https://ctan.org/pkg/minted}{|ctan.org/pkg/minted|}.
%
% Install |minted.sty| (and |minted2.sty| and |minted1.sty| if desired) within your \TeX\ installation.  For TeX Live, it may be best to put style files under |TEXMFLOCAL|, which can be located by running |kpsewhich --var-value TEXMFLOCAL|.  For example, you might put the files in |<texlive>/<year>/texmf-local/tex/latex/local/minted|.  For further details, consult your \TeX\ distribution's documentation, or an online guide such as \href{https://en.wikibooks.org/wiki/LaTeX/Installing_Extra_Packages}{\Verb{en.wikibooks.org/wiki/LaTeX/Installing_Extra_Packages}} or \href{https://texfaq.org/}{\Verb|texfaq.org|}.  After installing the |.sty| files, make \TeX\ aware of the new files by running |texhash| or |mktexlsr| (TeX Live), or |initexmf --update-fndb| (MiKTeX).
%
% Next, install the Python side of the package.  Python 3.8+ is required.  There are two options:  Install the \pypkg{latexminted} package and dependencies within a Python installation (typically easier, and required for compatibility with Pygments plugin packages), or install them within your \TeX\ installation.
%
% Note that if you are only using the \texpkg{minted2} package for backward compatibility with \mintedpkg\ version 2, you do not need \pypkg{latexminted}.   \texpkg{minted2} only requires the Pygments package, which can be installed with something like |pip install pygments|, |conda install anaconda::pygments|, or |brew install pygments|, depending on your operating system and Python distribution.  You may need to modify the command depending on system versus user installation and depending on virtual environments.
%
% \subsubsection{Option 1 (recommended):  Install \pypkg{latexminted} within Python installation}
%
% If your Python distribution is compatible with \href{https://pypi.org/}{The Python Package Index (PyPI)}, this can be accomplished by running |pip install latexminted|.  This will install \pypkg{latexminted} plus all dependencies including Pygments.  You may need to modify the command depending on whether you want a system or user (|--user|) installation, depending on whether you are using virtual environments, and depending on whether something like |pip3| is needed instead of |pip|.
%
% If you cannot or do not wish to use PyPI via |pip|, install the following packages manually or from other sources.
% \begin{itemize}
% \setlength{\itemsep}{0pt}
% \setlength{\parskip}{0pt}
% \setlength{\parsep}{0pt}
% \item \pypkg{latexminted}:  \url{https://pypi.org/project/latexminted/}
% \item \pypkg{latexrestricted}:  \url{https://pypi.org/project/latexrestricted/}
% \item \pypkg{latex2pydata}:  \url{https://pypi.org/project/latex2pydata/}
% \item Pygments:  \url{https://pypi.org/project/Pygments/}
% \end{itemize}
%
% \subsubsection{Option 2:  Install \pypkg{latexminted} within \TeX\ installation}
%
% This approach is more involved and essentially replicates the process that is performed automatically when using a \TeX\ package manager.
%
% Install the |latexminted.py| executable within your \TeX\ installation.  (It is part of the \mintedpkg\ \LaTeX\ package, separate from the \pypkg{latexminted} Python package.)  This should typically be within a |scripts| directory.  When TeX Live installs \mintedpkg\ with its package manager, this is something like |<texlive>/<year>/texmf-dist/scripts/minted|.
%
% Download Python wheels (|*.whl|) for the following Python packages, and place them in the same location as |latexminted.py|.
% \begin{itemize}
% \setlength{\itemsep}{0pt}
% \setlength{\parskip}{0pt}
% \setlength{\parsep}{0pt}
% \item \pypkg{latexminted}:  \url{https://pypi.org/project/latexminted/}
% \item \pypkg{latexrestricted}:  \url{https://pypi.org/project/latexrestricted/}
% \item \pypkg{latex2pydata}:  \url{https://pypi.org/project/latex2pydata/}
% \item Pygments:  \url{https://pypi.org/project/Pygments/}
% \end{itemize}
%
% Under non-Windows operating systems, create a symlink called |latexminted| in the \TeX\ binary directory or another appropriate location that points to |latexminted.py|.  When TeX Live installs \mintedpkg\ with its package manager, this is something like |<texlive>/<year>/bin/<architecture>|.
%
% Under Windows, a launcher executable for |latexminted.py| needs to be created.  When TeX Live installs \mintedpkg\ with its package manager, it creates a copy of |runscript.exe| named |latexminted.exe| within the \TeX\ binary directory, which is something like |<texlive>/<year>/bin/windows|.
%
%
%
% \section{Migrating from \mintedpkg\ version 2}
%
% \mintedpkg\ version 3 is a complete rewrite from version 2.9.  A brief summary of changes is provided below.  For full details, see |CHANGELOG_MINTED_LATEX_PACKAGE.md|.
%
% \subsubsection*{Backward compatibility}
%
% The new \texpkg{minted2} package provides the features of \texpkg{minted} version 2.9, the final release before version 3.  No additional version 2 releases are planned; no changes to the \texpkg{minted2} package are expected.
%
%
% \subsubsection*{New features and changes}
%
% \begin{itemize}
% \item Version 3 uses a new \mintedpkg-specific Python executable called |latexminted| to perform syntax highlighting.  This executable is specifically designed to meet the security requirements for restricted shell escape programs.  Once it has passed a security review and is accepted by \TeX\ distributions, it will be possible to highlight code without |-shell-escape| and its attendant security vulnerabilities.
%
%   Syntax highlighting is still performed with Pygments, but the |pygmentize| executable included with Pygments is no longer used.
%
% When \mintedpkg\ is installed with a \TeX\ package manager, the new |latexminted| executable and all Python libraries including Pygments are installed within the \TeX\ installation.  A separate step to install Pygments is no longer necessary.
%
% \item Temporary files are no longer created unless code needs to be highlighted.  There is a new naming scheme for temporary files and for cache files.
%
% \item New package options:  |debug| (additional debug info during compilation), |highlightmode| (modify when code is highlighted for faster compilation), |placeholder| (insert a placeholder instead of code), and |verbatim| (insert verbatim approximation of code).
%
% \item Renamed package options |langlinenos| to |lexerlinenos| and |inputlanglinenos| to |inputlexerlinenos|.  The old names are still supported.
%
% \item |bgcolor| now uses the new |bgcolor| option from \texpkg{fvextra} v1.8.  Because |bgcolor| now introduces no additional whitespace or padding, existing documents may require some modification.  Added new option |bgcolorpadding| for modifying padding in background color regions.  Added new option |bgcolorvphantom| for setting height of background color in inline contexts.  When more sophisticated background colors are needed, \texpkg{tcolorbox} or a similar package should be used.
%
% \item The default cache directory name is now |_minted|.  All files within a directory now share the same cache, instead of having separate per-document caches.  Document-specific caching as in |minted| version 2 can be restored using the package option |cachedir|.
%
% \item |\newminted| now creates an environment that takes an optional argument consisting of options, instead of taking no argument.
%
% \item File encoding changes:  The new |latexminted| executable assumes that \LaTeX\ output files are UTF-8, and saves highlighted code as UTF-8.  That is, LaTeX should be      configured so that everything is UTF-8.  The |encoding| option now defaults to UTF-8.  It is only used in decoding files for |\inputminted| and commands based on it.  The |outencoding| option is no longer supported.
%
% \item Added new options for including ranges of code based on literal string delimiters or regular expressions:  |rangestartstring|, |rangestartafterstring|, |rangestopstring|, |rangestopbeforestring|, |rangeregex|.
%
% \item There is now support for custom lexers in standalone Python files.  See the documentation for the new |.latexminted_config| configuration files for details.
%
% \item Several package options are no longer supported and result in errors or warnings.  The package options |finalizecache|, |outputdir|, and |kpsewhich| are no longer needed given new \mintedpkg\ version 3 capabilities.  The package options |draft| and |final| no longer have any effect and will soon be removed altogether.  The new package options |placeholder| and |verbatim| are available in cases where using highlighted code should be completely avoided.
% \end{itemize}
%
%
%
% \section{Basic usage}
%
% \subsection{The \Verb{latexminted} Python executable and shell escape}
%
% The \mintedpkg\ package operates by passing code to the |latexminted| Python executable, which performs syntax highlighting and then returns the highlighted code in \LaTeX\ format.
%
% Currently, |latexminted| requires special permission to run.  \LaTeX\ must be called with the |-shell-escape| option (TeX Live) or the |-enable-write18| option (MiKTeX).  Note that using |-shell-escape| or |-enable-write18| allows \LaTeX\ to run potentially arbitrary commands on your system.  These should only be used when necessary, with documents from trusted sources.
%
% |latexminted| is designed to be compatible with the security requirements for restricted shell escape.  Once |latexminted| finishes the security review for restricted shell escape executables, it will function automatically without |-shell-escape| or |-enable-write18|, so long as the default restricted shell escape has not been disabled.  It is possible to benefit from these enhanced security capabilities immediately and avoid the need for |-shell-escape| or |-enable-write18| by manually designating |latexminted| as a trusted executable.
% \begin{itemize}
% \item TeX Live:  Copy the variable |shell_escape_commands| from the distribution |texmf.cnf| (something like |<texlive>/<yr>/texmf-dist/web2c/texmf.cnf|) into the user |texmf.cnf| (something like |<texlive>/<yr>/texmf.cnf|), and then add |latexminted| to the |shell_escape_commands| list.  The location of the |texmf.cnf| files can be determined by running |kpsewhich -all texmf.cnf|.  Note that under Windows, this only works when |latexminted| is installed within a TeX Live installation; it is not compatible with |latexminted| being installed in a Python installation.
% \item MiKTeX:  Add a line |AllowedShellCommands[] = latexminted| to the existing list of allowed commands in |miktex.ini|.  You may want to modify the user-scoped configuration instead of the system-wide configuration.  See the \href{https://docs.miktex.org/manual/miktex.ini.html}{MiKTeX documentation} for more details, particularly |initexmf --edit-config-file| and |initexmf --set-config-value|.
% \end{itemize}
%
% For the |latexminted| Python executable to correctly inherit security settings from \LaTeX, there are requirements for system configuration when multiple \TeX\ installations are present.
% \begin{itemize}
% \item With MiKTeX on systems with multiple MiKTeX installations, the desired MiKTeX installation must be the first MiKTeX installation on |PATH|.
% \item With TeX Live on Windows systems with multiple TeX Live installations, the desired TeX Live installation must be the first TeX Live installation on |PATH|.
% \end{itemize}
% See the \href{https://github.com/gpoore/latexrestricted}{\pypkg{latexrestricted}} documentation for details.
%
%
% \subsection{A minimal complete example}
%
% The following file |minimal.tex| shows the basic usage of \mintedpkg.
%
% \begin{VerbatimOut}[gobble=1]{minted.doc.out}
%   \documentclass{article}
%
%   \usepackage{minted}
%   \usepackage[svgnames]{xcolor}
%
%   \begin{document}
%   \begin{minted}[bgcolor=Beige, bgcolorpadding=0.5em]{c}
%   int main() {
%       printf("hello, world");
%       return 0;
%   }
%   \end{minted}
%   \end{document}
% \end{VerbatimOut}
% \inputminted[frame=single]{latex}{minted.doc.out}
%
% This document can be compiled by running ``|pdflatex -shell-escape minimal|''
% to produce the following output in |minimal.pdf|:
%
% \begin{center}
% \begin{minipage}{0.6\textwidth}
% \inputminted[rangeregex=\^\\s*int.+?\\\}, rangeregexdotall=true, rangeregexmultiline=true, bgcolor=Beige, bgcolorpadding=0.5em]{c}{minted.doc.out}
% \end{minipage}
% \end{center}
%
%
% \subsection{Formatting source code}
%
% \DescribeEnv{minted}
% The |minted| environment highlights a block of code:
%
% \begin{example}
% \begin{minted}{python}
% def boring(args = None):
%     pass
% \end{minted}
% \end{example}
%
% The environment accepts a number of optional arguments in |key=value| notation.  These are described in \cref{sec:options:macro}.
%
% To use \mintedpkg\ with a language that is not supported by Pygments, or simply to disable highlighting, set the language to |text|:  |\begin{minted}{text}|.
%
%
% \DescribeMacro{\mint}
% For a single line of source code, you can use |\mint| as a shorthand for |minted|:
%
% \begin{example}
% \mint{python}/import this/
% \end{example}
%
% This typesets a single line of code using a command rather than an environment, so it saves a little typing, but its output is equivalent to that of the |minted| environment.
%
% The code is delimited by a pair of identical characters, similar to how  |\verb| works.  The complete syntax is \cmd\mint\oarg{options}\marg{language}\meta{delim}\meta{code}\meta{delim},
% where the code delimiter can be almost any punctuation character.
% The \meta{code} may also be delimited with paired curly braces |{}|, so long as \meta{code} itself does not contain unpaired curly braces.
%
% Note that the |\mint| command \textbf{is not for inline use}.  Rather, it is a shortcut for |minted| when only a single line of code is present.  The |\mintinline| command is provided for inline use.
%
%
% \DescribeMacro{\mintinline}
% Code can be typeset inline:
%
% \begin{example}
% \mintinline{py}{print("Hello!")}
% \end{example}
%
% The syntax is  \cmd\mintinline\oarg{options}\marg{language}\meta{delim}\meta{code}\meta{delim}.  The delimiters can be a single repeated character, just like for \cmd{\verb}.  They can also be a pair of curly braces, |{}|.  Curly braces are required when \cmd{\mintinline} is used in a movable argument, such as in a \cmd{\section}.
%
% Unlike \cmd{\verb}, \cmd{\mintinline} can usually be used inside other commands.  The main exception is when the code contains the percent \texttt{\%} or hash \texttt{\#} characters, or unpaired curly braces.  For example, \cmd{\mintinline} typically works in \cmd{\footnote} and \cmd{\section}!  Note that some document classes or packages, such as \texpkg{memoir}, redefine \cmd{\section} or have options that modify it in ways that are incompatible with \cmd{\mintinline}.  If you use \cmd{\mintinline} inside \cmd{\section} or otherwise in a movable argument, you should experiment to make sure it is compatible with your document configuration.  You may also want to consider \texpkg{fvextra}'s \cmd{\Verb} or \cmd{\EscVerb} as an alternative.
%
% The code typesetting for \cmd{\mintinline} is based on \texpkg{fvextra}'s \cmd{\Verb}.  See the \href{https://github.com/gpoore/fvextra/}{\texpkg{fvextra} documentation on \cmd{\Verb}} for additional details about functionality and limitations.
%
% \DescribeMacro{\inputminted}
% Finally, there's the |\inputminted| command to input external files.
% Its syntax is \cmd\inputminted\oarg{options}\marg{language}\marg{filename}.
%
%
% \subsection{Using different styles}
%
% \DescribeMacro{\usemintedstyle}
%
% \DescribeMacro{\setminted}
% Instead of using the default highlighting style you may choose another style provided by Pygments.  There are two equivalent ways to do this:
%
% \begin{minted}{latex}
% \usemintedstyle{name}
% \setminted{style=name}
% \end{minted}
%
% The |\setminted| approach has the advantage that other \mintedpkg\ options are accepted as well; |\usemintedstyle| is restricted to style modifications.  The full syntax is \cmd\usemintedstyle\oarg{language}\marg{style} and \cmd\setminted\oarg{language}\marg{key=value}.  The style may be set for the document as a whole (no language specified), or only for a particular language.  Note that the style may also be set via the optional argument for each command and environment.
%
% Highlighting styles with examples are at \href{https://pygments.org/styles/}{pygments.org/styles}.  It is possible to preview your code with different styles using the online demo at \href{https://pygments.org/demo/}{pygments.org/demo}.  Available styles can also be listed by running the command |pygmentize -L styles|.
%
% It is also possible to create your own styles.  See the instructions on the
% \href{https://pygments.org/docs/styles/#creating-own-styles}{\texpkg{Pygments} website}.
% \mintedpkg\ only supports style names that match the regular expression |^[0-9A-Za-z_-]+$|.
%
%
% \subsection{Supported languages}
%
% Pygments supports hundreds of different programming languages, template languages, and other markup languages.  The list of currently supported languages is at \href{https://pygments.org/docs/lexers/}{pygments.org/docs/lexers/}. You can also run |pygmentize -L lexers|.
%
%
%
% \section{Floating listings}\label{sec:float}
%
% \DescribeEnv{listing}
% \mintedpkg\ provides a |listing| environment that can be used to wrap code blocks.  This puts the code in a floating box similar to a figure or table, with default placement |tbp|.  You can also provide a |\caption| and a |\label|:
%
% \begin{longexample}
% \begin{listing}[H]
% \mint{cl}/(car (cons 1 '(2)))/
% \caption{Example of a listing.}
% \label{lst:example}
% \end{listing}
%
% Listing \ref{lst:example} contains an example of a listing.
% \end{longexample}
%
% The default |listing| placement can be modified easily.  When the package option |newfloat=false| (default), the \texpkg{float} package is used to create the |listing| environment.  Placement can be modified by redefining |\fps@listing|.  For example,
%\begin{verbatim}
%\makeatletter
%\renewcommand{\fps@listing}{htp}
%\makeatother
%\end{verbatim}
% When |newfloat=true|, the more powerful \texpkg{newfloat} package is used to create the |listing| environment.  In that case, \texpkg{newfloat} commands are available to customize |listing|:
%\begin{verbatim}
%\SetupFloatingEnvironment{listing}{placement=htp}
%\end{verbatim}
%
%
% \DescribeMacro{\listoflistings}
% The |\listoflistings| macro will insert a list of all (floated) listings in the document:
%
% \begin{example}
%   \listoflistings
% \end{example}
%
% \subsection*{Customizing the \texttt{listing} environment}
% By default, the |listing| environment is created using the \texpkg{float} package.  In that case, the |\listingscaption| and |\listoflistingscaption| macros described below may be used to customize the caption and list of listings.  If \mintedpkg\ is loaded with the |newfloat| option, then the |listing| environment will be created with the more powerful \href{https://www.ctan.org/pkg/newfloat}{\texpkg{newfloat}} package instead.  \texpkg{newfloat} is part of \href{https://www.ctan.org/pkg/caption}{\texpkg{caption}}, which provides many options for customizing captions.
%
% When \texpkg{newfloat} is used to create the |listing| environment, customization should be achieved using \texpkg{newfloat}'s |\SetupFloatingEnvironment| command.  For example, the string ``Listing'' in the caption could be changed to ``Program code'' using
%\begin{verbatim}
%\SetupFloatingEnvironment{listing}{name=Program code}
%\end{verbatim}
% And ``List of Listings'' could be changed to ``List of Program Code'' with %\begin{verbatim}
%\SetupFloatingEnvironment{listing}{listname=List of Program Code}
%\end{verbatim}
% Refer to the \texpkg{newfloat} and \texpkg{caption} documentation for additional information.
%
% \DescribeMacro{\listingscaption}
% This allows the string ``Listing'' in a listing's caption to be customized.  It only applies when package option |newfloat=false|.  For example:
%
%\begin{verbatim}
%\renewcommand{\listingscaption}{Program code}
%\end{verbatim}
%
% \DescribeMacro{\listoflistingscaption}
% This allows the caption of the listings list, ``List of Listings,'' to be customized. It only applies when package option |newfloat=false|. For example:
%
%\begin{verbatim}
%\renewcommand{\listoflistingscaption}{List of Program Code}
%\end{verbatim}
%
%
%
% \section{Configuration}
%
%
% \subsection{\mintedpkg\ config file \Verb{.latexminted_config}}
%
% Several \mintedpkg\ settings with security implications can be customized with a config file |.latexminted_config|.  This config file is loaded by the |latexminted| Python executable when it runs.
%
% The |latexminted| Python executable looks for |.latexminted_config| files in the following locations:
% \begin{itemize}
% \item User home directory, as found by Python's \href{https://docs.python.org/3/library/pathlib.html#pathlib.Path.home}{|pathlib.Path.home()|}.
% \item |TEXMFHOME|.  With MiKTeX on systems with multiple MiKTeX installations, this will be the |TEXMFHOME| from the first MiKTeX installation on |PATH|.  With TeX Live on Windows systems with multiple TeX Live installations, this will be the |TEXMFHOME| from the first TeX Live installation on |PATH|.  In all other cases, |TEXMFHOME| will correspond to the currently active \TeX\ installation.  See the \href{https://github.com/gpoore/latexrestricted}{\pypkg{latexrestricted}} documentation for details.  \pypkg{latexrestricted} is used by the |latexminted| Python executable to retrieve the value of |TEXMFHOME|.
% \item The current \TeX\ working directory.  Note that |enable_cwd_config| must be set |true| in the |.latexminted_config| in the user home directory or in the |TEXMFHOME| directory to enable this; |.latexminted_config| in the current \TeX\ working directory is not enabled by default for security reasons.  Even when a config file in the current \TeX\ working directory is enabled, it cannot be used to modify certain security-related settings.
% \end{itemize}
%
% Overall configuration is derived by merging all config files, with later files in the list above having precedence over earlier files.  Boolean and string values are overwritten by later config files.   Collection values (currently only sets derived from lists) are merged with earlier values.
%
% The |.latexminted_config| file may be in Python literal format (dicts and lists of strings and bools), JSON, or TOML (requires Python 3.11+).  It must be encoded as UTF-8.
%
%
% \subsubsection*{Config settings}
%
% \begin{description}
% \item[{\Verb/security: dict[str, str | bool]/}]  These settings relate to |latexminted| security.  They can only be set in |.latexminted_config| in the user home directory or in |TEXMFHOME|.  They cannot be set in |.latexminted_config| in the current \TeX\ working directory.
%   \begin{description}
%   \item[\Verb|enable_cwd_config: bool = False|]  Load a |.latexminted_config| file from the current \TeX\ working directory if it exists.  This is disabled by default because the config file can enable |custom_lexers|, which is equivalent to arbitrary code execution.
%   \item[\Verb/file_path_analysis: "resolve" | "string" = "resolve"/]  This specifies how |latexminted| determines whether files are readable and writable.  Relative file paths are always treated as being relative to the current \TeX\ working directory.
%
%   With |resolve|, any symlinks in file paths are resolved with the file system before paths are compared with permitted \LaTeX\ read/write locations.  Arbitrary relative paths including ``|..|'' are allowed so long as the final location is permitted.
%
%   With |string|, paths are analyzed as strings in comparing them with permitted \LaTeX\ read/write locations.  This follows the approach taken in \TeX's file system security.  Paths cannot contain ``|..|'' to access a parent directory, even if the parent directory is a valid location.  Because symlinks are not resolved with the file system, it is possible to access locations outside permitted \LaTeX\ read/write locations, if the permitted locations contain symlinks to elsewhere.
%
%  \item[{\Verb|permitted_pathext_file_extensions: list[str]|}]  As a security measure under Windows, \LaTeX\ cannot write files with file extensions in |PATHEXT|, such as |.bat| and |.exe|.  This setting allows |latexminted| to write files with the specified file extensions, overriding \LaTeX\ security.  File extensions should be in the form ``|.<ext>|'', for example, ``|.bat|''.  This setting is used in extracting source code from \LaTeX\ documents and saving it in standalone source files.
%
%   When these file extensions are enabled for writing, as a security measure |latexminted| will only allow them to be created in \textbf{subdirectories} of the current \TeX\ working directory, |TEXMFOUTPUT|, and |TEXMF_OUTPUT_DIRECTORY|.  These files cannot be created directly under the \TeX\ working directory, |TEXMFOUTPUT|, and |TEXMF_OUTPUT_DIRECTORY| because those locations are more likely to be used as a working directory in a shell, and thus writing executable files in those locations would increase the risk of accidental code execution.
%   \end{description}
%
% \item[{\Verb/custom_lexers: dict[str, str | list[str]]/}]  This is a mapping of custom lexer file names to SHA256 hashes.  Only custom lexers with these file names and the corresponding hashes are permitted.  Lists of hashes are allowed to permit multiple versions of a lexer with a given file name.  All other custom lexers are prohibited, because loading custom lexers is equivalent to arbitrary code execution.  For example:
%\begin{verbatim}
%"custom_lexers": {
%  "mylexer.py": "<sha256>"
%}
%\end{verbatim}
%
% By default, it is assumed that custom lexer files implement a class |CustomLexer|.  This can be modified by including the lexer class name with the file name, separated by a colon, when the lexer is used.  For example:
%
%\begin{verbatim}
%\inputminted{./<path>/mylexer.py:LexerClass}{<file>}
%\end{verbatim}
%
% Note that |custom_lexers| only applies to custom lexers in standalone Python files.  Lexers that are installed within Python as plugin packages work automatically with Pygments and do not need to be enabled separately.  However, in that case it is necessary to install \pypkg{latexminted} and Pygments within a Python installation.  When \TeX\ package managers install \pypkg{latexminted} and Pygments within a \TeX\ installation, these are not compatible with Pygments plugin packages.
% \end{description}
%
%
% \subsection{macOS compatibility}
% \label{sec:configuration:macos}
%
% If you are using \mintedpkg\ with some versions/configurations of macOS, and are using caching with a large number of code blocks ($>256$), you may receive a Python error during syntax highlighting that looks like this:
%\begin{Verbatim}
%OSError: [Errno 24] Too many open files:
%\end{Verbatim}
% This is due to the way files are handled by the operating system, combined with the way that caching works.  To resolve this, you may use one of the following commands to increase the number of files that may be used:
% \begin{itemize}
% \item |launchctl limit maxfiles|
% \item |ulimit -n|
% \end{itemize}
%
%
% \section{Options}
%
%
%
% \subsection{Package options}
%
% \DescribeMacro{chapter}
% To control how \LaTeX{} counts the |listing| floats, you can pass either the
% |chapter| or |section| option when loading the \mintedpkg\ package.
% For example, the following will cause listings to be counted by chapter:
%
% \begin{minted}{latex}
% \usepackage[chapter]{minted}
% \end{minted}
%
%
% \DescribeMacro{cache=\meta{boolean} (default:~true)}
% \mintedpkg\ works by saving code to a temporary file, highlighting it with Pygments, and then passing the result back to \LaTeX\ for inclusion in the document.  This process can become quite slow if there are several chunks of code to highlight.  To avoid this, the package provides a |cache| option.  This is on by default.
%
% The |cache| option creates a directory |_minted| in the document's root directory (this may be customized with the |cachedir| option).  Files of highlighted code are stored in this directory, so that the code will not have to be highlighted again in the future.  Cache files that are no longer used are automatically deleted.  In most cases, caching will significantly speed up document compilation.
%
%
% \DescribeMacro{cachedir=\meta{directory} (default:~\_minted)}
% This allows the directory in which cache files are stored to be customized.  Paths should use forward slashes, even under Windows.  Special characters must be escaped with |\string| or |\detokenize|.
%
% Note that the cache directory is relative to |-output-directory| or equivalently the  |TEXMF_OUTPUT_DIRECTORY| environment variable, if that is set.
%
%
% \DescribeMacro{debug=\meta{boolean} (default:~false)}
% Provide additional information for aid in debugging.  This keeps temp files that are used in generating highlighted code and also writes additional information to the log.
%
%
% \DescribeMacro{frozencache=\meta{boolean} (default:~false)}
% Use a frozen (static) cache.  When |frozencache=true|, Python and Pygments are not required, and any external files accessed through |\inputminted| are no longer necessary.  If a cache file is missing, an error will be reported and there will be no attempt to generate the missing cache file.
%
% When using |frozencache| with |-output-directory|, the |cachedir| package option       should be used to specify a full relative path to the cache (for example, |cachedir=./<output_directory>/_minted|).
%
%
% \DescribeMacro{highlightmode=\meta{string} (default:~fastfirst)}
% Determines when code is highlighted.
%
% The default is |fastfirst|.  If a cache for the document exists, then code is highlighted immediately.  If a cache for the document does not exist, then typeset a placeholder instead of code and highlight all code at the end of the document.  This will require a second compile before code is typeset, but because all code is highlighted at once, there is less overhead and the total time required can be significantly less for documents that include many code snippets.
%
% The alternatives are |fast| (always highlight at end of document, requiring a second compile) and |immediate| (always highlight immediately, so no second compile is needed).  |immediate| should be used when typesetting code in external temp files that are overwritten during compilation.
%
% When code is highlighted at the end of the document with |fast| or |fastfirst|, any error and warning messages will refer to a location at the end of the document rather than the original code location, since highlighting occurred at the end of the document.  In this case, messages are supplemented with original \LaTeX\ source file names and line numbers to aid in debugging.
%
%
% \DescribeMacro{inputlexerlinenos=\meta{boolean} (default:~false)}
% This enables |lexerlinenos| and causes it to apply to |\inputminted| (and custom commands based on it) in addition to |minted| environments and |\mint| commands (and custom environments/commands based on them).
%
% The regular |lexerlinenos| option treats all code within a document's |.tex| files as having one set of line numbering per language, and then treats each inputted source file as having its own separate numbering.  |inputlexerlinenos| defines a single numbering per lexer, regardless of where code originates.
%
%
% \DescribeMacro{lexerlinenos=\meta{boolean} (default:~false)}
% This allows all |minted| environments and |\mint| commands (and custom environments/commands based on them) for a given lexer (language) to share line numbering when |firstnumber=last|, so that each subsequent command/environment has line numbering that continues from the previous one.  This does not apply to |\inputminted| (and custom commands based on it); see the package option |inputlexerlinenos| for that.
%
% \mintedpkg\ uses the \texpkg{fancyvrb} package behind the scenes for the code typesetting.  \texpkg{fancyvrb} provides an option |firstnumber| that allows the starting line number of an environment to be specified.  For convenience, there is an option |firstnumber=last| that allows line numbering to pick up where it left off.  The |lexerlinenos| option makes |firstnumber| work for each lexer (language) individually with all |minted| and |\mint| usages.  For example, consider the code and output below.
%
% \begin{longexample}[xleftmargin=1em]
% \begin{minted}[linenos]{python}
% def f(x):
%     return x**2
% \end{minted}
%
% \begin{minted}[linenos]{ruby}
% def func
%     puts "message"
% end
% \end{minted}
%
% \begin{minted}[linenos, firstnumber=last]{python}
% def g(x):
%     return 2*x
% \end{minted}
% \end{longexample}
%
% Without the |lexerlinenos| option, the line numbering in the second Python environment would not pick up where the first Python environment left off.  Rather, it would pick up with the Ruby line numbering.
%
%
% \DescribeMacro{newfloat=\meta{boolean} (default:~false)}
% By default, the |listing| environment is created using the \texpkg{float} package.  The |newfloat| option creates the environment using \texpkg{newfloat} instead.  This provides better integration with the \texpkg{caption} package.
%
%
% \DescribeMacro{placeholder=\meta{boolean} (default:~false)}
% Instead of typesetting code, insert a placeholder.  This is enabled automatically when working with PGF/TikZ externalization.
%
%
% \DescribeMacro{section}
% To control how \LaTeX{} counts the |listing| floats, you can pass either the
% |section| or |chapter| option when loading the \mintedpkg\ package.
%
%
% \DescribeMacro{verbatim=\meta{boolean} (default:~false)}
% Instead of highlighting code, attempt to typeset it verbatim without using the |latexminted| Python executable.  This is not guaranteed to be an accurate representation of the code, since some features such as |autogobble| require Python.
%
%
% \subsection{Setting options for commands and environments}
% \label{sec:options:macro}
%
% All \mintedpkg\ highlighting commands and environment accept the same set of options.
% Options are specified as a comma-separated list of |key=value| pairs.
% For example, we can specify that the lines should be numbered:
%
% \begin{example}
%   \begin{minted}[linenos=true]{c++}
%   #include <iostream>
%   int main() {
%       std::cout << "Hello "
%                 << "world"
%                 << std::endl;
%   }
%   \end{minted}
% \end{example}
%
% An option value of |true| may also be omitted entirely (including the ``|=|'').
%
% |\mint| accepts the same options:
%
% \begin{example}
%   \mint[linenos]{perl}|$x=~/foo/|
% \end{example}
%
% Here's another example: we want to use the \LaTeX{} math mode inside comments:
%
% \begin{example}
%   \begin{minted}[mathescape]{py}
%   # Returns $\sum_{i=1}^{n}i$
%   def sum_from_one_to(n):
%       r = range(1, n + 1)
%       return sum(r)
%   \end{minted}
% \end{example}
%
% To make your \LaTeX{} code more readable you might want to indent the code inside a |minted|
% environment.
% The option |gobble| removes a specified number of characters from the output.  There is also an |autogobble| option that automatically removes indentation (dedents code).
%
% \begingroup
% \setminted{autogobble=false}
% \begin{example}
% \begin{minted}[showspaces]{py}
%     def boring(args = None):
%         pass
% \end{minted}
%
% versus
%
% \begin{minted}[gobble=4,
%   showspaces]{py}
%     def boring(args = None):
%         pass
% \end{minted}
% \end{example}
% \endgroup
%
% \DescribeMacro{\setminted}
% You may wish to set options for the document as a whole, or for an entire lexer (language).  This is possible via \cmd\setminted\oarg{lexer}\marg{key=value,...}.  Lexer-specific options override document-wide options.  Individual command and environment options override lexer-specific options.
%
% \DescribeMacro{\setmintedinline}
% You may wish to set separate options for \cmd\mintinline, either for the document as a whole or for a specific lexer (language).  This is possible via \cmd\setmintedinline.  The syntax is
% \cmd\setmintedinline\oarg{lexer}\marg{key=value,...}.  Lexer-specific options override document-wide options. Individual command options override lexer-specific options.  All settings specified with \cmd\setmintedinline\ override those set with \cmd\setminted.  That is, inline settings always have a higher precedence than general settings.
%
% \subsection{Command and environment options}
%
% \newcommand\appliesto[1]{\textsf{[For #1 only]}}
%
% Following is a full list of available options.  Several options are simply passed on to Pygments, \texpkg{fancyvrb}, and \texpkg{fvextra} for processing.  In those cases, more details may be in the documentation for those software packages.
%
% \begin{optionlist}
%   \item[autogobble (boolean) (false)]
%     Remove (gobble) all common leading whitespace from code.  Essentially a version of |gobble| that automatically determines what should be removed.  Good for code that originally is not indented, but is manually indented after being pasted into a \LaTeX\ document.
%
% \begin{example}
%   ...text.
%   \begin{minted}[autogobble]{py}
%       def f(x):
%           return x**2
%   \end{minted}
% \end{example}
%
% When |autogobble| and |gobble| are used together, the effect is cumulative.  First |autogobble| removes all common indentation, and then |gobble| is applied.
%
% |autogobble| and |gobble| operate on code before the highlighting process begins (before lexing), treating the code purely as text.  Meanwhile, |gobblefilter| operates on the token stream generated by a lexer.  If the removed characters are simply indentation coming from how the code was entered within \LaTeX, then |autogobble| and |gobble| should typically be preferred.  If the removed characters are syntactically significant, then |gobblefilter| may be better.  Which approach is preferable may also depend on the implementation details of the lexer.
%
%   \item[baselinestretch (dimension) (\meta{document default})]
%     Value to use for baselinestretch inside the listing.
%
%
% \item[beameroverlays (boolean) (false)]
% Give the |<| and |>| characters their normal text meanings when used with |escapeinside| and |texcomments|, so that \texpkg{beamer} overlays of the form |\only<1>{...}| will work.
%
%
% \item[bgcolor (string) (none)]
% Background color behind commands and environments.  This is only a basic, lightweight implementation of background colors using |\colorbox|.  For more control of background colors, consider \href{https://ctan.org/pkg/tcolorbox}{\pkg{tcolorbox}} or a similar package, or a custom background color implementation.
%
% |bgcolor| prevents line breaks for |\mintinline|. If you want to use \texttt{\string\setminted} to set background colors, and only want background colors on \texttt{minted} and \texttt{\string\mint}, you may use \texttt{\string\setmintedinline\{bgcolor=none\}} to turn off the coloring for inline commands.
%
% The value of this option must \emph{not} be a color command. Instead, it must be a color \emph{name}, given as a string, of a previously-defined color:
%
% \begin{example}
% \definecolor{bg}{rgb}{.9, .9, .9}
% \begin{minted}[bgcolor=bg]{php}
% <?php
%   echo "Hello, $x";
% ?>
% \end{minted}
% \end{example}
%
% As an alternative to |bgcolor|, \texpkg{tcolorbox} provides a built-in framing environment with \mintedpkg\ support.  Simply use \texttt{\string\tcbuselibrary\{minted\}} in the preamble, and then put code within a \texttt{tcblisting} environment:
%\begin{Verbatim}
%\begin{tcblisting}{<tcb options>,
%                   minted language=<language>,
%                   minted style=<style>,
%                   minted options={<option list>} }
%<code>
%\end{tcblisting}
%\end{Verbatim}
% \texpkg{tcolorbox} provides other commands and environments for fine-tuning listing appearance and for working with external code files.
%
%
% \item[bgcolorpadding (length) (none)]
% Padding when |bgcolor| is set.  For inline commands and for environments based on |BVerbatim|, this sets |\fboxsep| for the |\colorbox| that is used to create the background color.  For environments based on |Verbatim|, \texpkg{fancyvrb}'s frame options are used instead, particularly |framesep| and |fillcolor|.  See the \texpkg{fvextra} documentation for implementation details.
%
%
% \item[bgcolorvphantom (macro) (\Verb{\vphantom{\"Apgjy}})]
% |\vphantom| or similar macro such as |\strut| that is inserted at the beginning of each line of code using |bgcolor|.  This allows the height of the background for each line of code to be customized.  This is primarily useful for customizing the background for |\mintinline| and other inline code.  It will typically have no effect on |minted| environments and other block code unless it is set to a size larger than |\strut|.
%
%
%   \item[breakafter (string) (\meta{none})]
%     Break lines after specified characters, not just at spaces, when \texttt{breaklines=true}.
%
% For example, \texttt{breakafter=-/} would allow breaks after any hyphens or slashes.  Special characters given to \texttt{breakafter} should be backslash-escaped (usually \texttt{\hashchar}, \texttt{\{}, \texttt{\}}, \texttt{\%}, \texttt{[}, \texttt{]}; the backslash \texttt{\textbackslash} may be obtained via \texttt{\textbackslash\textbackslash}).
%
% For an alternative, see \texttt{breakbefore}.  When \texttt{breakbefore} and \texttt{breakafter} are used for the same character, \texttt{breakbeforeinrun} and \texttt{breakafterinrun} must both have the same setting.
%
% \begin{longexample}
%   \begin{minted}[breaklines, breakafter=d]{python}
%   some_string = 'SomeTextThatGoesOnAndOnForSoLongThatItCouldNeverFitOnOneLine'
%   \end{minted}
% \end{longexample}
%
%   \item[breakafterinrun] (boolean) (true)
%     When \texttt{breakafter} is used, group all adjacent identical characters together, and only allow a break after the last character.  When \texttt{breakbefore} and \texttt{breakafter} are used for the same character, \texttt{breakbeforeinrun} and \texttt{breakafterinrun} must both have the same setting.
%
%
%   \item[breakaftersymbolpost (string) (\meta{none})]
%     The symbol inserted post-break for breaks inserted by \texttt{breakafter}.
%
%   \item[breakaftersymbolpre (string) (\string\,\string\footnotesize\string\ensuremath\{\_\string\rfloor\}, \,\footnotesize\ensuremath{_\rfloor})]
%     The symbol inserted pre-break for breaks inserted by \texttt{breakafter}.
%
%
%   \item[breakanywhere (boolean) (false)]
%     Break lines anywhere, not just at spaces, when \texttt{breaklines=true}.
%
% \begingroup
% \fvset{xrightmargin=1em}
% \begin{longexample}
%   \begin{minted}[breaklines, breakanywhere]{python}
%   some_string = 'SomeTextThatGoesOnAndOnForSoLongThatItCouldNeverFitOnOneLine'
%   \end{minted}
% \end{longexample}
% \endgroup
%
% \item[breakanywhereinlinestretch (length) (\meta{none})]
% Stretch glue to insert at potential |breakanywhere| break locations in inline contexts, to give better line widths and avoid overfull |\hbox|.  This allows the spacing between adjacent non-space characters to stretch, so it should not be used when column alignment is important.  For typical line lengths, values between |0.01em| and |0.02em| should be sufficient to provide a cumulative stretch per line that is equal to or greater than the width of one character.
%
% This is typically not needed in cases where an overfull |\hbox| only overflows by tiny amount, perhaps a fraction of a pt.  In those cases, the overfull |\hbox| could be ignored, |\hfuzz| could be set to 1pt or 2pt to suppress tiny overfull |\hbox| warnings, or |breakanywheresymbolpre| might be redefined to adjust spacing.
%
%
%   \item[breakanywheresymbolpost (string) (\meta{none})]
%     The symbol inserted post-break for breaks inserted by \texttt{breakanywhere}.
%
%
%   \item[breakanywheresymbolpre (string) (\string\,\string\footnotesize\string\ensuremath\{\_\string\rfloor\}, \,\footnotesize\ensuremath{_\rfloor})]
%     The symbol inserted pre-break for breaks inserted by \texttt{breakanywhere}.
%
%
%   \item[breakautoindent (boolean) (true)]
%     When a line is broken, automatically indent the continuation lines to the indentation level of the first line.  When \texttt{breakautoindent} and \texttt{breakindent} are used together, the indentations add.  This  indentation is combined with \texttt{breaksymbolindentleft} to give the total actual left indentation.  Does not apply to \texttt{\string\mintinline}.
%
%   \item[breakbefore (string) (\meta{none})]
%     Break lines before specified characters, not just at spaces, when \texttt{breaklines=true}.
%
% For example, \texttt{breakbefore=A} would allow breaks before capital A's.  Special characters given to \texttt{breakbefore} should be backslash-escaped (usually \texttt{\hashchar}, \texttt{\{}, \texttt{\}}, \texttt{\%}, \texttt{[}, \texttt{]}; the backslash \texttt{\textbackslash} may be obtained via \texttt{\textbackslash\textbackslash}).
%
%  For an alternative, see \texttt{breakafter}.  When \texttt{breakbefore} and \texttt{breakafter} are used for the same character, \texttt{breakbeforeinrun} and \texttt{breakafterinrun} must both have the same setting.
%
% \begin{longexample}
%   \begin{minted}[breaklines, breakbefore=A]{python}
%   some_string = 'SomeTextThatGoesOnAndOnForSoLongThatItCouldNeverFitOnOneLine'
%   \end{minted}
% \end{longexample}
%
%   \item[breakbeforeinrun] (boolean) (true)
%     When \texttt{breakbefore} is used, group all adjacent identical characters together, and only allow a break before the first character.  When \texttt{breakbefore} and \texttt{breakafter} are used for the same character, \texttt{breakbeforeinrun} and \texttt{breakafterinrun} must both have the same setting.
%
%
%   \item[breakbeforesymbolpost (string) (\meta{none})]
%     The symbol inserted post-break for breaks inserted by \texttt{breakbefore}.
%
%
%   \item[breakbeforesymbolpre (string) (\string\,\string\footnotesize\string\ensuremath\{\_\string\rfloor\}, \,\footnotesize\ensuremath{_\rfloor})]
%     The symbol inserted pre-break for breaks inserted by \texttt{breakbefore}.
%
%
%   \item[breakbytoken (boolean) (false)]
%   Only break lines at locations that are not within tokens; prevent tokens from being split by line breaks.  By default, \texttt{breaklines} causes line breaking at the space nearest the margin.  While this minimizes the number of line breaks that are necessary, it can be inconvenient if a break occurs in the middle of a string or similar token.
%
%   This does not allow line breaks between immediately adjacent tokens; for that, see |breakbytokenanywhere|.
%
%   A complete list of Pygments tokens is available at \href{https://pygments.org/docs/tokens}{pygments.org/docs/tokens}.  If the breaks provided by \texttt{breakbytoken} occur in unexpected locations, it may indicate a bug or shortcoming in the Pygments lexer for the language.
%
%   \item[breakbytokenanywhere (boolean) (false)]
%   Like \texttt{breakbytoken}, but also allows line breaks between immediately adjacent tokens, not just between tokens that are separated by spaces.  Using \texttt{breakbytokenanywhere} with \texttt{breakanywhere} is redundant.
%
% \item[breakindent (dimension) (\meta{breakindentnchars})]
% When a line is broken, indent the continuation lines by this amount.
%
% When |breakautoindent| and |breakindent| are used together, the indentations add.  This  indentation is combined with |breaksymbolindentleft| to give the total actual left indentation.
%
% Does not apply to \texttt{\string\mintinline}.
%
% \item[breakindentnchars (integer) (0)]
% This allows |breakindent| to be specified as an integer number of characters rather than as a dimension (assumes a fixed-width font).
%
%   \item[breaklines (boolean) (false)]
%     Automatically break long lines in \texttt{minted} environments and \texttt{\string\mint} commands, and wrap longer lines in \texttt{\string\mintinline}.
%
% By default, automatic breaks occur at space characters.  Use \texttt{breakanywhere} to enable breaking anywhere; use \texttt{breakbytoken}, \texttt{breakbytokenanywhere}, \texttt{breakbefore}, and \texttt{breakafter} for more fine-tuned breaking.  Using \texttt{escapeinside} to escape to \LaTeX\ and then insert a manual break is also an option.  For example, use \Verb{escapeinside=||}, and then insert \Verb{|\\|} at the appropriate point.  (Note that \texttt{escapeinside} does not work within strings.)
%
% \begin{example}
%   ...text.
%   \begin{minted}[breaklines]{py}
%   def f(x):
%       return 'Some text ' + str(x)
%   \end{minted}
% \end{example}
%
%     Breaking in \texttt{minted} and \texttt{\string\mint} may be customized in several ways.  To customize the indentation of broken lines, see \texttt{breakindent} and \texttt{breakautoindent}.  To customize the line continuation symbols, use \texttt{breaksymbolleft} and \texttt{breaksymbolright}.  To customize the separation between the continuation symbols and the code, use \texttt{breaksymbolsepleft} and \texttt{breaksymbolsepright}.  To customize the extra indentation that is supplied to make room for the break symbols, use \texttt{breaksymbolindentleft} and \texttt{breaksymbolindentright}.  Since only the left-hand symbol is used by default, it may also be modified using the alias options \texttt{breaksymbol}, \texttt{breaksymbolsep}, and \texttt{breaksymbolindent}.  Note than none of these options applies to \texttt{\string\mintinline}, since they are not relevant in the inline context.
%
% An example using these options to customize the \texttt{minted} environment is shown below.  This uses the \texttt{\string\carriagereturn} symbol from the \texpkg{dingbat} package.
%
% \begingroup
% \fvset{breaklines, xleftmargin=2em, xrightmargin=2em}
% \begin{longexample}
%   \begin{minted}[breaklines,
%                  breakautoindent=false,
%                  breaksymbolleft=\raisebox{0.8ex}{
%                    \small\reflectbox{\carriagereturn}},
%                  breaksymbolindentleft=0pt,
%                  breaksymbolsepleft=0pt,
%                  breaksymbolright=\small\carriagereturn,
%                  breaksymbolindentright=0pt,
%                  breaksymbolsepright=0pt]{python}
%   def f(x):
%       return 'Some text ' + str(x) + ' some more text ' + str(x) + ' even more text that goes on for a while'
%   \end{minted}
% \end{longexample}
% \endgroup
%
%     Automatic line breaks are limited with Pygments styles that use a colored background behind large chunks of text.  This coloring is accomplished with \texttt{\string\colorbox}, which cannot break across lines.  It may be possible to create an alternative to \texttt{\string\colorbox} that supports line breaks, perhaps with \texpkg{TikZ}, but the author is unaware of a satisfactory solution.  The only current alternative is to redefine \texttt{\string\colorbox} so that it does nothing.  For example,
%\begin{Verbatim}
%\AtBeginEnvironment{minted}{\renewcommand{\colorbox}[3][]{#3}}
%\end{Verbatim}
%     uses the \texpkg{etoolbox} package to redefine \texttt{\string\colorbox} within all \texttt{minted} environments.
%
%   \item[breaksymbol (string) (breaksymbolleft)]
%     Alias for \texttt{breaksymbolleft}.
%
%
% \item[breaksymbolindent (dimension) (\meta{breaksymbolindentleftnchars})]
% Alias for |breaksymbolindentleft|.
%
% \item[breaksymbolindentnchars (integer) (\meta{breaksymbolindentleftnchars})]
% Alias for |breaksymbolindentleftnchars|.
%
%
% \item[breaksymbolindentleft (dimension) (\meta{breaksymbolindentleftnchars})]
% The extra left indentation that is provided to make room for |breaksymbolleft|.  This indentation is only applied when there is a |breaksymbolleft|.
%
%     Does not apply to \texttt{\string\mintinline}.
%
% \item[breaksymbolindentleftnchars (integer) (4)]
% This allows |breaksymbolindentleft| to be specified as an integer number of characters rather than as a dimension (assumes a fixed-width font).
%
% \item[breaksymbolindentright (dimension) (\meta{breaksymbolindentrightnchars})]
% The extra right indentation that is provided to make room for |breaksymbolright|.  This indentation is only applied when there is a |breaksymbolright|.
%
% \item[breaksymbolindentrightnchars (integer) (4)]
% This allows |breaksymbolindentright| to be specified as an integer number of characters rather than as a dimension (assumes a fixed-width font).
%
%
%   \item[breaksymbolleft (string) (\string\tiny\string\ensuremath\{\string\hookrightarrow\}, {\tiny\ensuremath{\hookrightarrow}})]
%     The symbol used at the beginning (left) of continuation lines when \texttt{breaklines=true}.  To have no symbol, simply set \texttt{breaksymbolleft} to an empty string (``\texttt{=,}'' or ``\texttt{=\{\}}'').  The symbol is wrapped within curly braces \texttt{\{\}} when used, so there is no danger of formatting commands such as \texttt{\string\tiny} ``escaping.''
%
%     The \texttt{\string\hookrightarrow} and \texttt{\string\hookleftarrow} may be further customized by the use of the \texttt{\string\rotatebox} command provided by \texpkg{graphicx}.  Additional arrow-type symbols that may be useful are available in the \texpkg{dingbat} (\texttt{\string\carriagereturn}) and \texpkg{mnsymbol} (hook and curve arrows) packages, among others.
%
%     Does not apply to \texttt{\string\mintinline}.
%
%   \item[breaksymbolright (string) (\meta{none})]
%     The symbol used at breaks (right) when \texttt{breaklines=true}. Does not appear at the end of the very last segment of a broken line.
%
%
% \item[breaksymbolsep (dimension) (\meta{breaksymbolsepleftnchars})]
% Alias for |breaksymbolsepleft|.
%
% \item[breaksymbolsepnchars (integer) (\meta{breaksymbolsepleftnchars})]
% Alias for |breaksymbolsepleftnchars|.
%
%
% \item[breaksymbolsepleft (dimension) (\meta{breaksymbolsepleftnchars})]
% The separation between the |breaksymbolleft| and the adjacent text.
%
% \item[breaksymbolsepleftnchars (integer) (2)]
% Allows |breaksymbolsepleft| to be specified as an integer number of characters rather than as a dimension (assumes a fixed-width font).
%
%
% \item[breaksymbolsepright (dimension) (\meta{breaksymbolseprightnchars})]
% The \emph{minimum} separation between the |breaksymbolright| and the adjacent text.  This is the separation between |breaksymbolright| and the furthest extent to which adjacent text could reach.  In practice, |\linewidth| will typically not be an exact integer multiple of the character width (assuming a fixed-width font), so the actual separation between the |breaksymbolright| and adjacent text will generally be larger than |breaksymbolsepright|.  This ensures that break symbols have the same spacing from the margins on both left and right.  If the same spacing from text is desired instead, |breaksymbolsepright| may be adjusted.  (See the definition of |\FV@makeLineNumber| in \texpkg{fvextra} for implementation details.)
%
% \item[breaksymbolseprightnchars (integer) (2)]
% Allows |breaksymbolsepright| to be specified as an integer number of characters rather than as a dimension (assumes a fixed-width font).
%
%
% \item[codetagify (single macro or backslash-escaped string) (XXX,TODO,FIXME,BUG,NOTE)]
% Highlight special code tags in comments and docstrings.
%
% The value must be a list of strings, either comma-delimited or space-delimited.  The value must be a single macro that gives the desired text when fully expanded, or a string that is interpreted literally except that backslash escapes of ASCII punctuation characters are allowed to give the literal characters (``|\\|'' for backslash, ``|\#|'' for ``|#|'', and so on).
%
% \item[curlyquotes (boolean) (false)]
% By default, the backtick \texttt{\textasciigrave} and typewriter single quotation mark \texttt{\textquotesingle} always appear literally, instead of becoming the left and right curly single quotation marks \texttt{`'}.  This option allows these characters to be replaced by the curly quotation marks when that is desirable.
%
%
%   \item[encoding (string) (UTF-8)]
%   File encoding used by |\inputminted| and derived commands when reading files.
%
%
% \item[envname (string) (\textrm{\texttt{Verbatim}, or \texttt{VerbEnv} for inline})]
% This is the name of the environment that wraps typeset code.  By default, it is |Verbatim| in block contexts and |VerbEnv| in inline contexts (|\setminted| versus |\setmintedinline|).  This is compatible with \texpkg{fancyvrb}'s |BVerbatim|.
%
% There are two requirements for using a custom environment other than |Verbatim| and |BVerbatim| in block contexts:
% \begin{itemize}
% \item For |minted| and |\mint| support, the custom environment must be created with \texpkg{fancyvrb}'s |\DefineVerbatimEnvironment| or otherwise defined in a manner compatible with \texpkg{fancyvrb}'s environment implementation conventions.
% \item For |\inputminted| support, a corresponding |\|\meta{envname}|Insert| command must be defined, using \texpkg{fancyvrb}'s |\CustomVerbatimCommand| or otherwise following \texpkg{fancyvrb} command conventions.  For example, using a custom variant of |BVerbatim| involves creating both a custom environment as well as a corresponding variant of |\BVerbatimInput|.
% \end{itemize}
%
% There is currently only limited support for using an environment other than |VerbEnv| in inline contexts.  If an environment other than |VerbEnv| is specified, it will be used for highlighted code, but will not be used if code is typeset verbatim instead or if highlighting fails and a verbatim fallback is needed.  In both of those cases, |\Verb| is currently used.
%
% Note that |envname| is the name of the environment that wraps typeset code, but it is \emph{not} the name of the environment that literally appears in highlighted code output.  Highlighted code output uses the |MintedVerbatim| environment by default, and then |MintedVerbatim| is redefined based on |envname|.  This allows a single cache file to be used in multiple contexts.  The name of the environment that literally appears in highlighted code output can be modified with |literalenvname|, but there should be few if any situations where that is actually necessary.
%
%
%   \item[escapeinside (single macro or backslash-escaped two-character string) (\meta{none})]
%   Escape to \LaTeX\ between the two characters specified.  All code between the two characters will be interpreted as \LaTeX\ and typeset accordingly.  This allows for additional formatting.  The escape characters need not be identical.
%
% The value must be a single macro that gives the desired text when fully expanded, or a string that is interpreted literally except that backslash escapes of ASCII punctuation characters are allowed to give the literal characters (``|\\|'' for backslash, ``|\#|'' for ``|#|'', and so on).  Special \LaTeX\ characters must be escaped when they are used as the escape characters (for example, \texttt{escapeinside=\textbackslash\#\textbackslash\%}).
%
% \textbf{Escaping does not work inside strings and comments (for comments, there is \texttt{texcomments}).  Escaping is ``fragile'' with some lexers.}  Due to the way that Pygments implements \texttt{escapeinside}, any ``escaped'' \LaTeX\ code that resembles a string or comment for the current lexer may break \texttt{escapeinside}.  There is a \href{https://github.com/pygments/pygments/issues/825}{Pygments issue} for this case.  Additional details and a limited workaround for some scenarios are available on the \href{https://github.com/gpoore/minted/issues/70#issuecomment-111729930}{\mintedpkg\ GitHub site}.
%
% \begingroup  ^^A Need to prevent active "|" from causing problems
% \catcode`\|=11
% \begin{example}
%   \setminted{escapeinside=||}
%   \begin{minted}{py}
%   def f(x):
%       y = x|\colorbox{green}{**}|2
%       return y
%   \end{minted}
% \end{example}
% \endgroup
%
% \textbf{Note that when math is used inside escapes, any active characters beyond those that are normally active in verbatim can cause problems.}  Any package that relies on special active characters in math mode (for example, \texpkg{icomma}) will produce errors along the lines of ``\texttt{TeX capacity exceeded}'' and ``\texttt{\string\leavevmode \string\kern \string\z@}''.  This may be fixed by modifying \texttt{\string\@noligs}, as described at \url{https://tex.stackexchange.com/questions/223876}.
%   \item[firstline (integer) (1)]
%     The first line to be shown.
%     All lines before that line are ignored and do not appear in the output.
%   \item[firstnumber (auto \| last \| integer) (auto = 1)]
%     Line number of the first line.
%
%
% \item [fontencoding (font encoding) (\meta{doc~encoding})]
% Set font encoding used for typesetting code.  For example, |fontencoding=T1|.
%
%
%   \item[fontfamily (family name) (tt)]
%     The font family to use.
%     |tt|, |courier| and |helvetica| are pre-defined.
%
%
%   \item[fontseries (series name) (auto\textrm{ -- the same as the current font})]
%     The font series to use.
%
%
%   \item[fontshape (font shape) (auto\textrm{ -- the same as the current font})]
%     The font shape to use.
%
%
%   \item[fontsize (font size) (auto\textrm{ -- the same as the current font})]
%     The size of the font to use, as a size command, e.g. |\footnotesize|.
%
%
%   \item[formatcom (command) (\meta{none})]
%     A format to execute before printing verbatim text.
%   \item[frame (none \| leftline \| topline \| bottomline \| lines \| single) (none)]
%     The type of frame to put around the source code listing.  For more sophisticated framing, consider \texpkg{tcolorbox}.
%   \item[framerule (dimension) (0.4pt)]
%     Width of the frame.
%   \item[framesep (dimension) (\cmd\fboxsep)]
%     Distance between frame and content.
%   \item[funcnamehighlighting (boolean) (true)] \appliesto{PHP}
%     If |true|, highlights built-in function names.
% \item[gobble (integer) (0)]
% Remove the first $n$ characters from each input line.
%
% When |autogobble| and |gobble| are used together, the effect is cumulative.  First |autogobble| removes all common indentation, and then |gobble| is applied.
%
% |autogobble| and |gobble| operate on code before the highlighting process begins (before lexing), treating the code purely as text.  Meanwhile, |gobblefilter| operates on the token stream generated by a lexer.  If the removed characters are simply indentation coming from how the code was entered within \LaTeX, then |autogobble| and |gobble| should typically be preferred.  If the removed characters are syntactically significant, then |gobblefilter| may be better.  Which approach is preferable may also depend on the implementation details of the lexer.
%
% \item[gobblefilter (integer) (0)]
% Remove the first $n$ characters from each input line, using the Pygments gobble filter.
%
% |autogobble| and |gobble| operate on code before the highlighting process begins (before lexing), treating the code purely as text.  Meanwhile, |gobblefilter| operates on the token stream generated by a lexer.  If the removed characters are simply indentation coming from how the code was entered within \LaTeX, then |autogobble| and |gobble| should typically be preferred.  If the removed characters are syntactically significant, then |gobblefilter| may be better.  Which approach is preferable may also depend on the implementation details of the lexer.
%
%
% \item[highlightcolor (string) (LightCyan)]
% Set the color used for |highlightlines|, using a predefined color name from \texpkg{color} or \texpkg{xcolor}, or a color defined via |\definecolor|.
%
%
% \item[highlightlines (string) (\meta{none})]
% This highlights a single line or a range of lines based on line numbers.  For example, |highlightlines={1, 3-4}|.  The line numbers refer to the line numbers that would appear if |linenos=true|, etc.  They do not refer to original or actual line numbers before adjustment by |firstnumber|.
%
% The highlighting color can be customized with |highlightcolor|.
%
%
%   \item[ignorelexererrors (boolean) (false)]
%     When lexer errors are shown in highlighted output (default), they are typically displayed as red boxes that surround the relevant text.  When lexer errors are ignored, the literal text that caused lexer errors is shown but there is no indication that it caused errors.
%
%   \begin{longexample}
%   \begin{minted}{python}
%   variable = !!!
%   \end{minted}
%   \end{longexample}
%
%   \begin{longexample}
%   \begin{minted}[ignorelexererrors=true]{python}
%   variable = !!!
%   \end{minted}
%   \end{longexample}
%
%
%   \item[keywordcase (lower \| upper \| capitalize \| none) (none)]
%     Changes capitalization of keywords.
%   \item[label (string) (\emph{empty})]
%     Add a label to the top, the bottom or both of the frames around the code.
%     See the \texpkg{fancyvrb} documentation for more information and examples.
%     \emph{Note:} This does \emph{not} add a |\label| to the current listing.
%     To achieve that, use a floating environment (section \ref{sec:float}) instead.
%   \item[labelposition (none \| topline \| bottomline \| all) (topline, all,  \textrm{or} none)]
%     Location for the label.  Default: |topline| if one label is defined, |all| if two are defined, |none| otherwise.
%     See the \texpkg{fancyvrb} documentation for more information.
%   \item[lastline (integer) (\meta{last line of input})]
%     The last line to be shown.
%   \item[linenos (boolean) (false)]
%     Enables line numbers.
%     In order to customize the display style of line numbers, you need to redefine the |\theFancyVerbLine| macro:
%
% \begin{example}
%   \renewcommand{\theFancyVerbLine}{%
%     \sffamily
%     \textcolor[rgb]{0.5,0.5,1.0}{%
%       \scriptsize\oldstylenums{%
%         \arabic{FancyVerbLine}}}}
%
%   \begin{minted}[linenos,
%     firstnumber=11]{python}
%   def all(iterable):
%       for i in iterable:
%           if not i:
%               return False
%       return True
%   \end{minted}
% \end{example}
%
%
% \item[listparameters  (macro) (\meta{empty})]
% \texpkg{fancyvrb} option for setting list-related lengths to modify spacing around lines of code.  For example, |listparameters=\setlength{\topsep}{0pt}| will remove space before and after a |minted| environment.
%
%
% \item[literalenvname (string) (MintedVerbatim)]
% This is the name of the environment that literally appears in highlighted code output as a wrapper around the code.  It is redefined to be equivalent to |envname|.  There should be few if any situations where modifying |literalenvname| rather than |envname| is actually necessary.
%
%
% \item[literatecomment (single macro or backslash-escaped string) (\meta{none})]
% This is for compatibility with literate programming formats, such as the |.dtx| format commonly used for writing \LaTeX\ packages.  If all lines of code begin with \meta{literatecomment}, then \meta{literatecomment} is removed from the beginning of all lines.  For example, for |.dtx|, |literatecomment=\%|.
%
% The value must be a single macro that gives the desired text when fully expanded, or a string that is interpreted literally except that backslash escapes of ASCII punctuation characters are allowed to give the literal characters (``|\\|'' for backslash, ``|\#|'' for ``|#|'', and so on).
%
%
%   \item[mathescape (boolean) (false)]
%     Enable \LaTeX{} math mode inside comments.
%     Usage as in package \texpkg{listings}.
%     See the note under \texttt{escapeinside} regarding math and ligatures.
%
%
%   \item[numberblanklines (boolean) (true)]
%     Enables or disables numbering of blank lines.
%
%
% \item[numberfirstline (boolean) (false)]
% Always number the first line, regardless of |stepnumber|.
%
%
%   \item[numbers (left \| right \| both \| none) (none)]
%     Essentially the same as |linenos|, except the side on which the numbers appear may be specified.
%
%
%   \item[numbersep (dimension) (12pt)]
%     Gap between numbers and start of line.
%   \item[obeytabs (boolean) (false)]
%     Treat tabs as tabs instead of converting them to spaces---that is, expand them to tab stops determined by |tabsize|.  \textbf{While this will correctly expand tabs within leading indentation, usually it will not correctly expand tabs that are preceded by anything other than spaces or other tabs.  It should be avoided in those case.}
%
%   \item[python3 (boolean) (true)] \appliesto{PythonConsoleLexer}
%     Specifies whether Python 3 highlighting is applied.
%
%
% \item[rangeregex (single macro or backslash-escaped string) (\meta{none})]
% Select code that matches this regular expression.
%
% The value must be a single macro that gives the desired text when fully expanded, or a string that is interpreted literally except that backslash escapes of ASCII punctuation characters are allowed to give the literal characters (``|\\|'' for backslash, ``|\#|'' for ``|#|'', and so on).
%
% If line numbers are displayed, they are based on the range of code that is selected; code that is discarded in selecting the range is not considered in calculating line numbers.
%
%
% \item[rangeregexmatchnumber (integer) (1)]
% If there are multiple non-overlapping matches for |rangeregex|, this determines which is used.
%
%
% \item[rangeregexdotall (boolean) (false)]
% ``|.|'' matches any character including the newline.
%
%
% \item[rangeregexmultiline (boolean) (false)]
% ``|^|'' and ``|$|'' match at internal newlines, not just at the start/end of the string.
%
%
% \item[rangestartafterstring (single macro or backslash-escaped string) (\meta{none})]
% Select code starting immediately after this string.
%
% The value must be a single macro that gives the desired text when fully expanded, or a string that is interpreted literally except that backslash escapes of ASCII punctuation characters are allowed to give the literal characters (``|\\|'' for backslash, ``|\#|'' for ``|#|'', and so on).
%
% If line numbers are displayed, they are based on the range of code that is selected; code that is discarded in selecting the range is not considered in calculating line numbers.
%
%
% \item[rangestartstring (single macro or backslash-escaped string) (\meta{none})]
% Select code starting with this string.
%
% The value must be a single macro that gives the desired text when fully expanded, or a string that is interpreted literally except that backslash escapes of ASCII punctuation characters are allowed to give the literal characters (``|\\|'' for backslash, ``|\#|'' for ``|#|'', and so on).
%
% If line numbers are displayed, they are based on the range of code that is selected; code that is discarded in selecting the range is not considered in calculating line numbers.
%
%
% \item[rangestopbeforestring (single macro or backslash-escaped string) (\meta{none})]
% Select code ending immediately before this string.
%
% The value must be a single macro that gives the desired text when fully expanded, or a string that is interpreted literally except that backslash escapes of ASCII punctuation characters are allowed to give the literal characters (``|\\|'' for backslash, ``|\#|'' for ``|#|'', and so on).
%
% If line numbers are displayed, they are based on the range of code that is selected; code that is discarded in selecting the range is not considered in calculating line numbers.
%
%
% \item [rangestopstring (single macro or backslash-escaped string) (\meta{none})]
% Select code ending with this string.
%
% The value must be a single macro that gives the desired text when fully expanded, or a string that is interpreted literally except that backslash escapes of ASCII punctuation characters are allowed to give the literal characters (``|\\|'' for backslash, ``|\#|'' for ``|#|'', and so on).
%
% If line numbers are displayed, they are based on the range of code that is selected; code that is discarded in selecting the range is not considered in calculating line numbers.
%
%
%   \item[resetmargins (boolean) (false)]
%     Resets the left margin inside other environments.
%   \item[rulecolor (color command) (black)]
%     The color of the frame.
%   \item[samepage (boolean) (false)]
%     Forces the whole listing to appear on the same page, even if it doesn't fit.
%
%
%   \item[showspaces (boolean) (false)]
%     Enables visible spaces: \verb*/visible spaces/.
%
%
%   \item[showtabs (boolean) (false)]
%     Enables visible tabs---only works in combination with |obeytabs|.
%
%
% \item[space (macro) (\string\textvisiblespace, \textvisiblespace)]
% Redefine the visible space character.  Note that this is only used if |showspaces=true|.
%
%
% \item[spacecolor (string) (none)]
% Set the color of visible spaces.  By default (|none|), they take the color of their surroundings.
%
%
%   \item[startinline (boolean) (false)] \appliesto{PHP}
%     Specifies that the code starts in PHP mode, i.e., leading |<?php| is omitted.
%
%
%   \item[stepnumber (integer) (1)]
%     Interval at which line numbers appear.
%
%
% \item[stepnumberfromfirst (boolean) (false)]
% By default, when line numbering is used with |stepnumber| $\ne 1$, only line numbers that are a multiple of |stepnumber| are included.  This offsets the line numbering from the first line, so that the first line, and all lines separated from it by a multiple of |stepnumber|, are numbered.
%
%
% \item[stepnumberoffsetvalues (boolean) (false)]
% By default, when line numbering is used with |stepnumber| $\ne 1$, only line numbers that are a multiple of |stepnumber| are included.  Using |firstnumber| to offset the numbering will change which lines are numbered and which line gets which number, but will not change which \emph{numbers} appear.  This option causes |firstnumber| to be ignored in determining which line numbers are a multiple of |stepnumber|.  |firstnumber| is still used in calculating the actual numbers that appear.  As a result, the line numbers that appear will be a multiple of |stepnumber|, plus |firstnumber| minus 1.
%
%
%   \item[stripall (boolean) (false)]
%     Strip all leading and trailing whitespace from the input.
%   \item[stripnl (boolean) (false)]
%     Strip leading and trailing newlines from the input.
%
%
%   \item[style] (string) (\meta{default})
%     Sets the stylesheet used by Pygments.
%
%
% \item[tab (macro) ({\rmfamily\texpkg{fancyvrb}'s} \string\FancyVerbTab, \FancyVerbTab)]
% Redefine the visible tab character.  Note that this is only used if |showtabs=true|.  |\rightarrowfill|, \hbox to 2em{\rightarrowfill}, may be a nice alternative.
%
%
% \item[tabcolor (string) (black)]
% Set the color of visible tabs.  If |tabcolor=none|, tabs take the color of their surroundings.  This is typically undesirable for tabs that indent multiline comments or strings.
%
%
%   \item[tabsize (integer) (8)]
%     The number of spaces a tab is equivalent to.  If |obeytabs| is \emph{not} active, tabs will be converted into this number of spaces.  If |obeytabs| is active, tab stops will be set this number of space characters apart.
%   \item[texcl (boolean) (false)]
%     Enables \LaTeX{} code inside comments.
%     Usage as in package \texpkg{listings}.  See the note under \texttt{escapeinside} regarding math and ligatures.
%   \item[texcomments (boolean) (false)]
%     Enables \LaTeX{} code inside comments.  The newer name for |texcl|.  See the note under |escapeinside| regarding math and ligatures.
%
%     \texttt{texcomments} fails with multiline C/C++ preprocessor directives, and may fail in some other circumstances.  This is because preprocessor directives are \href{https://pygments.org/docs/tokens/}{tokenized as \texttt{Comment.Preproc}}, so \texttt{texcomments} causes preprocessor directives to be treated as literal \LaTeX\ code.  \href{https://github.com/pygments/pygments/issues/793}{An issue has been opened} at the Pygments site; additional details are also available on the \href{https://github.com/gpoore/minted/issues/66}{\mintedpkg\ GitHub site}.
%   \item[xleftmargin (dimension) (0)]
%     Indentation to add before the listing.
%   \item[xrightmargin (dimension) (0)]
%     Indentation to add after the listing.
%
% \end{optionlist}
%
%
%
%
% \section{Defining shortcuts}
%
% Large documents with many listings may use the same lexer and the same set of options for most listings.  \mintedpkg\ therefore defines a set of commands that lets you define shortcuts for the highlighting commands and environments.  Each shortcut is specific to one lexer.
%
% \DescribeMacro{\newminted}
% |\newminted| defines a new alias for the |minted| environment:
%
% \begingroup
% \setminted{autogobble=false}
% \begin{example}
% \newminted{cpp}{gobble=2,linenos}
%
% \begin{cppcode}
%   template <typename T>
%   T id(T value) {
%       return value;
%   }
% \end{cppcode}
% \end{example}
% \endgroup
%
% If you want to provide extra options on the fly, or override existing default options, you can do that, too:
%
% \begingroup
% \setminted{autogobble=false}
% \begin{example}
% \newminted{cpp}{gobble=2,linenos}
%
% \begin{cppcode}[linenos=false,
%                 frame=single]
%   int const answer = 42;
% \end{cppcode}
% \end{example}
% \endgroup
%
% The default name of the environment is \meta{lexer}|code|.
% If this name clashes with another environment or if you want to choose a different name, you can use an optional argument: \cmd\newminted\oarg{environment name}\marg{lexer}\marg{options}.
%
% Like normal \mintedpkg\ environments, environments created with |\newminted| may be used within other environment definitions.  Since the \mintedpkg\ environments use \texpkg{fancyvrb} internally, any environment based on them must include the \texpkg{fancyvrb} command |\VerbatimEnvironment|.  This allows \texpkg{fancyvrb} to determine the name of the environment that is being defined, and correctly find its end.  It is best to include this command at the beginning of the definition.  For example,
%\begin{Verbatim}
%\newminted{cpp}{gobble=2,linenos}
%\newenvironment{env}{\VerbatimEnvironment\begin{cppcode}}{\end{cppcode}}
%\end{Verbatim}
%
% \DescribeMacro{\newmint}
% A shortcut for |\mint| is defined using \cmd\newmint\oarg{macro name}\marg{lexer}\marg{options}.
% The arguments and usage are identical to |\newminted|.
% If no \meta{macro name} is specified, \meta{lexer} is used.
%
% \begin{example}
%   \newmint{perl}{showspaces}
%   \perl/my $foo = $bar;/
% \end{example}
%
%
% \DescribeMacro{\newmintinline}
% This creates custom versions of \cmd\mintinline.  The syntax is the same as that for \cmd\newmint: \cmd\newmintinline\oarg{macro~name}\marg{lexer}\marg{options}.  If a \meta{macro~name} is not specified, then the created macro is called \meta{lexer}|inline|.
%
% \begin{example}
%   \newmintinline{perl}{showspaces}
%   \perlinline/my $foo = $bar;/
% \end{example}
%
% \DescribeMacro{\newmintedfile}
% This creates custom versions of \cmd\inputminted.  The syntax is
% \begin{center}
% \cmd\newmintedfile\oarg{macro~name}\marg{lexer}\marg{options}
% \end{center}
% If no \meta{macro name} is given, then the macro is called \meta{lexer}|file|.
%
%
%
% \section{FAQ and Troubleshooting}
%
% In some cases, \mintedpkg\ may not give the desired result due to other document settings that it cannot control, or due to limitations in \LaTeX\ or the PDF format.  Common issues are described below, with workarounds or solutions.  You may also wish to search \href{https://tex.stackexchange.com/}{tex.stackexchange.com} or ask a question there, if you are working with \mintedpkg\ in a non-typical context.
%
% \begin{itemize}
% \item \textbf{I can't copy and paste code out of a PDF created with \mintedpkg.  The line numbers also get copied, or whitespace is lost, or something else happens that makes the code incorrect.}  There is no known method that always guarantees correct copy and paste for code in a PDF.  This does not depend on whether \mintedpkg\ is used.  You may want to search \href{https://tex.stackexchange.com/}{tex.stackexchange.com} to find current approaches (and their limitations).  You may also want to consider using \href{https://ctan.org/pkg/attachfile}{\texpkg{attachfile}} or a similar package to bundle source code files as part of your PDF.
% \item \textbf{There are intermittent ``I can't write on file'' errors.}  This can be caused by using \mintedpkg\ in a directory that is synchronized with Dropbox or a similar file syncing program.  These programs can try to sync \mintedpkg's temporary files while it still needs to be able to modify them.  The solution is to turn off file syncing or use a directory that is not synced.
% \item \textbf{I receive a ``Font Warning:  Some font shapes were not available'' message, or bold or italic seem to be missing.}  This is due to a limitation in the font that is currently in use for typesetting code.  In some cases, the default font shapes that \LaTeX\ substitutes are perfectly adequate, and the warning may be ignored.  In other cases, the font substitutions may not clearly indicate bold or italic text, and you will want to switch to a different font.  See The \LaTeX\ Font Catalogue's section on \href{https://www.tug.org/FontCatalogue/typewriterfonts.html}{Typewriter Fonts} for alternatives.  If you like the default \LaTeX\ fonts, the \texpkg{lmodern} package is a good place to start.  The \texpkg{beramono} and \texpkg{courier} packages may also be good options.
% \item \textbf{I receive a ``Too many open files'' error under macOS when using caching.}  See the note on macOS under Section~\ref{sec:configuration:macos}.
% \item \textbf{Weird things happen when I use the \texpkg{fancybox} package.}  \texpkg{fancybox} conflicts with \texpkg{fancyvrb}, which \mintedpkg\ uses internally.  When using \texpkg{fancybox}, make sure that it is loaded before \mintedpkg\ (or before \texpkg{fancyvrb}, if \texpkg{fancyvrb} is not loaded by \mintedpkg).
% \item \textbf{When I use \mintedpkg\ with KOMA-Script document classes, I get warnings about \texttt{\string\float@addtolists}.}  \mintedpkg\ uses the \texpkg{float} package to produce floated listings, but this conflicts with the way KOMA-Script does floats.  Load the package \texpkg{scrhack} to resolve the conflict.  Or use \mintedpkg's |newfloat| package option.
% \item \textbf{Tilde characters \texttt{\string~} are raised, almost like superscripts.}
% This is a font issue.  You need a different font encoding, possibly with a different font.  Try |\usepackage[T1]{fontenc}|, perhaps with |\usepackage{lmodern}|, or something similar.
%
% \item \textbf{I'm getting errors with math, something like \texttt{TeX capacity exceeded} and \texttt{\string\leavevmode \string\kern \string\z@}.}  This is due to ligatures being disabled within verbatim content.  See the note under |escapeinside|.
%
% \item \textbf{With \texttt{mathescape} and the \texpkg{breqn} package (or another special math package), the document never finishes compiling or there are other unexpected results.}  Some math packages like \texpkg{breqn} give certain characters like the comma special meanings in math mode.  These can conflict with \mintedpkg.  In the \texpkg{breqn} and comma case, this can be fixed by redefining the comma within |minted| environments:
%\begin{verbatim}
%\AtBeginEnvironment{minted}{\catcode`\,=12\mathcode`\,="613B}
%\end{verbatim}
%Other packages/special characters may need their own modifications.
%
% \item \textbf{I'm getting errors with Beamer.}  Due to how Beamer treats verbatim content, you may need to use either the |fragile| or |fragile=singleslide| options for frames that contain \mintedpkg\ commands and environments.  |fragile=singleslide| works best, but it disables overlays.  |fragile| works by saving the contents of each frame to a temp file and then reusing them.  This approach allows overlays, but will break if you have the string |\end{frame}| at the beginning of a line (for example, in a |minted| environment).  To work around that, you can indent the content of the environment (so that the |\end{frame}| is preceded by one or more spaces) and then use the |gobble| or |autogobble| options to remove the indentation.
%
% \item \textbf{I'm trying to create several new \mintedpkg\ commands/environments, and want them all to have the same settings.  I'm saving the settings in a macro and then using the macro when defining the commands/environments.  But it's failing.}
% This is due to the way that key-value processing operates. See \href{https://tex.stackexchange.com/questions/13563/building-keyval-arguments-using-a-macro/13564#13564}{this} and \href{https://tex.stackexchange.com/questions/145363/why-does-includegraphics-varone-vartwo-not-compile/145366#145366}{this} for more information.  It is still possible to do what you want; you just need to expand the options macro before passing it to the commands that create the new commands/environments.  An example is shown below.  The |\expandafter| is the vital part.
%\begin{verbatim}
%\def\args{linenos,frame=single,fontsize=\footnotesize,style=bw}
%
%\newcommand{\makenewmintedfiles}[1]{%
%  \newmintedfile[inputlatex]{latex}{#1}%
%  \newmintedfile[inputc]{c}{#1}%
%}
%
%\expandafter\makenewmintedfiles\expandafter{\args}
%\end{verbatim}
%
% \item \textbf{I want to use \texttt{\string\mintinline} in a context that normally doesn't allow verbatim content.}
% The |\mintinline| command will already work in many places that do not allow normal verbatim commands like |\verb|, so make sure to try it first.  If it doesn't work, one of the simplest alternatives is to save your code in a box, and then use it later.  For example,
%\begin{verbatim}
%\newsavebox\mybox
%\begin{lrbox}{\mybox}
%\mintinline{cpp}{std::cout}
%\end{lrbox}
%
%\commandthatdoesnotlikeverbatim{Text \usebox{\mybox}}
%\end{verbatim}
%
% \item \textbf{Extended characters do not work inside \mintedpkg\ commands and environments, even when the \texpkg{inputenc} package is used.}
% Version 2.0 adds support for extended characters under the pdfTeX engine.  But if you need characters that are not supported by \texpkg{inputenc}, you should use the XeTeX or LuaTeX engines instead.
%
% \item \textbf{The \texpkg{polyglossia} package is doing undesirable things to code. (For example, adding extra space around colons in French.)}  You may need to put your code within |\begin{english}...\end{english}|.  This may done for all |minted| environments using \texpkg{etoolbox} in the preamble:
% \begin{verbatim}
%\usepackage{etoolbox}
%\BeforeBeginEnvironment{minted}{\begin{english}}
%\AfterEndEnvironment{minted}{\end{english}}
% \end{verbatim}
%
% \item \begin{sloppypar} \textbf{Tabs are being turned into the character sequence \texttt{\string^\string^I}}.
% This happens when you use XeLaTeX.  You need to use the |-8bit| command-line option so that tabs may be written correctly to temporary files.  See \url{https://tex.stackexchange.com/questions/58732/how-to-output-a-tabulation-into-a-file} for more on XeLaTeX's handling of tab characters. \end{sloppypar}
%
% \item \textbf{The \texpkg{caption} package produces an error when \texttt{\string\captionof} and other commands are used in combination with \mintedpkg.}
% Load the \texpkg{caption} package with the option |compatibility=false|.  Or better yet, use \mintedpkg's |newfloat| package option, which provides better \texpkg{caption} compatibility.
%
% \item \textbf{I need a listing environment that supports page breaks.}  The built-in listing environment is a standard float; it doesn't support page breaks.  You will probably want to define a new environment for long floats.  For example,
%\begin{verbatim}
%\usepackage{caption}
%\newenvironment{longlisting}{\captionsetup{type=listing}}{}
%\end{verbatim}
% With the \texpkg{caption} package, it is best to use \mintedpkg's |newfloat| package option.  See \url{https://tex.stackexchange.com/a/53540/10742} for more on |listing| environments with page breaks.
%
% \item \textbf{I want to use the command-line option \texttt{-output-directory}, or MiKTeX's \texttt{-aux-directory}, but am getting errors.}  With TeX Live 2024+, this should work automatically.  Otherwise, set the environment variable |TEXMF_OUTPUT_DIRECTORY| to the desired location.
%
% \item \textbf{\texttt{minted} environments have extra vertical space inside \texttt{tabular}.}  It is possible to \href{https://github.com/gpoore/minted/issues/82}{create a custom environment} that eliminates the extra space.  However, a general solution that behaves as expected in the presence of adjacent text remains to be found.
% \item \textbf{I'm receiving a warning from \texttt{lineno.sty} that ``Command \texttt{\string\@parboxrestore} has changed.''}  This can happen when \mintedpkg\ is loaded after \texpkg{csquotes}.  Try loading \mintedpkg\ first.  If you receive this message when you are not using \texpkg{csquotes}, you may want to experiment with the order of loading packages and might also open an issue.
% \item \textbf{I'm using \app{texi2pdf}, and getting ``Cannot stat'' errors from \app{tar}}:  This is due to the way that \app{texi2pdf} handles temporary files.  \mintedpkg\ automatically cleans up its temporary files, but \app{texi2pdf} assumes that any temporary file that is ever created will still exist at the end of the run, so it tries to access the files that \mintedpkg\ has deleted. It's possible to disable minted's temp file cleanup by adding |\renewcommand{\DeleteFile}[2][]{}| after the |\usepackage{minted}|.
% \end{itemize}
%
%
%
%
% \section{Acknowledgements}
%
% \textbf{Konrad Rudolph:}  Special thanks to Philipp Stephani and the rest of the guys from \texttt{comp.text.tex} and \texttt{tex.stackexchange.com}.
%
% ~\par
%
% \noindent\textbf{Geoffrey Poore:}
% \begin{itemize}
% \item Thanks to Marco Daniel for the code on \url{tex.stackexchange.com} that inspired automatic line breaking.
% \item Thanks to Patrick Vogt for improving TikZ externalization compatibility.
% \item Thanks to \textsf{@muzimuzhi} for assistance with GitHub issues.
% \item Thanks to \textsf{@jfbu} for suggestions and discussion regarding support for arbitrary Pygments style names (\#210, \#294, \#299, \#317), and for debugging assistance.
% \end{itemize}
%
% \StopEventually{} ^^A\StopEventually{\PrintIndex}
%
%
% \section{Implementation}
%
% \iffalse
%<*package>
% \fi
%
%
%
% \subsection{Required packages}
%
%
%    \begin{macrocode}
\RequirePackage{catchfile}
\RequirePackage{etoolbox}
\RequirePackage{fvextra}[2024/09/05]
\RequirePackage{latex2pydata}[2024/05/16]
\RequirePackage{pdftexcmds}
\RequirePackage{pgfkeys}
\RequirePackage{pgfopts}
\RequirePackage{shellesc}
%    \end{macrocode}
%
% Make sure that either |color| or |xcolor| is loaded by the beginning of the document.
%    \begin{macrocode}
\AtEndPreamble{%
  \IfPackageLoadedTF{color}%
   {}%
   {\IfPackageLoadedTF{xcolor}{}{\RequirePackage{xcolor}}}}
%    \end{macrocode}
%
%
%
% \subsection{Exception handling}
%
%
% \begin{macro}{\minted@error}
%    \begin{macrocode}
\def\minted@error#1{\PackageError{minted}{#1}{}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\minted@fatalerror}
% |\batchmode\read -1 to \minted@fatalerror@exitnow| forces an immediate exit with ``\Verb[breaklines]{! Emergency stop [...] cannot \read from terminal in nonstop modes}.''
%    \begin{macrocode}
\def\minted@fatalerror#1{%
  \minted@error{#1}%
  \batchmode\read -1 to \minted@fatalerror@exitnow}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\minted@warning}
%    \begin{macrocode}
\def\minted@warning#1{\PackageWarning{minted}{#1}}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Python executable and minimum supported version}
%
%
% \begin{macro}{\MintedExecutable}
% Name of \mintedpkg\ Python executable.
%    \begin{macrocode}
\edef\MintedExecutable{\detokenize{latexminted}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@executable@minversion}
%    \begin{macrocode}
\edef\minted@executable@minversion{\detokenize{0.1.0}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@executable@minmajor,\minted@executable@minminor,\minted@executable@minpatch}
%    \begin{macrocode}
\def\minted@executable@setminversioncomponents{%
  \expandafter\minted@executable@setminversioncomponents@i
    \minted@executable@minversion\relax}
\begingroup
\catcode`\.=12
\gdef\minted@executable@setminversioncomponents@i#1.#2.#3\relax{%
  \def\minted@executable@minmajor{#1}%
  \def\minted@executable@minminor{#2}%
  \def\minted@executable@minpatch{#3}}
\endgroup
\minted@executable@setminversioncomponents
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@executable@version}
%    \begin{macrocode}
\let\minted@executable@version\relax
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{minted@executable@exists}
%    \begin{macrocode}
\newbool{minted@executable@exists}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{minted@executable@issupported}
%    \begin{macrocode}
\newbool{minted@executable@issupported}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Timestamp}
%
%
% Timestamp for current compile.  This could eventually be simplified to use |\c_sys_timestamp_str| for all engines; that macro is in \texpkg{l3kernel} from 2023-08-29.
%
% \begin{macro}{\minted@timestamp}
%    \begin{macrocode}
\begingroup
\catcode`\-=12
\catcode`\+=12
\catcode`\:=12
\def\minted@creationdatetotimestamp#1{%
  \expandafter\minted@creationdatetotimestamp@i#1-\relax}
\def\minted@creationdatetotimestamp@i#1:#2-#3\relax{%
  \minted@creationdatetotimestamp@ii#2+\relax}
\def\minted@creationdatetotimestamp@ii#1+#2\relax{%
  #1}
\expandafter\ifx\csname pdftexversion\endcsname\relax
\else
  \xdef\minted@timestamp{\minted@creationdatetotimestamp{\pdfcreationdate}}
\fi
\expandafter\ifx\csname XeTeXrevision\endcsname\relax
\else
  \xdef\minted@timestamp{\minted@creationdatetotimestamp{\creationdate}}
\fi
\expandafter\ifx\csname directlua\endcsname\relax
\else
  \xdef\minted@timestamp{\minted@creationdatetotimestamp{\pdffeedback creationdate}}
\fi
\endgroup
\ifcsname minted@timestamp\endcsname
\else
  \begingroup
  \newcounter{minted@timestamp@hr}
  \newcounter{minted@timestamp@min}
  \setcounter{minted@timestamp@min}{\number\time}
  \loop\unless\ifnum\value{minted@timestamp@min}<60\relax
    \addtocounter{minted@timestamp@hr}{1}
    \addtocounter{minted@timestamp@min}{-60}
  \repeat
  \xdef\minted@timestamp{%
    \the\year
    \ifnum\month<10 0\fi\the\month
    \ifnum\day<10 0\fi\the\day
    \ifnum\value{minted@timestamp@hr}<10 0\fi\theminted@timestamp@hr
    \ifnum\value{minted@timestamp@min}<10 0\fi\theminted@timestamp@min}
  \endgroup
\fi
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Jobname MD5 and derived file names}
%
%
% \begin{macro}{\MintedJobnameMdfive}
% MD5 hash of |\jobname|.  If |\jobname| contains spaces so that \LaTeX\ inserts wrapping quotes (\href{https://tex.stackexchange.com/a/93829/10742}{single} or double) within |\jobname|, these quotes are stripped, so that only the stem (basename without file extension) of the file path is hashed.  This makes it simple to calculate the hash externally outside of \LaTeX.
%
% |\MintedJobnameMdfive| is used for creating temp files rather than |\jobname| to avoid shell escaping issues.  Under restricted shell escape, shell commands are quoted and escaped by \LaTeX\ itself, so using |\jobname| would work correctly in most cases.  However, when full shell escape is enabled, no command escaping is performed by \LaTeX, so \mintedpkg\ would have to quote/escape |\jobname| in a platform-specific manner.  (See for example \href{https://github.com/TeX-Live/texlive-source/blob/e47512fcb293e2390b609bce612449d579efc230/texk/web2c/doc/web2c.info#L1573}{\Verb{web2c.info}} and \href{https://github.com/TeX-Live/texlive-source/blob/e47512fcb293e2390b609bce612449d579efc230/texk/web2c/lib/texmfmp.c#L228}{\Verb{texmfmp.c}} in the TeX Live source for shell escape implementation details.)  It is simpler to avoid escaping issues altogether, including edge cases in the restricted shell escape scenario, by using an MD5 hash that is guaranteed to consist only of ASCII alphanumeric characters.
%    \begin{macrocode}
\begingroup
\catcode`\"=12
\catcode`\'=12
\gdef\minted@setjobnamemdfive#1#2\FV@Sentinel{%
  \ifx#1"\relax
    \let\minted@next\minted@setjobnamemdfive@dquoted
  \else\ifx#1'\relax
    \let\minted@next\minted@setjobnamemdfive@squoted
  \else
    \let\minted@next\minted@setjobnamemdfive@uquoted
  \fi\fi
  \minted@next#1#2\FV@Sentinel}
\gdef\minted@setjobnamemdfive@dquoted#1#2\FV@Sentinel{%
  \minted@setjobnamemdfive@dquoted@i#2"\FV@Sentinel}
\gdef\minted@setjobnamemdfive@dquoted@i#1"#2\FV@Sentinel{%
  \if\relax\detokenize{#2}\relax
    \edef\MintedJobnameMdfive{\pdf@mdfivesum{\jobname}}%
  \else\if\relax\detokenize\expandafter{\@gobble#2}\relax
    \edef\MintedJobnameMdfive{\pdf@mdfivesum{#1}}%
  \else
    \edef\MintedJobnameMdfive{\pdf@mdfivesum{\jobname}}%
  \fi\fi}
\gdef\minted@setjobnamemdfive@squoted#1#2\FV@Sentinel{%
  \minted@setjobnamemdfive@squoted@i#2'\FV@Sentinel}
\gdef\minted@setjobnamemdfive@squoted@i#1'#2\FV@Sentinel{%
  \if\relax\detokenize{#2}\relax
    \edef\MintedJobnameMdfive{\pdf@mdfivesum{\jobname}}%
  \else\if\relax\detokenize\expandafter{\@gobble#2}\relax
    \edef\MintedJobnameMdfive{\pdf@mdfivesum{#1}}%
  \else
    \edef\MintedJobnameMdfive{\pdf@mdfivesum{\jobname}}%
  \fi\fi}
\gdef\minted@setjobnamemdfive@uquoted#1\FV@Sentinel{%
  \edef\MintedJobnameMdfive{\pdf@mdfivesum{#1}}}
\endgroup
\expandafter\minted@setjobnamemdfive\jobname\FV@Sentinel
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\MintedCacheIndexFilename}
% Index file in cache.  Used to detect whether cache exists.
%    \begin{macrocode}
\edef\MintedCacheIndexFilename{%
  \detokenize{_}\MintedJobnameMdfive\detokenize{.index.minted}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\MintedConfigFilename}
% File containing config info such as Python executable version.  Written by the Python side, read by the \LaTeX\ side, and then immediately deleted.
%    \begin{macrocode}
\edef\MintedConfigFilename{%
  \detokenize{_}\MintedJobnameMdfive\detokenize{.config.minted}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\MintedDataFilename}
% Temp file for data.  Written by the \LaTeX\ side, read by the Python side.  Frequently overwritten, so only cleaned up at the end of the compile.
%    \begin{macrocode}
\edef\MintedDataFilename{%
  \detokenize{_}\MintedJobnameMdfive\detokenize{.data.minted}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\MintedErrlogFilename}
% Log file created when the Python side encounters an unexpected error that it is not designed to report to the \LaTeX\ side.
%    \begin{macrocode}
\edef\MintedErrlogFilename{%
  \detokenize{_}\MintedJobnameMdfive\detokenize{.errlog.minted}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\MintedMessageFilename}
% Messages from the Python side to the LaTeX side.  Deleted immediately after reading.
%    \begin{macrocode}
\edef\MintedMessageFilename{%
  \detokenize{_}\MintedJobnameMdfive\detokenize{.message.minted}}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Package options}
%
%
% \begin{macro}{\minted@pgfopts}
%    \begin{macrocode}
\def\minted@pgfopts#1{%
  \pgfkeys{/minted/pkg/.cd,#1}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Package option definitions}
%
%
% \begin{macro}{\minted@float@within}
% Control the section numbering of the |listing| float.
%    \begin{macrocode}
\minted@pgfopts{
  chapter/.code=\def\minted@float@within{chapter},
  chapter/.value forbidden,
  section/.code=\def\minted@float@within{section},
  section/.value forbidden,
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{minted@newfloat}
% Use \texpkg{newfloat} rather than \texpkg{float} to create a floating |listing| environment.
%    \begin{macrocode}
\newbool{minted@newfloat}
\minted@pgfopts{
  newfloat/.is if=minted@newfloat,
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{minted@debug}
% Keep temp files for aid in debugging.
%    \begin{macrocode}
\newbool{minted@debug}
\minted@pgfopts{
  debug/.is if=minted@debug,
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{minted@cache}
% Determine whether highlighted content is cached.
%    \begin{macrocode}
\newbool{minted@cache}
\booltrue{minted@cache}
\minted@pgfopts{
  cache/.is if=minted@cache,
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\minted@cachedir}
% Set the directory in which cached content is saved.
%    \begin{macrocode}
\edef\minted@cachedir{\detokenize{_minted}}
\minted@pgfopts{
  cachedir/.estore in=\minted@cachedir,
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{minted@frozencache}
% When a cache file is missing, raise an error instead of attempting to update the cache.  This is intended for editing a document with a pre-existing cache in an environment in which |\ShellEscape| support is disabled or the \mintedpkg\ executable is not available.
%    \begin{macrocode}
\newbool{minted@frozencache}
\minted@pgfopts{
  frozencache/.is if=minted@frozencache,
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{minted@lexerlinenos}
% Make all |minted| environments and |\mint| commands for a given lexer share cumulative line numbering (if |firstnumber=last|).  |langlinenos| is for backward compatility with \mintedpkg\ v2.
%    \begin{macrocode}
\newbool{minted@lexerlinenos}
\minted@pgfopts{
  lexerlinenos/.is if=minted@lexerlinenos,
  langlinenos/.is if=minted@lexerlinenos,
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{minted@inputlexerlinenos}
% Enable |lexerlinenos| and make it apply to |\inputminted|.  |inputlanglinenos| is for backward compatility with \mintedpkg\ v2.
%    \begin{macrocode}
\newbool{minted@inputlexerlinenos}
\minted@pgfopts{
  inputlexerlinenos/.is if=minted@inputlexerlinenos,
  inputlanglinenos/.is if=minted@inputlexerlinenos,
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{minted@placeholder,\minted@insertplaceholder}
% Cause all commands and environments to insert a placeholder rather than typesetting code.  This functionality is primarily intended for use with PGF/Ti\textit{k}Z externalization, when all non-PGF/Ti\textit{k}Z features should be disabled.
%    \begin{macrocode}
\newbool{minted@placeholder}
\minted@pgfopts{
  placeholder/.is if=minted@placeholder,
}
\gdef\minted@insertplaceholder{%
  \ifbool{minted@isinline}%
   {\begingroup
    \fvset{extra=true}\Verb[formatcom=\color{red}\bfseries]{<MINTED>}%
    \endgroup}%
   {\begingroup
    \par\noindent
    \fvset{extra=true}\Verb[formatcom=\color{red}\bfseries]{<MINTED>}%
    \par
    \endgroup}}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{minted@verbatim}
% Typeset all code verbatim using \texpkg{fancyvrb}; do not use Python at all.
%    \begin{macrocode}
\newbool{minted@verbatim}
\minted@pgfopts{
  verbatim/.is if=minted@verbatim,
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@highlightmode@init,\minted@fasthighlightmode@checkstart,\minted@fasthighlightmode@checkend}
% Determine whether highlighting is performed immediately or at the end of the compile.  Immediately means more overhead during the compile, but no second compile is required.  Highlighting at the end of the compile means a second compile is required, but also makes highlighing much faster since there is only a single |\ShellEscape|.
%
% |\minted@highlightmode@init| is invoked within |\minted@detectconfig| if the Python executable is available and enabled.  For the |fastfirst| case, |\minted@highlightmode@init| requires the |\minted@cachepath| that is set within |\minted@detectconfig|.
%
% |\minted@fasthighlightmode@checkend| is invoked |\AfterEndDocument| with |\minted@clean|; the |\AtEndDocument| is created with the definition of |\minted@clean| so that everything is in the correct order.
%    \begin{macrocode}
\newbool{minted@fasthighlightmode}
\newbool{minted@fasthighlightmode@open}
\minted@pgfopts{
  highlightmode/.is choice,
  highlightmode/fast/.code=
    \let\minted@highlightmode@init\minted@highlightmode@init@fast,
  highlightmode/fastfirst/.code=
    \let\minted@highlightmode@init\minted@highlightmode@init@fastfirst,
  highlightmode/immediate/.code=
    \let\minted@highlightmode@init\minted@highlightmode@init@immediate,
}
\def\minted@highlightmode@init@fast{%
  \global\booltrue{minted@fasthighlightmode}}
\def\minted@highlightmode@init@fastfirst{%
  \IfFileExists{\minted@cachepath\MintedCacheIndexFilename}%
   {\global\boolfalse{minted@fasthighlightmode}}
   {\global\booltrue{minted@fasthighlightmode}}}
\def\minted@highlightmode@init@immediate{%
  \global\boolfalse{minted@fasthighlightmode}}
\let\minted@highlightmode@init\minted@highlightmode@init@fastfirst
\def\minted@fasthighlightmode@checkstart{%
  \ifbool{minted@fasthighlightmode}%
   {\pydatawritelistopen
    \global\booltrue{minted@fasthighlightmode@open}}%
   {}%
  \global\let\minted@fasthighlightmode@checkstart\relax}
\def\minted@fasthighlightmode@checkend{%
  \ifbool{minted@fasthighlightmode@open}%
   {\pydatasetfilename{\MintedDataFilename}%
    \pydatawritelistclose
    \pydataclosefilename{\MintedDataFilename}%
    \global\boolfalse{minted@fasthighlightmode@open}%
    \global\boolfalse{minted@fasthighlightmode}%
    \begingroup
    \minted@exec@batch
    \ifx\minted@exec@warning\relax
    \else
      \expandafter\minted@exec@warning
    \fi
    \ifx\minted@exec@error\relax
    \else
      \expandafter\minted@exec@error
    \fi
    \endgroup
    \global\boolfalse{minted@canexec}}%
   {}%
  \global\let\minted@fasthighlightmode@checkend\relax}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsubsection{Package options that are no longer supported or deprecated}
%
%
% \paragraph{finalizecache}
% Old, no longer needed option from \mintedpkg\ v2.
%    \begin{macrocode}
\minted@pgfopts{
  finalizecache/.code=\minted@error{%
    Package option "finalizecache" is no longer needed with minted v3+},
}
%    \end{macrocode}
%
%
% \paragraph{kpsewhich}
% Old, no longer needed option from \mintedpkg\ v2.
%    \begin{macrocode}
\minted@pgfopts{
  kpsewhich/.code=\minted@error{%
    Package option "kpsewhich" is no longer needed with minted v3+},
}
%    \end{macrocode}
%
%
% \paragraph{outputdir}
% Old, no longer needed option from \mintedpkg\ v2.
%
% The empty |\minted@outputdir| is for backward compatibility with packages that depend on \mintedpkg\ v2 internals.
%    \begin{macrocode}
\minted@pgfopts{
  outputdir/.code=\minted@error{%
    Package option "outputdir" is no longer needed with minted v3+;
    the output directory is automatically detected for TeX Live 2024+,
    and the environment variable \detokenize{TEXMF_OUTPUT_DIRECTORY}
    can be set manually in other cases},
}
\def\minted@outputdir{}
%    \end{macrocode}
%
%
% \paragraph{draft}
% Old, no longer supported option from \mintedpkg\ v2.  Improvements in caching combined with the new \mintedpkg\ v3 package options |placeholder| and |verbatim| provide better alternatives.
%    \begin{macrocode}
\minted@pgfopts{
  draft/.code=\minted@warning{%
    Package option "draft" no longer has any effect with minted v3+},
}
%    \end{macrocode}
%
% \paragraph{final}
% Old, no longer supported option from \mintedpkg\ v2.  Improvements in caching combined with the new \mintedpkg\ v3 package options |placeholder| and |verbatim| provide better alternatives.
%    \begin{macrocode}
\minted@pgfopts{
  final/.code=\minted@warning{%
    Package option "final" no longer has any effect with minted v3+},
}
%    \end{macrocode}
%
%
%
% \subsubsection{Package option processing}
%
%
%    \begin{macrocode}
\ProcessPgfOptions{/minted/pkg}
\ifbool{minted@cache}{}{\def\minted@cachedir{}}%
\ifbool{minted@newfloat}{\RequirePackage{newfloat}}{\RequirePackage{float}}
\ifcsname tikzifexternalizing\endcsname
  \ifx\tikzifexternalizing\relax
  \else
    \tikzifexternalizing{\booltrue{minted@placeholder}}{}
  \fi
\fi
%    \end{macrocode}
%
%
%
% \subsection{Util}
%
%
% \begin{macro}{\minted@styleprefix}
% Prefix for generating Pygments style names.
%    \begin{macrocode}
\def\minted@styleprefix{PYG}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{minted@tmpcnt}
% Temp counter.
%    \begin{macrocode}
\newcounter{minted@tmpcnt}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@forcsvlist}
% Wrapper for \texpkg{etoolbox} |\forcsvlist|.  Syntax:  |\minted@forcsvlist|\marg{handler}\marg{listmacro}.
%    \begin{macrocode}
\def\minted@forcsvlist#1#2{%
  \if\relax\detokenize\expandafter{\@gobble#2}\relax
    \expandafter\minted@forcsvlist@exp
  \else
    \expandafter\minted@forcsvlist@i
  \fi
  {#2}{#1}}
\def\minted@forcsvlist@exp#1#2{%
  \expandafter\minted@forcsvlist@i\expandafter{#1}{#2}}
\def\minted@forcsvlist@i#1#2{%
  \forcsvlist{#2}{#1}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@apptoprovidecs}
%    \begin{macrocode}
\def\minted@apptoprovidecs#1#2{%
  \ifcsname#1\endcsname
  \else
    \expandafter\def\csname#1\endcsname{}%
  \fi
  \expandafter\let\expandafter\minted@tmp\csname#1\endcsname
  \expandafter\def\expandafter\minted@tmp\expandafter{\minted@tmp#2}%
  \expandafter\let\csname#1\endcsname\minted@tmp}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@const@pgfkeysnovalue}
%    \begin{macrocode}
\def\minted@const@pgfkeysnovalue{\pgfkeysnovalue}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@ensureatletter}
%    \begin{macrocode}
\def\minted@ensureatletter#1{%
  \edef\minted@tmpatcat{\the\catcode`\@}%
  \catcode`\@=11\relax
  #1%
  \catcode`\@=\minted@tmpatcat\relax}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsubsection{Check whether a string matches the regex \Verb{^[0-9A-Za-z_-]+$}}
%
% These macros are used to restrict possible names of highlighting styles on the \LaTeX\ side.
%
% \begin{macro}{\minted@is\detokenize{<char_category><codepoint_decimal>}}
% Create macros used in determining whether a given character is part of a specified set of characters.
%    \begin{macrocode}
% [0-9]
\setcounter{minted@tmpcnt}{48}
\loop\unless\ifnum\value{minted@tmpcnt}>57\relax
  \expandafter\let\csname minted@isnum\arabic{minted@tmpcnt}\endcsname\relax
  \expandafter\let\csname minted@isalphanum\arabic{minted@tmpcnt}\endcsname\relax
  \expandafter\let
    \csname minted@isalphanumhyphenunderscore\arabic{minted@tmpcnt}\endcsname\relax
  \stepcounter{minted@tmpcnt}
\repeat
% [A-Z]
\setcounter{minted@tmpcnt}{65}
\loop\unless\ifnum\value{minted@tmpcnt}>90\relax
  \expandafter\let\csname minted@isalpha\arabic{minted@tmpcnt}\endcsname\relax
  \expandafter\let\csname minted@isalphanum\arabic{minted@tmpcnt}\endcsname\relax
  \expandafter\let
    \csname minted@isalphanumhyphenunderscore\arabic{minted@tmpcnt}\endcsname\relax
  \stepcounter{minted@tmpcnt}
\repeat
% [a-z]
\setcounter{minted@tmpcnt}{97}
\loop\unless\ifnum\value{minted@tmpcnt}>122\relax
  \expandafter\let\csname minted@isalpha\arabic{minted@tmpcnt}\endcsname\relax
  \expandafter\let\csname minted@isalphanum\arabic{minted@tmpcnt}\endcsname\relax
  \expandafter\let
    \csname minted@isalphanumhyphenunderscore\arabic{minted@tmpcnt}\endcsname\relax
  \stepcounter{minted@tmpcnt}
\repeat
% [-]
\expandafter\let\csname minted@isalphanumhyphenunderscore45\endcsname\relax
% [_]
\expandafter\let\csname minted@isalphanumhyphenunderscore95\endcsname\relax
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@ifalphanumhyphenunderscore}
% Conditional based on whether first argument is ASCII alphanumeric, hyphen, or underscore.
%    \begin{macrocode}
\def\minted@ifalphanumhyphenunderscore#1#2#3{%
  \if\relax\detokenize{#1}\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {#3}%
  {\expandafter\minted@ifalphanumhyphenunderscore@i\detokenize{#1}\FV@Sentinel{#2}{#3}}}
\def\minted@ifalphanumhyphenunderscore@i#1#2\FV@Sentinel{%
  \if\relax#2\relax
    \expandafter\minted@ifalphanumhyphenunderscore@iii
  \else
    \expandafter\minted@ifalphanumhyphenunderscore@ii
  \fi
  #1#2\FV@Sentinel}
\def\minted@ifalphanumhyphenunderscore@ii#1#2\FV@Sentinel{%
  \ifcsname minted@isalphanumhyphenunderscore\number`#1\endcsname
    \expandafter\minted@ifalphanumhyphenunderscore@i
  \else
    \expandafter\minted@ifalphanumhyphenunderscore@false
  \fi
  #2\FV@Sentinel}
\def\minted@ifalphanumhyphenunderscore@iii#1\FV@Sentinel{%
  \ifcsname minted@isalphanumhyphenunderscore\number`#1\endcsname
    \expandafter\minted@ifalphanumhyphenunderscore@true
  \else
    \expandafter\minted@ifalphanumhyphenunderscore@false
  \fi
  \FV@Sentinel}
\def\minted@ifalphanumhyphenunderscore@true\FV@Sentinel#1#2{#1}
\def\minted@ifalphanumhyphenunderscore@false#1\FV@Sentinel#2#3{#3}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{State}
%
%
% \begin{macro}{\minted@lexer}
% Current lexer (language).  Should be the empty macro if not set; it is used within |\ifcsname...\endcsname| to check for the existence of lexer-specific settings macros.
%    \begin{macrocode}
\let\minted@lexer\@empty
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{minted@isinline}
% Whether in command or environment.
%    \begin{macrocode}
\newbool{minted@isinline}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{minted@tmpcodebufferlength}
% Length of buffer in which code to be highlighted is stored.
%    \begin{macrocode}
\newcounter{minted@tmpcodebufferlength}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Calling \mintedpkg\ executable}
%
%
% \begin{macro}{minted@canexec}
%    \begin{macrocode}
\newbool{minted@canexec}
\booltrue{minted@canexec}
\ifnum\csname c_sys_shell_escape_int\endcsname=0\relax
  \boolfalse{minted@canexec}
\fi
\ifbool{minted@frozencache}{\boolfalse{minted@canexec}}{}
\ifbool{minted@placeholder}{\boolfalse{minted@canexec}}{}
\ifbool{minted@verbatim}{\boolfalse{minted@canexec}}{}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@ShellEscapeMaybeMessages,\minted@ShellEscapeNoMessages}
%    \begin{macrocode}
\def\minted@ShellEscapeMaybeMessages#1{%
  \let\minted@exec@warning\relax
  \let\minted@exec@error\relax
  \ifbool{minted@canexec}{\ShellEscape{#1}\minted@inputexecmessages}{}}
\def\minted@ShellEscapeNoMessages#1{%
  \ifbool{minted@canexec}{\ShellEscape{#1}}{}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@execarg@debug,\minted@execarg@timestamp}
%    \begin{macrocode}
\def\minted@execarg@debug{%
  \ifbool{minted@debug}{\detokenize{ --debug }}{}}
\def\minted@execarg@timestamp{%
  \detokenize{ --timestamp }\minted@timestamp\detokenize{ }}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@exec@cleanfile}
% Clean (delete) a temp file in all locations where it might be expected to exist.  Only files under the working directory, |TEXMFOUTPUT|, or |TEXMF_OUTPUT_DIRECTORY| can be cleaned, and only if their names match the regex
%\begin{verbatim}
%[0-9a-zA-Z_-]+\.(?:config|data|errlog|highlight|message|style)\.minted
%\end{verbatim}
% The identifier immediately before the |.minted| file extension describes the role of the file.  Files ending with |.errlog.minted| are not automatically cleaned up at the end of a compile, but are deleted at the beginning as part of config detection.
%    \begin{macrocode}
\def\minted@exec@cleanfile#1{%
  \minted@ShellEscapeNoMessages{%
    \MintedExecutable\detokenize{ cleanfile }\minted@execarg@debug#1}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@inputexecmessages}
% If temp file containing warning and/or error messages exists, |\input| and then delete.
%   \begin{macrocode}
\def\minted@inputexecmessages{%
  \minted@ensureatletter{\InputIfFileExists{\MintedMessageFilename}{}{}}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@exec@batch}
% Run in batch mode, for |highlightmode=fast| or |highlightmode=fastfirst|.
%    \begin{macrocode}
\def\minted@exec@batch{%
  \minted@ShellEscapeMaybeMessages{%
    \MintedExecutable
    \detokenize{ batch }\minted@execarg@timestamp\minted@execarg@debug
    \MintedJobnameMdfive}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@exec@config}
% Detect configuration.
%    \begin{macrocode}
\def\minted@exec@config{%
  \minted@ShellEscapeMaybeMessages{%
    \MintedExecutable
    \detokenize{ config }\minted@execarg@timestamp\minted@execarg@debug
    \MintedJobnameMdfive}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@exec@styledef}
% Create style definition.
%    \begin{macrocode}
\def\minted@exec@styledef{%
  \minted@ShellEscapeMaybeMessages{%
    \MintedExecutable
    \detokenize{ styledef }\minted@execarg@timestamp\minted@execarg@debug
    \MintedJobnameMdfive}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@exec@highlight}
% Highlight code.
%    \begin{macrocode}
\def\minted@exec@highlight{%
  \minted@ShellEscapeMaybeMessages{%
    \MintedExecutable
    \detokenize{ highlight }\minted@execarg@timestamp\minted@execarg@debug
    \MintedJobnameMdfive}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@exec@clean}
% Clean output directory and cache.
%    \begin{macrocode}
\def\minted@exec@clean{%
  \minted@ShellEscapeNoMessages{%
    \MintedExecutable
    \detokenize{ clean }\minted@execarg@timestamp\minted@execarg@debug
    \MintedJobnameMdfive}}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Config detection}
%
%
% \begin{macro}{minted@diddetectconfig}
%    \begin{macrocode}
\newbool{minted@diddetectconfig}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@detectconfig}
% When the |minted@canexec| bool is defined, it is set false if shell escape is completely disabled (|\c_sys_shell_escape_int=0|) or if execution is disabled by package options, so those cases don't need to be handled here.
%
% If the Python executable is available, then it will create a |.config.minted| file to notify the \LaTeX\ side that it is present.  This |.config.minted| file always contains a timestamp |\minted@executable@timestamp|, which is the timestamp passed directly to the executable as a command-line option.  If the executable finds a |.data.minted| file, then it will extract the timestamp from this file and save it in the |.config.minted| file as |\minted@config@timestamp|; otherwise, the |.config.minted| file will not contain this timestamp.  When \LaTeX\ loads the |.config.minted| file, the presence and values of these timestamps is used to determine whether the executable is present and whether the correct |.data.minted| file was located by the executable.
%    \begin{macrocode}
\def\minted@detectconfig{%
  \ifbool{minted@diddetectconfig}%
   {}%
   {\ifx\minted@cachedir\@empty
      \gdef\minted@cachepath{}%
    \else
      \gdef\minted@cachepath{\minted@cachedir/}%
    \fi
    \ifbool{minted@canexec}{\begingroup\minted@detectconfig@i\endgroup}{}%
    \global\booltrue{minted@diddetectconfig}}}
\def\minted@detectconfig@i{%
  \global\let\minted@executable@version\relax
  \global\let\minted@executable@timestamp\relax
  \global\let\minted@config@timestamp\relax
  \pydatasetfilename{\MintedDataFilename}%
  \pydatawritedictopen
  \pydatawritekeyvalue{command}{config}%
  \pydatawritekeyedefvalue{jobname}{\jobname}%
  \pydatawritekeyedefvalue{timestamp}{\minted@timestamp}%
  \pydatawritekeyedefvalue{cachedir}{\minted@cachedir}%
  \pydatawritedictclose
  \pydataclosefilename{\MintedDataFilename}%
  \minted@exec@config
  \minted@ensureatletter{%
    \InputIfFileExists{\MintedConfigFilename}{}{}}%
  \ifx\minted@executable@version\relax
    \expandafter\minted@detectconfig@noexecutable
  \else
    \expandafter\minted@detectconfig@ii
  \fi}
\def\minted@detectconfig@noexecutable{%
  \global\boolfalse{minted@canexec}%
  \ifnum\csname c_sys_shell_escape_int\endcsname=1\relax
    \minted@error{minted v3+ executable is not installed or is not added to PATH}%
  \else
    \minted@error{minted v3+ executable is not installed, is not added to PATH,
      or is not permitted with restricted shell escape}%
  \fi}
\def\minted@detectconfig@ii{%
  \ifx\minted@timestamp\minted@config@timestamp
    \expandafter\minted@detectconfig@iii
  \else
    \expandafter\minted@detectconfig@wrongtimestamp
  \fi}
\def\minted@detectconfig@wrongtimestamp{%
  \ifx\minted@timestamp\minted@executable@timestamp
    \minted@exec@cleanfile{\MintedConfigFilename}%
    \global\boolfalse{minted@canexec}%
    \minted@error{minted v3 Python executable could not find output directory;
      upgrade to TeX distribution that supports \detokenize{TEXMF_OUTPUT_DIRECTORY}
      or set environment variable \detokenize{TEXMF_OUTPUT_DIRECTORY} manually)}%
  \else
    \expandafter\minted@detectconfig@noexecutable
  \fi}
\def\minted@detectconfig@iii{%
  \minted@exec@cleanfile{\MintedConfigFilename}%
  \ifx\minted@exec@warning\relax
  \else
    \expandafter\minted@exec@warning
  \fi
  \ifx\minted@exec@error\relax
    \expandafter\minted@detectconfig@iv
  \else
    \expandafter\minted@detectconfig@error
  \fi}
\def\minted@detectconfig@error{%
  \global\boolfalse{minted@canexec}%
  \minted@exec@error}
\def\minted@detectconfig@iv{%
  \expandafter\minted@detectconfig@v\minted@executable@version\relax}
\begingroup
\catcode`\.=12
\gdef\minted@detectconfig@v#1.#2.#3\relax{%
  \def\minted@executable@major{#1}%
  \def\minted@executable@minor{#2}%
  \def\minted@executable@patch{#3}%
  \minted@detectconfig@vi}
\endgroup
\def\minted@detectconfig@vi{%
  \ifnum\minted@executable@major>\minted@executable@minmajor\relax
    \global\booltrue{minted@executable@issupported}%
  \else\ifnum\minted@executable@major=\minted@executable@minmajor\relax
    \ifnum\minted@executable@minor>\minted@executable@minminor\relax
      \global\booltrue{minted@executable@issupported}%
    \else\ifnum\minted@executable@minor=\minted@executable@minminor\relax
      \ifnum\minted@executable@patch<\minted@executable@minpatch\relax
      \else
        \global\booltrue{minted@executable@issupported}%
      \fi
    \fi\fi
  \fi\fi
  \ifbool{minted@executable@issupported}%
   {\ifx\minted@config@cachepath\relax
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi
    {\global\boolfalse{minted@canexec}%
      \minted@error{minted Python executable returned incomplete configuration data;
        this may indicate a bug in minted or file corruption}}%
    {\global\let\minted@cachepath\minted@config@cachepath
     \minted@highlightmode@init}}%
   {\global\boolfalse{minted@canexec}%
    \minted@error{minted Python executable is version \minted@executable@version,
      but version \minted@executable@minversion+ is required}}}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Options}
%
%
% \subsubsection{Option processing}
%
% \begin{macro}{\minted@optcats,\minted@optkeyslist@<optcat>}
% Option categories, along with lists of keys for each.
% \begin{itemize}
% \item |fv|:  Passed on to \texpkg{fancyvrb}.  Options are stored in scope-specific lists, rather than in individual per-option macros.
% \item |py|:  Passed to Python.  Options are stored in scope-specific, individual per-option macros.  Some of these are passed to \texpkg{fancyvrb} when the Python executable isn't available or is disabled.
% \item |tex|:  Processed in \LaTeX.  Options are stored in scope-specific, individual per-option macros.
% \end{itemize}
%    \begin{macrocode}
\begingroup
\catcode`\,=12
\gdef\minted@optcats{fv,py,tex}
\endgroup
\def\minted@do#1{\expandafter\def\csname minted@optkeyslist@#1\endcsname{}}
\minted@forcsvlist{\minted@do}{\minted@optcats}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@optscopes,\minted@optscopes@onlyblock}
% Scopes for options.  |cmd| scope is the scope of a single command or environment.
%    \begin{macrocode}
\begingroup
\catcode`\,=12
\gdef\minted@optscopes{global,lexer,globalinline,lexerinline,cmd}
\gdef\minted@optscopes@onlyblock{global,lexer,cmd}
\endgroup
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\minted@iflexerscope}
%    \begin{macrocode}
\let\minted@iflexerscope@lexer\relax
\let\minted@iflexerscope@lexerinline\relax
\def\minted@iflexerscope#1#2#3{%
  \ifcsname minted@iflexerscope@#1\endcsname
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {#2}{#3}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\mintedpgfkeyscreate}
% Core macro for defining options.
%
% Syntax: |\mintedpgfkeyscreate|\oarg{processor}\marg{option category}\marg{key(=value)? list}.
% \begin{itemize}
% \item Optional \meta{processor} is a macro that processes \meta{value}.  It can take two forms.
%   \begin{enumerate}
%   \item It can take a single argument.  In this case, it is used to wrap \meta{value}:  |\processor|\marg{value}.  It is not invoked until \meta{value} wrapped in \meta{processor} is actually used.
%   \item It can take two arguments.  The first is the \meta{csname} that the processed \meta{value} should be stored in, and the second is \meta{value}.  In this case, \meta{processor} is invoked immediately and stores the processed \meta{value} in \meta{csname}.  See |\minted@opthandler@deforrestrictedescape| for an example of implementing this sort of \meta{processor}.
%   \end{enumerate}
% \meta{processor} is only supported for |py| and |tex| options.
% \item \meta{option category} is |fv| (for \texpkg{fancyvrb}), |py| (Python side of \mintedpkg), or |tex| (\LaTeX\ side of \mintedpkg).
% \item If only \meta{key} is given, then \meta{value} defaults to |\pgfkeysnovalue|.  In that case, options are defined so that they can be used in the future, but they are ignored until an explicit \meta{value} is provided later.  |fv| options are typically  defined only with \meta{key}.  |py| and |tex| options are currently required to have an initial \meta{value}.  If a \meta{key} is given an initial \meta{value} when it is defined, then that \meta{value} is stored for the \meta{key} in the |global| scope.  When an initial value is needed for a different scope such as |lexer| or |inline|, |\pgfkeys| is used directly (|\setminted| and |\setmintedinline| don't yet exist).
% \item |py| only:  A default value for \meta{key} (value used when only \meta{key} is given without a value) can be specified with the syntax |key<default>=value|.  Default values for |fv| options are already defined in \texpkg{fancyvrb}, and currently the few |tex| options are the sort that always need an explicit value for clarity.
% \end{itemize}
%    \begin{macrocode}
\def\minted@addoptkey#1#2{%
  \ifcsname minted@optkeyslist@#1\endcsname
  \else
    \minted@fatalerror{Defining options under category "#1" is not supported}%
  \fi
  \expandafter\let\expandafter\minted@tmp\csname minted@optkeyslist@#1\endcsname
  \ifx\minted@tmp\@empty
    \def\minted@tmp{#2}%
  \else
    \expandafter\def\expandafter\minted@tmp\expandafter{\minted@tmp,#2}%
  \fi
  \expandafter\let\csname minted@optkeyslist@#1\endcsname\minted@tmp}
\newcommand*{\mintedpgfkeyscreate}[3][]{%
  \mintedpgfkeyscreate@i{#1}{#2}{#3}}
\begingroup
\catcode`\==12
\gdef\mintedpgfkeyscreate@i#1#2#3{%
  \def\minted@do##1{%
    \minted@do@i##1=\FV@Sentinel}%
  \def\minted@do@i##1=##2\FV@Sentinel{%
    \minted@do@ii##1<>\FV@Sentinel}%
  \def\minted@do@ii##1<##2>##3\FV@Sentinel{%
    \minted@addoptkey{#2}{##1}}%
  \minted@forcsvlist{\minted@do}{#3}%
  \csname minted@pgfkeyscreate@#2\endcsname{#1}{#3}}
\endgroup
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@pgfkeyscreate@fv,\minted@fvoptlist@<scope>(@<lexer>)?,\minted@usefvopts,\minted@usefvoptsnopy}
% Syntax: |\minted@pgfkeyscreate@fv|\marg{key(=value)? list}.
%
% Options are stored in scope-specific lists.  They are applied by passing these lists to |\fvset|.  Individual option values are not retrievable.
%
% The |\begingroup\fvset{...}\endgroup| checks \texpkg{fancyvrb} options at definition time so that any errors are caught immediately instead of when the options are used later elsewhere.
%
% |\minted@usefvopts| applies options via |\fvset|.  |\minted@useadditionalfvoptsnopy| applies additional options that are usually handled on the Python side and is intended for situations where Python is not available or is not used, such as purely verbatim typesetting.
%    \begin{macrocode}
\def\minted@pgfkeyscreate@fv#1#2{%
  \if\relax\detokenize{#1}\relax
  \else
    \minted@fatalerror{Processor macros are not supported in defining fancyvrb options}%
  \fi
  \minted@forcsvlist{\minted@pgfkeycreate@fv}{#2}}
\begingroup
\catcode`\==12
\gdef\minted@pgfkeycreate@fv#1{%
  \minted@pgfkeycreate@fv@i#1=\FV@Sentinel}
\gdef\minted@pgfkeycreate@fv@i#1=#2\FV@Sentinel{%
  \if\relax\detokenize{#2}\relax
    \expandafter\minted@pgfkeycreate@fv@ii
  \else
    \expandafter\minted@pgfkeycreate@fv@iii
  \fi
  {#1}#2\FV@Sentinel}
\gdef\minted@pgfkeycreate@fv@ii#1\FV@Sentinel{%
  \minted@pgfkeycreate@fv@iv{#1}{\minted@const@pgfkeysnovalue}}
\gdef\minted@pgfkeycreate@fv@iii#1#2=\FV@Sentinel{%
  \minted@pgfkeycreate@fv@iv{#1}{#2}}
\endgroup
\def\minted@pgfkeycreate@fv@iv#1#2{%
  \def\minted@do##1{%
    \minted@iflexerscope{##1}%
     {\minted@do@i{##1}{@\minted@lexer}}%
     {\minted@do@i{##1}{}}}%
  \def\minted@do@i##1##2{%
    \pgfkeys{%
      /minted/##1/.cd,
      #1/.code=
        \def\minted@tmp{####1}%
        \ifx\minted@tmp\minted@const@pgfkeysnovalue
          \begingroup\fvset{#1}\endgroup
          \minted@apptoprovidecs{minted@fvoptlist@##1##2}{#1,}%
        \else
          \begingroup\fvset{#1=####1}\endgroup
          \minted@apptoprovidecs{minted@fvoptlist@##1##2}{#1=####1,}%
        \fi,
    }%
  }%
  \minted@forcsvlist{\minted@do}{\minted@optscopes}%
  \ifx\minted@const@pgfkeysnovalue#2\relax
  \else
    \pgfkeys{%
      /minted/global/.cd,
      #1=#2,
    }%
  \fi}
\def\minted@usefvopts{%
  \ifbool{minted@isinline}%
   {\minted@forcsvlist{\minted@usefvopts@do}{\minted@optscopes}}%
   {\minted@forcsvlist{\minted@usefvopts@do}{\minted@optscopes@onlyblock}}}
\def\minted@usefvopts@do#1{%
  \minted@iflexerscope{#1}%
   {\ifcsname minted@fvoptlist@#1@\minted@lexer\endcsname
    \expandafter
      \let\expandafter\minted@tmp\csname minted@fvoptlist@#1@\minted@lexer\endcsname
    \expandafter\fvset\expandafter{\minted@tmp}%
    \fi}%
   {\ifcsname minted@fvoptlist@#1\endcsname
    \expandafter
      \let\expandafter\minted@tmp\csname minted@fvoptlist@#1\endcsname
    \expandafter\fvset\expandafter{\minted@tmp}%
    \fi}}
\def\minted@useadditionalfvoptsnopy{%
  \edef\minted@tmp{\mintedpyoptvalueof{gobble}}%
  \ifx\minted@tmp\minted@const@pgfkeysnovalue
  \else
    \expandafter\minted@useadditionalfvoptsnopy@fvsetvk
      \expandafter{\minted@tmp}{gobble}%
  \fi
  \edef\minted@tmp{\mintedpyoptvalueof{mathescape}}%
  \ifx\minted@tmp\minted@const@pgfkeysnovalue
  \else
    \expandafter\minted@useadditionalfvoptsnopy@fvsetvk
      \expandafter{\minted@tmp}{mathescape}%
  \fi}
\def\minted@useadditionalfvoptsnopy@fvsetvk#1#2{%
  \fvset{#2=#1}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@pgfkeyscreate@py,\mintedpyoptvalueof}
% Syntax:  |\minted@pgfkeyscreate@py|\marg{processor}\marg{key(<default>)?=initial value list}.
%
% Currently, initial values are required.  The key processing macros are written to handle the possibility of optional initial values:  If no initial value is set, use |\pgfkeysnovalue|, which is skipped in passing data to the Python side to invoke defaults.
%
% |\mintedpyoptvalueof| is used for retrieving values via |\edef|.
%    \begin{macrocode}
\def\minted@pgfkeyscreate@py#1#2{%
  \minted@forcsvlist{\minted@pgfkeycreate@py{#1}}{#2}}
\begingroup
\catcode`\==12
\catcode`\<=12
\catcode`\>=12
\gdef\minted@pgfkeycreate@py#1#2{%
  \minted@pgfkeycreate@py@i{#1}#2=\FV@Sentinel}
\gdef\minted@pgfkeycreate@py@i#1#2=#3\FV@Sentinel{%
  \if\relax\detokenize{#3}\relax
    \expandafter\minted@pgfkeycreate@py@ii
  \else
    \expandafter\minted@pgfkeycreate@py@iii
  \fi
  {#1}{#2}#3\FV@Sentinel}
\gdef\minted@pgfkeycreate@py@ii#1#2\FV@Sentinel{%
  \minted@pgfkeycreate@py@iv{#1}{\pgfkeysnovalue}#2<>\FV@Sentinel}
\gdef\minted@pgfkeycreate@py@iii#1#2#3=\FV@Sentinel{%
  \minted@pgfkeycreate@py@iv{#1}{#3}#2<>\FV@Sentinel}
\gdef\minted@pgfkeycreate@py@iv#1#2#3<#4>#5\FV@Sentinel{%
  \if\relax\detokenize{#4}\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {\minted@pgfkeycreate@py@v{#1}{#3}{#2}{\minted@const@pgfkeysnovalue}}%
  {\minted@pgfkeycreate@py@v{#1}{#3}{#2}{#4}}}
\endgroup
\def\minted@pgfkeycreate@py@v#1#2#3#4{%
  \def\minted@do##1{%
    \minted@iflexerscope{##1}%
     {\minted@do@i{##1}{@\minted@lexer}}%
     {\minted@do@i{##1}{}}}
  \def\minted@do@i##1##2{%
    \if\relax\detokenize{#1}\relax
      \pgfkeys{%
        /minted/##1/.cd,
        #2/.code=\expandafter\def\csname minted@pyopt@##1##2@#2\endcsname{####1},
      }%
    \else
      \pgfkeys{%
        /minted/##1/.cd,
        #2/.code=
          \def\minted@tmp{####1}%
          \ifx\minted@tmp\minted@const@pgfkeysnovalue
            \expandafter\let\csname minted@pyopt@##1##2@#2\endcsname\minted@tmp
          \else\ifcsname minted@opthandler@immediate@\string#1\endcsname
            #1{minted@pyopt@##1##2@#2}{####1}%
          \else
            \expandafter\def\csname minted@pyopt@##1##2@#2\endcsname{#1{####1}}%
          \fi\fi,
      }%
    \fi
    \ifx\minted@const@pgfkeysnovalue#4\relax
      \pgfkeys{%
        /minted/##1/.cd,
        #2/.value required,
      }%
    \else
      \pgfkeys{%
        /minted/##1/.cd,
        #2/.default=#4,
      }%
    \fi
  }%
  \minted@forcsvlist{\minted@do}{\minted@optscopes}%
  \pgfkeys{%
    /minted/global/.cd,
    #2=#3,
  }}
\def\mintedpyoptvalueof#1{%
  \ifbool{minted@isinline}%
   {\minted@pyoptvalueof@inline{#1}}%
   {\minted@pyoptvalueof@block{#1}}}
\def\minted@pyoptvalueof@inline#1{%
  \ifcsname minted@pyopt@cmd@#1\endcsname
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@pyopt@cmd@#1\endcsname}%
  \else\ifcsname minted@pyopt@lexerinline@\minted@lexer @#1\endcsname
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@pyopt@lexerinline@\minted@lexer @#1\endcsname}%
  \else\ifcsname minted@pyopt@globalinline@#1\endcsname
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@pyopt@globalinline@#1\endcsname}%
  \else\ifcsname minted@pyopt@lexer@\minted@lexer @#1\endcsname
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@pyopt@lexer@\minted@lexer @#1\endcsname}%
  \else
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@pyopt@global@#1\endcsname}%
  \fi\fi\fi\fi}
\def\minted@pyoptvalueof@block#1{%
  \ifcsname minted@pyopt@cmd@#1\endcsname
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@pyopt@cmd@#1\endcsname}%
  \else\ifcsname minted@pyopt@lexer@\minted@lexer @#1\endcsname
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@pyopt@lexer@\minted@lexer @#1\endcsname}%
  \else
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@pyopt@global@#1\endcsname}%
  \fi\fi}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@pgfkeyscreate@tex,\mintedtexoptvalueof,\minted@usetexoptsnonpygments}
% Syntax:  |\minted@pgfkeyscreate@tex|\marg{processor}\marg{key=initial value list}.
%
% Currently, initial values are required.  The key processing macros are written to handle the possibility of optional initial values:  If no initial value is set, use |\pgfkeysnovalue|.
%
% |\mintedtexoptvalueof| is used for retrieving values via |\edef|.
%
% |\minted@usetexoptsnonpygments| applies the |tex| options that aren't used by Pygments.  It is initially empty and is redefined after |tex| options are defined.  Unlike the |\minted@usefvopts| case, it isn't possible to simply loop through all defined options; more specialized per-option handling is required, since some options are handled in separate Pygments-related macros and there is no equivalent of |\fvset|.
%    \begin{macrocode}
\def\minted@pgfkeyscreate@tex#1#2{%
  \minted@forcsvlist{\minted@pgfkeycreate@tex{#1}}{#2}}
\begingroup
\catcode`\==12
\gdef\minted@pgfkeycreate@tex#1#2{%
  \minted@pgfkeycreate@tex@i{#1}#2=\FV@Sentinel}
\gdef\minted@pgfkeycreate@tex@i#1#2=#3\FV@Sentinel{%
  \if\relax\detokenize{#3}\relax
    \expandafter\minted@pgfkeycreate@tex@ii
  \else
    \expandafter\minted@pgfkeycreate@tex@iii
  \fi
  {#1}{#2}#3\FV@Sentinel}
\gdef\minted@pgfkeycreate@tex@ii#1#2\FV@Sentinel{%
  \minted@pgfkeycreate@tex@iv{#1}{#2}{\pgfkeysnovalue}}
\gdef\minted@pgfkeycreate@tex@iii#1#2#3=\FV@Sentinel{%
  \minted@pgfkeycreate@tex@iv{#1}{#2}{#3}}
\endgroup
\def\minted@pgfkeycreate@tex@iv#1#2#3{%
  \def\minted@do##1{%
    \minted@iflexerscope{##1}%
     {\minted@do@i{##1}{@\minted@lexer}}%
     {\minted@do@i{##1}{}}}
  \def\minted@do@i##1##2{%
    \if\relax\detokenize{#1}\relax
      \pgfkeys{%
        /minted/##1/.cd,
        #2/.code=\expandafter\def\csname minted@texopt@##1##2@#2\endcsname{####1},
        #2/.value required,
      }%
    \else
      \pgfkeys{%
        /minted/##1/.cd,
        #2/.code=
          \def\minted@tmp{####1}%
          \ifx\minted@tmp\minted@const@pgfkeysnovalue
            \expandafter\let\csname minted@texopt@##1##2@#2\endcsname\minted@tmp
          \else\ifcsname minted@opthandler@immediate@\string#1\endcsname
            #1{minted@texopt@##1##2@#2}{####1}%
          \else
            \expandafter\def\csname minted@texopt@##1##2@#2\endcsname{#1{####1}}%
          \fi\fi,
        #2/.value required,
      }%
    \fi
  }%
  \minted@forcsvlist{\minted@do}{\minted@optscopes}%
  \pgfkeys{%
    /minted/global/.cd,
    #2=#3,
  }}
\def\mintedtexoptvalueof#1{%
  \ifbool{minted@isinline}%
   {\minted@texoptvalueof@inline{#1}}%
   {\minted@texoptvalueof@block{#1}}}
\def\minted@texoptvalueof@inline#1{%
  \ifcsname minted@texopt@cmd@#1\endcsname
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@texopt@cmd@#1\endcsname}%
  \else\ifcsname minted@texopt@lexerinline@\minted@lexer @#1\endcsname
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@texopt@lexerinline@\minted@lexer @#1\endcsname}%
  \else\ifcsname minted@texopt@globalinline@#1\endcsname
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@texopt@globalinline@#1\endcsname}%
  \else\ifcsname minted@texopt@lexer@\minted@lexer @#1\endcsname
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@texopt@lexer@\minted@lexer @#1\endcsname}%
  \else
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@texopt@global@#1\endcsname}%
  \fi\fi\fi\fi}
\def\minted@texoptvalueof@block#1{%
  \ifcsname minted@texopt@cmd@#1\endcsname
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@texopt@cmd@#1\endcsname}%
  \else\ifcsname minted@texopt@lexer@\minted@lexer @#1\endcsname
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@texopt@lexer@\minted@lexer @#1\endcsname}%
  \else
    \unexpanded\expandafter\expandafter\expandafter{%
      \csname minted@texopt@global@#1\endcsname}%
  \fi\fi}
\def\minted@usetexoptsnonpygments{}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsubsection{Option handlers}
%
%
% \begin{macro}{\minted@opthandler@deforrestrictedescape}
% Syntax:  |\minted@opthandler@deforrestrictedescape|\marg{csname}\marg{value}.  \meta{value} is processed and then the result is stored in \meta{csname}.
%
% Leave \meta{value} unchanged if a single macro.  Otherwise process it with |\FVExtraDetokenizeREscVArg|, which performs backslash escapes but restricted to ASCII symbols and punctuation.  This guarantees exact output (no issues with spaces due to detokenizing alphabetical control sequences).
%
% The |\minted@opthandler@immediate@<macro_name>| tells option processing to invoke the macro immediately, instead of simply storing it as a value wrapper that will only be invoked when the value is used.  This provides immediate error messages in the event of invalid escapes.  |\FVExtraDetokenizeREscVArg| is not fully expandable, so waiting to invoke it later when \meta{value} is expanded (|\edef|) isn't an option.
%    \begin{macrocode}
\def\minted@opthandler@deforrestrictedescape#1#2{%
  \if\relax\detokenize{#2}\relax
    \expandafter\def\csname#1\endcsname{#2}%
  \else\if\relax\detokenize\expandafter{\@gobble#2}\relax
    \ifcat\relax\noexpand#2%
      \expandafter\expandafter\expandafter\minted@opthandler@deforrestrictedescape@i
        \expandafter\@gobble\string#2\FV@Sentinel{#1}{#2}%
    \else
      \FVExtraDetokenizeREscVArg{\expandafter\def\csname#1\endcsname}{#2}%
    \fi
  \else
    \FVExtraDetokenizeREscVArg{\expandafter\def\csname#1\endcsname}{#2}%
  \fi\fi}
\def\minted@opthandler@deforrestrictedescape@i#1#2\FV@Sentinel#3#4{%
  \ifcsname minted@isalpha\number`#1\endcsname
    \expandafter\def\csname#3\endcsname{#4}%
  \else
    \FVExtraDetokenizeREscVArg{\expandafter\def\csname#3\endcsname}{#4}%
  \fi}
\expandafter\let\csname
  minted@opthandler@immediate@\string\minted@opthandler@deforrestrictedescape
  \endcsname\relax
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsubsection{Option definitions}
%
%
% \paragraph{\texpkg{fancyvrb}}
% \begin{itemize}
% \item |tabcolor|:  Visible tabs should have a specified color so that they don't change colors when used to indent multiline strings or comments.
% \end{itemize}
%    \begin{macrocode}
\mintedpgfkeyscreate{fv}{
  baselinestretch,
  beameroverlays,
  backgroundcolor,
  backgroundcolorvphantom,
  bgcolor,
  bgcolorpadding,
  bgcolorvphantom,
  breakafter,
  breakafterinrun,
  breakaftersymbolpost,
  breakaftersymbolpre,
  breakanywhere,
  breakanywhereinlinestretch,
  breakanywheresymbolpost,
  breakanywheresymbolpre,
  breakautoindent,
  breakbefore,
  breakbeforeinrun,
  breakbeforesymbolpost,
  breakbeforesymbolpre,
  breakbytoken,
  breakbytokenanywhere,
  breakindent,
  breakindentnchars,
  breaklines,
  breaksymbol,
  breaksymbolindent,
  breaksymbolindentleft,
  breaksymbolindentleftnchars,
  breaksymbolindentnchars,
  breaksymbolindentright,
  breaksymbolindentrightnchars,
  breaksymbolleft,
  breaksymbolright,
  breaksymbolsep,
  breaksymbolsepleft,
  breaksymbolsepleftnchars,
  breaksymbolsepnchars,
  breaksymbolsepright,
  breaksymbolseprightnchars,
  curlyquotes,
  fillcolor,
  firstline,
  firstnumber,
  fontencoding,
  fontfamily,
  fontseries,
  fontshape,
  fontsize,
  formatcom,
  frame,
  framerule,
  framesep,
  highlightcolor,
  highlightlines,
  label,
  labelposition,
  lastline,
  linenos,
  listparameters,
  numberblanklines,
  numberfirstline,
  numbers,
  numbersep,
  obeytabs,
  resetmargins,
  rulecolor,
  samepage,
  showspaces,
  showtabs,
  space,
  spacecolor,
  stepnumber,
  stepnumberfromfirst,
  stepnumberoffsetvalues,
  tab,
  tabcolor=black,
  tabsize,
  xleftmargin,
  xrightmargin,
}
%    \end{macrocode}
%
% \paragraph{\mintedpkg\ (passed to Python)}
% \begin{itemize}
% \item PHP should use |startinline| for |\mintinline|.
% \end{itemize}
%    \begin{macrocode}
\mintedpgfkeyscreate{py}{
  autogobble<true>=false,
  encoding=utf8,
  funcnamehighlighting<true>=true,
  gobble=0,
  gobblefilter=0,
  keywordcase=none,
  literalenvname=MintedVerbatim,
  mathescape<true>=false,
  python3<true>=true,
  rangeregexmatchnumber=1,
  rangeregexdotall<true>=false,
  rangeregexmultiline<true>=false,
  startinline<true>=false,
  stripall<true>=false,
  stripnl<true>=false,
  texcl<true>=false,
  texcomments<true>=false,
}
\mintedpgfkeyscreate[\minted@opthandler@deforrestrictedescape]{py}{
  codetagify=,
  escapeinside=,
  literatecomment=,
  rangestartstring=,
  rangestartafterstring=,
  rangestopstring=,
  rangestopbeforestring=,
  rangeregex=,
}
\let\minted@tmplexer\minted@lexer
\def\minted@lexer{php}
\pgfkeys{
  /minted/lexerinline/.cd,
  startinline=true,
}
\let\minted@lexer\minted@tmplexer
%    \end{macrocode}
%
% \paragraph{\mintedpkg\ (kept in \LaTeX)}
% \begin{itemize}
% \item The |\minted@def@optcl| is for backward compatibility with versions of \texpkg{tcolorbox} that used this to define an |envname| option under \mintedpkg\ v2.
% \end{itemize}
%    \begin{macrocode}
\mintedpgfkeyscreate{tex}{
  envname=Verbatim,
  ignorelexererrors=false,
  style=default,
}
\pgfkeys{
  /minted/globalinline/.cd,
  envname=VerbEnv,
}
\expandafter\def\expandafter\minted@usetexoptsnonpygments\expandafter{%
  \minted@usetexoptsnonpygments
  \edef\minted@literalenvname{\mintedpyoptvalueof{literalenvname}}%
  \edef\minted@envname{\mintedtexoptvalueof{envname}}%
  \expandafter\def\expandafter\minted@literalenv\expandafter{%
    \csname \minted@literalenvname\endcsname}%
  \expandafter\def\expandafter\minted@endliteralenv\expandafter{%
    \csname end\minted@literalenvname\endcsname}%
  \expandafter\expandafter\expandafter
    \let\expandafter\minted@literalenv\csname \minted@envname\endcsname
  \expandafter\expandafter\expandafter
    \let\expandafter\minted@endliteralenv\csname end\minted@envname\endcsname}%
\ifcsname minted@def@optcl\endcsname
  \ifx\minted@def@optcl\relax
    \let\minted@def@optcl\minted@undefined
  \fi
\fi
\providecommand{\minted@def@optcl}[4][]{%
  \minted@warning{Macro \string\minted@def@optcl\space is deprecated with minted v3
    and no longer has any effect}}
%    \end{macrocode}
%
%
%
% \subsection{Caching, styles, and highlighting}
%
%
%
% \subsubsection{Cache management}
%
%
% \begin{macro}{\minted@addcachefilename,\minted@cachefile<n>}
% Track cache files that are used, so that unused files can be removed.
%    \begin{macrocode}
\newcounter{minted@numcachefiles}
\def\minted@addcachefilename#1{%
  \ifbool{minted@canexec}%
   {\stepcounter{minted@numcachefiles}%
    \expandafter
      \xdef\csname minted@cachefile\arabic{minted@numcachefiles}\endcsname{#1}}%
   {}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@clean}
% If the Python executable is available and was used, clean up temp files.  If a cache is in use, also update the cache index and remove unused cache files.
%
% Only create a |.data.minted| file if there is a cache list to save.  Otherwise, no file is needed.
%
% Runs |\AfterEndDocument| so that all typesetting is complete, and thus the cache list is complete.  |\minted@fasthighlightmode@checkend| is placed within the same |\AfterEndDocument| to guarantee correct ordering.
%
%    \begin{macrocode}
\def\minted@clean{%
  \ifbool{minted@canexec}%
   {\ifbool{minted@diddetectconfig}{\minted@clean@i}{}}%
   {}}
\def\minted@clean@i{%
  \ifnum\value{minted@numcachefiles}>0\relax
    \expandafter\minted@savecachelist
  \fi
  \ifbool{minted@fasthighlightmode}%
   {}%
   {\minted@exec@clean
    \global\boolfalse{minted@canexec}}}
\def\minted@savecachelist{%
  \pydatasetfilename{\MintedDataFilename}%
  \minted@fasthighlightmode@checkstart
  \pydatawritedictopen
  \pydatawritekeyvalue{command}{clean}%
  \pydatawritekeyedefvalue{jobname}{\jobname}%
  \pydatawritekeyedefvalue{timestamp}{\minted@timestamp}%
  \pydatawritekeyedefvalue{cachepath}{\minted@cachepath}%
  \pydatawritekey{cachefiles}%
  \pydatawritemlvaluestart
  \pydatawritemlvalueline{[}%
  \setcounter{minted@tmpcnt}{1}%
  \loop\unless\ifnum\value{minted@tmpcnt}>\value{minted@numcachefiles}\relax
    \expandafter\minted@savecachelist@writecachefile\expandafter{%
      \csname minted@cachefile\arabic{minted@tmpcnt}\endcsname}%
    \expandafter\global\expandafter
      \let\csname minted@cachefile\arabic{minted@tmpcnt}\endcsname\minted@undefined
    \stepcounter{minted@tmpcnt}%
  \repeat
  \setcounter{minted@numcachefiles}{0}%
  \pydatawritemlvalueline{]}%
  \pydatawritemlvalueend
  \pydatawritedictclose
  \ifbool{minted@fasthighlightmode}{}{\pydataclosefilename{\MintedDataFilename}}}
\begingroup
\catcode`\"=12
\catcode`\,=12
\gdef\minted@savecachelist@writecachefile#1{%
  \expandafter\pydatawritemlvalueline\expandafter{\expandafter"#1",}}
\endgroup
\AfterEndDocument{%
  \minted@clean
  \minted@fasthighlightmode@checkend}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsubsection{Style definitions}
%
%
% \begin{macro}{\minted@patch@PygmentsStyledef}
% The macros generated by Pygments must be patched:  the single quote macro is redefined for \texpkg{upquote} compatibility, and the hyphen is redefined to prevent unintended line breaks under LuaTeX.
%    \begin{macrocode}
\def\minted@patch@PygmentsZsq{%
  \ifcsname\minted@styleprefix Zsq\endcsname
    \ifcsstring{\minted@styleprefix Zsq}{\char`\'}{\minted@patch@PygmentsZsq@i}{}%
  \fi}
\begingroup
\catcode`\'=\active
\gdef\minted@patch@PygmentsZsq@i{\def\PYGZsq{'}}
\endgroup
\def\minted@patch@PygmentsZhy{%
  \ifcsname\minted@styleprefix Zhy\endcsname
    \ifcsstring{\minted@styleprefix Zhy}{\char`\-}{\def\PYGZhy{\mbox{-}}}{}%
  \fi}
\def\minted@patch@ignorelexererrors{%
  \edef\minted@tmp{\mintedtexoptvalueof{ignorelexererrors}}%
  \ifdefstring{\minted@tmp}{true}%
   {\expandafter\let\csname\minted@styleprefix @tok@err\endcsname\relax}%
   {}}
\def\minted@patch@PygmentsStyledef{%
  \minted@patch@PygmentsZsq
  \minted@patch@PygmentsZhy
  \minted@patch@ignorelexererrors}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@VerbatimPygments}
% Enable \texpkg{fancyvrb} features for Pygments macros.
%    \begin{macrocode}
\def\minted@VerbatimPygments{%
  \expandafter\minted@VerbatimPygments@i\expandafter{%
    \csname\minted@styleprefix\endcsname}}
\def\minted@VerbatimPygments@i#1{%
  \VerbatimPygments{#1}{#1}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@standardcatcodes}
% Set standard catcodes.  Used before |\input| of style definitions and in reading the optional argument of environments that wrap Pygments output.
%    \begin{macrocode}
\def\minted@standardcatcodes{%
  \catcode`\\=0
  \catcode`\{=1
  \catcode`\}=2
  \catcode`\#=6
  \catcode`\ =10
  \catcode`\@=11
  \catcode`\`=12
  \catcode`\==12
  \catcode`\+=12
  \catcode`\.=12
  \catcode`\,=12
  \catcode`\[=12
  \catcode`\]=12
  \catcode`\%=14}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@defstyle}
% Define highlighting style macros.
%    \begin{macrocode}
\def\minted@defstyle{%
  \edef\minted@tmp{\mintedtexoptvalueof{style}}%
  \expandafter\minted@defstyle@i\expandafter{\minted@tmp}}
\def\minted@defstyle@i#1{%
  \minted@ifalphanumhyphenunderscore{#1}%
   {\minted@defstyle@ii{#1}}%
   {\minted@error{Highlighting style is set to "#1" but only style names with
      alphanumeric characters, hyphens, and underscores are supported;
      falling back to default style}%
    \minted@defstyle@ii{default}}}
\def\minted@defstyle@ii#1{%
  \ifcsname minted@styledef@#1\endcsname
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {\csname minted@styledef@#1\endcsname
   \minted@patch@PygmentsStyledef
   \minted@VerbatimPygments}%
  {\minted@defstyle@load{#1}}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@defstyle@load}
% Certain catcodes are required when loading Pygments style definitions from file.
% \begin{itemize}
% \item At sign |@| would be handled by the |\makeatletter| within the Pygments style definition if the style were brought in via |\input|, but |\makeatletter| doesn't affect tokenization with the |catchfile| approach.
% \item Percent |%| may not have its normal meaning within a |.dtx| file.
% \item Backtick |`| is made active by some \texpkg{babel} package options, such as |magyar|.
% \item Catcodes for other symbolic/non-alphanumeric characters may (probably rarely) not have their normal definitions.
% \end{itemize}
% |\endlinechar| also requires special handling to avoid introducing unwanted spaces.
%
% The |\begingroup...\endgroup| around |\minted@exec@styledef| and associated messages is necessary to prevent errors related to the message file.  If a style does not exist, then the Python executable will create a |_<hash>.message.minted| file, which is brought in via |\InputIfFileExists| and generates an error message.  After this, there is an attempt to load the default style.  If the default style needs to be generated, then |\InputIfFileExists| will attempt to bring in a |_<hash>.message.minted| file regardless of whether it exists, unless it is wrapped in the |\begingroup...\endgroup|.
%    \begin{macrocode}
\def\minted@catchfiledef#1#2{%
  \CatchFileDef{#1}{#2}{\minted@standardcatcodes\endlinechar=-1}}
\def\minted@defstyle@load#1{%
  \minted@detectconfig
  \ifbool{minted@cache}%
   {\edef\minted@styledeffilename{#1\detokenize{.style.minted}}%
    \edef\minted@styledeffilepath{\minted@cachepath\minted@styledeffilename}%
    \IfFileExists{\minted@styledeffilepath}%
     {\minted@defstyle@input{#1}}%
     {\ifbool{minted@canexec}%
      {\minted@defstyle@generate{#1}}%
      {\minted@error{Missing definition for highlighting style "#1" (minted executable
         is unavailable or disabled); attempting to substitute fallback style}%
       \minted@defstyle@fallback{#1}}}}%
   {\edef\minted@styledeffilename{%
      \detokenize{_}\MintedJobnameMdfive\detokenize{.style.minted}}%
    \let\minted@styledeffilepath\minted@styledeffilename
    \ifbool{minted@canexec}%
     {\minted@defstyle@generate{#1}}%
     {\minted@error{Missing definition for highlighting style "#1" (minted executable
        is unavailable or disabled); attempting to substitute fallback style}%
      \minted@defstyle@fallback{#1}}}}
\def\minted@defstyle@input#1{%
  \begingroup
  \minted@catchfiledef{\minted@tmp}{\minted@styledeffilepath}%
  \minted@tmp
  \ifcsname\minted@styleprefix\endcsname
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {\expandafter\global\expandafter\let\csname minted@styledef@#1\endcsname\minted@tmp
   \endgroup
   \ifbool{minted@cache}{\minted@addcachefilename{\minted@styledeffilename}}{}%
   \csname minted@styledef@#1\endcsname
   \minted@patch@PygmentsStyledef
   \minted@VerbatimPygments}%
  {\endgroup
   \ifbool{minted@canexec}%
    {\minted@warning{Invalid or corrupted style definition file
       "\minted@styledeffilename"; attempting to regenerate}%
     \minted@defstyle@generate{#1}}%
    {\minted@error{Invalid or corrupted style definition file
       "\minted@styledeffilename"; attempting to substitute fallback style
       (minted executable is unavailable or disabled)}%
     \minted@defstyle@fallback{#1}}}}
\def\minted@defstyle@generate#1{%
  \pydatasetfilename{\MintedDataFilename}%
  \minted@fasthighlightmode@checkstart
  \pydatawritedictopen
  \pydatawritekeyvalue{command}{styledef}%
  \pydatawritekeyedefvalue{jobname}{\jobname}%
  \pydatawritekeyedefvalue{timestamp}{\minted@timestamp}%
  \pydatawritekeyedefvalue{currentfilepath}{\CurrentFilePath}%
  \pydatawritekeyedefvalue{currentfile}{\CurrentFile}%
  \pydatawritekeyedefvalue{inputlineno}{\the\inputlineno}%
  \pydatawritekeyedefvalue{cachepath}{\minted@cachepath}%
  \pydatawritekeyedefvalue{styledeffilename}{\minted@styledeffilename}%
  \pydatawritekeyvalue{style}{#1}%
  \pydatawritekeyedefvalue{commandprefix}{\minted@styleprefix}%
  \pydatawritedictclose
  \ifbool{minted@fasthighlightmode}%
   {\minted@defstyle@fallback{#1}}%
   {\pydataclosefilename{\MintedDataFilename}%
    \begingroup
    \minted@exec@styledef
    \ifx\minted@exec@warning\relax
    \else
      \expandafter\minted@exec@warning
    \fi
    \ifx\minted@exec@error\relax
      \expandafter\minted@defstyle@generate@i
    \else
      \expandafter\minted@defstyle@generate@error
    \fi
    {#1}}}
\def\minted@defstyle@generate@i#1{%
  \endgroup
  \begingroup
  \minted@catchfiledef{\minted@tmp}{\minted@styledeffilepath}%
  \minted@tmp
  \ifcsname\minted@styleprefix\endcsname
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {\expandafter\global\expandafter\let\csname minted@styledef@#1\endcsname\minted@tmp
   \endgroup
   \ifbool{minted@cache}{\minted@addcachefilename{\minted@styledeffilename}}{}%
   \csname minted@styledef@#1\endcsname
   \minted@patch@PygmentsStyledef
   \minted@VerbatimPygments}%
  {\endgroup
   \minted@error{Failed to create style definition file "\minted@styledeffilename"
     (no error message, see "\MintedErrlogFilename" if it exists);
     attempting to substitute fallback style}%
   \minted@defstyle@fallback{#1}}}
\def\minted@defstyle@generate@error#1{%
  \minted@exec@error
  \endgroup
  \minted@defstyle@fallback{#1}}
\def\minted@defstyle@fallback#1{%
  \ifstrequal{#1}{default}%
   {\expandafter\global\expandafter
      \let\csname minted@styledef@default\endcsname\minted@styledeffallback}%
   {\ifcsname minted@styledef@default\endcsname
    \else
      \minted@defstyle@load{default}%
    \fi
    \expandafter\let\expandafter\minted@tmp\csname minted@styledef@default\endcsname
    \expandafter\global\expandafter\let\csname minted@styledef@#1\endcsname\minted@tmp}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@styledeffallback}
% Basic style definition to make |.highlight.minted| cache files usable if no styles exist, not even the default style, and no styles can be generated.
%    \begin{macrocode}
\def\minted@styledeffallback{%
  \expandafter\def\csname\minted@styleprefix\endcsname##1##2{##2}%
  \expandafter\def\csname\minted@styleprefix Zbs\endcsname{\char`\\}%
  \expandafter\def\csname\minted@styleprefix Zus\endcsname{\char`\_}%
  \expandafter\def\csname\minted@styleprefix Zob\endcsname{\char`\{}%
  \expandafter\def\csname\minted@styleprefix Zcb\endcsname{\char`\}}%
  \expandafter\def\csname\minted@styleprefix Zca\endcsname{\char`\^}%
  \expandafter\def\csname\minted@styleprefix Zam\endcsname{\char`\&}%
  \expandafter\def\csname\minted@styleprefix Zlt\endcsname{\char`\<}%
  \expandafter\def\csname\minted@styleprefix Zgt\endcsname{\char`\>}%
  \expandafter\def\csname\minted@styleprefix Zsh\endcsname{\char`\#}%
  \expandafter\def\csname\minted@styleprefix Zpc\endcsname{\char`\%}%
  \expandafter\def\csname\minted@styleprefix Zdl\endcsname{\char`\$}%
  \expandafter\def\csname\minted@styleprefix Zhy\endcsname{\char`\-}%
  \expandafter\def\csname\minted@styleprefix Zsq\endcsname{\char`\'}%
  \expandafter\def\csname\minted@styleprefix Zdq\endcsname{\char`\"}%
  \expandafter\def\csname\minted@styleprefix Zti\endcsname{\char`\~}%
  \minted@patch@PygmentsStyledef
  \minted@VerbatimPygments}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsubsection{Lexer-specific line numbering}
%
%
% \begin{macro}{minted@FancyVerbLineTemp}
% Temporary counter for storing and then restoring the value of |FancyVerbLine|.  When using the |lexerlinenos| option, we need to store the current value of |FancyVerbLine|, then set |FancyVerbLine| to the current value of a lexer-specific counter, and finally restore |FancyVerbLine| to its initial value after the current chunk of code has been typeset.
%    \begin{macrocode}
\newcounter{minted@FancyVerbLineTemp}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\minted@lexerlinenoson,\minted@lexerlinenosoff,\minted@inputlexerlinenoson,\minted@inputlexerlinenosoff}
% Line counters on a per-lexer basis for |minted| and |\mintinline|; line counters on a per-lexer basis for |\inputminted|.
%    \begin{macrocode}
\def\minted@lexerlinenoson{%
  \ifcsname c@minted@lexer\minted@lexer\endcsname
  \else
    \newcounter{minted@lexer\minted@lexer}%
  \fi
  \setcounter{minted@FancyVerbLineTemp}{\value{FancyVerbLine}}%
  \setcounter{FancyVerbLine}{\value{minted@lexer\minted@lexer}}}
\def\minted@lexerlinenosoff{%
  \setcounter{minted@lexer\minted@lexer}{\value{FancyVerbLine}}%
  \setcounter{FancyVerbLine}{\value{minted@FancyVerbLineTemp}}}
\ifbool{minted@inputlexerlinenos}%
 {\let\minted@inputlexerlinenoson\minted@lexerlinenoson
  \let\minted@inputlexerlinenosoff\minted@lexerlinenosoff}%
 {\let\minted@inputlexerlinenoson\relax
  \let\minted@inputlexerlinenosoff\relax
  \ifbool{minted@lexerlinenos}
   {}%
   {\let\minted@lexerlinenoson\relax
    \let\minted@lexerlinenosoff\relax}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\minted@codewrapper}
% Wrapper around typeset code.  |\minted@inputfilepath| will exist when the code is brought in from an external file.
%    \begin{macrocode}
\def\minted@codewrapper#1{%
  \ifcsname minted@inputfilepath\endcsname
    \minted@inputlexerlinenoson
  \else
    \minted@lexerlinenoson
  \fi
  #1%
  \ifcsname minted@inputfilepath\endcsname
    \minted@inputlexerlinenosoff
  \else
    \minted@lexerlinenosoff
  \fi}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsubsection{Highlighting code}
%
%
% \begin{macro}{\minted@highlight,\minted@highlightinputfile}
% Highlight code previously stored in buffer |minted@tmpdatabuffer|, or code in an external file.
%
% |\minted@defstyle| will invoke |\minted@detectconfig| the first time a style is loaded, so no separate |\minted@detectconfig| is needed.
%
% The default |\minted@highlight@fallback| inserts a placeholder.  Typically commands/environments will redefine the fallback locally to inserted a verbatim approximation of code that could not be highlighted.
%
% Python-related options are buffered/written under a |pyopt| namespace.  This prevents the possibility of naming collisions between options and other data that must be passed to Python.
%
% Some data such as |jobname|, |timestamp|, and |cachepath| should be written to file, but not used in hashing because otherwise it would unnecessarily make the cache files dependent on irrelevant data.
%    \begin{macrocode}
\def\minted@debug@input{%
  \ifbool{minted@debug}%
   {\immediate\typeout{%
     minted debug: \string\input\space at
     \ifx\CurrentFile\@empty\else\CurrentFile\space\fi line \the\inputlineno}}%
   {}}
\def\minted@highlight{%
  \minted@defstyle
  \pydatasetbuffername{minted@tmpdatabuffer}%
  \pydatabufferkeyvalue{command}{highlight}%
  \pydatabufferkey{code}%
  \pydatabuffermlvaluestart
  \setcounter{minted@tmpcnt}{1}%
  \loop\unless\ifnum\value{minted@tmpcnt}>\value{minted@tmpcodebufferlength}\relax
    \expandafter\let\expandafter
      \minted@tmp\csname minted@tmpcodebufferline\arabic{minted@tmpcnt}\endcsname
    \expandafter\pydatabuffermlvalueline\expandafter{\minted@tmp}%
    \stepcounter{minted@tmpcnt}%
  \repeat
  \pydatabuffermlvalueend
  \minted@highlight@i}
\def\minted@highlightinputfile{%
  \minted@defstyle
  \edef\minted@inputfilemdfivesum{\pdf@filemdfivesum{\minted@inputfilepath}}%
  \ifx\minted@inputfilemdfivesum\@empty
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {\minted@error{Cannot find input file "\minted@inputfilepath"; inserting placeholder}%
   \minted@insertplaceholder}%
  {\pydatasetbuffername{minted@tmpdatabuffer}%
   \pydatabufferkeyvalue{command}{highlight}%
   \pydatabufferkeyedefvalue{inputfilepath}{\minted@inputfilepath}%
   \pydatabufferkeyedefvalue{inputfilemdfivesum}{\minted@inputfilemdfivesum}%
   \minted@highlight@i}}
\def\minted@def@FV@GetKeyValues@standardcatcodes{%
  \let\minted@FV@GetKeyValues@orig\FV@GetKeyValues
  \def\FV@GetKeyValues##1{%
    \begingroup
    \minted@standardcatcodes
    \minted@FV@GetKeyValues@i{##1}}%
  \def\minted@FV@GetKeyValues@i##1[##2]{%
    \endgroup
    \let\FV@GetKeyValues\minted@FV@GetKeyValues@orig
    \let\minted@FV@GetKeyValues@i\minted@undefined
    \FV@GetKeyValues{##1}[##2]}}
\def\minted@highlight@i{%
  \pydatabufferkeyedefvalue{pyopt.lexer}{\minted@lexer}%
  \pydatabufferkeyedefvalue{pyopt.commandprefix}{\minted@styleprefix}%
  \minted@forcsvlist{\minted@highlight@bufferpykeys}{\minted@optkeyslist@py}%
  \ifbool{minted@cache}%
   {\edef\minted@highlightfilename{\pydatabuffermdfivesum\detokenize{.highlight.minted}}%
    \edef\minted@highlightfilepath{\minted@cachepath\minted@highlightfilename}%
    \IfFileExists{\minted@highlightfilepath}%
     {\minted@codewrapper{%
        \minted@def@FV@GetKeyValues@standardcatcodes
        \minted@debug@input
        \input{\minted@highlightfilepath}}%
      \minted@addcachefilename{\minted@highlightfilename}}%
     {\ifbool{minted@canexec}%
       {\minted@highlight@create}%
       {\minted@error{Cannot highlight code (minted executable is unavailable or
          disabled); attempting to typeset without highlighting}%
        \minted@highlight@fallback}}}%
   {\edef\minted@highlightfilename{%
      \detokenize{_}\MintedJobnameMdfive\detokenize{.highlight.minted}}%
    \let\minted@highlightfilepath\minted@highlightfilename
    \ifbool{minted@canexec}%
     {\minted@highlight@create}%
     {\minted@error{Cannot highlight code (minted executable is unavailable or
        disabled); attempting to typeset without highlighting}%
      \minted@highlight@fallback}}%
  \pydataclearbuffername{minted@tmpdatabuffer}}
\def\minted@highlight@bufferpykeys#1{%
  \edef\minted@tmp{\mintedpyoptvalueof{#1}}%
  \ifx\minted@tmp\minted@const@pgfkeysnovalue
  \else
    \pydatabufferkeyedefvalue{pyopt.#1}{\minted@tmp}%
  \fi}
\def\minted@highlight@create{%
  \pydatasetfilename{\MintedDataFilename}%
  \minted@fasthighlightmode@checkstart
  \pydatawritedictopen
  \pydatawritebuffer
  \pydatawritekeyedefvalue{jobname}{\jobname}%
  \pydatawritekeyedefvalue{timestamp}{\minted@timestamp}%
  \pydatawritekeyedefvalue{currentfilepath}{\CurrentFilePath}%
  \pydatawritekeyedefvalue{currentfile}{\CurrentFile}%
  \pydatawritekeyedefvalue{inputlineno}{\the\inputlineno}%
  \pydatawritekeyedefvalue{cachepath}{\minted@cachepath}%
  \pydatawritekeyedefvalue{highlightfilename}{\minted@highlightfilename}%
  \pydatawritedictclose
  \ifbool{minted@fasthighlightmode}%
   {\minted@insertplaceholder}%
   {\pydataclosefilename{\MintedDataFilename}%
    \begingroup
    \minted@exec@highlight
    \IfFileExists{\minted@highlightfilepath}%
     {\ifx\minted@exec@warning\relax
      \else
        \expandafter\minted@exec@warning
      \fi
      \ifx\minted@exec@error\relax
      \else
        \expandafter\minted@exec@error
      \fi
      \endgroup
      \minted@codewrapper{%
        \minted@def@FV@GetKeyValues@standardcatcodes
        \minted@debug@input
        \input{\minted@highlightfilepath}}%
      \ifbool{minted@cache}{\minted@addcachefilename{\minted@highlightfilename}}{}}%
     {\ifx\minted@exec@warning\relax
      \else
        \expandafter\minted@exec@warning
      \fi
      \ifx\minted@exec@error\relax
        \minted@error{Minted executable failed during syntax highlighting
          but returned no error message (see if "\MintedErrlogFilename" exists)}%
      \else
        \expandafter\minted@exec@error
      \fi
      \endgroup
      \minted@highlight@fallback}}}
\def\minted@highlight@fallback{%
  \minted@insertplaceholder}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Public API}
%
%
% \begin{macro}{\setminted}
% Set global or lexer-level options.
%    \begin{macrocode}
\newcommand{\setminted}[2][]{%
  \ifstrempty{#1}%
   {\pgfkeys{/minted/global/.cd,#2}}%
   {\let\minted@tmplexer\minted@lexer
    \edef\minted@lexer{#1}%
    \pgfkeys{/minted/lexer/.cd,#2}%
    \let\minted@lexer\minted@tmplexer}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\setmintedinline}
% Set global or lexer-level options, but only for inline (|\mintinline|) content.  These settings will override the corresponding |\setminted| settings.
%    \begin{macrocode}
\newcommand{\setmintedinline}[2][]{%
  \ifstrempty{#1}%
   {\pgfkeys{/minted/globalinline/.cd,#2}}%
   {\let\minted@tmplexer\minted@lexer
    \edef\minted@lexer{#1}%
    \pgfkeys{/minted/lexerinline/.cd,#2}%
    \let\minted@lexer\minted@tmplexer}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\usemintedstyle}
% Set style.  This is a holdover from \mintedpkg\ v1, before |\setminted| could be used to set the style.
%    \begin{macrocode}
\newcommand{\usemintedstyle}[2][]{\setminted[#1]{style=#2}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\mintinline}
% Define an inline command.  This is modeled after the reimplemented |\Verb| from \texpkg{fvextra}.  See the \texpkg{fvextra} documentation for details about expansion handling, argument reading, and (re)tokenization.
%
% Everything needs to be within a |\begingroup...\endgroup| to prevent settings from escaping.
%
% |\RobustMintInlineProcess@verbatim| doesn't need an explicit |\FVExtraRetokenizeVArg| step because this is done when the code is inserted into |\Verb|.
%    \begin{macrocode}
\def\mintinline{%
  \FVExtraRobustCommand\RobustMintInline\FVExtraUnexpandedReadStarOArgMArgBVArg}
\FVExtrapdfstringdefDisableCommands{%
  \def\RobustMintInline{}}
\newrobustcmd{\RobustMintInline}[2][]{%
  \ifbool{FVExtraRobustCommandExpanded}%
   {\@ifnextchar\bgroup
     {\FVExtraReadVArg{\RobustMintInlineProcess{#1}{#2}}}%
     {\minted@error{Inline delimiters must be paired curly braces in this context}}}%
   {\FVExtraReadVArg{\RobustMintInlineProcess{#1}{#2}}}}
\def\RobustMintInlineProcess@highlight#1#2#3{%
  \begingroup
  \booltrue{minted@isinline}%
  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
  \edef\minted@lexer{#2}%
  \minted@usefvopts
  \minted@usetexoptsnonpygments
  \FVExtraDetokenizeVArg{%
     \FVExtraRetokenizeVArg{\RobustMintInlineProcess@highlight@i}{\FV@CatCodes}}{#3}}
\def\RobustMintInlineProcess@highlight@i#1{%
  \expandafter\def\csname minted@tmpcodebufferline1\endcsname{#1}%
  \setcounter{minted@tmpcodebufferlength}{1}%
  \let\minted@highlight@fallback\RobustMintInlineProcess@highlight@fallback
  \minted@highlight
  \setcounter{minted@tmpcodebufferlength}{0}%
  \endgroup}
\def\RobustMintInlineProcess@highlight@fallback{%
  \minted@useadditionalfvoptsnopy
  \fvset{extra=true}%
  \minted@codewrapper{%
    \expandafter\let\expandafter\minted@tmp\csname minted@tmpcodebufferline1\endcsname
    \expandafter\Verb\expandafter{\minted@tmp}}}
\def\RobustMintInlineProcess@placeholder#1#2#3{%
  \begingroup
  \booltrue{minted@isinline}%
  \minted@insertplaceholder
  \endgroup}
\def\RobustMintInlineProcess@verbatim#1#2#3{%
  \begingroup
  \booltrue{minted@isinline}%
  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
  \edef\minted@lexer{#2}%
  \minted@usefvopts
  \minted@useadditionalfvoptsnopy
  \minted@usetexoptsnonpygments
  \fvset{extra=true}%
  \minted@codewrapper{\Verb{#3}}%
  \endgroup}
\ifbool{minted@placeholder}%
 {\let\RobustMintInlineProcess\RobustMintInlineProcess@placeholder}%
 {\ifbool{minted@verbatim}%
   {\let\RobustMintInlineProcess\RobustMintInlineProcess@verbatim}%
   {\let\RobustMintInlineProcess\RobustMintInlineProcess@highlight}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\mint}
% Highlight a single line of code.  This is essentially a shortcut for the \env{minted} environment when there is only a single line of code.  The implementation follows \cmd{\mintinline} for argument reading and processing, but then typesets the code as an environment rather than command.  The \cmd{\@doendpe} ensures proper paragraph indentation for following text (immediately following text with no intervening blank lines does not begin a new paragraph).
%    \begin{macrocode}
\def\mint{%
  \FVExtraRobustCommand\RobustMint\FVExtraUnexpandedReadStarOArgMArgBVArg}
\FVExtrapdfstringdefDisableCommands{%
  \def\RobustMint{}}
\newrobustcmd{\RobustMint}[2][]{%
  \ifbool{FVExtraRobustCommandExpanded}%
   {\@ifnextchar\bgroup
     {\FVExtraReadVArg{\RobustMintProcess{#1}{#2}}}%
     {\minted@error{Delimiters must be paired curly braces in this context}}}%
   {\FVExtraReadVArg{\RobustMintProcess{#1}{#2}}}}
\def\RobustMintProcess@highlight#1#2#3{%
  \begingroup
  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
  \edef\minted@lexer{#2}%
  \minted@usefvopts
  \minted@usetexoptsnonpygments
  \FVExtraDetokenizeVArg{%
    \FVExtraRetokenizeVArg{\RobustMintProcess@highlight@i}{\FV@CatCodes}}{#3}}
\def\RobustMintProcess@highlight@i#1{%
  \expandafter\def\csname minted@tmpcodebufferline1\endcsname{#1}%
  \setcounter{minted@tmpcodebufferlength}{1}%
  \let\minted@highlight@fallback\RobustMintProcess@highlight@fallback
  \minted@highlight
  \setcounter{minted@tmpcodebufferlength}{0}%
  \endgroup}
\def\RobustMintProcess@highlight@fallback{%
  \minted@useadditionalfvoptsnopy
  \minted@codewrapper{%
    \VerbatimInsertBuffer[buffername=minted@tmpcodebuffer,insertenvname=\minted@envname]}}
\def\RobustMintProcess@placeholder#1#2#3{%
  \minted@insertplaceholder}
\def\RobustMintProcess@verbatim#1#2#3{%
  \begingroup
  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
  \edef\minted@lexer{#2}%
  \minted@usefvopts
  \minted@useadditionalfvoptsnopy
  \minted@usetexoptsnonpygments
  \FVExtraDetokenizeVArg{%
    \FVExtraRetokenizeVArg{\RobustMintProcess@verbatim@i}{\FV@CatCodes}}{#3}}
\def\RobustMintProcess@verbatim@i#1{%
  \expandafter\def\csname minted@tmpcodebufferline1\endcsname{#1}%
  \setcounter{minted@tmpcodebufferlength}{1}%
  \minted@codewrapper{%
    \VerbatimInsertBuffer[buffername=minted@tmpcodebuffer,insertenvname=\minted@envname]}%
  \setcounter{minted@tmpcodebufferlength}{0}%
  \endgroup}
\ifbool{minted@placeholder}%
 {\let\RobustMintProcess\RobustMintProcess@placeholder}%
 {\ifbool{minted@verbatim}%
   {\let\RobustMintProcess\RobustMintProcess@verbatim}%
   {\let\RobustMintProcess\RobustMintProcess@highlight}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{environment}{minted}
% Highlight a longer piece of code inside a verbatim environment.
%    \begin{macrocode}
\newenvironment{minted}[2][]%
 {\VerbatimEnvironment
  \MintedBegin{#1}{#2}}%
 {\MintedEnd}
\def\MintedBegin@highlight#1#2{%
  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
  \edef\minted@lexer{#2}%
  \minted@usefvopts
  \minted@usetexoptsnonpygments
  \begin{VerbatimBuffer}[buffername=minted@tmpcodebuffer,globalbuffer=true]}
\def\MintedEnd@highlight{%
  \end{VerbatimBuffer}%
  \let\minted@highlight@fallback\MintedEnv@highlight@fallback
  \minted@highlight
  \VerbatimClearBuffer[buffername=minted@tmpcodebuffer]}
\def\MintedEnv@highlight@fallback{%
  \minted@useadditionalfvoptsnopy
  \minted@codewrapper{%
    \VerbatimInsertBuffer[buffername=minted@tmpcodebuffer,insertenvname=\minted@envname]}}
\def\MintedBegin@placeholder#1#2{%
  \begin{VerbatimBuffer}[buffername=minted@tmpcodebuffer]}
\def\MintedEnd@placeholder{%
  \end{VerbatimBuffer}%
  \minted@insertplaceholder}
\def\MintedBegin@verbatim#1#2{%
  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
  \edef\minted@lexer{#2}%
  \minted@usefvopts
  \minted@useadditionalfvoptsnopy
  \minted@usetexoptsnonpygments
  \begin{\minted@envname}}
\def\MintedEnd@verbatim{%
  \end{\minted@envname}}
\ifbool{minted@placeholder}%
 {\let\MintedBegin\MintedBegin@placeholder
  \let\MintedEnd\MintedEnd@placeholder}%
 {\ifbool{minted@verbatim}%
   {\let\MintedBegin\MintedBegin@verbatim
    \let\MintedEnd\MintedEnd@verbatim}%
   {\let\MintedBegin\MintedBegin@highlight
    \let\MintedEnd\MintedEnd@highlight}}
%    \end{macrocode}
% \end{environment}
%
%
% \begin{macro}{\inputminted}
% Highlight an external source file.
%    \begin{macrocode}
\def\minted@readinputmintedargs#1#{%
  \minted@readinputmintedargs@i{#1}}
\def\minted@readinputmintedargs@i#1#2#3{%
  \FVExtraAlwaysUnexpanded{\minted@readinputmintedargs#1{#2}{#3}}}
\FVExtrapdfstringdefDisableCommands{%
  \makeatletter
  \def\minted@readinputmintedargs@i#1#2#3{%
    \detokenize{<input from file "}#3\detokenize{">}}%
  \makeatother}
\def\inputminted{%
  \FVExtraRobustCommand\RobustInputMinted\minted@readinputmintedargs}
\FVExtrapdfstringdefDisableCommands{%
  \def\RobustInputMinted{}}
\newrobustcmd{\RobustInputMinted}[3][]{%
  \RobustInputMintedProcess{#1}{#2}{#3}}
\def\RobustInputMintedProcess@highlight#1#2#3{%
  \begingroup
  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
  \edef\minted@lexer{#2}%
  \edef\minted@inputfilepath{#3}%
  \minted@usefvopts
  \minted@usetexoptsnonpygments
  \let\minted@highlight@fallback\RobustInputMintedProcess@highlight@fallback
  \minted@highlightinputfile
  \endgroup}
\def\RobustInputMintedProcess@highlight@fallback{%
  \minted@useadditionalfvoptsnopy
  \minted@codewrapper{%
    \csname\minted@envname Input\endcsname{\minted@inputfilepath}}}
\def\RobustInputMintedProcess@placeholder#1#2#3{%
  \minted@insertplaceholder}
\def\RobustInputMintedProcess@verbatim#1#2#3{%
  \begingroup
  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
  \edef\minted@lexer{#2}%
  \edef\minted@inputfilepath{#3}%
  \minted@usefvopts
  \minted@useadditionalfvoptsnopy
  \minted@usetexoptsnonpygments
  \minted@codewrapper{%
    \csname\minted@envname Input\endcsname{\minted@inputfilepath}}%
  \endgroup}
\ifbool{minted@placeholder}%
 {\let\RobustInputMintedProcess\RobustInputMintedProcess@placeholder}%
 {\ifbool{minted@verbatim}%
   {\let\RobustInputMintedProcess\RobustInputMintedProcess@verbatim}%
   {\let\RobustInputMintedProcess\RobustInputMintedProcess@highlight}}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Command shortcuts}
%
% Allow the user to define shortcuts for the highlighting commands.
%
% \begin{macro}{\newminted}
% Define a new language-specific alias for the |minted| environment.
%
% The starred |*| version of the environment takes a mandatory argument containing options.  It is retained for backward compatibility purposes with \mintedpkg\ v1 and v2.  \mintedpkg\ v3 added support for an optional argument to the standard environment, so the starred version is no longer necessary.
%
% The |^^M| is needed because |\FVExtraReadOArgBeforeVEnv| strips a following |^^M| (basically the newline), but \texpkg{fancyvrb} environments expect |^^M| before the start of environment contents.
%    \begin{macrocode}
\newcommand{\newminted}[3][]{%
  \ifstrempty{#1}%
   {\newminted@i{#2code}{#2}{#3}}%
   {\newminted@i{#1}{#2}{#3}}}
\begingroup
\catcode`\^^M=\active%
\gdef\newminted@i#1#2#3{%
  \expandafter\def\csname#1@i\endcsname##1{%
    \begin{minted}[#3,##1]{#2}^^M}%
  \newenvironment{#1}%
   {\VerbatimEnvironment%
    \FVExtraReadOArgBeforeVEnv{\csname#1@i\endcsname}}%
   {\end{minted}}%
  \newenvironment{#1*}[1]%
   {\VerbatimEnvironment%
    \begin{minted}[#3,##1]{#2}}%
   {\end{minted}}}%
\endgroup
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\newmint}
% Define a new language-specific alias for the |\mint| short form.
%    \begin{macrocode}
\newcommand{\newmint}[3][]{%
  \ifstrempty{#1}%
   {\edef\minted@tmp{#2}}%
   {\edef\minted@tmp{#1}}
  \expandafter\newmint@i\expandafter{\minted@tmp}{#2}{#3}}
\def\newmint@i#1#2#3{%
  \expandafter\newcommand\csname#1\endcsname{%
    \expandafter\FVExtraRobustCommand\csname RobustNewMint#1\endcsname
    \FVExtraUnexpandedReadStarOArgBVArg}%
  \FVExtrapdfstringdefDisableCommands{%
    \expandafter\def\csname RobustNewMint#1\endcsname{}}%
  \expandafter\newrobustcmd\csname RobustNewMint#1\endcsname{%
    \FVExtraReadOArgBeforeVArg{\csname RobustNewMint#1@i\endcsname}}%
  \expandafter\def\csname RobustNewMint#1@i\endcsname##1{%
    \ifbool{FVExtraRobustCommandExpanded}%
     {\@ifnextchar\bgroup
       {\FVExtraReadVArg{\csname RobustNewMint#1@ii\endcsname{##1}}}%
       {\minted@error{Delimiters must be paired curly braces in this context}}}%
     {\FVExtraReadVArg{\csname RobustNewMint#1@ii\endcsname{##1}}}}
  \expandafter\def\csname RobustNewMint#1@ii\endcsname##1##2{%
    \RobustMintProcess{#3,##1}{#2}{##2}}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\newmintedfile}
% Define a new language-specific alias for |\inputminted|.
%    \begin{macrocode}
\def\minted@readnewmintedfileargs#1#{%
  \minted@readnewmintedfileargs@i{#1}}
\def\minted@readnewmintedfileargs@i#1#2{%
  \FVExtraAlwaysUnexpanded{\minted@readnewmintedfileargs#1{#2}}}
\FVExtrapdfstringdefDisableCommands{%
  \makeatletter
  \def\minted@readnewmintedfileargs@i#1#2{%
    \detokenize{<input from file "}#2\detokenize{">}}%
  \makeatother}
\newcommand{\newmintedfile}[3][]{%
  \ifstrempty{#1}%
   {\edef\minted@tmp{#2file}}%
   {\edef\minted@tmp{#1}}%
  \expandafter\newmintedfile@i\expandafter{\minted@tmp}{#2}{#3}}
\def\newmintedfile@i#1#2#3{%
  \expandafter\newcommand\csname#1\endcsname{%
    \expandafter\FVExtraRobustCommand\csname RobustNewMintedFile#1\endcsname
    \minted@readnewmintedfileargs}%
  \FVExtrapdfstringdefDisableCommands{%
    \expandafter\def\csname RobustNewMintedFile#1\endcsname{}}%
  \expandafter\newrobustcmd\csname RobustNewMintedFile#1\endcsname[2][]{%
    \RobustInputMintedProcess{#3,##1}{#2}{##2}}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\newmintinline}
% Define an alias for |\mintinline|.
%    \begin{macrocode}
\newcommand{\newmintinline}[3][]{%
  \ifstrempty{#1}%
   {\edef\minted@tmp{#2inline}}%
   {\edef\minted@tmp{#1}}%
  \expandafter\newmintinline@i\expandafter{\minted@tmp}{#2}{#3}}
\def\newmintinline@i#1#2#3{%
  \expandafter\newcommand\csname#1\endcsname{%
    \expandafter\FVExtraRobustCommand\csname RobustNewMintInline#1\endcsname
    \FVExtraUnexpandedReadStarOArgBVArg}%
  \FVExtrapdfstringdefDisableCommands{%
    \expandafter\def\csname RobustNewMintInline#1\endcsname{}}%
  \expandafter\newrobustcmd\csname RobustNewMintInline#1\endcsname{%
    \FVExtraReadOArgBeforeVArg{\csname RobustNewMintInline#1@i\endcsname}}%
  \expandafter\def\csname RobustNewMintInline#1@i\endcsname##1{%
    \ifbool{FVExtraRobustCommandExpanded}%
     {\@ifnextchar\bgroup
       {\FVExtraReadVArg{\csname RobustNewMintInline#1@ii\endcsname{##1}}}%
       {\minted@error{Inline delimiters must be paired curly braces in this context}}}%
     {\FVExtraReadVArg{\csname RobustNewMintInline#1@ii\endcsname{##1}}}}
  \expandafter\def\csname RobustNewMintInline#1@ii\endcsname##1##2{%
    \RobustMintInlineProcess{#3,##1}{#2}{##2}}}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Float support}
%
%
% \begin{environment}{listing}
% Define a new floating environment to use for floated listings.  This is defined conditionally based on the |newfloat| package option.
%    \begin{macrocode}
\ifbool{minted@newfloat}%
 {\@ifundefined{minted@float@within}%
   {\DeclareFloatingEnvironment[fileext=lol,placement=tbp]{listing}}%
   {\def\minted@tmp#1{%
      \DeclareFloatingEnvironment[fileext=lol,placement=tbp,within=#1]{listing}}%
    \expandafter\minted@tmp\expandafter{\minted@float@within}}}%
 {\@ifundefined{minted@float@within}%
   {\newfloat{listing}{tbp}{lol}}%
   {\newfloat{listing}{tbp}{lol}[\minted@float@within]}}
%    \end{macrocode}
% \end{environment}
%
% The following macros only apply when |listing| is created with the \texpkg{float} package.  When |listing| is created with \texpkg{newfloat}, its properties should be modified using \texpkg{newfloat}'s |\SetupFloatingEnvironment|.
%    \begin{macrocode}
\ifminted@newfloat\else
%    \end{macrocode}
%
% \begin{macro}{\listingcaption}
% The name that is displayed before each individual listings caption and its number.
% The macro |\listingscaption| can be redefined by the user.
%    \begin{macrocode}
\newcommand{\listingscaption}{Listing}
%    \end{macrocode}
%
% The following definition should not be changed by the user.
%    \begin{macrocode}
\floatname{listing}{\listingscaption}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\listoflistingscaption}
% The caption that is displayed for the list of listings.
%    \begin{macrocode}
\newcommand{\listoflistingscaption}{List of Listings}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\listoflistings}
% Used to produce a list of listings (like |\listoffigures| etc.).
% This may well clash with other packages (for example, \texpkg{listings}) but we choose to ignore this
% since these two packages shouldn't be used together in the first place.
%    \begin{macrocode}
\providecommand{\listoflistings}{\listof{listing}{\listoflistingscaption}}
%    \end{macrocode}
% \end{macro}
%
% Again, the preceding macros only apply when \texpkg{float} is used to create listings, so we need to end the conditional.
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
%
% \iffalse
%</package>
% \fi
%
%
% \Finale
\endinput
