texlive[72363] Master/texmf-dist: minted (23sep24)

commits+karl at tug.org commits+karl at tug.org
Mon Sep 23 23:20:32 CEST 2024


Revision: 72363
          https://tug.org/svn/texlive?view=revision&revision=72363
Author:   karl
Date:     2024-09-23 23:20:32 +0200 (Mon, 23 Sep 2024)
Log Message:
-----------
minted (23sep24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/minted/DEPENDS.txt
    trunk/Master/texmf-dist/doc/latex/minted/README
    trunk/Master/texmf-dist/doc/latex/minted/minted.pdf
    trunk/Master/texmf-dist/source/latex/minted/minted.dtx
    trunk/Master/texmf-dist/source/latex/minted/minted.ins
    trunk/Master/texmf-dist/tex/latex/minted/minted.sty

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/minted/CHANGELOG_LATEXMINTED_PYTHON_PACKAGE.md
    trunk/Master/texmf-dist/doc/latex/minted/CHANGELOG_MINTED_LATEX_PACKAGE.md
    trunk/Master/texmf-dist/doc/latex/minted/latex2pydata-0.4.0-py3-none-any.whl
    trunk/Master/texmf-dist/doc/latex/minted/latexminted-0.1.0-py3-none-any.whl
    trunk/Master/texmf-dist/doc/latex/minted/latexrestricted-0.4.0-py3-none-any.whl
    trunk/Master/texmf-dist/doc/latex/minted/pygments-2.18.0-py3-none-any.whl
    trunk/Master/texmf-dist/tex/latex/minted/latexminted.py
    trunk/Master/texmf-dist/tex/latex/minted/minted2.sty

Removed Paths:
-------------
    trunk/Master/texmf-dist/source/latex/minted/Makefile

Added: trunk/Master/texmf-dist/doc/latex/minted/CHANGELOG_LATEXMINTED_PYTHON_PACKAGE.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/minted/CHANGELOG_LATEXMINTED_PYTHON_PACKAGE.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/minted/CHANGELOG_LATEXMINTED_PYTHON_PACKAGE.md	2024-09-23 21:20:32 UTC (rev 72363)
@@ -0,0 +1,6 @@
+# Changelog: `latexminted` — Python library for LaTeX minted package
+
+
+## v0.1.0 (2024-09-22)
+
+*  Initial release.


Property changes on: trunk/Master/texmf-dist/doc/latex/minted/CHANGELOG_LATEXMINTED_PYTHON_PACKAGE.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/minted/CHANGELOG_MINTED_LATEX_PACKAGE.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/minted/CHANGELOG_MINTED_LATEX_PACKAGE.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/minted/CHANGELOG_MINTED_LATEX_PACKAGE.md	2024-09-23 21:20:32 UTC (rev 72363)
@@ -0,0 +1,918 @@
+# Changelog — minted LaTeX package
+
+
+## v3.0.0 (2024/09/22)
+
+*  Backward compatibility:  The new `minted2` package provides the features of
+   `minted` v2.9, the final release before v3.  No additional v2 releases are
+   planned; no changes to the `minted2` package are expected.
+
+*  `minted` v3 is a complete rewrite from v2.9.  `minted` v3 includes
+   significant changes from `minted` v2 on the LaTeX side, and also uses a new
+   `minted`-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.
+
+*  Installing the `minted` package now also installs the `latexminted` Python
+   executable and all required Python libraries, including Pygments, within
+   your TeX distribution.  These require Python >= 3.8.  If the default Python
+   version on `PATH` is < 3.8, then the `latexminted` Python executable will
+   attempt to locate a more recent version and run itself with that version in
+   a subprocess.
+
+   Manually installing Python libraries is only necessary if you want to use
+   plugin packages for Pygments.  In that case, install the `latexminted`
+   Python package in a Python installation.  This automatically installs
+   `latex2pydata`, `latexrestricted`, and Pygments as dependencies.
+   `latexminted` is available from the
+   [Python Package Index (PyPI)](https://pypi.org/project/latexminted/).  Then
+   install plugin packages for Pygments within the same Python installation.
+
+*  The new `latexminted` Python executable is designed to be compatible with
+   the security requirements for restricted shell escape, so that in the
+   future TeX distributions can enable `latexminted` without requiring
+   `-shell-escape`.  It is possible to benefit from these enhanced security
+   capabilities immediately and avoid the need for `-shell-escape`.
+
+   - TeX Live:  Copy the variable `shell_escape_commands` from the
+     distribution `texmf.cnf` (typically something like
+     `<tex_distro>/texmf-dist/web2c/texmf.cnf`) into the user `texmf.cnf`
+     (typically something like `<tex_distro>/texmf.cnf`), and then add
+     `latexminted` to the end of the `shell_escape_commands` list.  The
+     location of the `texmf.cnf` files can be determined by running
+     `kpsewhich -all texmf.cnf`.
+
+   - 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
+     [MiKTeX documentation](https://docs.miktex.org/manual/miktex.ini.html)
+     for more details, particularly `initexmf --edit-config-file <file>`.
+
+*  Errors and warnings that occur within Python are now reported as `minted`
+   package errors and warnings within LaTeX in nearly all cases.  It should no
+   longer be necessary to look through the compile log for Python errors and
+   warnings.  A temp file `*.errlog.minted` containing Python traceback
+   information is created in some cases when errors cannot be fully reported
+   within LaTeX or more details may be needed.
+
+*  [`latex2pydata`](https://github.com/gpoore/latex2pydata) is now required
+   for passing data from LaTeX to Python and then processing it within Python.
+   This consists of a LaTeX package, available from
+   [CTAN](https://ctan.org/pkg/latex2pydata), and a Python package, available
+   from [PyPI](https://pypi.org/project/latex2pydata/).  The LaTeX package can
+   typically be installed with your TeX distribution's package manager.  The
+   Python package is automatically installed within your TeX distribution when
+   `minted` is installed.
+
+*  On the LaTeX side, all syntax highlighting settings are now serialized in
+   Python literal format using `latex2pydata` and then saved to a temp file,
+   which is loaded on the Python side.  Settings are no longer passed to the
+   Python side using command-line arguments.  Temp files for passing data to
+   Python are now named using MD5 hashes, instead of using a sanitized version
+   of document `\jobname`.  This eliminates an entire class of security issues
+   and bugs related to escaping and quoting command-line arguments (#180,
+   #276, #298, #322, #338, #354).  It also eliminates bugs related to
+   processing settings as a sequence of command-line options, since
+   `pygmentize` accumulates some options that are used multiple times rather
+   than overwriting earlier values with later values (#258, #337).
+
+*  Options are now handled with `pgfkeys` and `pgfopts`, instead of
+   `keyval` and `kvoptions`.
+
+*  Temporary files are no longer created unless the cache needs to be updated
+   (or caching is disabled).  All MD5 hashing of code now takes place in
+   memory instead of using one temp file per command/environment.
+
+   All temporary files are cleaned up automatically when compiling completes
+   without interruption.  All temporary files now have names of the form
+   `_<hash>.<role>.minted`.  `<hash>` is an MD5 hash of `\jobname` (if
+   `\jobname` is wrapped in double or single quotation marks, these are
+   stripped before the MD5 is computed).  `<role>` is the role of the temp
+   file: `data` (data passed to Python), `config` (detected system
+   configuration), `style` (highlighting style definition), `highlight`
+   (highlighted code), or `message` (message passed back to LaTeX by Python
+   executable).  `<role>` can also be `errlog` when the Python executable
+   encounters an unexpected error that it is not designed to report to the
+   LaTeX side; this is not automatically cleaned up.  There are no more
+   `<jobname>.pyg` and `<jobname>.out.pyg` files.
+
+*  Several package options are no longer supported and result in errors or
+   warnings.
+
+   - `finalizecache`:  No longer needed.  The `frozencache` package option now
+      uses the regular cache, rather than requiring a new, special cache
+      containing files with sequentially numbered names (#342).  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`).
+
+   - `outputdir`:  No longer needed (#268).  TeX Live 2024+ saves a custom
+     output directory from `-output-directory` in the environment variable
+     [`TEXMF_OUTPUT_DIRECTORY`](https://tug.org/texinfohtml/web2c.html#Output-file-location).
+     The environment variable `TEXMF_OUTPUT_DIRECTORY` can be set manually in
+     other cases.
+
+   - `kpsewhich`:  No longer needed.  `kpsewhich` is now automatically
+     invoked as necessary by the `latexminted` Python executable in locating
+     files.
+
+   - `draft` and `final`:  These no longer have any effect and result in a
+     warning.  They will soon be removed altogether.  Improvements in caching
+     have largely eliminated the overhead that `draft` mode was designed to
+     avoid, while new features that are implemented purely within Python have
+     made it impossible in some cases to typeset code using only LaTeX.  The
+     new package options `placeholder` and `verbatim` offer alternatives when
+     maximum compilation speed is needed or the `latexminted` Python
+     executable is unavailable.
+
+*  New package options:
+
+   - `debug`:  Keep temp files from highlighting to aid in debugging.  Also
+     write current file name and line number to log before `\input` of
+     highlighted code (#348).
+
+   - `highlightmode`:  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.
+
+   - `placeholder`:  Instead of typesetting code, insert a placeholder.  This
+     is enabled automatically when working with PGF/TikZ externalization.
+
+   - `verbatim`:  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.
+
+*  `bgcolor` now uses the new `bgcolor` option from `fvextra` v1.8, rather
+   than `snugshade*` from `framed`.  This resolves incompatibilities between
+   `bgcolor` and `xleftmargin`/`xrightmargin` (#214), eliminates unneeded
+   whitespace before/after the background (#220), prevents text from
+   overflowing the background (#278), and provides uniform background height
+   for `\mintinline` (#397).  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.
+
+*  Renamed package options `langlinenos` to `lexerlinenos` and
+   `inputlanglinenos` to `inputlexerlinenos`.  The old names are still
+   supported.
+
+*  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.  The new `latexminted` Python executable improves cache management
+   so that a shared cache functions correctly.  A cache file that is shared by
+   multiple documents will not be deleted if one document ceases to use the
+   file.
+
+   Document-specific caching as in `minted` v2 can be restored using the
+   package option `cachedir`.  For example, for files whose names do not
+   contain spaces, simply use `cachedir=\detokenize{_minted-}\jobname`.  For
+   files with names that do contain spaces, use a copy of `\jobname` in which
+   the wrapping quotation marks have been removed or replaced with other
+   characters and the spaces have been replaced with placeholders such as `_`.
+
+*  Cache file names now take the form `<hash>_highlight.minted` and
+   `<style>_style.minted`.  `<hash>` is a single MD5 hash of code and options,
+   when serialized in Python literal format.  Cache file names no longer use
+   two concatenated MD5 hashes, one of code and one of options.  The cache
+   directory will also contain files `_<hash>.index.minted`.  These list all
+   cache files used by a given document.  In this case, `<hash>` is the MD5
+   hash of the document's `\jobname` (if `\jobname` is wrapped in double or
+   single quotation marks, these are stripped before the MD5 is computed).
+
+*  Highlighting style names must now match the regular expression
+   `^[0-9A-Za-z_-]+$`.  This is checked on the LaTeX side.
+
+*  `\inputminted` is redefined as robust and is usable in movable arguments.
+
+*  `\newminted` now creates an environment that takes an optional argument
+   consisting of options, instead of taking no argument.  It still creates a
+   starred `*` environment variant that takes a mandatory argument consisting
+   of options, but this is only retained for backward-compatibility purposes.
+
+*  Improved fallback behavior in the event of errors.  If code cannot be
+   highlighted, it is automatically typeset with a verbatim approximation if
+   possible and otherwise replaced by a placeholder.  If a highlighting style
+   definition cannot be generated, it is automatically replaced with the
+   default style if available, and otherwise a built-in style with no syntax
+   highlighting is used.
+
+*  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.
+
+*  Added new options for including ranges of code based on literal string
+   delimiters or regular expressions.  These work with all commands and
+   environments, including `\inputminted`.
+
+   - `rangestartstring`:  Select code starting with this string.
+
+   - `rangestartafterstring`:  Select code starting immediately after this
+     string.
+
+   - `rangestopstring`:  Select code ending with this string.
+
+   - `rangestopbeforestring`:  Select code ending immediately before this
+     string.
+
+   - `rangeregex`:  Select code that matches this regular expression.
+
+   - `rangeregexmatchnumber` [default=`1`]:  If there are multiple
+     non-overlapping matches for `rangeregex`, this determines which is
+     used.
+
+   - `rangeregexdotall` [default=`false`]:  `.` matches any character
+     including the newline.
+
+   - `rangeregexmultiline` [default=`false`]:  `^` and `$` match at
+     internal newlines, not just at the start/end of the string.
+
+   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.
+
+   String values and regular expressions can be set using text with backslash
+   escapes, in a manner analogous to regular (non-raw) Python strings.  Any
+   ASCII symbols and punctuation, including those that have special LaTeX
+   meaning, can be backslash escaped.  For example, `rangeregex=\\\\.` is
+   processed like the Python string `"\\\\."`, becoming the literal text
+   `\\.`, which is then interpreted as the regular expression for a literal
+   backslash followed by any character.  Alternatively, string values and
+   regular expressions can be set using a single macro that, when fully
+   expanded (`\edef`), gives the desired literal text.  For example,
+   `\def\pattern{\detokenize{\\.}}` and then `rangeregex=\pattern` would be
+   equivalent to `rangeregex=\\\\.`.
+
+*  There is now official support for custom lexers.  Custom lexers that are
+   installed as Pygments [plugins](https://pygments.org/docs/plugins/) have
+   always been supported, since Pygments can find them automatically.
+   However, custom lexers in the form of `*.py` files in the document
+   directory have not officially been supported.
+
+   Custom lexers can be specified in place of builtin lexers.  For example,
+   `\inputminted{lexer.py}{<file>}` or
+   `\inputminted{./path/lexer.py:LexerClass}{<file>}`.
+
+   Custom lexers in the form of `*.py` files are not automatically enabled,
+   since they are equivalent to arbitrary code execution and are thus a
+   significant security risk.  To enable custom lexers, create a file
+   `.latexminted_config`.  This can be in your home directory (as found by
+   Python's `pathlib.Path.home()`) or in `TEXMFHOME`; if this file is found in
+   both locations, settings from the TeX location overwrite settings from the
+   home directory.  It is also possible to enable a `.latexminted_config` file
+   in your document directory; see the documentation for
+   `.latexminted_config`.  This file must contain data in Python literal,
+   JSON, or TOML format.  TOML requires Python >= 3.11.  The data must contain
+   an entry equivalent to this Python data:
+   ```
+   {
+      "custom_lexers": {
+         "<lexer file name>": "<SHA-256 hash of lexer file>"
+      }
+   }
+   ```
+   `<lexer file name>` is just the name of the file, with no path or class
+   included.  For example, for `./path/lexer.py:LexerClass` it would be just
+   `lexer.py`.  Any number of file names and hashes can be provided.
+
+*  Enhancements of existing options:
+
+   - `codetagify` now supports comma-delimited lists of strings, not just
+     space-delimited lists (#126).
+
+*  New options:
+
+   - `envname`:  Name of the environment that wraps typeset code.  By default,
+     it is `Verbatim` in block contexts and `VerbEnv` in inline contexts.
+     This is compatible with `fancyvrb`'s `BVerbatim` (#281).
+
+     Implementation note:  Code is actually wrapped a `MintedVerbatim`
+     environment, and then this is redefined to be equivalent to `envname`
+     (see the new option `literalenvname`).
+
+   - `literalenvname`:  This is the name of the environment that literally
+     appears in highlighted code output as a wrapper around the code.  By
+     default it is `MintedVerbatim`.  This environment is redefined to be
+     equivalent to the current value of `envname`.  There should be few if any
+     situations where modifying `literalenvname` rather than `envname` is
+     actually necessary.
+
+   - `literatecomment`:   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 `<literatecomment>`, then
+     `<literatecomment>` is removed from the beginning of all lines.  For
+     example, for `.dtx`, `literatecomment=\%`.
+
+   - `listparameters`:  Previously unsupported `fancyvrb` option (#256).
+
+   - `breakanywhereinlinestretch`:  New `fvextra` option.
+
+*  `gobble` is now applied to code before syntax highlighting and no longer
+   uses the Pygments `gobble` filter, which operates on the token stream
+   generated by a lexer.  This makes `gobble` and `autogobble` behave in the
+   same manner.  The Pygments `gobble` filter is still accessible via the new
+   option `gobblefilter` (#379).
+
+*  Standard catcodes are now enforced in reading the optional argument of
+   environments that wrap Pygments output.  This prevents issues with
+   `babel`'s `magyar` (#382).
+
+
+## v2.9 (2023/12/18)
+
+*  This is expected to be the last release of `minted` v2.x.  If so, it will
+   then become the new package `minted2` for backward compatibility.
+
+*  Added new option `ignorelexererrors`.  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 (#374).
+
+*  There is now a warning if `fvextra` version is less than 1.5.
+
+
+
+## v2.8 (2023/09/12)
+
+*   Under non-Windows operating systems, detect executables with `command -v`
+    rather than `which` to provide better cross-platform support (#345).
+
+*   Added new package option `inputlanglinenos`.  This extends the existing
+    `langlinenos` to cover `\inputminted` as well (#361).
+
+*   Improved and updated Pygments documentation (#339).
+
+*   Improved `\mintinline` documentation to address packages that redefine
+    `\section` (#368).
+
+*   Added support for `fvextra` options `breakafterinrun` and
+    `breakbeforeinrun` (#358).  In `fvextra` version 1.5, `breakaftergroup`
+    and `breakbeforegroup` were renamed to `breakafterinrun` and
+    `breakbeforeinrun` to avoid naming ambiguity with new options.  The old
+    options `breakaftergroup` and `breakbeforegroup` are no longer supported.
+
+*   Added `DEPENDS.txt` (#331).
+
+*   Removed unnecessary dependency on `calc` package (#313).
+
+*   Added documentation in FAQ about copy and paste limitations (#302).
+
+*   Added note on `text` lexer to documentation (#274).
+
+
+
+## v2.7 (2022/12/12)
+
+*   Reimplemented `\mintinline` to use `fvextra`'s argument reading and
+    processing macros, and to use `fvextra`'s `\Verb` internally.
+    `\mintinline` now works with all line breaking options supported by
+    `fvextra`'s `\Verb`, including `breakanywhere` (#329, #340).  It now
+    gives better results when used inside other commands, since it uses
+    `fvextra`'s retokenization macros.  It is now compatible with `hyperref`
+    for PDF strings such as bookmarks.
+
+*   Reimplemented `\newmintinline` based on new `\mintinline`.
+
+*   Reimplemented `\mint` to use `fvextra`'s argument reading and processing
+    macros.  It now gives better results when used inside other commands,
+    since it uses `fvextra`'s retokenization macros.  Fixed a bug that caused
+    a continued paragraph after `\mint` to be indented (#218).
+
+*   Reimplemented `\newmint` based on new `\mint`.  Commands created with
+    `\newmint` can now use curly braces as delimiters, just like `\mint`
+    (#254).
+
+*   Settings passed to `pygmentize` as command-line options are now quoted.
+    This prevents `escapeinside` characters from being interpreted as special
+    shell characters (#179, #262).
+
+*   Fixed bug with `autogobble` that produced incorrect dedent when using
+    `lastline` with the lines beyond `lastline` having less indentation than
+    the selected range (#326).
+
+*   Fixed unintended line breaks after hyphens under LuaTeX (#263).
+
+*   Added warning to documentation of `\inputminted` regarding filenames
+    and shell command execution (#338).
+
+
+
+## v2.6 (2021/12/24)
+
+*   `autogobble` automatically uses `python` or `python3` executables,
+    depending on availability, instead of requiring `python`.  A custom
+    executable can be specified by redefining `\MintedPython` (#277, #287).
+
+*   Fixed `autogobble` compatibility with `fancyvrb` 4.0+ (#315, #316).
+
+*   Pygments style names may now contain arbitrary non-whitespace characters.
+    Previously, style names containing digits and some punctuation characters
+    were incompatible (#210, #294, #299, #317).  Pygments macros are now only
+    defined just before use locally within `minted` commands and environments,
+    rather than globally.  Pygments macros now always use a `\PYG` prefix
+    regardless of style, rather than a prefix of the form `\PYG<style>` (for
+    example, what was previously `\PYGdefault` is now simply `\PYG`).
+
+*   Removed Python-based MD5 hashing for XeTeX, which was necessary before
+    XeTeX added `\mdfivesum` in 2017.
+
+*   The default for `stripnl` is now `false`, so that original code is
+    preserved exactly by default (#198).
+
+*   Added support for `fontencoding` option from `fvextra` (#208).
+
+*   Added note to FAQ about getting `texi2pdf` to work with `minted` given
+    `texi2pdf`'s assumptions about temp files (#186).
+
+*   Reimplemented `bgcolor` option to be compatible with `color` package.
+
+
+
+## v2.5 (2017/07/19)
+
+*  The default placement for the `listing` float is now `tbp` instead of `h`,
+   to parallel `figure` and `table` and also avoid warnings caused by `h`
+   (#165).  The documentation now contains information about changing default
+   placement.  The `float` package is no longer loaded when the `newfloat`
+   package option is used.
+
+*  Added support for `*nchars` options from `fvextra` v1.3 that allow setting
+   `breaklines`-related indentation in terms of a number of characters, rather
+   than as a fixed dimension.
+
+*  Fixed incompatibility with `babel magyar` (#158).
+
+*  Added support for `beamer` overlays with `beameroverlays` option (#155).
+
+*  Comments in the Pygments LaTeX style files no longer appear as literal
+   text when `minted` is used in `.dtx` files (#161).
+
+*  `autogobble` now works with package option `kpsewhich` (#151).  Under
+   Windows, the `kpsewhich` option no longer requires PowerShell.
+
+*  Fixed a bug that prevented `finalizecache` from working with `outputdir`
+   (#149).
+
+*  Fixed a bug with `firstline` and `lastline` that prevented them from
+   working with the `minted` environment (#145).
+
+*  Added note on `breqn` conflicts to FAQ (#163).
+
+
+
+## v2.4.1 (2016/10/31)
+
+*  Single quotation marks in `\jobname` are now replaced with underscores in
+   `\minted at jobname` to prevent quoting errors (#137).
+
+*  The `autogobble` option now takes `firstline` and `lastline` into account
+   (#130).
+
+*  Fixed `numberblanklines`, which had been lost in the transition to v2.0+
+   (#135).
+
+
+
+## v2.4 (2016/07/20)
+
+*  Line breaking and all associated options are now completely delegated to
+   `fvextra`.
+
+*  Fixed a bug from v2.2 that could cause the first command or environment to
+   vanish when `cache=false` (related to work on `\MintedPygmentize`).
+
+
+
+## v2.3 (2016/07/14)
+
+*  The `fvextra` package is now required.  `fvextra` extends and patches
+   `fancyvrb`, and includes improved versions of `fancyvrb` extensions that
+   were formerly in `minted`.
+
+*  As part of `fvextra`, the `upquote` package is always loaded.  `fvextra`
+   brings the new option `curlyquotes`, which allows curly single quotation
+   marks instead of the literal backtick and typewriter single quotation mark
+   produced by `upquote`.  This allows the default `upquote` behavior to be
+   disabled when desired.
+
+*  Thanks to `fvextra`, the options `breakbefore`, `breakafter`, and
+   `breakanywhere` are now compatible with non-ASCII characters under
+   pdfTeX (#123).
+
+*  Thanks to `fvextra`, `obeytabs` no longer causes lines in multi-line
+   comments or strings to vanish (#88), and is now compatible with
+   `breaklines` (#99).  `obeytabs` will now always give correct results with
+   tabs used for indentation.  However, tab stops are not guaranteed to be
+   correct for tabs in the midst of text.
+
+*  `fvextra` brings the new options `space`, `spacecolor`, `tab`, and
+    `tabcolor` that allow these characters and their colors to be redefined
+    (#98).  The tab may now be redefined to a flexible-width character such
+    as `\rightarrowfill`.  The visible tab will now always be black by default,
+    instead of changing colors depending on whether it is part of indentation
+    for a multiline string or comment.
+
+*  `fvextra` brings the new options `highlightcolor` and `highlightlines`,
+   which allow single lines or ranges of lines to be highlighted based on line
+   number (#124).
+
+*  `fvextra` brings the new options `numberfirstline`, `stepnumberfromfirst`,
+   and `stepnumberoffsetvalues` that provide better control over line
+   numbering when `stepnumber` is not 1.
+
+*  Fixed a bug from v2.2.2 that prevented `upquote` from working.
+
+
+
+## v2.2.2 (2016/06/21)
+
+*  Fixed a bug introduced in v2.2 that prevented setting the Pygments style in
+   the preamble.  Style definitions are now more compatible with using
+   `\MintedPygmentize` to call a custom `pygmentize`.
+
+
+
+## v2.2.1 (2016/06/15)
+
+*  The `shellesc` package is loaded before `ifplatform` and other packages
+   that might invoke `\write18` (#112).
+
+*  When caching is enabled, XeTeX uses the new `\mdfivesum` macro from TeX
+   Live 2016 to hash cache content, rather than using `\ShellEscape` with
+   Python to perform hashing.
+
+
+
+## v2.2 (2016/06/08)
+
+*  All uses of `\ShellEscape` (`\write18`) no longer wrap file names and paths
+   with double quotes.  This allows a cache directory to be specified relative
+   to a user's home directory, for example, `~/minted_cache`.  `cachedir` and
+   `outputdir` paths containing spaces will now require explicit quoting of
+   the parts of the paths that contain spaces, since `minted` no longer
+   supplies quoting.  See the updated documentation for examples (#89).
+
+*  Added `breakbefore`, `breakbeforegroup`, `breakbeforesymbolpre`, and
+   `breakbeforesymbolpost`.  These parallel `breakafter*`.  It is possible to
+   use `breakbefore` and `breakafter` for the same character, so long as
+   `breakbeforegroup` and `breakaftergroup` have the same setting (#117).
+
+*  Added package options `finalizecache` and `frozencache`.  These allow the
+   cache to be prepared for (`finalizecache`) and then used (`frozencache`) in
+   an environment in which `-shell-escape`, Python, and/or Pygments are not
+   available.  Note that this only works if `minted` content does not need to
+   be modified, and if no settings that depend on Pygments or Python need to
+   be changed (#113).
+
+*  Style names containing hyphens and underscores (`paraiso-light`,
+   `paraiso-dark`, `algol_nu`) now work (#111).
+
+*  The `shellesc` package is now loaded, when available, for compatibility
+   with LuaTeX 0.87+ (TeX Live 2016+, etc.).  `\ShellEscape` is now used
+   everywhere instead of `\immediate\write18`.  If `shellesc` is not available,
+   then a `\ShellEscape` macro is created.  When `shellesc` is loaded, there
+   is a check for versions before v0.01c to patch a bug in v0.01b (present in
+   TeX Live 2015) (#112).
+
+*  The `bgcolor` option now uses the `snugshade*` environment from the `framed`
+   package, so `bgcolor` is now compatible with page breaks.  When `bgcolor`
+   is in use, immediately preceding text will no longer push the `minted`
+   environment into the margin, and there is now adequate spacing from
+   surrounding text (#121).
+
+*  Added missing support for `fancyvrb`'s `labelposition` (#102).
+
+*  Improved fix for TikZ externalization, thanks to Patrick Vogt (#73).
+
+*  Fixed `breakautoindent`; it was disabled in version 2.1 due to a bug in
+   `breakanywhere`.
+
+*  Properly fixed handling of `\MintedPygmentize` (#62).
+
+*  Added note on incompatibility of `breaklines` and `obeytabs` options.
+   Trying to use these together will now result in a package error (#99).
+   Added note on issues with `obeytabs` and multiline comments (#88).  Due to
+   the various `obeytabs` issues, the docs now discourage using `obeytabs`.
+
+*  Added note to FAQ on `fancybox` and `fancyvrb` conflict (#87).
+
+*  Added note to docs on the need for `\VerbatimEnvironment` in environment
+   definitions based on `minted` environments.
+
+
+
+## v2.1 (2015/09/09)
+
+*  Changing the highlighting style now no longer involves re-highlighing
+   code.  Style may be changed with almost no overhead.
+
+*  Improved control of automatic line breaks.  New option `breakanywhere`
+   allows line breaks anywhere when `breaklines=true`.  The pre-break and
+   post-break symbols for these types of breaks may be set with
+   `breakanywheresymbolpre` and `breakanywheresymbolpost` (#79).  New option
+   `breakafter` allows specifying characters after which line breaks are
+   allowed.  Breaks between adjacent, identical characters may be controlled
+   with `breakaftergroup`.  The pre-break and post-break symbols for these
+   types of breaks may be set with `breakaftersymbolpre` and
+   `breakaftersymbolpost`.
+
+*  `breakbytoken` now only breaks lines between tokens that are separated by
+   spaces, matching the documentation.  The new option `breakbytokenanywhere`
+   allows for breaking between tokens that are immediately adjacent.  Fixed a
+   bug in `\mintinline` that produced a following linebreak when
+   `\mintinline` was the first thing in a paragraph and `breakbytoken` was
+   true (#77).
+
+*  Fixed a bug in draft mode option handling for `\inputminted` (#75).
+
+*  Fixed a bug with `\MintedPygmentize` when a custom `pygmentize` was
+   specified and there was no `pygmentize` on the default path (#62).
+
+*  Added note to docs on caching large numbers of code blocks under OS X (#78).
+
+*  Added discussion of current limitations of `texcomments` (#66) and
+   `escapeinside` (#70).
+
+*  PGF/Ti*k*Z externalization is automatically detected and supported
+   (#73).
+
+*  The package is now compatible with LaTeX files whose names contain spaces (#85).
+
+
+
+## v2.0 (2015/01/31)
+
+*  Added the compatibility package `minted1`, which provides the `minted` 1.7
+   code.  This may be loaded when 1.7 compatibility is required.  This package
+   works with other packages that `\RequirePackage{minted}`, so long as it is
+   loaded first.
+
+*  Moved all old `\changes` into `changelog`.
+
+
+
+## Development releases for 2.0 (2014-January 2015)
+
+*  Caching is now on by default.
+
+*  Fixed a bug that prevented compiling under Windows when file names
+   contained commas.
+
+*  Added `breaksymbolleft`, `breaksymbolsepleft`,
+   `breaksymbolindentleft`, `breaksymbolright`, `breaksymbolsepright`,
+   and `breaksymbolindentright` options. `breaksymbol`,
+   `breaksymbolsep`, and `breaksymbolindent` are now aliases for the
+   correspondent `*left` options.
+
+*  Added `kpsewhich` package option. This uses `kpsewhich` to locate
+   the files that are to be highlighted. This provides compatibility
+   with build tools like `texi2pdf` that function by modifying
+   `TEXINPUTS` (#25).
+
+*  Fixed a bug that prevented `\inputminted` from working with `outputdir`.
+
+*  Added informative error messages when Pygments output is missing.
+
+*  Added `final` package option (opposite of `draft`).
+
+*  Renamed the default cache directory to `_minted-<jobname>` (replaced
+   leading period with underscore). The leading period caused the cache
+   directory to be hidden on many systems, which was a potential source
+   of confusion.
+
+*  `breaklines` and `breakbytoken` now work with `\mintinline` (#31).
+
+*  `bgcolor` may now be set through `\setminted` and `\setmintedinline`.
+
+*  When math is enabled via `texcomments`, `mathescape`, or
+   `escapeinside`, space characters now behave as in normal math by
+   vanishing, instead of appearing as literal spaces. Math need no
+   longer be specially formatted to avoid undesired spaces.
+
+*  In default value of `\listoflistingscaption`, capitalized “Listings” so that
+   capitalization is consistent with default values for other lists
+   (figures, tables, algorithms, etc.).
+
+*  Added `newfloat` package option that creates the `listing`
+   environment using `newfloat` rather than `float`, thus providing
+   better compatibility with the `caption` package (#12).
+
+*  Added support for Pygments option `stripall`.
+
+*  Added `breakbytoken` option that prevents `breaklines` from breaking
+   lines within Pygments tokens.
+
+*  `\mintinline` uses a `\colorbox` when `bgcolor` is set, to give more
+   reasonable behavior (#57).
+
+*  For PHP, `\mintinline` automatically begins with `startinline=true` (#23).
+
+*  Fixed a bug that threw off line numbering in `minted` when
+   `langlinenos=false` and `firstnumber=last`. Fixed a bug in `\mintinline` that
+   threw off subsequent line numbering when `langlinenos=false` and
+   `firstnumber=last`.
+
+*  Improved behavior of `\mint` and `\mintinline` in `draft` mode.
+
+*  The `\mint` command now has the additional capability to take code
+   delimited by paired curly braces `{}`.
+
+*  It is now possible to set options only for `\mintinline` using the new
+   `\setmintedinline` command. Inline options override options specified via
+   `\setminted`.
+
+*  Completely rewrote option handling. `fancyvrb` options are now handled on the
+   LaTeX side directly, rather than being passed to Pygments and then
+   returned. This makes caching more efficient, since code is no longer
+   rehighlighted just because options changed.
+
+*  Fixed buffer size error caused by using `cache` with a very large
+   number of files (#61).
+
+*  Fixed `autogobble` bug that caused failure under some operating
+   systems.
+
+*  Added support for `escapeinside` (requires Pygments 2.0+; #38).
+
+*  Fixed issues with XeTeX and caching (#40).
+
+*  The `upquote` package now works correctly with single quotes when
+   using Pygments 1.6+ (#34).
+
+*  Fixed caching incompatibility with Linux and OS X under xelatex
+   (#18 and #42).
+
+*  Fixed `autogobble` incompatibility with Linux and OS X.
+
+*  `\mintinline` and derived commands are now robust, via `\newrobustcmd`
+   from `etoolbox`.
+
+*  Unused styles are now cleaned up when caching.
+
+*  Fixed a bug that could interfere with caching (#24).
+
+*  Added `draft` package option (#39). This typesets all code using
+   `fancyvrb`; Pygments is not used. This trades syntax highlighting
+   for maximum speed in compiling.
+
+*  Added automatic line breaking with `breaklines` and related options
+   (#1).
+
+*  Fixed a bug with boolean options that needed a False argument to
+   cooperate with `\setminted` (#48).
+
+
+
+## v2.0-alpha3 (2013/12/21)
+
+*  Added `autogobble` option.  This sends code through Python's
+   `textwrap.dedent()` to remove common leading whitespace.
+
+*  Added package option `cachedir`.  This allows the directory in which
+   cached content is saved to be specified.
+
+*  Added package option `outputdir`.  This allows an output directory for
+   temporary files to be specified, so that the package can work with
+   LaTeX's `-output-directory` command-line option.
+
+*  The `kvoptions` package is now required.  It is needed to process
+   key-value package options, such as the new `cachedir` option.
+
+*  Many small improvements, including better handling of paths under
+   Windows and improved key system.
+
+
+
+## v2.0-alpha2 (2013/08/21)
+
+*  `\DeleteFile` now only deletes files if they do indeed exist.  This
+   eliminates warning messages due to missing files.
+
+*  Fixed a bug in the definition of `\DeleteFile` for non-Windows systems.
+
+*  Added support for Pygments option `stripnl`.
+
+*  Settings macros that were previously defined globally are now defined
+   locally, so that `\setminted` may be confined by `\begingroup...\endgroup`
+   as expected.
+
+*  Macro definitions for a given style are now loaded only once per document,
+   rather than once per command/environment.  This works even without caching.
+
+*  A custom script/executable may now be substituted for `pygmentize` by
+   redefining `\MintedPygmentize`.
+
+
+
+## v2.0alpha (2013/07/30)
+
+*  Added the package option `cache`. This significantly increases
+   compilation speed by caching old output. For example, compiling the
+   documentation is around 5x faster.
+
+*  New inline command `\mintinline`. Custom versions can be created via
+   `\newmintinline`. The command works inside other commands (for example,
+   footnotes) in most situations, so long as the percent and hash
+   characters are avoided.
+
+*  The new `\setminted` command allows options to be specified at the
+   document and language levels.
+
+*  All extended characters (Unicode, etc.) supported by `inputenc` now
+   work under the pdfTeX engine. This involved using `\detokenize` on
+   everything prior to saving.
+
+*  New package option `langlinenos` allows line numbering to pick up
+   where it left off for a given language when `firstnumber=last`.
+
+*  New options, including `style`, `encoding`, `outencoding`,
+   `codetagify`, `keywordcase`, `texcomments` (same as `texcl`),
+   `python3` (for the `PythonConsoleLexer`), and `numbers`.
+
+*  `\usemintedstyle` now takes an optional argument to specify the style for a
+   particular language, and works anywhere in the document.
+
+*  `xcolor` is only loaded if `color` isn’t, preventing potential
+   package clashes.
+
+
+
+## v1.7 (2011/09/17)
+
+*  Options for float placement added [2011/09/12]
+
+*  Fixed `tabsize` option [2011/08/30]
+
+*  More robust detection of the `-shell-escape` option [2011/01/21]
+
+*  Added the `label` option [2011/01/04]
+
+*  Installation instructions added [2010/03/16]
+
+*  Minimal working example added [2010/03/16]
+
+*  Added PHP-specific options [2010/03/14]
+
+*  Removed unportable flag from Unix shell command [2010/02/16]
+
+
+## v1.6 (2010/01/31)
+
+*  Added font-related options [2010/01/27]
+
+*  Windows support added [2010/01/27]
+
+*  Added command shortcuts [2010/01/22]
+
+*  Simpler versioning scheme [2010/01/22]
+
+
+
+## v0.1.5 (2010/01/13)
+
+*  Added `fillcolor` option [2010/01/10]
+
+*  Added float support [2010/01/10]
+
+*  Fixed `firstnumber` option [2010/01/10]
+
+* Removed `caption` option [2010/01/10]
+
+
+
+## v0.0.4 (2010/01/08)
+
+*  Initial version [2010/01/08]


Property changes on: trunk/Master/texmf-dist/doc/latex/minted/CHANGELOG_MINTED_LATEX_PACKAGE.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/minted/DEPENDS.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/minted/DEPENDS.txt	2024-09-23 21:20:10 UTC (rev 72362)
+++ trunk/Master/texmf-dist/doc/latex/minted/DEPENDS.txt	2024-09-23 21:20:32 UTC (rev 72363)
@@ -1,15 +1,11 @@
 catchfile
 etoolbox
 float
-framed
 fvextra
-ifplatform
-ifthen
-keyval
-kvoptions
-lineno
+latex2pydata
 newfloat
 pdftexcmds
+pgfkeys
+pgfopts
 shellesc
 xcolor
-xstring

Modified: trunk/Master/texmf-dist/doc/latex/minted/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/minted/README	2024-09-23 21:20:10 UTC (rev 72362)
+++ trunk/Master/texmf-dist/doc/latex/minted/README	2024-09-23 21:20:32 UTC (rev 72363)
@@ -8,9 +8,7 @@
 installation and usage.
 
 This work may be distributed and/or modified under the conditions of the
-LaTeX Project Public License (LPPL), version 1.3 or later.  Additionally,
-the project may be distributed under the terms of the 3-Clause ("New") BSD
-license.
+LaTeX Project Public License (LPPL), version 1.3c or later.
 
 For suggestions, feature requests, and bug reports, please use the project's
 GitHub site:  https://github.com/gpoore/minted.

Added: trunk/Master/texmf-dist/doc/latex/minted/latex2pydata-0.4.0-py3-none-any.whl
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/minted/latex2pydata-0.4.0-py3-none-any.whl
===================================================================
--- trunk/Master/texmf-dist/doc/latex/minted/latex2pydata-0.4.0-py3-none-any.whl	2024-09-23 21:20:10 UTC (rev 72362)
+++ trunk/Master/texmf-dist/doc/latex/minted/latex2pydata-0.4.0-py3-none-any.whl	2024-09-23 21:20:32 UTC (rev 72363)

Property changes on: trunk/Master/texmf-dist/doc/latex/minted/latex2pydata-0.4.0-py3-none-any.whl
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/minted/latexminted-0.1.0-py3-none-any.whl
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/minted/latexminted-0.1.0-py3-none-any.whl
===================================================================
--- trunk/Master/texmf-dist/doc/latex/minted/latexminted-0.1.0-py3-none-any.whl	2024-09-23 21:20:10 UTC (rev 72362)
+++ trunk/Master/texmf-dist/doc/latex/minted/latexminted-0.1.0-py3-none-any.whl	2024-09-23 21:20:32 UTC (rev 72363)

Property changes on: trunk/Master/texmf-dist/doc/latex/minted/latexminted-0.1.0-py3-none-any.whl
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/minted/latexrestricted-0.4.0-py3-none-any.whl
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/minted/latexrestricted-0.4.0-py3-none-any.whl
===================================================================
--- trunk/Master/texmf-dist/doc/latex/minted/latexrestricted-0.4.0-py3-none-any.whl	2024-09-23 21:20:10 UTC (rev 72362)
+++ trunk/Master/texmf-dist/doc/latex/minted/latexrestricted-0.4.0-py3-none-any.whl	2024-09-23 21:20:32 UTC (rev 72363)

Property changes on: trunk/Master/texmf-dist/doc/latex/minted/latexrestricted-0.4.0-py3-none-any.whl
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/latex/minted/minted.pdf
===================================================================
(Binary files differ)

Added: trunk/Master/texmf-dist/doc/latex/minted/pygments-2.18.0-py3-none-any.whl
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/minted/pygments-2.18.0-py3-none-any.whl
===================================================================
--- trunk/Master/texmf-dist/doc/latex/minted/pygments-2.18.0-py3-none-any.whl	2024-09-23 21:20:10 UTC (rev 72362)
+++ trunk/Master/texmf-dist/doc/latex/minted/pygments-2.18.0-py3-none-any.whl	2024-09-23 21:20:32 UTC (rev 72363)

Property changes on: trunk/Master/texmf-dist/doc/latex/minted/pygments-2.18.0-py3-none-any.whl
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Deleted: trunk/Master/texmf-dist/source/latex/minted/Makefile
===================================================================
--- trunk/Master/texmf-dist/source/latex/minted/Makefile	2024-09-23 21:20:10 UTC (rev 72362)
+++ trunk/Master/texmf-dist/source/latex/minted/Makefile	2024-09-23 21:20:32 UTC (rev 72363)
@@ -1,38 +0,0 @@
-TEXFLAGS = -e '$$pdflatex=q/pdflatex %O -shell-escape %S/' -pdf
-LATEXMK = latexmk
-
-PACKAGE = minted.dtx \
-		  minted.ins \
-		  minted.pdf \
-		  README \
-		  Makefile
-
-.PHONY: minted all doc dist clean cleanall
-
-minted: minted.sty
-
-doc: minted.pdf
-
-all: minted doc
-
-minted.sty: minted.ins minted.dtx
-	tex minted.ins
-
-minted.pdf: minted.sty minted.gls minted.dtx
-	$(LATEXMK) $(TEXFLAGS) minted.dtx
-
-minted.gls: minted.glo
-	makeindex -s gglo.ist -o minted.gls minted.glo
-
-minted.glo: minted.dtx minted.sty
-	$(LATEXMK) $(TEXFLAGS) minted.dtx
-
-dist: $(PACKAGE)
-	@$(RM) minted.zip
-	@zip minted-$(shell grep '^\\ProvidesPackage' < minted.sty | grep -o '\<v[[:digit:]]*\.[[:digit:]]*\>').zip $(PACKAGE)
-
-clean:
-	@$(RM) *.aux *.log *.out *.toc *.fdb_latexmk *.ilg *.glo *.gls *.lol
-
-cleanall: clean
-	@$(RM) minted.sty minted.zip

Modified: trunk/Master/texmf-dist/source/latex/minted/minted.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/minted/minted.dtx	2024-09-23 21:20:10 UTC (rev 72362)
+++ trunk/Master/texmf-dist/source/latex/minted/minted.dtx	2024-09-23 21:20:32 UTC (rev 72363)
@@ -1,19 +1,16 @@
 % \iffalse meta-comment
 %
-% Copyright (C) 2013-2023 by Geoffrey M. Poore <gpoore at gmail.com>
+% Copyright (C) 2013-2024 by Geoffrey M. Poore <gpoore at gmail.com>
 % Copyright (C) 2010-2011 by Konrad Rudolph <konrad_rudolph at madrat.net>
-% ---------------------------------------------------------------------------
+% --------------------------------------------------------------------------
 % This work may be distributed and/or modified under the
-% conditions of the LaTeX Project Public License, either version 1.3
+% 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
-%   http://www.latex-project.org/lppl.txt
-% and version 1.3 or later is part of all distributions of LaTeX
-% version 2005/12/01 or later.
+%   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.
 %
-% Additionally, the project may be distributed under the terms of the 3-Clause
-% ("New") BSD license:  http://opensource.org/licenses/BSD-3-Clause.
-%
 % This work has the LPPL maintenance status `maintained'.
 %
 % The Current Maintainer of this work is Geoffrey M. Poore.
@@ -21,7 +18,6 @@
 % This work consists of the files minted.dtx and minted.ins
 % and the derived file minted.sty.
 %
-%
 % \fi
 %
 % \iffalse
@@ -31,30 +27,31 @@
 %<package>\NeedsTeXFormat{LaTeX2e}
 %<package>\ProvidesPackage{minted}
 %<*package>
-    [2023/12/18 v2.9 Yet another Pygments shim for LaTeX]
+    [2024/09/22 v3.0.0 Yet another Pygments shim for LaTeX]
 %</package>
 %<*driver>
 \documentclass{ltxdoc}
-\EnableCrossrefs
-%\CodelineIndex
-%\DisableCrossrefs
-%\RecordChanges
-%\OnlyDescription
+\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{textcomp}
-\usepackage[cache, langlinenos]{minted}
+\usepackage{graphicx}
+\usepackage[lexerlinenos, highlightmode=immediate]{minted}
+\setminted{literatecomment=\%, autogobble}
 
 \usepackage{calc}
-\usepackage{environ}
-\usepackage{graphicx}
 \usepackage{multicol}
-\usepackage{hyperref}
+\usepackage[hyperindex]{hyperref}
+\usepackage{cleveref}
 
 \newcommand{\env}[1]{\texttt{#1}}
 
@@ -95,28 +92,11 @@
   \def\FV at SV@pipe at active@verbatim{%
     \FV at Gobble
     \expandafter\FV at ProcessLine\expandafter{#1}}%
-  %\let\FV at BeginVBox\relax
-  %\let\FV at EndVBox\relax
-  %\def\FV at BProcessLine##1{\FancyVerbFormatLine{##1}}%
   \BUseVerbatim{pipe at active@verbatim}%
   \endgroup}
 \AtBeginDocument{\let|\pipe at active@verbatim}
 \endgroup
 
-\newcommand{\changestext}{}
-\NewEnviron{changelog}[2]{%
-    \g at addto@macro\changestext{\item[#1] (#2) \begin{itemize}}%
-    \expandafter\g at addto@macro\expandafter\changestext\expandafter{\BODY}%
-    \g at addto@macro\changestext{\end{itemize}}%
-}
-\newcommand{\PrintChangelog}{%
-    \section{Changelog}%
-    \label{sec:changelog}
-    \begin{description}%
-    \changestext
-    \end{description}%
-}
-
 \def\MacroFont{%
   \fontencoding\encodingdefault%
   \fontfamily\ttdefault%
@@ -125,13 +105,55 @@
   \small}
 
 \definecolor{minted at mint}{HTML}{0B610B}
-\definecolor{minted at samplebg}{HTML}{F0F0E0}
 \colorlet{minted at linkcolor}{minted at mint}
-%
+
 \def\PrintDescribeMacro#1{\strut \MacroFont\textcolor{minted at linkcolor}{\string #1\ }}
 \let\PrintDescribeEnv\PrintDescribeMacro
 \let\PrintMacroName\PrintDescribeMacro
 \let\PrintEnvName\PrintDescribeEnv
+
+\renewenvironment{macro}{\macro at custom@arg}{}
+\def\macro at custom@arg{%
+  \begingroup\makeatletter\macro at custom@arg at i}
+\def\macro at custom@arg at i#1{%
+  \makeatother
+  \par\noindent
+  \ifstrempty{#1}%
+   {~\par}%
+   {\ttfamily\color{minted at mint}\hspace*{-0.5in}%
+    \macro at custom@arg at split#1,\FV at Sentinel\par}%
+  \endgroup}
+\def\macro at custom@arg at spacegobble#1{#1}
+\def\macro at custom@arg at split#1,#2\FV at Sentinel{%
+  \expandafter\string\macro at custom@arg at spacegobble#1%
+  \if\relax\detokenize{#2}\relax
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+  {}{\\\hspace*{-0.5in}\macro at custom@arg at split#2\FV at Sentinel}}
+
+\renewenvironment{environment}{\env at custom@arg}{}
+\def\env at custom@arg{%
+  \begingroup\makeatletter\env at custom@arg at i}
+\def\env at custom@arg at i#1{%
+  \makeatother
+  \ifstrempty{#1}%
+   {~\par}%
+   {\ttfamily\color{minted at mint}\hspace*{-0.5in}%
+    \env at custom@arg at split#1,\FV at Sentinel\par}%
+  \endgroup}
+\def\env at custom@arg at spacegobble#1{#1}
+\def\env at custom@arg at split#1,#2\FV at Sentinel{%
+  \env at custom@arg at spacegobble#1{\textrm{ \textit{(env.)}}}%
+  \if\relax\detokenize{#2}\relax
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+  {}{\\\hspace*{-0.5in}\env at custom@arg at split#2\FV at Sentinel}}
+
+
 \def\theCodelineNo{\textcolor{minted at linkcolor}{\sffamily\footnotesize\oldstylenums{\arabic{CodelineNo}}}}
 %
 \hypersetup{
@@ -141,36 +163,57 @@
   colorlinks=true,
   allcolors=minted at linkcolor,
 }
-%
-% Shamelessly stolen from http://blog.karssen.org/2009/11/15/a-latex-example-environment/
+
+\newenvironment{mintedminted}%
+ {\VerbatimEnvironment
+  \begin{minted}}%
+ {\end{minted}}
+
+
 \newenvironment{example}
   {\VerbatimEnvironment
-   \begin{VerbatimOut}[gobble=3]{example.out}}
+   \begin{VerbatimOut}[gobble=1]{example.out}}
   {\end{VerbatimOut}%
-   \vspace{1ex}%
    \setlength{\parindent}{0pt}%
-   \fbox{\begin{minipage}{0.5\linewidth}%
+   \vspace{1em}%
+   \fbox{%
+     \vspace{1ex}%
+     \begin{minipage}{0.5\linewidth-2em-\fboxsep}%
      \inputminted[resetmargins]{latex}{example.out}%
-   \end{minipage}%
-   \hspace{0.05\linewidth}%
-   \begin{minipage}{0.45\linewidth-2\fboxsep}%
+     \end{minipage}%
+     \hspace{2em}\vrule\hspace{2em}%
+     \begin{minipage}{0.5\linewidth-2em-\fboxsep}%
      \input{example.out}%
-   \end{minipage}%
-   \vspace{1ex}}}
+     \end{minipage}%
+     \vspace{1ex}}%
+   \vspace{1em}}
 
+
+\begingroup
+\catcode`\^^M=\active%
+\gdef\longexample at i#1{%
+  \def\longexample at arg{#1}%
+  \begin{VerbatimOut}[gobble=1]{example.out}^^M}%
+\endgroup
+
 \newenvironment{longexample}
-  {\VerbatimEnvironment
-   \begin{VerbatimOut}[gobble=3]{example.out}}
-  {\end{VerbatimOut}%
-   \vspace{1ex}%
-   \setlength{\parindent}{0pt}%
-   \fbox{\begin{minipage}{\linewidth-2\fboxsep}%
-     \inputminted[resetmargins]{latex}{example.out}%
-     ~\hrulefill~
-     \input{example.out}%
-   \end{minipage}%
-   \vspace{1ex}}}
+ {\VerbatimEnvironment
+  \FVExtraReadOArgBeforeVEnv{\longexample at 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 at arg}%
+    \input{example.out}%
+    \end{minipage}%
+    \vspace{1ex}}%
+  \vspace{1em}}
 
+
 \def\minted at printopt#1(#2) (#3){%
   \vspace{0.1in}%
   \leavevmode%
@@ -178,301 +221,64 @@
   \kern-\parindent\textsf{(#2)}\hfill(default: \texttt{#3})\\}
 
 \newenvironment{optionlist}%
- {%
-  ~\par\vspace{-14pt}%
+ {~\par\vspace{-14pt}%
   \def\pipechar{|}
   \let\|\pipechar
   \newcommand*\mintednext{}%
+  \let\item at orig\item
   \renewcommand*\item[1][]{%
-    \mintednext%
-    \renewcommand*\mintednext{\par}%
-    \minted at printopt##1%
-    \ignorespaces}}
- {%
-  \par}
+    \ifdefstring{\@currenvir}{optionlist}%
+     {\mintednext%
+      \renewcommand*\mintednext{\par}%
+      \minted at printopt##1%
+      \ignorespaces}%
+     {\ifstrempty{##1}%
+      {\vspace{-4pt}\item at orig}
+      {\vspace{-4pt}\item at orig[##1]}}}}
+ {\par}
 
 \edef\hashchar{\string#}
+
+
+\renewcommand*\l at subsection{\@dottedtocline{2}{1.5em}{3em}}
+\renewcommand*\l at subsubsection{\@dottedtocline{3}{4.5em}{3.8em}}
+
+
 \makeatother
 
-\newcommand{\hide}[1]{}
 
-\setlength{\parindent}{0pt}
-\addtolength{\parskip}{0.5\baselineskip}
 
-\def\warn{\textcolor{red}{\large\textbf{\textsf{WARNING}}}}
 
+\newenvironment{mintedexample}%
+ {\VerbatimEnvironment
+  \begin{minted}}%
+ {\end{minted}}
+
 \begin{document}
 \DocInput{minted.dtx}
-% \PrintIndex
+% ^^A\PrintIndex
 \end{document}
 %</driver>
 % \fi
 %
-% \CheckSum{2572}
 %
-% \CharacterTable
-%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
-%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
-%   Digits        \0\1\2\3\4\5\6\7\8\9
-%   Exclamation   \!     Double quote  \"     Hash (number) \#
-%   Dollar        \$     Percent       \%     Ampersand     \&
-%   Acute accent  \'     Left paren    \(     Right paren   \)
-%   Asterisk      \*     Plus          \+     Comma         \,
-%   Minus         \-     Point         \.     Solidus       \/
-%   Colon         \:     Semicolon     \;     Less than     \<
-%   Equals        \=     Greater than  \>     Question mark \?
-%   Commercial at \@     Left bracket  \[     Backslash     \\
-%   Right bracket \]     Circumflex    \^     Underscore    \_
-%   Grave accent  \`     Left brace    \{     Vertical bar  \|
-%   Right brace   \}     Tilde         \~}
+% ^^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}
 %
 %
-%
-%
-% \begin{changelog}{v2.9}{2023/12/18}
-% \item This is expected to be the last release of \pkg{minted} v2.x.  If so, it will then become the new package \Verb{minted2} for backward compatibility.
-% \item Added new option \Verb{ignorelexererrors}.  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 (\#374).
-% \item There is now a warning if \pkg{fvextra} version is less than 1.5.
-% \end{changelog}
-%
-% \begin{changelog}{v2.8}{2023/09/12}
-% \item Under non-Windows operating systems, detect executables with \Verb{command -v} rather than \Verb{which} to provide better cross-platform support (\#345).
-% \item Added new package option \Verb{inputlanglinenos}.  This extends the existing \Verb{langlinenos} to cover \Verb{\inputminted} as well (\#361).
-% \item Improved and updated Pygments documentation (\#339).
-% \item Improved \Verb{\mintinline} documentation to address packages that redefine \Verb{\section} (\#368).
-% \item Added support for \texpkg{fvextra} options \texttt{breakafterinrun} and \texttt{breakbeforeinrun} (\#358).  In \texpkg{fvextra} version 1.5, \texttt{breakaftergroup} and \texttt{breakbeforegroup} were renamed to \texttt{breakafterinrun} and \texttt{breakbeforeinrun} to avoid naming ambiguity with new options.  The old options \texttt{breakaftergroup} and \texttt{breakbeforegroup} are no longer supported.
-% \item Added \texttt{DEPENDS.txt} (\#331).
-% \item Removed unnecessary dependency on \texpkg{calc} package (\#313).
-% \item Added documentation in FAQ about copy and paste limitations (\#302).
-% \item Added note on \texttt{text} lexer to documentation (\#274).
-% \end{changelog}
-%
-%
-% \begin{changelog}{v2.7}{2022/12/12}
-% \item Reimplemented \texttt{\string\mintinline} to use \texttt{fvextra}'s argument reading and processing macros, and to use \texttt{fvextra}'s \texttt{\string\Verb} internally.  \texttt{\string\mintinline} now works with all line breaking options supported by \texttt{fvextra}'s \texttt{\string\Verb}, including \texttt{breakanywhere} (\#329, \#340).  It now gives better results when used inside other commands, since it uses \texttt{fvextra}'s retokenization macros.  It is now compatible with \texttt{hyperref} for PDF strings such as bookmarks.
-% \item Reimplemented \texttt{\string\newmintinline} based on new \texttt{\string\mintinline}.
-% \item Reimplemented \texttt{\string\mint} to use \texttt{fvextra}'s argument reading and processing macros.  It now gives better results when used inside other commands, since it uses \texttt{fvextra}'s retokenization macros.  Fixed a bug that caused a continued paragraph after \texttt{\string\mint} to be indented (\#218).
-% \item Reimplemented \texttt{\string\newmint} based on new \texttt{\string\mint}.  Commands created with \texttt{\string\newmint} can now use curly braces as delimiters, just like \texttt{\string\mint} (\#254).
-% \item Settings passed to \Verb{pygmentize} as command-line options are now quoted.  This prevents \Verb{escapeinside} characters from being interpreted as special shell characters (\#179, \#262).
-% \item Fixed bug with \texttt{autogobble} that produced incorrect dedent when using \texttt{lastline} with the lines beyond \texttt{lastline} having less indentation than the selected range (\#326).
-% \item Fixed unintended line breaks after hyphens under LuaTeX (\#263).
-% \item Added warning to documentation of \Verb{\inputminted} regarding filenames and shell command execution (\#338).
-% \end{changelog}
-%
-%
-% \begin{changelog}{v2.6}{2021/12/24}
-% \item \texttt{autogobble} automatically uses \texttt{python} or \texttt{python3} executables, depending on availability, instead of requiring \texttt{python}.  A custom executable can be specified by redefining \texttt{\string\MintedPython} (\#277, \#287).
-% \item Fixed \texttt{autogobble} compatibility with \texttt{fancyvrb} 4.0+ (\#315, \#316).
-% \item Pygments style names may now contain arbitrary non-whitespace characters.  Previously, style names containing digits and some punctuation characters were incompatible (\#210, \#294, \#299, \#317).  Pygments macros are now only defined just before use locally within \texttt{minted} commands and environments, rather than globally.  Pygments macros now always use a \texttt{\string\PYG} prefix regardless of style, rather than a prefix of the form \texttt{\string\PYG<style>} (for example, what was previously \texttt{\string\PYGdefault} is now simply \texttt{\string\PYG}).
-% \item Removed Python-based MD5 hashing for XeTeX, which was necessary before XeTeX added \texttt{\string\mdfivesum} in 2017.
-% \item The default for \texttt{stripnl} is now \texttt{false}, so that original code is preserved exactly by default (\#198).
-% \item Added support for \texttt{fontencoding} option from \texttt{fvextra} (\#208).
-% \item Added note to FAQ about getting \texttt{texi2pdf} to work with \texttt{minted} given \texttt{texi2pdf}'s assumptions about temp files (\#186).
-% \item Reimplemented \texttt{bgcolor} option to be compatible with \texttt{color} package.
-% \end{changelog}
-%
-%
-% \begin{changelog}{v2.5}{2017/07/19}
-% \item The default placement for the \texttt{listing} float is now \texttt{tbp} instead of \texttt{h}, to parallel \texttt{figure} and \texttt{table} and also avoid warnings caused by \texttt{h} (\#165).  The documentation now contains information about changing default placement.  The \texttt{float} package is no longer loaded when the \texttt{newfloat} package option is used.
-% \item Added support for \texttt{*nchars} options from \texttt{fvextra} v1.3 that allow setting \texttt{breaklines}-related indentation in terms of a number of characters, rather than as a fixed dimension.
-% \item Fixed incompatibility with \texttt{babel magyar} (\#158).
-% \item Added support for \texttt{beamer} overlays with \texttt{beameroverlays} option (\#155).
-% \item Comments in the Pygments \LaTeX\ style files no longer appear as literal text when \texttt{minted} is used in \texttt{.dtx} files (\#161).
-% \item \texttt{autogobble} now works with package option \texttt{kpsewhich} (\#151).  Under Windows, the \texttt{kpsewhich} option no longer requires PowerShell.
-% \item Fixed a bug that prevented \texttt{finalizecache} from working with \texttt{outputdir} (\#149).
-% \item Fixed a bug with \texttt{firstline} and \texttt{lastline} that prevented them from working with the \texttt{minted} environment (\#145).
-% \item Added note on \texttt{breqn} conflicts to FAQ (\#163).
-% \end{changelog}
-%
-%
-% \begin{changelog}{v2.4.1}{2016/10/31}
-% \item Single quotation marks in \texttt{\string\jobname} are now replaced with underscores in \texttt{\string\minted at jobname} to prevent quoting errors (\#137).
-% \item The \texttt{autogobble} option now takes \texttt{firstline} and \texttt{lastline} into account (\#130).
-% \item Fixed \texttt{numberblanklines}, which had been lost in the transition to v2.0+ (\#135).
-% \end{changelog}
-%
-%
-% \begin{changelog}{v2.4}{2016/07/20}
-% \item Line breaking and all associated options are now completely delegated to \texttt{fvextra}.
-% \item Fixed a bug from v2.2 that could cause the first command or environment to vanish when \texttt{cache=false} (related to work on \texttt{\string\MintedPygmentize}).
-% \end{changelog}
-%
-%
-% \begin{changelog}{v2.3}{2016/07/14}
-% \item The \texttt{fvextra} package is now required.  \texttt{fvextra} extends and patches \texttt{fancyvrb}, and includes improved versions of \texttt{fancyvrb} extensions that were formerly in \texttt{minted}.
-% \item As part of \texttt{fvextra}, the \texttt{upquote} package is always loaded.  \texttt{fvextra} brings the new option \texttt{curlyquotes}, which allows curly single quotation marks instead of the literal backtick and typewriter single quotation mark produced by \texttt{upquote}.  This allows the default \texttt{upquote} behavior to be disabled when desired.
-% \item Thanks to \texttt{fvextra}, the options \texttt{breakbefore}, \texttt{breakafter}, and \texttt{breakanywhere} are now compatible with non-ASCII characters under pdfTeX (\#123).
-% \item Thanks to \texttt{fvextra}, \texttt{obeytabs} no longer causes lines in multi-line comments or strings to vanish (\#88), and is now compatible with \texttt{breaklines} (\#99).  \texttt{obeytabs} will now always give correct results with tabs used for indentation.  However, tab stops are not guaranteed to be correct for tabs in the midst of text.
-% \item \texttt{fvextra} brings the new options \texttt{space}, \texttt{spacecolor}, \texttt{tab}, and \texttt{tabcolor} that allow these characters and their colors to be redefined (\#98).  The tab may now be redefined to a flexible-width character such as \texttt{\string\rightarrowfill}.  The visible tab will now always be black by default, instead of changing colors depending on whether it is part of indentation for a multiline string or comment.
-% \item \texttt{fvextra} brings the new options \texttt{highlightcolor} and \texttt{highlightlines}, which allow single lines or ranges of lines to be highlighted based on line number (\#124).
-% \item \texttt{fvextra} brings the new options \texttt{numberfirstline}, \texttt{stepnumberfromfirst}, and \texttt{stepnumberoffsetvalues} that provide better control over line numbering when \texttt{stepnumber} is not 1.
-% \item Fixed a bug from v2.2.2 that prevented \texttt{upquote} from working.
-% \end{changelog}
-%
-%
-% \begin{changelog}{v2.2.2}{2016/06/21}
-% \item Fixed a bug introduced in v2.2 that prevented setting the Pygments style in the preamble.  Style definitions are now more compatible with using \texttt{\string\MintedPygmentize} to call a custom \texttt{pygmentize}.
-% \end{changelog}
-%
-%
-% \begin{changelog}{v2.2.1}{2016/06/15}
-% \item The \texttt{shellesc} package is loaded before \texttt{ifplatform} and other packages that might invoke \texttt{\string\write18} (\#112).
-% \item When caching is enabled, XeTeX uses the new \texttt{\string\mdfivesum} macro from TeX Live 2016 to hash cache content, rather than using \texttt{\string\ShellEscape} with Python to perform hashing.
-% \end{changelog}
-%
-%
-% \begin{changelog}{v2.2}{2016/06/08}
-% \item All uses of \texttt{\string\ShellEscape} (\texttt{\string\write18}) no longer wrap file names and paths with double quotes.  This allows a cache directory to be specified relative to a user's home directory, for example, \texttt{\string~/minted\_cache}.  \texttt{cachedir} and \texttt{outputdir} paths containing spaces will now require explicit quoting of the parts of the paths that contain spaces, since \texttt{minted} no longer supplies quoting.  See the updated documentation for examples (\#89).
-% \item Added \texttt{breakbefore}, \texttt{breakbeforegroup}, \texttt{breakbeforesymbolpre}, and \texttt{breakbeforesymbolpost}.  These parallel \texttt{breakafter*}.  It is possible to use \texttt{breakbefore} and \texttt{breakafter} for the same character, so long as \texttt{breakbeforegroup} and \texttt{breakaftergroup} have the same setting (\#117).
-% \item Added package options \texttt{finalizecache} and \texttt{frozencache}.  These allow the cache to be prepared for (\texttt{finalizecache}) and then used (\texttt{frozencache}) in an environment in which \texttt{-shell-escape}, Python, and/or Pygments are not available.  Note that this only works if \texttt{minted} content does not need to be modified, and if no settings that depend on Pygments or Python need to be changed (\#113).
-% \item Style names containing hyphens and underscores (\texttt{paraiso-light}, \texttt{paraiso-dark}, \texttt{algol\_nu}) now work (\#111).
-% \item The \texttt{shellesc} package is now loaded, when available, for compatibility with LuaTeX 0.87+ (TeX Live 2016+, etc.).  \texttt{\string\ShellEscape} is now used everywhere instead of \texttt{\string\immediate\string\write18}.  If \texttt{shellesc} is not available, then a \texttt{\string\ShellEscape} macro is created.  When \texttt{shellesc} is loaded, there is a check for versions before v0.01c to patch a bug in v0.01b (present in TeX Live 2015) (\#112).
-% \item The \texttt{bgcolor} option now uses the \texttt{snugshade*} environment from the \texttt{framed} package, so \texttt{bgcolor} is now compatible with page breaks.  When \texttt{bgcolor} is in use, immediately preceding text will no longer push the \texttt{minted} environment into the margin, and there is now adequate spacing from surrounding text (\#121).
-% \item Added missing support for \texttt{fancyvrb}'s \texttt{labelposition} (\#102).
-% \item Improved fix for TikZ externalization, thanks to Patrick Vogt (\#73).
-% \item Fixed \texttt{breakautoindent}; it was disabled in version 2.1 due to a bug in \texttt{breakanywhere}.
-% \item Properly fixed handling of \texttt{\string\MintedPygmentize} (\#62).
-% \item Added note on incompatibility of \texttt{breaklines} and \texttt{obeytabs} options.  Trying to use these together will now result in a package error (\#99).  Added note on issues with \texttt{obeytabs} and multiline comments (\#88).  Due to the various \texttt{obeytabs} issues, the docs now discourage using \texttt{obeytabs}.
-% \item Added note to FAQ on \texttt{fancybox} and \texttt{fancyvrb} conflict (\#87).
-% \item Added note to docs on the need for \texttt{\string\VerbatimEnvironment} in environment definitions based on \texttt{minted} environments.
-% \end{changelog}
-%
-%
-% \begin{changelog}{v2.1}{2015/09/09}
-% \item Changing the highlighting style now no longer involves re-highlighing code.  Style may be changed with almost no overhead.
-% \item Improved control of automatic line breaks.  New option \texttt{breakanywhere} allows line breaks anywhere when \texttt{breaklines=true}.  The pre-break and post-break symbols for these types of breaks may be set with \texttt{breakanywheresymbolpre} and \texttt{breakanywheresymbolpost} (\#79).  New option \texttt{breakafter} allows specifying characters after which line breaks are allowed.  Breaks between adjacent, identical characters may be controlled with \texttt{breakaftergroup}.  The pre-break and post-break symbols for these types of breaks may be set with \texttt{breakaftersymbolpre} and \texttt{breakaftersymbolpost}.
-% \item \texttt{breakbytoken} now only breaks lines between tokens that are separated by spaces, matching the documentation.  The new option \texttt{breakbytokenanywhere} allows for breaking between tokens that are immediately adjacent.  Fixed a bug in \texttt{\string\mintinline} that produced a following linebreak when \texttt{\string\mintinline} was the first thing in a paragraph and \texttt{breakbytoken} was true (\#77).
-% \item Fixed a bug in draft mode option handling for \texttt{\string\inputminted} (\#75).
-% \item Fixed a bug with \texttt{\string\MintedPygmentize} when a custom \texttt{pygmentize} was specified and there was no \texttt{pygmentize} on the default path (\#62).
-% \item Added note to docs on caching large numbers of code blocks under OS~X (\#78).
-% \item Added discussion of current limitations of \texttt{texcomments} (\#66) and \texttt{escapeinside} (\#70).
-% \item PGF/Ti\textit{k}Z externalization is automatically detected and supported (\#73).
-% \item The package is now compatible with \LaTeX\ files whose names contain spaces (\#85).
-% \end{changelog}
-%
-%
-% \begin{changelog}{v2.0}{2015/01/31}
-% \item Added the compatibility package \texttt{minted1}, which provides the \texpkg{minted} 1.7 code.  This may be loaded when 1.7 compatibility is required.  This package works with other packages that \texttt{\string\RequirePackage\{minted\}}, so long as it is loaded first.
-% \item Moved all old \texttt{\string\changes} into \texttt{changelog}.
-% \end{changelog}
-%
-%
-% \begin{changelog}{Development releases for 2.0}{2014--January 2015}
-% \item Caching is now on by default.
-% \item Fixed a bug that prevented compiling under Windows when file names contained commas.
-% \item Added \texttt{breaksymbolleft}, \texttt{breaksymbolsepleft}, \texttt{breaksymbolindentleft}, \texttt{breaksymbolright}, \texttt{breaksymbolsepright}, and \texttt{breaksymbolindentright} options.  \texttt{breaksymbol}, \texttt{breaksymbolsep}, and \texttt{breaksymbolindent} are now aliases for the correspondent \texttt{*left} options.
-% \item Added \texttt{kpsewhich} package option. This uses \texttt{kpsewhich} to locate the files that are to be highlighted. This provides compatibility with build tools like \texttt{texi2pdf} that function by modifying \texttt{TEXINPUTS} (\#25).
-% \item Fixed a bug that prevented \texttt{\string\inputminted} from working with \texttt{outputdir}.
-% \item Added informative error messages when Pygments output is missing.
-% \item Added \texttt{final} package option (opposite of \texttt{draft}).
-% \item Renamed the default cache directory to \texttt{\_minted-<jobname>} (replaced leading period with underscore).  The leading period caused the cache directory to be hidden on many systems, which was a potential source of confusion.
-% \item \texttt{breaklines} and \texttt{breakbytoken} now work with \texttt{\string\mintinline} (\#31).
-% \item \texttt{bgcolor} may now be set through \texttt{\string\setminted} and \texttt{\string\setmintedinline}.
-% \item When math is enabled via \texttt{texcomments}, \texttt{mathescape}, or \texttt{escapeinside}, space characters now behave as in normal math by vanishing, instead of appearing as literal spaces.  Math need no longer be specially formatted to avoid undesired spaces.
-% \item In default value of \texttt{\string\listoflistingscaption}, capitalized ``Listings'' so that capitalization is consistent with default values for other lists (figures, tables, algorithms, etc.).
-% \item Added \texttt{newfloat} package option that creates the \texttt{listing} environment using \texttt{newfloat} rather than \texttt{float}, thus providing better compatibility with the \texttt{caption} package (\#12).
-% \item Added support for Pygments option \texttt{stripall}.
-% \item Added \texttt{breakbytoken} option that prevents \texttt{breaklines} from breaking lines within Pygments tokens.
-% \item \texttt{\string\mintinline} uses a \texttt{\string\colorbox} when \texttt{bgcolor} is set, to give more reasonable behavior (\#57).
-% \item For PHP, \texttt{\string\mintinline} automatically begins with \texttt{startinline=true} (\#23).
-% \item Fixed a bug that threw off line numbering in \texttt{minted} when \texttt{langlinenos=false} and \texttt{firstnumber=last}.  Fixed a bug in \texttt{\string\mintinline} that threw off subsequent line numbering when \texttt{langlinenos=false} and \texttt{firstnumber=last}.
-% \item Improved behavior of \texttt{\string\mint} and \texttt{\string\mintinline} in \texttt{draft} mode.
-% \item The \texttt{\string\mint} command now has the additional capability to take code delimited by paired curly braces \texttt{\{\}}.
-% \item It is now possible to set options only for \texttt{\string\mintinline} using the new \texttt{\string\setmintedinline} command.  Inline options override options specified via \texttt{\string\setminted}.
-% \item Completely rewrote option handling.  \texpkg{fancyvrb} options are now handled on the \LaTeX\ side directly, rather than being passed to Pygments and then returned.  This makes caching more efficient, since code is no longer rehighlighted just because \texpkg{fancyvrb} options changed.
-% \item Fixed buffer size error caused by using \texttt{cache} with a very large number of files (\#61).
-% \item Fixed \texttt{autogobble} bug that caused failure under some operating systems.
-% \item Added support for \texttt{escapeinside} (requires Pygments 2.0+; \#38).
-% \item Fixed issues with XeTeX and caching (\#40).
-% \item The \texttt{upquote} package now works correctly with single quotes when using Pygments 1.6+ (\#34).
-% \item Fixed caching incompatibility with Linux and OS X under xelatex (\#18 and \#42).
-% \item Fixed \texttt{autogobble} incompatibility with Linux and OS X.
-% \item \texttt{\string\mintinline} and derived commands are now robust, via \texttt{\string\newrobustcmd} from \texttt{etoolbox}.
-% \item Unused styles are now cleaned up when caching.
-% \item Fixed a bug that could interfere with caching (\#24).
-% \item Added \texttt{draft} package option (\#39).  This typesets all code using \texttt{fancyvrb}; Pygments is not used.  This trades syntax highlighting for maximum speed in compiling.
-% \item Added automatic line breaking with \texttt{breaklines} and related options (\#1).
-% \item Fixed a bug with boolean options that needed a False argument to cooperate with \texttt{\string\setminted} (\#48).
-% \end{changelog}
-%
-% \begin{changelog}{v2.0-alpha3}{2013/12/21}
-% \item Added \texttt{autogobble} option.  This sends code through Python's \texttt{textwrap.dedent()} to remove common leading whitespace.
-% \item Added package option \texttt{cachedir}.  This allows the directory in which cached content is saved to be specified.
-% \item Added package option \texttt{outputdir}.  This allows an output directory for temporary files to be specified, so that the package can work with LaTeX's \texttt{-output-directory} command-line option.
-% \item The \texttt{kvoptions} package is now required.  It is needed to process key-value package options, such as the new \texttt{cachedir} option.
-% \item Many small improvements, including better handling of paths under Windows and improved key system.
-% \end{changelog}
-%
-% \begin{changelog}{v2.0-alpha2}{2013/08/21}
-% \item \texttt{\string\DeleteFile} now only deletes files if they do indeed exist.  This eliminates warning messages due to missing files.
-% \item Fixed a bug in the definition of \texttt{\string\DeleteFile} for non-Windows systems.
-% \item Added support for Pygments option \texttt{stripnl}.
-% \item Settings macros that were previously defined globally are now defined locally, so that \texttt{\string\setminted} may be confined by \texttt{\string\begingroup...\string\endgroup} as expected.
-% \item Macro definitions for a given style are now loaded only once per document, rather than once per command/environment.  This works even without caching.
-% \item A custom script/executable may now be substituted for \texttt{pygmentize} by redefining \texttt{\string\MintedPygmentize}.
-% \end{changelog}
-%
-%
-% \begin{changelog}{v2.0alpha}{2013/07/30}
-% \item Added the package option \texttt{cache}.  This significantly increases compilation speed by caching old output.  For example, compiling the documentation is around 5x faster.
-% \item New inline command \texttt{\string\mintinline}.  Custom versions can be created via \texttt{\string\newmintinline}.  The command works inside other commands (for example, footnotes) in most situations, so long as the percent and hash characters are avoided.
-% \item The new \texttt{\string\setminted} command allows options to be specified at the document and language levels.
-% \item All extended characters (Unicode, etc.) supported by \texttt{inputenc} now work under the pdfTeX engine.  This involved using \texttt{\string\detokenize} on everything prior to saving.
-% \item New package option \texttt{langlinenos} allows line numbering to pick up where it left off for a given language when \texttt{firstnumber=last}.
-% \item New options, including \texttt{style}, \texttt{encoding}, \texttt{outencoding}, \texttt{codetagify}, \texttt{keywordcase}, \texttt{texcomments} (same as \texttt{texcl}), \texttt{python3} (for the \texttt{PythonConsoleLexer}), and \texttt{numbers}.
-% \item \texttt{\string\usemintedstyle} now takes an optional argument to specify the style for a particular language, and works anywhere in the document.
-% \item \texttt{xcolor} is only loaded if \texttt{color} isn't, preventing potential package clashes.
-% \end{changelog}
-%
-%
-% \begin{changelog}{1.7}{2011/09/17}
-% \item Options for float placement added [2011/09/12]
-% \item Fixed \texttt{tabsize} option [2011/08/30]
-% \item More robust detection of the \texttt{-shell-escape} option [2011/01/21]
-% \item Added the \texttt{label} option [2011/01/04]
-% \item Installation instructions added [2010/03/16]
-% \item Minimal working example added [2010/03/16]
-% \item Added PHP-specific options [2010/03/14]
-% \item Removed unportable flag from Unix shell command [2010/02/16]
-% \end{changelog}
-%
-%
-% \begin{changelog}{1.6}{2010/01/31}
-% \item Added font-related options [2010/01/27]
-% \item Windows support added [2010/01/27]
-% \item Added command shortcuts [2010/01/22]
-% \item Simpler versioning scheme [2010/01/22]
-% \end{changelog}
-%
-%
-% \begin{changelog}{0.1.5}{2010/01/13}
-% \item Added \texttt{fillcolor} option [2010/01/10]
-% \item Added float support [2010/01/10]
-% \item Fixed \texttt{firstnumber} option [2010/01/10]
-% \item Removed \texttt{caption} option [2010/01/10]
-% \end{changelog}
-%
-%
-% \begin{changelog}{0.0.4}{2010/01/08}
-% \item Initial version [2010/01/08]
-% \end{changelog}
-%
-%
-% %\DoNotIndex{\newcommand,\newenvironment}
-% %\DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ }
-% %\DoNotIndex{\@ne}
-% %\DoNotIndex{\advance,\begingroup,\catcode,\closein}
-% %\DoNotIndex{\closeout,\day,\def,\edef,\else,\empty,\endgroup}
-% %\DoNotIndex{\begin,\end,\bgroup,\egroup}
-% %\DoNotIndex{\@namedef,\@nameuse,=,\csname,\endcsname}
-%
-%
 % \GetFileInfo{minted.sty}
 %
-% \newcommand{\texpkg}[1]{\textsf{#1}}
+% \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 at mint}{\texpkg{minted}} package:\\Highlighted source code in \LaTeX}
+% \title{The \textcolor{minted at mint}{\mintedpkg} package:\\Highlighted source code in \LaTeX}
 % \author{Geoffrey M.\ Poore \\ \url{gpoore at 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}
 %
@@ -479,22 +285,17 @@
 % \maketitle
 %
 % \begin{abstract}
-%   \noindent\texpkg{minted} is a package that facilitates expressive syntax highlighting
-%   using the powerful \app{Pygments} library. The package also provides options to
-%   customize the highlighted source code output.
+%   \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\textbf{Development status:}  \pkg{minted} version 3.0 is now under development, thanks to a \href{https://tug.org/tc/devfund/grants.html}{\TeX\ Development Fund grant} from the \href{https://tug.org/}{\TeX\ Users Group}.  This will bring a new Python executable that replaces |pygmentize|.  The new executable will be compatible with restricted shell escape, so no more |-shell-escape| with associated security vulnerabilities.  The new executable will also make it possible to extend \pkg{minted} using Python, not just \LaTeX\ macros.  This will bring official support for custom lexers, allow including snippets of external files based on regular expressions, and make possible a number of other improvements and bugfixes.  For compatibility purposes, the final version of \pkg{minted} v2.x will be released as the compatibility package \pkg{minted2}.  Initial beta versions of minted v3.0 are expected by early 2024.  A final minted v3.x release including all planned features is expected before the end of summer 2024.
+% \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{http://www.latex-project.org/lppl.txt}{LaTeX Project Public License (LPPL)} version 1.3.
+% \href{https://www.latex-project.org/lppl.txt}{LaTeX Project Public License (LPPL)} version 1.3c.
 %
-% Additionally, the project may be distributed under the terms of the 3-Clause
-% (``New'') BSD license:  \url{http://opensource.org/licenses/BSD-3-Clause}.
-%
 % \pagebreak
 %
 %   \tableofcontents
@@ -510,162 +311,186 @@
 %
 %
 %
-% \texpkg{minted} is a package that allows formatting source code in \LaTeX.
-% For example:
-% \begin{VerbatimOut}[gobble=1]{minted.doc.out}
-%   \begin{minted}{<language>}
-%     <code>
-%   \end{minted}
-% \end{VerbatimOut}
-% \inputminted[gobble=2,frame=lines]{latex}{minted.doc.out}
+% \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}
 %
-% will highlight a piece of code in a chosen language.
-% The appearance can be customized with a number of options and color schemes.
+% 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:
 %
-% Unlike some other packages, most notably \texpkg{listings}, \texpkg{minted} requires
-% the installation of additional software, \app{Pygments}.
-% This may seem like a disadvantage, but there are also significant advantages.
-%
-% \app{Pygments} provides superior syntax highlighting compared to conventional packages.
-% For example, \texpkg{listings} basically only highlights strings, comments and keywords.
-% \app{Pygments}, on the other hand, can be completely customized to highlight any kind of token the
-% source language might support.
-% This might include special formatting sequences inside strings, numbers, different kinds of
-% identifiers and exotic constructs such as HTML tags.
-%
-% Some languages make this especially desirable.
-% Consider the following Ruby code as an extreme, but at the same time typical, example:
-%
-% \begin{minted}[gobble=3]{ruby}
+% \begin{example}
+% \begin{minted}{ruby}
 %   class Foo
 %     def init
 %       pi = Math::PI
-%       @var = "Pi is approx. #{pi}"
+%       @var = "Pi = #{pi}..."
 %     end
 %   end
 % \end{minted}
+% \end{example}
 %
-% Here we have four different colors for identifiers (five, if you count keywords) and escapes from
-% inside strings, none of which pose a problem for \app{Pygments}.
+% 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.
 %
-% Additionally, installing \app{Pygments} is actually incredibly easy (see the next section).
 %
-%
 % \section{Installation}
 %
-% \subsection{Prerequisites}
+% \subsection{Package manager}
 %
-% \app{Pygments} is written in Python, so make sure that you have Python 2.6 or later installed on your system.  This may be easily checked from the command line:
+% 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.
 %
-% \begin{Verbatim}[gobble=3,commandchars=\\\{\}]
-%   \$ python --version
-%   Python 2.7.5
-% \end{Verbatim}
+% 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|.
 %
-% If you don't have Python installed, you can download it from the \href{http://www.python.org/download/}{Python website} or
-% use your operating system's package manager.
+% 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}
 %
-% Some Python distributions include \texpkg{Pygments} (see some of the options under ``Alternative Implementations'' on the Python site).  Otherwise, you will need to install \texpkg{Pygments} manually. This may  be done by installing \href{http://pypi.python.org/pypi/setuptools}{\app{setuptools}}, which facilitates the distribution of Python applications.  You can then install \app{Pygments} using the following command:
-% \begin{Verbatim}[gobble=3,commandchars=\\\{\}]
-%   \$ sudo easy_install Pygments
-% \end{Verbatim}
-% Under Windows, you will not need the |sudo|, but may need to run the command prompt as administrator.  \texpkg{Pygments} may also be installed with |pip|:
-% \begin{Verbatim}[gobble=3,commandchars=\\\{\}]
-%   \$ pip install Pygments
-% \end{Verbatim}
 %
-% If you already have \app{Pygments} installed, be aware that the latest version is recommended (at least 1.4 or later).  Some features, such as |escapeinside|, will only work with 2.0+.  \texpkg{minted} may work with versions as early as 1.2, but there are no guarantees.
+% \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|}.
 %
-% \subsection{Required packages}
+% 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).
 %
-% \texpkg{minted} requires that the following packages be available and reasonably up to date on your system.  All of these ship with recent \TeX\ distributions.
+% 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.
 %
-% \begin{multicols}{3}
-% \begingroup
-% \setlength\parskip{0pt}
-% \setlength\topsep{0pt}
-% \begin{list}{\textrm{\labelitemi}}{\ttfamily}
-%   \item keyval
-%   \item kvoptions
-%   \item fancyvrb
-%   \item fvextra
-%   \item upquote
-%   \item float
-%   \item ifthen
-%   \item calc
-%   \item ifplatform
-%   \item pdftexcmds
-%   \item etoolbox
-%   \item xstring
-%   \item xcolor
-%   \item lineno
-%   \item framed
-%   \item shellesc (for luatex 0.87+)
-%   \item catchfile
+% 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.
 %
-%   ~
-% \end{list}
-% \endgroup
-% \end{multicols}
+% \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|.
 %
-% \subsection{Installing \texpkg{minted}}
-% \label{sec:installing:installing}
+% 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}
 %
-% You can probably install \texpkg{minted} with your \TeX\ distribution's package manager.  Otherwise, or if you want the absolute latest version, you can install it manually by following the directions below.
+% \subsubsection{Option 2:  Install \pypkg{latexminted} within \TeX\ installation}
 %
-% You may download |minted.sty| from the
-% \href{https://github.com/gpoore/minted}{project's homepage}.  We have to install the file so that \TeX\ is able to find it.
-% In order to do that, please refer to the
-% \href{http://www.tex.ac.uk/cgi-bin/texfaq2html?label=inst-wlcf}{\TeX{} FAQ}.
-% If you just want to experiment with the latest version, you could locate your current |minted.sty| in your \TeX\ installation and replace it with the latest version.  Or you could just put the latest |minted.sty| in the same directory as the file you wish to use it with.
+% 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|.
 %
-% \section{Basic usage}
+% 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}
 %
-% \subsection{Preliminary}
-% \label{sec:basic:preliminary}
+% 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>|.
 %
-% Since \texpkg{minted} makes calls to the outside world (that is, \app{Pygments}), you need to tell the
-% \LaTeX{} processor about this by passing it the |-shell-escape| option or it won't allow such calls.
-% In effect, instead of calling the processor like this:
-% \begin{Verbatim}[gobble=3,commandchars=\\\{\}]
-%   \$ latex input
-% \end{Verbatim}
+% 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|.
 %
-% you need to call it like this:
 %
-% \begin{Verbatim}[gobble=3,commandchars=\\\{\}]
-%   \$ latex -shell-escape input
-% \end{Verbatim}
 %
-% The same holds for other processors, such as |pdflatex| or |xelatex|.
+% \section{Migrating from \mintedpkg\ version 2}
 %
-% You should be aware that using |-shell-escape| allows \LaTeX\ to run potentially arbitrary commands on your system.  It is probably best to use |-shell-escape| only when you need it, and to use it only with documents from trusted sources.
+% \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}
 %
-% \subsubsection*{Working with OS X}
+% 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.
 %
-% If you are using \texpkg{minted} with some versions/configurations of OS X, and are using caching with a large number of code blocks ($>256$), you may receive an error like
-%\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 the OS X commands |launchctl limit maxfiles| or |ulimit -n| to increase the number of files that may be used.
 %
+% \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 \texpkg{minted}.
+% 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}{c}
+%   \begin{minted}[bgcolor=Beige, bgcolorpadding=0.5em]{c}
 %   int main() {
 %       printf("hello, world");
 %       return 0;
@@ -673,47 +498,40 @@
 %   \end{minted}
 %   \end{document}
 % \end{VerbatimOut}
-% \inputminted[gobble=2,frame=lines]{latex}{minted.doc.out}
+% \inputminted[frame=single]{latex}{minted.doc.out}
 %
-% By compiling the source file like this:
+% This document can be compiled by running ``|pdflatex -shell-escape minimal|''
+% to produce the following output in |minimal.pdf|:
 %
-% \begin{Verbatim}[gobble=3,commandchars=\\\{\}]
-%   \$ pdflatex -shell-escape minimal
-% \end{Verbatim}
+% \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}
 %
-% we end up with the following output in |minimal.pdf|:
 %
-% \hfill
-% \colorbox{minted at samplebg}{\begin{minipage}{0.6\textwidth}
-%   \inputminted[firstline=7,lastline=10]{c}{minted.doc.out}
-% \end{minipage}}
-% \hfill\hfill
-%
-%
 % \subsection{Formatting source code}
 %
 % \DescribeEnv{minted}
-% Using \texpkg{minted} is straightforward. For example, to highlight some Python source code we might use
-% the following code snippet (result on the right):
+% The |minted| environment highlights a block of code:
 %
 % \begin{example}
-%   \begin{minted}{python}
-%   def boring(args = None):
-%       pass
-%   \end{minted}
+% \begin{minted}{python}
+% def boring(args = None):
+%     pass
+% \end{minted}
 % \end{example}
 %
-% Optionally, the environment accepts a number of options in |key=value| notation, which are described
-% in more detail below.
+% The environment accepts a number of optional arguments in |key=value| notation.  These are described in \cref{sec:options:macro}.
 %
-% To use \texpkg{minted} with a language that is not supported by Pygments, or simply to disable highlighting, set the language to |text|:  |\begin{minted}{text}|.
+% 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 alternatively use a shorthand notation:
+% For a single line of source code, you can use |\mint| as a shorthand for |minted|:
 %
 % \begin{example}
-%   \mint{python}|import this|
+% \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.
@@ -720,8 +538,7 @@
 %
 % 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 matched curly braces |{}|, so long as \meta{code} itself does not contain unmatched curly braces.
-% Again, this command supports a number of options described below.
+% 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.
 %
@@ -730,74 +547,62 @@
 % Code can be typeset inline:
 %
 % \begin{example}
-%   X\mintinline{python}{print(x**2)}X
+% \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 unmatched 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.
+% 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 read and format whole files.
+% Finally, there's the |\inputminted| command to input external files.
 % Its syntax is \cmd\inputminted\oarg{options}\marg{language}\marg{filename}.
 %
-% \warn:  \meta{filename} is used to generate a shell command for highlighing the file.  Due to limitations in the design of \texpkg{minted} and limitations with TeX as a programming language, there is currently no escaping or sanitization of the filename as part of this process.  Providing a malformed filename can execute arbitrary system commands.  For example, providing ``|file.txt; touch file2.txt|'' as \meta{filename} could highlight one file while subsequently creating a new file.  (Issue \href{https://github.com/gpoore/minted/issues/338}{\#338}.)
 %
-%
 % \subsection{Using different styles}
 %
 % \DescribeMacro{\usemintedstyle}
-% Instead of using the default style you may choose another stylesheet provided by \app{Pygments}.  This may be done via the following:
 %
-% \mint[frame=lines]{latex}/\usemintedstyle{name}/
+% \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:
 %
-% The full syntax is \cmd\usemintedstyle\oarg{language}\marg{style}.  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 \cmd\setminted\ and via the optional argument for each command and environment.\footnote{Version 2.0 added the optional language argument and removed the restriction that the command be used in the preamble.}
+% \begin{minted}{latex}
+% \usemintedstyle{name}
+% \setminted{style=name}
+% \end{minted}
 %
-% Highlighting styles with examples can be viewed online 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{http://pygments.org/demo/}{pygments.org/demo}.  Available styles can also be listed by executing the following command on the command line:
+% 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.
 %
-% \begin{Verbatim}[gobble=3,commandchars=\\\{\}]
-%   \$ pygmentize -L styles
-% \end{Verbatim}
+% 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_-]+$|.
 %
-% Creating your own styles is also easy. Just follow the instructions provided on the
-% \href{http://pygments.org/docs/styles/#creating-own-styles}{\texpkg{Pygments} website}.
 %
-%
 % \subsection{Supported languages}
 %
-% \app{Pygments} supports hundreds of different programming languages, template languages, and other markup languages.  To see an exhaustive list of the currently supported languages, use the command
+% 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|.
 %
-% \begin{Verbatim}[gobble=3,commandchars=\\\{\}]
-%   \$ pygmentize -L lexers
-% \end{Verbatim}
 %
 %
 % \section{Floating listings}\label{sec:float}
 %
 % \DescribeEnv{listing}
-% \texpkg{minted} provides the |listing| environment to wrap around a source code block.  This puts the code into a floating box, with the default placement |tbp| like figures and tables.  You can also provide a |\caption| and a |\label| for such a listing in the usual way (that is, as for the |figure| and |table| environments):
-% \begin{VerbatimOut}[gobble=1]{minted.doc.out}
-%   \begin{listing}[H]
-%     \mint{cl}/(car (cons 1 '(2)))/
-%     \caption{Example of a listing.}
-%     \label{lst:example}
-%   \end{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|:
 %
-%   Listing \ref{lst:example} contains an example of a listing.
-% \end{VerbatimOut}
-% \inputminted[gobble=2,frame=lines]{latex}{minted.doc.out}
+% \begin{longexample}
+% \begin{listing}[H]
+% \mint{cl}/(car (cons 1 '(2)))/
+% \caption{Example of a listing.}
+% \label{lst:example}
+% \end{listing}
 %
-% will yield:
+% Listing \ref{lst:example} contains an example of a listing.
+% \end{longexample}
 %
-% \hfill
-% \colorbox{minted at samplebg}{\begin{minipage}{0.6\textwidth}
-%   \input{minted.doc.out}
-% \end{minipage}}
-% \hfill\hfill
-%
 % 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 at listing|.  For example,
 %\begin{verbatim}
 %\makeatletter
@@ -818,7 +623,7 @@
 % \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 \texpkg{minted} is loaded with the |newfloat| option, then the |listing| environment will be created with the more powerful \href{http://www.ctan.org/pkg/newfloat}{\texpkg{newfloat}} package instead.  \texpkg{newfloat} is part of \href{http://www.ctan.org/pkg/caption}{\texpkg{caption}}, which provides many options for customizing captions.
+% 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}
@@ -830,155 +635,189 @@
 % Refer to the \texpkg{newfloat} and \texpkg{caption} documentation for additional information.
 %
 % \DescribeMacro{\listingscaption}
-% (Only applies when package option |newfloat| is not used.) The string ``Listing'' in a listing's caption can be changed.
-% To do this, simply redefine the macro |\listingscaption|, for example:
+% This allows the string ``Listing'' in a listing's caption to be customized.  It only applies when package option |newfloat=false|.  For example:
 %
-% \mint[frame=lines]{latex}/\renewcommand{\listingscaption}{Program code}/
+%\begin{verbatim}
+%\renewcommand{\listingscaption}{Program code}
+%\end{verbatim}
 %
 % \DescribeMacro{\listoflistingscaption}
-% (Only applies when package option |newfloat| is not used.) Likewise, the caption of the listings list, ``List of Listings,'' can be changed by redefining
-% |\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:
 %
-% \mint[frame=lines]{latex}/\renewcommand{\listoflistingscaption}{List of Program Code}/
+%\begin{verbatim}
+%\renewcommand{\listoflistingscaption}{List of Program Code}
+%\end{verbatim}
 %
 %
-% \section{Options}
 %
+% \section{Configuration}
 %
 %
-% \subsection{Package options}
+% \subsection{\mintedpkg\ config file \Verb{.latexminted_config}}
 %
-% \DescribeMacro{chapter}
-% To control how \LaTeX{} counts the |listing| floats, you can pass either the
-% |section| or |chapter| option when loading the \texpkg{minted} package.
-% For example, the following will cause listings to be counted by chapter:
+% 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.
 %
-% \mint[frame=lines]{latex}/\usepackage[chapter]{minted}/
+% 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.
 %
-% \DescribeMacro{cache=\meta{boolean} (default:~true)}
-% \texpkg{minted} works by saving code to a temporary file, highlighting the code via \app{Pygments} and saving the output to another temporary file, and inputting the output into the \LaTeX\ 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 |.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.
 %
-% The |cache| option creates a directory |_minted-|\meta{jobname} in the document's root directory (this may be customized with the |cachedir| option).\footnote{The directory is actually named using a ``sanitized'' copy of \meta{jobname}, in which spaces and asterisks have been replaced by underscores, and double quotation marks have been stripped.  If the file name contains spaces, \texttt{\string\jobname} will contain a quote-wrapped name, except under older versions of MiKTeX which used the name with spaces replaced by asterisks.  Using a ``sanitized'' \meta{jobname} is simpler than accomodating the various escaping conventions.}  Files of highlighted code are stored in this directory, so that the code will not have to be highlighted again in the future.  In most cases, caching will significantly speed up document compilation.
 %
-% Cached files that are no longer in use are automatically deleted.\footnote{This depends on the main auxiliary file not being deleted or becoming corrupted.  If that happens, you could simply delete the cache directory and start over.}
+% \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.
 %
-% \DescribeMacro{cachedir=\meta{directory} (def:~\_minted-\meta{jobname})}
-% This allows the directory in which cached files are stored to be specified.  Paths should use forward slashes, even under Windows.
+%   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.
 %
-% Special characters must be escaped.  For example, |cachedir=~/mintedcache| would not work because the tilde |~| would be converted into the \LaTeX\ commands for a non-breaking space, rather than being treated literally.  Instead, use |\string~/mintedcache|, |\detokenize{~/mintedcache}|, or an equivalent solution.
+%   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.
 %
-% Paths may contain spaces, but only if the entire \meta{directory} is wrapped in curly braces |{}|, and only if the spaces are quoted.  For example,
+%  \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}
-%cachedir = {\detokenize{~/"minted cache"/"with spaces"}}
+%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}
 %
-% Note that the cache directory is relative to the |outputdir|, if an |outputdir| is specified.
 %
+% \section{Options}
 %
-% \DescribeMacro{finalizecache=\meta{boolean} (default:~false)}
-% In some cases, it may be desirable to use \texpkg{minted} in an environment in which |-shell-escape| is not allowed.  A document might be submitted to a publisher or preprint server or used with an online service that does not support |-shell-escape|.  This is possible as long as \texpkg{minted} content does not need to be modified.
 %
-% Compiling with the |finalizecache| option prepares the cache for use in an environment without |-shell-escape|.\footnote{Ordinarily, cache files are named using an MD5 hash of highlighting settings and highlighted text.  \texttt{finalizecache} renames cache files using a \texttt{listing<number>.pygtex} scheme.  This makes it simpler to match up document content and cache files, and is also necessary for the XeTeX engine since prior to TeX Live 2016 it lacked the built-in MD5 capabilities that pdfTeX and LuaTeX have.}  Once this has been done, the |finalizecache| option may be swapped for the |frozencache| option, which will then use the frozen (static) cache in the future, without needing |-shell-escape|.
 %
+% \subsection{Package options}
 %
-% \DescribeMacro{fontencoding=\meta{encoding} (default:~\meta{doc~encoding})}
-% Set font encoding used for typesetting code.
+% \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:
 %
-% For example, |fontencoding=T1|.
+% \begin{minted}{latex}
+% \usepackage[chapter]{minted}
+% \end{minted}
 %
-% \DescribeMacro{frozencache=\meta{boolean} (default:~false)}
-% Use a frozen (static) cache created with the |finalizecache| option.  When |frozencache| is on, |-shell-escape| is not needed, and Python and Pygments are not required.  In addition, any external files accessed through |\inputminted| are no longer necessary.
 %
-% \textbf{This option must be used with care.  A document \emph{must} be in final form, as far as \texpkg{minted} is concerned, \emph{before} \texttt{frozencache} is turned on, and the document \emph{must} have been compiled with \texttt{finalizecache}.   When this option is on, \texpkg{minted} content cannot be modified, except by editing the cache files directly.  Changing any \texpkg{minted} settings that require Pygments or Python is not possible.  If \texpkg{minted} content is incorrectly modified after \texttt{frozencache} is turned on, \texpkg{minted} \emph{cannot} detect the modification.}
+% \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.
 %
-% If you are using |frozencache|, and want to verify that \texpkg{minted} settings or content have not been modified in an invalid fashion, you can test the cache using the following procedure.
-% \begin{enumerate}
-% \item Obtain a copy of the cache used with |frozencache|.
-% \item Compile the document in an environment that supports |-shell-escape|, with |finalizecache=true| and |frozencache=false|.  This essentially regenerates the frozen (static) cache.
-% \item Compare the original cache with the newly generated cache.  Under Linux and OS X, you could use |diff|; under Windows, you probably want |fc|.  If \texpkg{minted} content and settings have not been modified in an invalid fashion, all files will be identical (assuming that compatible versions of Pygments are used for both caches).
-% \end{enumerate}
+% 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{draft=\meta{boolean} (default:~false)}
-% This uses \texpkg{fancyvrb} alone for all typesetting; \app{Pygments} is not used.  This trades syntax highlighting and some other \app{minted} features for faster compiling.  Performance should be essentially the same as using \texpkg{fancyvrb} directly; no external temporary files are used.  Note that if you are not changing much code between compiles, the difference in performance between caching and draft mode may be minimal.  Also note that |draft| settings are typically inherited from the document class.
+% \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|.
 %
-% Draft mode does not support |autogobble|.  Regular |gobble|, |linenos|, and most other options not related to syntax highlighting will still function in draft mode.
+% Note that the cache directory is relative to |-output-directory| or equivalently the  |TEXMF_OUTPUT_DIRECTORY| environment variable, if that is set.
 %
-% Documents can usually be compiled without shell escape in draft mode.  The \texpkg{ifplatform} package may issue a warning about limited functionality due to shell escape being disabled, but this may be ignored in almost all cases.  (Shell escape is only really required if you have an unusual system configuration such that the |\ifwindows| macro must fall back to using shell escape to determine the system.  See the \texpkg{ifplatform} documentation for more details:  \url{http://www.ctan.org/pkg/ifplatform}.)
 %
-% If the |cache| option is set, then all existing cache files will be kept while draft mode is on.  This allows caching to be used intermitently with draft mode without requiring that the cache be completely recreated each time.  Automatic cleanup of cached files will resume as soon as draft mode is turned off.  (This assumes that the auxiliary file has not been deleted in the meantime; it contains the cache history and allows automatic cleanup of unused files.)
+% \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{final=\meta{boolean} (default:~true)}
-% This is the opposite of |draft|; it is equivalent to |draft=false|.  Again, note that |draft| and |final| settings are typically inherited from the document class.
+% \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{inputlanglinenos=\meta{boolean} (default:~false)}
-% This enables |langlinenos| 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 |langlinenos| 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.  |inputlanglinenos| defines a single numbering per language, regardless of where code originates.
+% \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.
 %
-% \DescribeMacro{kpsewhich=\meta{boolean} (default:~false)}
-% This option uses |kpsewhich| to locate files that are to be highlighted.  Some build tools such as |texi2pdf| function by modifying |TEXINPUTS|; in some cases, users may customize |TEXINPUTS| as well.  The |kpsewhich| option allows \texpkg{minted} to work with such configurations.
+% 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.
 %
-% This option may add a noticeable amount of overhead on some systems, or with some system configurations.
+% 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.
 %
-% This option does \emph{not} make \texpkg{minted} work with the |-output-directory| and |-aux-directory| command-line options for \LaTeX.  For those, see the |outputdir| package option.
 %
+% \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).
 %
-% \DescribeMacro{langlinenos=\meta{boolean} (default:~false)}
-% This allows all |minted| environments and |\mint| commands (and custom environments/commands based on them) for a given 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 |inputlanglinenos| for that.
+% 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.
 %
-% \texpkg{minted} 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 |langlinenos| option makes |firstnumber| work for each language individually with all |minted| and |\mint| usages.  For example, consider the code and output below.
 %
-% \begin{VerbatimOut}[gobble=1]{minted.doc.out}
-%   \begin{minted}[linenos]{python}
-%   def f(x):
-%       return x**2
-%   \end{minted}
+% \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.
 %
-%   \begin{minted}[linenos]{ruby}
-%   def func
-%       puts "message"
-%   end
-%   \end{minted}
+% \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{minted}[linenos, firstnumber=last]{python}
-%   def g(x):
-%       return 2*x
-%   \end{minted}
-% \end{VerbatimOut}
-% \inputminted[frame=single, rulecolor=minted at linkcolor]{latex}{minted.doc.out}
-% \hfill
-% \colorbox{minted at samplebg}{\begin{minipage}{0.6\textwidth}
-%   \input{minted.doc.out}
-% \end{minipage}}
-% \hfill\hfill
+% \begin{longexample}[xleftmargin=1em]
+% \begin{minted}[linenos]{python}
+% def f(x):
+%     return x**2
+% \end{minted}
 %
-% Without the |langlinenos| 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.
+% \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{outputdir=\meta{directory} (default:~\meta{none})}
-% The |-output-directory| and |-aux-directory| (MiKTeX) command-line options for \LaTeX\ cause problems for \texpkg{minted}, because the \texpkg{minted} temporary files are saved in |<outputdir>|, but \texpkg{minted} still looks for them in the document root directory.  There is no way to access the value of the command-line option so that \texpkg{minted} can automatically look in the right place.  But it is possible to allow the output directory to be specified manually as a package option.
+% \DescribeMacro{placeholder=\meta{boolean} (default:~false)}
+% Instead of typesetting code, insert a placeholder.  This is enabled automatically when working with PGF/TikZ externalization.
 %
-% The output directory should be specified using an absolute path or a path relative to the document root directory.  Paths should use forward slashes, even under Windows.  Special characters must be escaped, while spaces require quoting and need the entire \meta{directory} to be wrapped in curly braces |{}|.  See |cachedir| above for examples of escaping and quoting.
 %
-%
 % \DescribeMacro{section}
 % To control how \LaTeX{} counts the |listing| floats, you can pass either the
-% |section| or |chapter| option when loading the \texpkg{minted} package.
+% |section| or |chapter| option when loading the \mintedpkg\ package.
 %
 %
-% \subsection{Macro option usage}
+% \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.
 %
-% All \texpkg{minted} highlighting commands accept the same set of options.
+%
+% \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:
 %
@@ -994,8 +833,6 @@
 % \end{example}
 %
 % An option value of |true| may also be omitted entirely (including the ``|=|'').
-% To customize the display of the line numbers further, override the |\theFancyVerbLine| command.
-% Consult the \texpkg{fancyvrb} documentation for details.
 %
 % |\mint| accepts the same options:
 %
@@ -1006,7 +843,7 @@
 % Here's another example: we want to use the \LaTeX{} math mode inside comments:
 %
 % \begin{example}
-%   \begin{minted}[mathescape]{python}
+%   \begin{minted}[mathescape]{py}
 %   # Returns $\sum_{i=1}^{n}i$
 %   def sum_from_one_to(n):
 %       r = range(1, n + 1)
@@ -1016,36 +853,38 @@
 %
 % To make your \LaTeX{} code more readable you might want to indent the code inside a |minted|
 % environment.
-% The option |gobble| removes these unnecessary whitespace characters from the output.  There is also an |autogobble| option that detects the length of this whitespace automatically.
+% 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}[gobble=2,
-%     showspaces]{python}
+% \begin{minted}[showspaces]{py}
 %     def boring(args = None):
 %         pass
-%   \end{minted}
+% \end{minted}
 %
-%   versus
+% versus
 %
-%   \begin{minted}[showspaces]{python}
+% \begin{minted}[gobble=4,
+%   showspaces]{py}
 %     def boring(args = None):
 %         pass
-%   \end{minted}
+% \end{minted}
 % \end{example}
+% \endgroup
 %
 % \DescribeMacro{\setminted}
-% You may wish to set options for the document as a whole, or for an entire language.  This is possible via \cmd\setminted\oarg{language}\marg{key=value,...}.  Language-specific options override document-wide options.  Individual command and environment options override language-specific options.
+% 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 language.  This is possible via \cmd\setmintedinline.  The syntax is
-% \cmd\setmintedinline\oarg{language}\marg{key=value,...}.  Language-specific options override document-wide options. Individual command options override language-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.
+% 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{Available options}
+% \subsection{Command and environment options}
 %
 % \newcommand\appliesto[1]{\textsf{[For #1 only]}}
 %
-% Following is a full list of available options.
-% For more detailed option descriptions please refer to the \texpkg{fancyvrb} and \app{Pygments} documentation.
+% 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)]
@@ -1053,14 +892,18 @@
 %
 % \begin{example}
 %   ...text.
-%   \begin{minted}[autogobble]{python}
+%   \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 as for baselinestretch inside the listing.
+%     Value to use for baselinestretch inside the listing.
 %
 %
 % \item[beameroverlays (boolean) (false)]
@@ -1067,39 +910,24 @@
 % 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) (\meta{none})]
-%     Background color of the listing.  Be aware that this option has several limitations (described below); see ``Framing alternatives'' below for more powerful alternatives.
+% \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.
 %
-%     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:
+% |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}{0.95,0.95,0.95}
-%   \begin{minted}[bgcolor=bg]{php}
-%   <?php
-%     echo "Hello, $x";
-%   ?>
-%   \end{minted}
+% \definecolor{bg}{rgb}{.9, .9, .9}
+% \begin{minted}[bgcolor=bg]{php}
+% <?php
+%   echo "Hello, $x";
+% ?>
+% \end{minted}
 % \end{example}
 %
-% This option puts \texttt{minted} environments and \texttt{\string\mint} commands in a \texttt{snugshade*} environment from the \texpkg{framed} package, which supports breaks across pages.  (Prior to \texpkg{minted} 2.2, a \texttt{minipage} was used, which prevented page breaks and gave undesirable spacing from surrounding text.)  Be aware that if \texttt{bgcolor} is used with \texttt{breaklines=true}, and a line break occurs just before a page break, then text may extend below the colored background in some instances.  It is best to use a more advanced framing package in those cases; see ``Framing alternatives'' below.
-%
-% This option puts \texttt{\string\mintinline} inside a \texttt{\string\colorbox}, which \textbf{does not allow line breaks}.  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=\{\}\}} to turn off the coloring for inline commands.
-%
-% ~
-%
-% \textbf{Framing alternatives}
-%
-% If you want more reliable and advanced options for background colors and framing, you should consider a more advanced framing package such as \texpkg{mdframed} or \texpkg{tcolorbox}.  It is easy to add framing to \texpkg{minted} commands and environments using the \texpkg{etoolbox} package, which is automatically loaded by \texpkg{minted}.  For example, using \texpkg{mdframed}:
+% 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}
-%\BeforeBeginEnvironment{minted}{\begin{mdframed}}
-%\AfterEndEnvironment{minted}{\end{mdframed}}
-%\end{Verbatim}
-% Some framing packages also provide built-in commands for such purposes.  For example, \texpkg{mdframed} provides a \texttt{\string\surroundwithmdframed} command, which could be used to add a frame to all \texttt{minted} environments:
-%\begin{Verbatim}
-%\surroundwithmdframed{minted}
-%\end{Verbatim}
-% \texpkg{tcolorbox} even provides a built-in framing environment with \texpkg{minted} 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>,
@@ -1110,6 +938,14 @@
 % \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}.
 %
@@ -1126,12 +962,14 @@
 %   \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[breakaftersymbolpre (string) (\string\,\string\footnotesize\string\ensuremath\{\_\string\rfloor\}, \,\footnotesize\ensuremath{_\rfloor})]
-%     The symbol inserted pre-break for breaks inserted by \texttt{breakafter}.
 %
 %   \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}.
 %
@@ -1144,12 +982,20 @@
 % \end{longexample}
 % \endgroup
 %
-%   \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[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}.
 %
@@ -1169,23 +1015,30 @@
 %   \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[breakbeforesymbolpre (string) (\string\,\string\footnotesize\string\ensuremath\{\_\string\rfloor\}, \,\footnotesize\ensuremath{_\rfloor})]
-%     The symbol inserted pre-break for breaks inserted by \texttt{breakbefore}.
 %
 %   \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 is not compatible with \texttt{draft} mode.  A complete list of Pygments tokens is available at \url{http://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.
+%   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.
+% 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)]
@@ -1194,11 +1047,11 @@
 %   \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 \texttt{escapeinside=||}, and then insert \texttt{|\textbackslash\textbackslash|} at the appropriate point.  (Note that \texttt{escapeinside} does not work within strings.)
+% 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]{python}
+%   \begin{minted}[breaklines]{py}
 %   def f(x):
 %       return 'Some text ' + str(x)
 %   \end{minted}
@@ -1226,28 +1079,16 @@
 % \end{longexample}
 % \endgroup
 %
-%     Automatic line breaks are limited with \app{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,
+%     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.
 %
-%     Automatic line breaks will not work with \texttt{showspaces=true} unless you use \texttt{breakanywhere} or \texttt{breakafter=\string\space}.
-%
 %   \item[breaksymbol (string) (breaksymbolleft)]
 %     Alias for \texttt{breaksymbolleft}.
 %
-%   \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[breaksymbolindent (dimension) (\meta{breaksymbolindentleftnchars})]
 % Alias for |breaksymbolindentleft|.
 %
@@ -1270,6 +1111,17 @@
 % 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|.
 %
@@ -1291,23 +1143,45 @@
 % Allows |breaksymbolsepright| to be specified as an integer number of characters rather than as a dimension (assumes a fixed-width font).
 %
 %
-%   \item[codetagify (list of strings) (\textrm{highlight \texttt{XXX}, \texttt{TODO}, \texttt{BUG}, and \texttt{NOTE}})]
-%     Highlight special code tags in comments and docstrings.
+% \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) (\meta{system-specific})]
-%     Sets the file encoding that \app{Pygments} expects.  See also |outencoding|.
-%   \item[escapeinside (string) (\meta{none})]
-%   Escape to \LaTeX\ between the two characters specified in \texttt{\string(string\string)}.  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.  Special \LaTeX\ characters must be escaped when they are used as the escape characters (for example, \texttt{escapeinside=\textbackslash\#\textbackslash\%}).  Requires \app{Pygments} 2.0+.
 %
-% \textbf{Escaping does not work inside strings and comments (for comments, there is \texttt{texcomments}).  As of Pygments 2.0.2, this means that 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://bitbucket.org/birkenfeld/pygments-main/issue/1118}{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}{\texpkg{minted} GitHub site}.
+%   \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}
-%   \begin{minted}[escapeinside=||]{py}
+%   \setminted{escapeinside=||}
+%   \begin{minted}{py}
 %   def f(x):
 %       y = x|\colorbox{green}{**}|2
 %       return y
@@ -1315,25 +1189,39 @@
 % \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{http://tex.stackexchange.com/questions/223876}.
+% \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})]
+%
+%
+%   \item[fontseries (series name) (auto\textrm{ -- the same as the current font})]
 %     The font series to use.
-%   \item[fontsize (font size) (auto \textrm{-- the same as the current font})]
+%
+%
+%   \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[fontshape (font shape) (auto \textrm{-- the same as the current font})]
-%     The font shape to use.
+%
+%
 %   \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.
+%     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)]
@@ -1340,9 +1228,19 @@
 %     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.
+% \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|.
 %
@@ -1353,8 +1251,24 @@
 % The highlighting color can be customized with |highlightcolor|.
 %
 %
-%   \item[keywordcase] (string) (lower)
-%     Changes capitalization of keywords.  Takes |lower|, |upper|, or |capitalize|.
+%   \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.
@@ -1361,7 +1275,7 @@
 %     \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)]
-%     Position where to print the label (see above;  default: |topline| if one label is defined, |all| if two are defined, |none| else).
+%     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.
@@ -1370,9 +1284,11 @@
 %     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}}}}
+%   \renewcommand{\theFancyVerbLine}{%
+%     \sffamily
+%     \textcolor[rgb]{0.5,0.5,1.0}{%
+%       \scriptsize\oldstylenums{%
+%         \arabic{FancyVerbLine}}}}
 %
 %   \begin{minted}[linenos,
 %     firstnumber=11]{python}
@@ -1384,27 +1300,100 @@
 %   \end{minted}
 % \end{example}
 %
-% \item[numberfirstline (boolean) (false)]
-% Always number the first line, regardless of |stepnumber|.
 %
+% \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[numbers (left \| right \| both \| none) (none)]
-%     Essentially the same as |linenos|, except the side on which the numbers appear may be specified.
+%
+% \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|.  \textcolor{DarkRed}{\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.}}
+%     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[outencoding (string) (\meta{system-specific})]
-%     Sets the file encoding that \app{Pygments} uses for highlighted output.  Overrides any encoding previously set via |encoding|.
-%   \item[python3 (boolean) (false)] \appliesto{PythonConsoleLexer}
+%   \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)]
@@ -1411,22 +1400,12 @@
 %     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[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[showspaces (boolean) (false)]
 %     Enables visible spaces: \verb*/visible spaces/.
+%
+%
 %   \item[showtabs (boolean) (false)]
 %     Enables visible tabs---only works in combination with |obeytabs|.
 %
@@ -1441,8 +1420,8 @@
 %
 %   \item[startinline (boolean) (false)] \appliesto{PHP}
 %     Specifies that the code starts in PHP mode, i.e., leading |<?php| is omitted.
-%   \item[style] (string) (\meta{default})
-%     Sets the stylesheet used by \app{Pygments}.
+%
+%
 %   \item[stepnumber (integer) (1)]
 %     Interval at which line numbers appear.
 %
@@ -1461,6 +1440,10 @@
 %     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.
 %
@@ -1477,7 +1460,7 @@
 %   \item[texcomments (boolean) (false)]
 %     Enables \LaTeX{} code inside comments.  The newer name for |texcl|.  See the note under |escapeinside| regarding math and ligatures.
 %
-%     As of Pygments 2.0.2, \texttt{texcomments} fails with multiline C/C++ preprocessor directives, and may fail in some other circumstances.  This is because preprocessor directives are \href{http://pygments.org/docs/tokens/}{tokenized as \texttt{Comment.Preproc}}, so \texttt{texcomments} causes preprocessor directives to be treated as literal \LaTeX\ code.  \href{https://bitbucket.org/birkenfeld/pygments-main/issue/1086/wrong-processing-of-in-c-c-macros-if-is}{An issue has been opened} at the Pygments site; additional details are also available on the \href{https://github.com/gpoore/minted/issues/66}{\texpkg{minted} GitHub site}.
+%     \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)]
@@ -1490,49 +1473,43 @@
 %
 % \section{Defining shortcuts}
 %
-% Large documents with a lot of listings will nonetheless use the same source language and the
-% same set of options for most listings.
-% Always specifying all options is redundant, a lot to type and makes performing changes hard.
+% 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.
 %
-% One option is to use \cmd\setminted, but even then you must still specify the language each time.
-%
-% \texpkg{minted} therefore defines a set of commands that lets you define shortcuts for the highlighting commands.
-% Each shortcut is specific for one programming language.
-%
 % \DescribeMacro{\newminted}
 % |\newminted| defines a new alias for the |minted| environment:
 %
+% \begingroup
+% \setminted{autogobble=false}
 % \begin{example}
-%   \newminted{cpp}{gobble=2,linenos}
+% \newminted{cpp}{gobble=2,linenos}
 %
-%   \begin{cppcode}
-%     template <typename T>
-%     T id(T value) {
-%         return value;
-%     }
-%   \end{cppcode}
+% \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}
+% \newminted{cpp}{gobble=2,linenos}
 %
-%   \begin{cppcode*}{linenos=false,
-%                    frame=single}
-%     int const answer = 42;
-%   \end{cppcode*}
+% \begin{cppcode}[linenos=false,
+%                 frame=single]
+%   int const answer = 42;
+% \end{cppcode}
 % \end{example}
+% \endgroup
 %
-% Notice the star ``|*|'' behind the environment name---due to restrictions in \texpkg{fancyvrb}'s handling
-% of options, it is necessary to provide a \emph{separate} environment that accepts options, and the options
-% are \emph{not} optional on the starred version of the environment.
+% 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}.
 %
-% The default name of the environment is \meta{language}|code|.
-% If this name clashes with another environment or if you want to choose an own name for another reason, you may
-% do so by specifying it as the first argument: \cmd\newminted\oarg{environment name}\marg{language}\marg{options}.
-%
-% Like normal \texpkg{minted} environments, environments created with |\newminted| may be used within other environment definitions.  Since the \texpkg{minted} 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,
+% 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}}
@@ -1539,67 +1516,59 @@
 %\end{Verbatim}
 %
 % \DescribeMacro{\newmint}
-% The above macro only defines shortcuts for the |minted| environment.
-% The main reason is that the short command form |\mint| often needs different options---at the very least, it
-% will generally not use the |gobble| option.
-% A shortcut for |\mint| is defined using \cmd\newmint\oarg{macro name}\marg{language}\marg{options}.
+% 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{language} is used.
+% 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{language}\marg{options}.  If a \meta{macro~name} is not specified, then the created macro is called |\|\meta{language}|inline|.
+% 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}
-%
-%   X\perlinline/my $foo = $bar;/X
+%   \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{language}\marg{options}
+% \cmd\newmintedfile\oarg{macro~name}\marg{lexer}\marg{options}
 % \end{center}
-% If no \meta{macro name} is given, then the macro is called |\|\meta{language}|file|.
+% If no \meta{macro name} is given, then the macro is called \meta{lexer}|file|.
 %
 %
 %
 % \section{FAQ and Troubleshooting}
 %
-% In some cases, \texpkg{minted} 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{http://tex.stackexchange.com/}{tex.stackexchange.com} or ask a question there, if you are working with \texpkg{minted} in a non-typical context.
+% 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 \texpkg{minted}.  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 \texpkg{minted} is used.  You may want to search \href{http://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 \texpkg{minted} in a directory that is synchronized with Dropbox or a similar file syncing program.  These programs can try to sync \texpkg{minted}'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{http://www.tug.dk/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 OS X when using caching.}  See the note on OS X under Section~\ref{sec:basic:preliminary}.
-% \item \textbf{TeXShop can't find \texttt{pygmentize}.}  You may need to create a symlink.  See \url{https://tex.stackexchange.com/questions/279214}.
-% \item \textbf{Weird things happen when I use the \texpkg{fancybox} package.}  \texpkg{fancybox} conflicts with \texpkg{fancyvrb}, which \texpkg{minted} uses internally.  When using \texpkg{fancybox}, make sure that it is loaded before \texpkg{minted} (or before \texpkg{fancyvrb}, if \texpkg{fancyvrb} is not loaded by \texpkg{minted}).
-% \item \textbf{When I use \texpkg{minted} with KOMA-Script document classes, I get warnings about \texttt{\string\float at addtolists}.}  \texpkg{minted} 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 \texpkg{minted}'s |newfloat| package option.
+% \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 at 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 \texpkg{minted}.  In the \texpkg{breqn} and comma case, this can be fixed by redefining the comma within |minted| environments:
+% \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 \texpkg{minted} 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 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{Tabs are eaten by Beamer.}  This is due to \href{https://bitbucket.org/rivanvx/beamer/issue/310/tab-characters-in-listings-lost-when-using}{a bug in Beamer's treatment of verbatim content}.  Upgrade Beamer or use the linked patch.  Otherwise, try |fragile=singleslide| if you don't need overlays, or consider using \cmd\inputminted\ or converting the tabs into spaces.
-%
-% \item \textbf{I'm trying to create several new \texpkg{minted} 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 \texpkg{keyval} works (\texpkg{minted} uses it to manage options). Arguments are not expanded. See \href{http://tex.stackexchange.com/questions/13563/building-keyval-arguments-using-a-macro/13564#13564}{this} and \href{http://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.
+% \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}
 %
@@ -1622,7 +1591,7 @@
 %\commandthatdoesnotlikeverbatim{Text \usebox{\mybox}}
 %\end{verbatim}
 %
-% \item \textbf{Extended characters do not work inside \texpkg{minted} commands and environments, even when the \texpkg{inputenc} package is used.}
+% \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:
@@ -1633,10 +1602,10 @@
 % \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{http://tex.stackexchange.com/questions/58732/how-to-output-a-tabulation-into-a-file} for more on XeLaTeX's handling of tab characters. \end{sloppypar}
+% 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 \texpkg{minted}.}
-% Load the \texpkg{caption} package with the option |compatibility=false|.  Or better yet, use \texpkg{minted}'s |newfloat| package option, which provides better \texpkg{caption} compatibility.
+% \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}
@@ -1643,19 +1612,13 @@
 %\usepackage{caption}
 %\newenvironment{longlisting}{\captionsetup{type=listing}}{}
 %\end{verbatim}
-% With the \texpkg{caption} package, it is best to use \texpkg{minted}'s |newfloat| package option.  See \url{http://tex.stackexchange.com/a/53540/10742} for more on |listing| environments with page breaks.
+% 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 a custom script/executable to access Pygments, rather than |pygmentize|.}  Redefine |\MintedPygmentize|:
-%\begin{verbatim}
-%\renewcommand{\MintedPygmentize}{...}
-%\end{verbatim}
+% \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{I want to use the command-line option \texttt{-output-directory}, or MiKTeX's \texttt{-aux-directory}, but am getting errors.}  Use the package option |outputdir| to specify the location of the output directory.  Unfortunately, there is no way for \texpkg{minted} to detect the output directory automatically.
-%
-% \item \textbf{I want extended characters in frame labels, but am getting errors.}  This can happen with \texpkg{minted} <2.0 and Python 2.7, due to a \href{https://bitbucket.org/birkenfeld/pygments-main/issue/801/python-2-fails-to-detect-terminal-encoding}{terminal encoding issue with Pygments}.  It should work with any version of Python with \texpkg{minted} 2.0+, which processes labels internally and does not send them to Python.
 % \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 \texpkg{minted} is loaded after \texpkg{csquotes}.  Try loading \texpkg{minted} 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.  \texpkg{minted} 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 \texpkg{minted} has deleted. It's possible to disable minted's temp file cleanup by adding |\renewcommand{\DeleteFile}[2][]{}| after the |\usepackage{minted}|.
+% \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}
 %
 %
@@ -1665,7 +1628,9 @@
 %
 % \textbf{Konrad Rudolph:}  Special thanks to Philipp Stephani and the rest of the guys from \texttt{comp.text.tex} and \texttt{tex.stackexchange.com}.
 %
-% \textbf{Geoffrey Poore:}
+% ~\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.
@@ -1673,11 +1638,9 @@
 % \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}
 %
-% \PrintChangelog
+% \StopEventually{} ^^A\StopEventually{\PrintIndex}
 %
-% \StopEventually{} %\StopEventually{\PrintIndex}
 %
-%
 % \section{Implementation}
 %
 % \iffalse
@@ -1685,1647 +1648,2128 @@
 % \fi
 %
 %
+%
 % \subsection{Required packages}
-% Load required packages.  For compatibility reasons, most old functionality should be supported with the original set of packages.  More recently added packages, such as |etoolbox| and |xstring|, should only be used for new features when possible.  |shellesc| must be loaded before any packages that invoke |\write18|, since it is possible that they haven't yet been patched to work with LuaTeX 0.87+.
+%
+%
 %    \begin{macrocode}
-\RequirePackage{keyval}
-\RequirePackage{kvoptions}
-\RequirePackage{fvextra}[2022/11/30]
-\RequirePackage{ifthen}
-\IfFileExists{shellesc.sty}
- {\RequirePackage{shellesc}
-  \@ifpackagelater{shellesc}{2016/04/29}
-   {}
-   {\protected\def\ShellEscape{\immediate\write18 }}}
- {\protected\def\ShellEscape{\immediate\write18 }}
-\RequirePackage{ifplatform}
+\RequirePackage{catchfile}
+\RequirePackage{etoolbox}
+\RequirePackage{fvextra}[2024/09/05]
+\RequirePackage{latex2pydata}[2024/05/16]
 \RequirePackage{pdftexcmds}
-\RequirePackage{etoolbox}
-\RequirePackage{xstring}
-\RequirePackage{lineno}
-\RequirePackage{framed}
-\RequirePackage{catchfile}
+\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{%
-  \@ifpackageloaded{color}{}{%
-    \@ifpackageloaded{xcolor}{}{\RequirePackage{xcolor}}}%
-}
+  \IfPackageLoadedTF{color}%
+   {}%
+   {\IfPackageLoadedTF{xcolor}{}{\RequirePackage{xcolor}}}}
 %    \end{macrocode}
 %
 %
 %
-% \subsection{Package options}
+% \subsection{Exception handling}
 %
-% \begin{macro}{\minted at float@within}
 %
-% Define an option that controls the section numbering of the |listing| float.
+% \begin{macro}{\minted at error}
+%    \begin{macrocode}
+\def\minted at error#1{\PackageError{minted}{#1}{}}
+%    \end{macrocode}
+% \end{macro}
 %
+% \begin{macro}{\minted at fatalerror}
+% |\batchmode\read -1 to \minted at fatalerror@exitnow| forces an immediate exit with ``\Verb[breaklines]{! Emergency stop [...] cannot \read from terminal in nonstop modes}.''
 %    \begin{macrocode}
-\DeclareVoidOption{chapter}{\def\minted at float@within{chapter}}
-\DeclareVoidOption{section}{\def\minted at float@within{section}}
+\def\minted at fatalerror#1{%
+  \minted at error{#1}%
+  \batchmode\read -1 to \minted at fatalerror@exitnow}
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\minted at warning}
+%    \begin{macrocode}
+\def\minted at warning#1{\PackageWarning{minted}{#1}}
+%    \end{macrocode}
+% \end{macro}
 %
-% \begin{macro}{newfloat}
 %
-% Define an option to use \texpkg{newfloat} rather than \texpkg{float} to create a floated |listing| environment.
 %
+% \subsection{Python executable and minimum supported version}
+%
+%
+% \begin{macro}{\MintedExecutable}
+% Name of \mintedpkg\ Python executable.
 %    \begin{macrocode}
-\DeclareBoolOption{newfloat}
+\edef\MintedExecutable{\detokenize{latexminted}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{cache}
-% Define an option that determines whether highlighted content is cached.  We use a boolean to keep track of its state.
+% \begin{macro}{\minted at executable@minversion}
 %    \begin{macrocode}
-\DeclareBoolOption[true]{cache}
+\edef\minted at executable@minversion{\detokenize{0.1.0}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at jobname}
-% At various points, temporary files and directories will need to be named after the main |.tex| file.  The typical way to do this is to use |\jobname|.  However, if the file name contains spaces, then |\jobname| will contain the name wrapped in quotes (older versions of MiKTeX replace spaces with asterisks instead, and \texttt{XeTeX} apparently \href{http://tex.stackexchange.com/a/93829/10742}{allows double quotes within file names}, in which case names are wrapped in single quotes).  While that is perfectly fine for working with \LaTeX\ internally, it causes problems with |\write18|, since quotes will end up in unwanted locations in shell commands.  It would be possible to strip the wrapping quotation marks when they are present, and maintain any spaces in the file name.  But it is simplest to create a ``sanitized'' version of |\jobname| in which spaces and asterisks are replaced by underscores, and double quotes are stripped.  Single quotes are also replaced, since they can cause quoted string errors, or become double quotes in the process of being passed to the system through |\write18|.
+% \begin{macro}{\minted at executable@minmajor,\minted at executable@minminor,\minted at executable@minpatch}
 %    \begin{macrocode}
-\StrSubstitute{\jobname}{ }{_}[\minted at jobname]
-\StrSubstitute{\minted at jobname}{*}{_}[\minted at jobname]
-\StrSubstitute{\minted at jobname}{"}{}[\minted at jobname]
-\StrSubstitute{\minted at jobname}{'}{_}[\minted at jobname]
+\def\minted at executable@setminversioncomponents{%
+  \expandafter\minted at executable@setminversioncomponents at i
+    \minted at executable@minversion\relax}
+\begingroup
+\catcode`\.=12
+\gdef\minted at executable@setminversioncomponents at i#1.#2.#3\relax{%
+  \def\minted at executable@minmajor{#1}%
+  \def\minted at executable@minminor{#2}%
+  \def\minted at executable@minpatch{#3}}
+\endgroup
+\minted at executable@setminversioncomponents
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at cachedir}
-% Set the directory in which cached content is saved.  The default uses a |minted-| prefix followed by the sanitized |\minted at jobname|.
+% \begin{macro}{\minted at executable@version}
 %    \begin{macrocode}
-\newcommand{\minted at cachedir}{\detokenize{_}minted-\minted at jobname}
-\let\minted at cachedir@windows\minted at cachedir
-\define at key{minted}{cachedir}{%
-  \@namedef{minted at cachedir}{#1}%
-  \StrSubstitute{\minted at cachedir}{/}{\@backslashchar}[\minted at cachedir@windows]}
+\let\minted at executable@version\relax
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{finalizecache}
-% Define an option that switches the naming of cache files from an MD5-based system to a |listing<number>| scheme.  Compiling with this option is a prerequisite to turning on |frozencache|.
+% \begin{macro}{minted at executable@exists}
 %    \begin{macrocode}
-\DeclareBoolOption{finalizecache}
+\newbool{minted at executable@exists}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{frozencache}
-% Define an option that uses a fixed set of cache files, using |listing<number>| file naming with |\write18| disabled.  This is convenient for working with a document in an environment in which |\write18| support is disabled and \texpkg{minted} content does not need to be modified.
+% \begin{macro}{minted at executable@issupported}
 %    \begin{macrocode}
-\DeclareBoolOption{frozencache}
+\newbool{minted at executable@issupported}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at outputdir}
-% The |-output-directory| command-line option for \LaTeX\ causes problems for \texpkg{minted}, because the \texpkg{minted} temporary files are saved in the output directory, but \texpkg{minted} still looks for them in the document root directory.  There is no way to access the value of the command-line option.  But it is possible to allow the output directory to be specified manually as a package option.  A trailing slash is automatically appended to the |outputdir|, so that it may be directly joined to |cachedir|.  This may be redundant if the user-supplied value already ends with a slash, but doubled slashes are ignored under *nix and Windows, so it isn't a problem.
+%
+% \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 at timestamp}
 %    \begin{macrocode}
-\let\minted at outputdir\@empty
-\let\minted at outputdir@windows\@empty
-\define at key{minted}{outputdir}{%
-  \@namedef{minted at outputdir}{#1/}%
-  \StrSubstitute{\minted at outputdir}{/}%
-    {\@backslashchar}[\minted at outputdir@windows]}
+\begingroup
+\catcode`\-=12
+\catcode`\+=12
+\catcode`\:=12
+\def\minted at creationdatetotimestamp#1{%
+  \expandafter\minted at creationdatetotimestamp@i#1-\relax}
+\def\minted at creationdatetotimestamp@i#1:#2-#3\relax{%
+  \minted at creationdatetotimestamp@ii#2+\relax}
+\def\minted at creationdatetotimestamp@ii#1+#2\relax{%
+  #1}
+\expandafter\ifx\csname pdftexversion\endcsname\relax
+\else
+  \xdef\minted at timestamp{\minted at creationdatetotimestamp{\pdfcreationdate}}
+\fi
+\expandafter\ifx\csname XeTeXrevision\endcsname\relax
+\else
+  \xdef\minted at timestamp{\minted at creationdatetotimestamp{\creationdate}}
+\fi
+\expandafter\ifx\csname directlua\endcsname\relax
+\else
+  \xdef\minted at timestamp{\minted at creationdatetotimestamp{\pdffeedback creationdate}}
+\fi
+\endgroup
+\ifcsname minted at timestamp\endcsname
+\else
+  \begingroup
+  \newcounter{minted at timestamp@hr}
+  \newcounter{minted at timestamp@min}
+  \setcounter{minted at timestamp@min}{\number\time}
+  \loop\unless\ifnum\value{minted at timestamp@min}<60\relax
+    \addtocounter{minted at timestamp@hr}{1}
+    \addtocounter{minted at timestamp@min}{-60}
+  \repeat
+  \xdef\minted at timestamp{%
+    \the\year
+    \ifnum\month<10 0\fi\the\month
+    \ifnum\day<10 0\fi\the\day
+    \ifnum\value{minted at timestamp@hr}<10 0\fi\theminted at timestamp@hr
+    \ifnum\value{minted at timestamp@min}<10 0\fi\theminted at timestamp@min}
+  \endgroup
+\fi
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{inputlanglinenos}
-% Enable |langlinenos| and make it apply to |\inputminted|.
+%
+% \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}
-\DeclareBoolOption{inputlanglinenos}
+\begingroup
+\catcode`\"=12
+\catcode`\'=12
+\gdef\minted at setjobnamemdfive#1#2\FV at Sentinel{%
+  \ifx#1"\relax
+    \let\minted at next\minted at setjobnamemdfive@dquoted
+  \else\ifx#1'\relax
+    \let\minted at next\minted at setjobnamemdfive@squoted
+  \else
+    \let\minted at next\minted at setjobnamemdfive@uquoted
+  \fi\fi
+  \minted at next#1#2\FV at Sentinel}
+\gdef\minted at setjobnamemdfive@dquoted#1#2\FV at Sentinel{%
+  \minted at setjobnamemdfive@dquoted at i#2"\FV at Sentinel}
+\gdef\minted at setjobnamemdfive@dquoted at i#1"#2\FV at Sentinel{%
+  \if\relax\detokenize{#2}\relax
+    \edef\MintedJobnameMdfive{\pdf at mdfivesum{\jobname}}%
+  \else\if\relax\detokenize\expandafter{\@gobble#2}\relax
+    \edef\MintedJobnameMdfive{\pdf at mdfivesum{#1}}%
+  \else
+    \edef\MintedJobnameMdfive{\pdf at mdfivesum{\jobname}}%
+  \fi\fi}
+\gdef\minted at setjobnamemdfive@squoted#1#2\FV at Sentinel{%
+  \minted at setjobnamemdfive@squoted at i#2'\FV at Sentinel}
+\gdef\minted at setjobnamemdfive@squoted at i#1'#2\FV at Sentinel{%
+  \if\relax\detokenize{#2}\relax
+    \edef\MintedJobnameMdfive{\pdf at mdfivesum{\jobname}}%
+  \else\if\relax\detokenize\expandafter{\@gobble#2}\relax
+    \edef\MintedJobnameMdfive{\pdf at mdfivesum{#1}}%
+  \else
+    \edef\MintedJobnameMdfive{\pdf at mdfivesum{\jobname}}%
+  \fi\fi}
+\gdef\minted at setjobnamemdfive@uquoted#1\FV at Sentinel{%
+  \edef\MintedJobnameMdfive{\pdf at mdfivesum{#1}}}
+\endgroup
+\expandafter\minted at setjobnamemdfive\jobname\FV at Sentinel
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{kpsewhich}
-% Define an option that invokes |kpsewhich| to locate the files that are to be |pygmentize|d.  This isn't done by default to avoid the extra overhead, but can be useful with some build tools such as |texi2pdf| that rely on modifying |TEXINPUTS|.
+%
+% \begin{macro}{\MintedCacheIndexFilename}
+% Index file in cache.  Used to detect whether cache exists.
 %    \begin{macrocode}
-\DeclareBoolOption{kpsewhich}
+\edef\MintedCacheIndexFilename{%
+  \detokenize{_}\MintedJobnameMdfive\detokenize{.index.minted}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{langlinenos}
-% Define an option that makes all |minted| environments and |\mint| commands for a given language share cumulative line numbering (if |firstnumber=last|).
+% \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}
-\DeclareBoolOption{langlinenos}
+\edef\MintedConfigFilename{%
+  \detokenize{_}\MintedJobnameMdfive\detokenize{.config.minted}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{draft}
-% Define an option that allows \texpkg{fancyvrb} to do all typesetting directly, without using \app{Pygments}.  This trades syntax highlighting for speed.  Note that in many cases, the difference in performance between caching and draft mode will be minimal.  Also note that draft settings may be inherited from the document class.
+% \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}
-\DeclareBoolOption{draft}
+\edef\MintedDataFilename{%
+  \detokenize{_}\MintedJobnameMdfive\detokenize{.data.minted}}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{final}
-% Define a |final| option that is the opposite of |draft|, since many packages do this.
+%
+% \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}
-\DeclareComplementaryOption{final}{draft}
+\edef\MintedErrlogFilename{%
+  \detokenize{_}\MintedJobnameMdfive\detokenize{.errlog.minted}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% Process package options.  Proceed with everything that immediately relies upon them.  If PGF/Ti\textit{k}Z externalization is in use, switch on |draft| mode and turn off |cache|.  Externalization involves compiling the \emph{entire} document; all parts not related to the current image are ``silently thrown away.'' \texpkg{minted} needs to cooperate with that by not writing any temp files or creating any directories.  Two checks are done for externalization.  The first, using |\tikzifexternalizing|, works if externalization is set before \texpkg{minted} is loaded.  The second, using |\tikzexternalrealjob|, works if externalization is set after \texpkg{minted} is loaded.
+% \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 at pgfopts}
 %    \begin{macrocode}
-\ProcessKeyvalOptions*
-\ifthenelse{\boolean{minted at newfloat}}{\RequirePackage{newfloat}}{\RequirePackage{float}}
-\ifcsname tikzifexternalizing\endcsname
-  \tikzifexternalizing{\minted at drafttrue\minted at cachefalse}{}
-\else
-  \ifcsname tikzexternalrealjob\endcsname
-    \minted at drafttrue
-    \minted at cachefalse
-  \else
-  \fi
-\fi
-\ifthenelse{\boolean{minted at finalizecache}}%
- {\ifthenelse{\boolean{minted at frozencache}}%
-   {\PackageError{minted}%
-     {Options "finalizecache" and "frozencache" are not compatible}%
-     {Options "finalizecache" and "frozencache" are not compatible}}%
-   {}}%
- {}
-\ifthenelse{\boolean{minted at cache}}%
- {\ifthenelse{\boolean{minted at frozencache}}%
-   {}%
-   {\AtEndOfPackage{\ProvideDirectory{\minted at outputdir\minted at cachedir}}}}%
- {}
+\def\minted at pgfopts#1{%
+  \pgfkeys{/minted/pkg/.cd,#1}}
 %    \end{macrocode}
+% \end{macro}
 %
 %
+% \subsubsection{Package option definitions}
 %
-% \subsection{Input, caching, and temp files}
 %
-% \begin{macro}{\minted at input}
-% We need a wrapper for |\input|.  In most cases, |\input| failure will be due to attempts to use |\inputminted| with files that don't exist, but we also want to give informative error messages when |outputdir| is needed or incompatible build tools are used.
+% \begin{macro}{\minted at float@within}
+% Control the section numbering of the |listing| float.
 %    \begin{macrocode}
-\newcommand{\minted at input}[1]{%
-  \IfFileExists{#1}%
-   {\input{#1}}%
-   {\PackageError{minted}{Missing Pygments output; \string\inputminted\space
-     was^^Jprobably given a file that does not exist--otherwise, you may need
-     ^^Jthe outputdir package option, or may be using an incompatible build
-     tool,^^Jor may be using frozencache with a missing file}%
-    {This could be caused by using -output-directory or -aux-directory
-     ^^Jwithout setting minted's outputdir, or by using a build tool that
-     ^^Jchanges paths in ways minted cannot detect,
-     ^^Jor using frozencache with a missing file.}}%
+\minted at pgfopts{
+  chapter/.code=\def\minted at float@within{chapter},
+  chapter/.value forbidden,
+  section/.code=\def\minted at float@within{section},
+  section/.value forbidden,
 }
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at infile}
-% Define a default name for files of highlighted content that are brought it.  Caching will redefine this.  We start out with the default, non-caching value.
+% \begin{macro}{minted at newfloat}
+% Use \texpkg{newfloat} rather than \texpkg{float} to create a floating |listing| environment.
 %    \begin{macrocode}
-\newcommand{\minted at infile}{\minted at jobname.out.pyg}
+\newbool{minted at newfloat}
+\minted at pgfopts{
+  newfloat/.is if=minted at newfloat,
+}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% We need a way to track the cache files that are created, and delete those that are not in use.  This is accomplished by creating a comma-delimited list of cache files and saving this list to the |.aux| file so that it may be accessed on subsequent runs.  During subsequent runs, this list is compared against the cache files that are actually used, and unused files are deleted.  Cache file names are created with MD5 hashes of highlighting settings and file contents, with a |.pygtex| extension, so they never contain commas. Thus comma-delimiting the list of file names doesn't introduce a potential for errors.
+% \begin{macro}{minted at debug}
+% Keep temp files for aid in debugging.
+%    \begin{macrocode}
+\newbool{minted at debug}
+\minted at pgfopts{
+  debug/.is if=minted at debug,
+}
+%    \end{macrocode}
+% \end{macro}
 %
-% \begin{macro}{\minted at cachelist}
-% This is a list of the current cache files.
+%
+% \begin{macro}{minted at cache}
+% Determine whether highlighted content is cached.
 %    \begin{macrocode}
-\newcommand{\minted at cachelist}{}
+\newbool{minted at cache}
+\booltrue{minted at cache}
+\minted at pgfopts{
+  cache/.is if=minted at cache,
+}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\minted at addcachefile}
-% This adds a file to the list of cache files.  It also creates a macro involving the hash, so that the current usage of the hash can be easily checked by seeing if the macro exists.  The list of cache files must be created with built-in linebreaks, so that when it is written to the |.aux| file, it won't all be on one line and thereby risk buffer errors.
+% \begin{macro}{\minted at cachedir}
+% Set the directory in which cached content is saved.
 %    \begin{macrocode}
-\newcommand{\minted at addcachefile}[1]{%
-  \expandafter\long\expandafter\gdef\expandafter\minted at cachelist\expandafter{%
-    \minted at cachelist,^^J%
-    \space\space#1}%
-  \expandafter\gdef\csname minted at cached@#1\endcsname{}%
+\edef\minted at cachedir{\detokenize{_minted}}
+\minted at pgfopts{
+  cachedir/.estore in=\minted at cachedir,
 }
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{minted at 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 at frozencache}
+\minted at pgfopts{
+  frozencache/.is if=minted at frozencache,
+}
+%    \end{macrocode}
+% \end{macro}
 %
-% \begin{macro}{\minted at savecachelist}
 %
-% We need to be able to save the list of cache files to the |.aux| file, so that we can reload it on the next run.
+% \begin{macro}{minted at 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}
-\newcommand{\minted at savecachelist}{%
-  \ifdefempty{\minted at cachelist}{}{%
-    \immediate\write\@mainaux{%
-      \string\gdef\string\minted at oldcachelist\string{%
-        \minted at cachelist\string}}%
-  }%
+\newbool{minted at lexerlinenos}
+\minted at pgfopts{
+  lexerlinenos/.is if=minted at lexerlinenos,
+  langlinenos/.is if=minted at lexerlinenos,
 }
 %    \end{macrocode}
 % \end{macro}
 %
-%
-% \begin{macro}{\minted at cleancache}
-% Clean up old cache files that are no longer in use.
+% \begin{macro}{minted at inputlexerlinenos}
+% Enable |lexerlinenos| and make it apply to |\inputminted|.  |inputlanglinenos| is for backward compatility with \mintedpkg\ v2.
 %    \begin{macrocode}
-\newcommand{\minted at cleancache}{%
-  \ifcsname minted at oldcachelist\endcsname
-    \def\do##1{%
-      \ifthenelse{\equal{##1}{}}{}{%
-        \ifcsname minted at cached@##1\endcsname\else
-          \DeleteFile[\minted at outputdir\minted at cachedir]{##1}%
-        \fi
-      }%
-    }%
-    \expandafter\docsvlist\expandafter{\minted at oldcachelist}%
-  \else
-  \fi
+\newbool{minted at inputlexerlinenos}
+\minted at pgfopts{
+  inputlexerlinenos/.is if=minted at inputlexerlinenos,
+  inputlanglinenos/.is if=minted at inputlexerlinenos,
 }
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% At the end of the document, save the list of cache files and clean the cache.  If in draft mode, don't clean up the cache and save the old cache file list for next time.  This allows draft mode to be switched on and off without requiring that all highlighted content be regenerated.  The saving and cleaning operations may be called without conditionals, since their definitions already contain all necessary checks for their correct operation.
+% \begin{macro}{minted at placeholder,\minted at 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}
-\ifthenelse{\boolean{minted at draft}}%
- {\AtEndDocument{%
-    \ifcsname minted at oldcachelist\endcsname
-      \StrSubstitute{\minted at oldcachelist}{,}{,^^J }[\minted at cachelist]
-      \minted at savecachelist
-    \fi}}%
- {\ifthenelse{\boolean{minted at frozencache}}%
-   {\AtEndDocument{%
-      \ifcsname minted at oldcachelist\endcsname
-        \StrSubstitute{\minted at oldcachelist}{,}{,^^J }[\minted at cachelist]
-        \minted at savecachelist
-      \fi}}%
-   {\AtEndDocument{%
-    \minted at savecachelist
-    \minted at cleancache}}}%
+\newbool{minted at placeholder}
+\minted at pgfopts{
+  placeholder/.is if=minted at placeholder,
+}
+\gdef\minted at insertplaceholder{%
+  \ifbool{minted at 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}
 %
-%
-%
-% \subsection{OS interaction}
-%
-% We need system-dependent macros for communicating with the ``outside world.''
-%
-% \begin{macro}{\DeleteFile}
-%
-% Delete a file.  Define conditionally in case an equivalent macro has already been defined.
-%
+% \begin{macro}{minted at verbatim}
+% Typeset all code verbatim using \texpkg{fancyvrb}; do not use Python at all.
 %    \begin{macrocode}
-\ifwindows
-  \providecommand{\DeleteFile}[2][]{%
-    \ifthenelse{\equal{#1}{}}%
-      {\IfFileExists{#2}{\ShellEscape{del #2}}{}}%
-      {\IfFileExists{#1/#2}{%
-        \StrSubstitute{#1}{/}{\@backslashchar}[\minted at windir]
-        \ShellEscape{del \minted at windir\@backslashchar #2}}{}}}
-\else
-  \providecommand{\DeleteFile}[2][]{%
-    \ifthenelse{\equal{#1}{}}%
-      {\IfFileExists{#2}{\ShellEscape{rm #2}}{}}%
-      {\IfFileExists{#1/#2}{\ShellEscape{rm #1/#2}}{}}}
-\fi
+\newbool{minted at verbatim}
+\minted at pgfopts{
+  verbatim/.is if=minted at verbatim,
+}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\ProvideDirectory}
+% \begin{macro}{\minted at highlightmode@init,\minted at fasthighlightmode@checkstart,\minted at 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|.
 %
-% We need to be able to create a directory, if it doesn't already exist.  This is primarily for storing cached highlighted content.
+% |\minted at highlightmode@init| is invoked within |\minted at detectconfig| if the Python executable is available and enabled.  For the |fastfirst| case, |\minted at highlightmode@init| requires the |\minted at cachepath| that is set within |\minted at detectconfig|.
 %
+% |\minted at fasthighlightmode@checkend| is invoked |\AfterEndDocument| with |\minted at clean|; the |\AtEndDocument| is created with the definition of |\minted at clean| so that everything is in the correct order.
 %    \begin{macrocode}
-\ifwindows
-  \newcommand{\ProvideDirectory}[1]{%
-    \StrSubstitute{#1}{/}{\@backslashchar}[\minted at windir]
-    \ShellEscape{if not exist \minted at windir\space mkdir \minted at windir}}
-\else
-  \newcommand{\ProvideDirectory}[1]{%
-    \ShellEscape{mkdir -p #1}}
-\fi
+\newbool{minted at fasthighlightmode}
+\newbool{minted at fasthighlightmode@open}
+\minted at pgfopts{
+  highlightmode/.is choice,
+  highlightmode/fast/.code=
+    \let\minted at highlightmode@init\minted at highlightmode@init at fast,
+  highlightmode/fastfirst/.code=
+    \let\minted at highlightmode@init\minted at highlightmode@init at fastfirst,
+  highlightmode/immediate/.code=
+    \let\minted at highlightmode@init\minted at highlightmode@init at immediate,
+}
+\def\minted at highlightmode@init at fast{%
+  \global\booltrue{minted at fasthighlightmode}}
+\def\minted at highlightmode@init at fastfirst{%
+  \IfFileExists{\minted at cachepath\MintedCacheIndexFilename}%
+   {\global\boolfalse{minted at fasthighlightmode}}
+   {\global\booltrue{minted at fasthighlightmode}}}
+\def\minted at highlightmode@init at immediate{%
+  \global\boolfalse{minted at fasthighlightmode}}
+\let\minted at highlightmode@init\minted at highlightmode@init at fastfirst
+\def\minted at fasthighlightmode@checkstart{%
+  \ifbool{minted at fasthighlightmode}%
+   {\pydatawritelistopen
+    \global\booltrue{minted at fasthighlightmode@open}}%
+   {}%
+  \global\let\minted at fasthighlightmode@checkstart\relax}
+\def\minted at fasthighlightmode@checkend{%
+  \ifbool{minted at fasthighlightmode@open}%
+   {\pydatasetfilename{\MintedDataFilename}%
+    \pydatawritelistclose
+    \pydataclosefilename{\MintedDataFilename}%
+    \global\boolfalse{minted at fasthighlightmode@open}%
+    \global\boolfalse{minted at fasthighlightmode}%
+    \begingroup
+    \minted at exec@batch
+    \ifx\minted at exec@warning\relax
+    \else
+      \expandafter\minted at exec@warning
+    \fi
+    \ifx\minted at exec@error\relax
+    \else
+      \expandafter\minted at exec@error
+    \fi
+    \endgroup
+    \global\boolfalse{minted at canexec}}%
+   {}%
+  \global\let\minted at fasthighlightmode@checkend\relax}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\TestAppExists}
 %
-% Determine whether a given application exists.
+% \subsubsection{Package options that are no longer supported or deprecated}
 %
-% Usage is a bit roundabout, but has been retained for backward compatibility.  At some point, it may be worth replacing this with something using \verb`\@@input"|<command>"`. That would require MiKTeX users to |--enable-pipes|, however, which would make things a little more complicated.  If Windows XP compatibility is ever no longer required, the |where| command could be used instead of the approach for Windows.
 %
-% To test whether an application exists, use the following code:
+% \paragraph{finalizecache}
+% Old, no longer needed option from \mintedpkg\ v2.
+%    \begin{macrocode}
+\minted at pgfopts{
+  finalizecache/.code=\minted at error{%
+    Package option "finalizecache" is no longer needed with minted v3+},
+}
+%    \end{macrocode}
 %
-% \begin{Verbatim}
-%\TestAppExists{appname}
-%\ifthenelse{\boolean{AppExists}}{app exists}{app doesn't exist}
-% \end{Verbatim}
 %
+% \paragraph{kpsewhich}
+% Old, no longer needed option from \mintedpkg\ v2.
 %    \begin{macrocode}
-\newboolean{AppExists}
-\newread\minted at appexistsfile
-\newcommand{\TestAppExists}[1]{%
-  \ifwindows
+\minted at pgfopts{
+  kpsewhich/.code=\minted at error{%
+    Package option "kpsewhich" is no longer needed with minted v3+},
+}
 %    \end{macrocode}
 %
-% On Windows, we need to use path expansion and write the result to a file.
-% If the application doesn't exist, the file will be empty (except for a newline);
-% otherwise, it will contain the full path of the application.
 %
+% \paragraph{outputdir}
+% Old, no longer needed option from \mintedpkg\ v2.
+%
+% The empty |\minted at outputdir| is for backward compatibility with packages that depend on \mintedpkg\ v2 internals.
 %    \begin{macrocode}
-    \DeleteFile{\minted at jobname.aex}%
-    \ShellEscape{for \string^\@percentchar i in (#1.exe #1.bat #1.cmd)
-      do set > \minted at jobname.aex <nul: /p
-      x=\string^\@percentchar \string~$PATH:i>> \minted at jobname.aex}%
-    %$ <- balance syntax highlighting
-    \immediate\openin\minted at appexistsfile\minted at jobname.aex
-    \expandafter\def\expandafter\@tmp at cr\expandafter{\the\endlinechar}%
-    \endlinechar=-1\relax
-    \readline\minted at appexistsfile to \minted at apppathifexists
-    \endlinechar=\@tmp at cr
-    \ifthenelse{\equal{\minted at apppathifexists}{}}%
-     {\AppExistsfalse}%
-     {\AppExiststrue}%
-    \immediate\closein\minted at appexistsfile
-    \DeleteFile{\minted at jobname.aex}%
-  \else
+\minted at pgfopts{
+  outputdir/.code=\minted at 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 at outputdir{}
 %    \end{macrocode}
 %
-% On Unix-like systems, we do a straightforward |which| test and create a file upon success, whose existence we can then check.
 %
+% \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}
-    \ShellEscape{command -v #1 && touch \minted at jobname.aex}%
-    \IfFileExists{\minted at jobname.aex}%
-      {\AppExiststrue
-        \DeleteFile{\minted at jobname.aex}}%
-      {\AppExistsfalse}%
-  \fi
+\minted at pgfopts{
+  draft/.code=\minted at warning{%
+    Package option "draft" no longer has any effect with minted v3+},
 }
 %    \end{macrocode}
-% \end{macro}
 %
+% \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 at pgfopts{
+  final/.code=\minted at warning{%
+    Package option "final" no longer has any effect with minted v3+},
+}
+%    \end{macrocode}
 %
-% \subsection{Option processing}
 %
-% Option processing is somewhat involved, because we want to be able to define options at various levels of hierarchy:  individual command/environment, language, global (document).  And once those options are defined, we need to go through the hierarchy in a defined order of precedence to determine which option to apply.  As if that wasn't complicated enough, some options need to be sent to Pygments, some need to be sent to \texpkg{fancyvrb}, and some need to be processed within \texpkg{minted} itself.
 %
-% To begin with, we need macros for storing lists of options that will later be passed via the command line to Pygments (|optlistcl|).  These are defined at the global (|cl at g|), language (|cl at lang|), and command or environment (|cl at cmd|) levels, so that settings can be specified at various levels of hierarchy.  The language macro is actually a placeholder.  The current language will be tracked using |\minted at lang|.  Each individual language will create a |\minted at optlistcl@lang|\meta{language} macro.  |\minted at optlistcl@lang| may be |\let| to this macro as convenient; otherwise, the general language macro merely serves as a placeholder.
+% \subsubsection{Package option processing}
 %
-% The global- and language-level lists also have an |inline| (|i|) variant.  This allows different settings to be applied in inline settings.  An inline variant is not needed at the command/environment level, since at that level settings would not be present unless they were supposed to be applied.
 %
-% \begin{macro}{\minted at optlistcl@g}
 %    \begin{macrocode}
-\newcommand{\minted at optlistcl@g}{}
+\ProcessPgfOptions{/minted/pkg}
+\ifbool{minted at cache}{}{\def\minted at cachedir{}}%
+\ifbool{minted at newfloat}{\RequirePackage{newfloat}}{\RequirePackage{float}}
+\ifcsname tikzifexternalizing\endcsname
+  \ifx\tikzifexternalizing\relax
+  \else
+    \tikzifexternalizing{\booltrue{minted at placeholder}}{}
+  \fi
+\fi
 %    \end{macrocode}
-% \end{macro}
 %
-% \begin{macro}{\minted at optlistcl@g at i}
+%
+%
+% \subsection{Util}
+%
+%
+% \begin{macro}{\minted at styleprefix}
+% Prefix for generating Pygments style names.
 %    \begin{macrocode}
-\newcommand{\minted at optlistcl@g at i}{}
+\def\minted at styleprefix{PYG}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\minted at lang}
+%
+% \begin{macro}{minted at tmpcnt}
+% Temp counter.
 %    \begin{macrocode}
-\let\minted at lang\@empty
+\newcounter{minted at tmpcnt}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\minted at optlistcl@lang}
+%
+% \begin{macro}{\minted at forcsvlist}
+% Wrapper for \texpkg{etoolbox} |\forcsvlist|.  Syntax:  |\minted at forcsvlist|\marg{handler}\marg{listmacro}.
 %    \begin{macrocode}
-\newcommand{\minted at optlistcl@lang}{}
+\def\minted at forcsvlist#1#2{%
+  \if\relax\detokenize\expandafter{\@gobble#2}\relax
+    \expandafter\minted at forcsvlist@exp
+  \else
+    \expandafter\minted at forcsvlist@i
+  \fi
+  {#2}{#1}}
+\def\minted at forcsvlist@exp#1#2{%
+  \expandafter\minted at forcsvlist@i\expandafter{#1}{#2}}
+\def\minted at forcsvlist@i#1#2{%
+  \forcsvlist{#2}{#1}}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\minted at optlistcl@lang at i}
+%
+% \begin{macro}{\minted at apptoprovidecs}
 %    \begin{macrocode}
-\newcommand{\minted at optlistcl@lang at i}{}
+\def\minted at apptoprovidecs#1#2{%
+  \ifcsname#1\endcsname
+  \else
+    \expandafter\def\csname#1\endcsname{}%
+  \fi
+  \expandafter\let\expandafter\minted at tmp\csname#1\endcsname
+  \expandafter\def\expandafter\minted at tmp\expandafter{\minted at tmp#2}%
+  \expandafter\let\csname#1\endcsname\minted at tmp}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\minted at optlistcl@cmd}
+%
+% \begin{macro}{\minted at const@pgfkeysnovalue}
 %    \begin{macrocode}
-\newcommand{\minted at optlistcl@cmd}{}
+\def\minted at const@pgfkeysnovalue{\pgfkeysnovalue}
 %    \end{macrocode}
 % \end{macro}
 %
-% We also need macros for storing lists of options that will later be passed to \texpkg{fancyvrb} (|optlistfv|).  As before, these exist at the global (|fv at g|), language (|fv at lang|), and command or environment (|fv at cmd|) levels.  Pygments accepts \texpkg{fancyvrb} options, but in almost all cases, these options may be applied via |\fvset| rather than via running Pygments.  This is significantly more efficient when caching is turned on, since it allows formatting changes to be applied without having to re-highlight the code.
 %
-% \begin{macro}{\minted at optlistfv@g}
+% \begin{macro}{\minted at ensureatletter}
 %    \begin{macrocode}
-\newcommand{\minted at optlistfv@g}{}
+\def\minted at ensureatletter#1{%
+  \edef\minted at tmpatcat{\the\catcode`\@}%
+  \catcode`\@=11\relax
+  #1%
+  \catcode`\@=\minted at tmpatcat\relax}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\minted at optlistfv@g at i}
+%
+%
+% \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 at 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}
-\newcommand{\minted at optlistfv@g at i}{}
+% [0-9]
+\setcounter{minted at tmpcnt}{48}
+\loop\unless\ifnum\value{minted at tmpcnt}>57\relax
+  \expandafter\let\csname minted at isnum\arabic{minted at tmpcnt}\endcsname\relax
+  \expandafter\let\csname minted at isalphanum\arabic{minted at tmpcnt}\endcsname\relax
+  \expandafter\let
+    \csname minted at isalphanumhyphenunderscore\arabic{minted at tmpcnt}\endcsname\relax
+  \stepcounter{minted at tmpcnt}
+\repeat
+% [A-Z]
+\setcounter{minted at tmpcnt}{65}
+\loop\unless\ifnum\value{minted at tmpcnt}>90\relax
+  \expandafter\let\csname minted at isalpha\arabic{minted at tmpcnt}\endcsname\relax
+  \expandafter\let\csname minted at isalphanum\arabic{minted at tmpcnt}\endcsname\relax
+  \expandafter\let
+    \csname minted at isalphanumhyphenunderscore\arabic{minted at tmpcnt}\endcsname\relax
+  \stepcounter{minted at tmpcnt}
+\repeat
+% [a-z]
+\setcounter{minted at tmpcnt}{97}
+\loop\unless\ifnum\value{minted at tmpcnt}>122\relax
+  \expandafter\let\csname minted at isalpha\arabic{minted at tmpcnt}\endcsname\relax
+  \expandafter\let\csname minted at isalphanum\arabic{minted at tmpcnt}\endcsname\relax
+  \expandafter\let
+    \csname minted at isalphanumhyphenunderscore\arabic{minted at tmpcnt}\endcsname\relax
+  \stepcounter{minted at tmpcnt}
+\repeat
+% [-]
+\expandafter\let\csname minted at isalphanumhyphenunderscore45\endcsname\relax
+% [_]
+\expandafter\let\csname minted at isalphanumhyphenunderscore95\endcsname\relax
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\minted at optlistfv@lang}
+%
+% \begin{macro}{\minted at ifalphanumhyphenunderscore}
+% Conditional based on whether first argument is ASCII alphanumeric, hyphen, or underscore.
 %    \begin{macrocode}
-\newcommand{\minted at optlistfv@lang}{}
+\def\minted at ifalphanumhyphenunderscore#1#2#3{%
+  \if\relax\detokenize{#1}\relax
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+  {#3}%
+  {\expandafter\minted at ifalphanumhyphenunderscore@i\detokenize{#1}\FV at Sentinel{#2}{#3}}}
+\def\minted at ifalphanumhyphenunderscore@i#1#2\FV at Sentinel{%
+  \if\relax#2\relax
+    \expandafter\minted at ifalphanumhyphenunderscore@iii
+  \else
+    \expandafter\minted at ifalphanumhyphenunderscore@ii
+  \fi
+  #1#2\FV at Sentinel}
+\def\minted at ifalphanumhyphenunderscore@ii#1#2\FV at Sentinel{%
+  \ifcsname minted at isalphanumhyphenunderscore\number`#1\endcsname
+    \expandafter\minted at ifalphanumhyphenunderscore@i
+  \else
+    \expandafter\minted at ifalphanumhyphenunderscore@false
+  \fi
+  #2\FV at Sentinel}
+\def\minted at ifalphanumhyphenunderscore@iii#1\FV at Sentinel{%
+  \ifcsname minted at isalphanumhyphenunderscore\number`#1\endcsname
+    \expandafter\minted at ifalphanumhyphenunderscore@true
+  \else
+    \expandafter\minted at ifalphanumhyphenunderscore@false
+  \fi
+  \FV at Sentinel}
+\def\minted at ifalphanumhyphenunderscore@true\FV at Sentinel#1#2{#1}
+\def\minted at ifalphanumhyphenunderscore@false#1\FV at Sentinel#2#3{#3}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\minted at optlistfv@lang at i}
+%
+%
+% \subsection{State}
+%
+%
+% \begin{macro}{\minted at 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}
-\newcommand{\minted at optlistfv@lang at i}{}
+\let\minted at lexer\@empty
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\minted at optlistfv@cmd}
+%
+% \begin{macro}{minted at isinline}
+% Whether in command or environment.
 %    \begin{macrocode}
-\newcommand{\minted at optlistfv@cmd}{}
+\newbool{minted at isinline}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\minted at configlang}
 %
-% We need a way to check whether a language has had all its option list macros created.  This generally occurs in a context where |\minted at lang| needs to be set.  So we create a macro that does both at once.  If the language list macros do not exist, we create them globally to simplify future operations.
+% \begin{macro}{minted at tmpcodebufferlength}
+% Length of buffer in which code to be highlighted is stored.
 %    \begin{macrocode}
-\newcommand{\minted at configlang}[1]{%
-  \def\minted at lang{#1}%
-  \ifcsname minted at optlistcl@lang\minted at lang\endcsname\else
-    \expandafter\gdef\csname minted at optlistcl@lang\minted at lang\endcsname{}%
-  \fi
-  \ifcsname minted at optlistcl@lang\minted at lang @i\endcsname\else
-    \expandafter\gdef\csname minted at optlistcl@lang\minted at lang @i\endcsname{}%
-  \fi
-  \ifcsname minted at optlistfv@lang\minted at lang\endcsname\else
-    \expandafter\gdef\csname minted at optlistfv@lang\minted at lang\endcsname{}%
-  \fi
-  \ifcsname minted at optlistfv@lang\minted at lang @i\endcsname\else
-    \expandafter\gdef\csname minted at optlistfv@lang\minted at lang @i\endcsname{}%
-  \fi
-}
+\newcounter{minted at tmpcodebufferlength}
 %    \end{macrocode}
 % \end{macro}
 %
-% We need a way to define options in bulk at the global, language, and command levels.  How this is done will depend on the type of option.  The keys created are grouped by level:  |minted at opt@g|, |minted at opt@lang|, and |minted at opt@cmd|, plus inline variants.  The language-level key groupings use |\minted at lang| internally, so we don't need to duplicate the internals for different languages.  The key groupings are independent of whether a given option relates to Pygments, \texpkg{fancyvrb}, etc.  Organization by level is the only thing that is important here, since keys are applied in a hierarchical fashion.  Key values are stored in macros of the form |\minted at opt@|\meta{level}|:|\meta{key}, so that they may be retrieved later.  In practice, these key macros will generally not be used directly (hence the colon in the name).  Rather, the hierarchy of macros will be traversed until an existing macro is found.
 %
-% \begin{macro}{\minted at def@optcl}
 %
-% Define a generic option that will be passed to the command line.  Options are given in a |{key}{value}| format that is transformed into |key=value| and then passed to |pygmentize|.  This allows |value| to be easily stored in a separate macro for later access.  This is useful, for example, in separately accessing the value of |encoding| for performing |autogobble|.
+% \subsection{Calling \mintedpkg\ executable}
 %
-% If a |key| option is specified without |=value|, the default is assumed.  Options are automatically created at all levels.
 %
-% Options are added to the option lists in such a way that they will be detokenized.  This is necessary since they will ultimately be used in |\write18|.
+% \begin{macro}{minted at canexec}
 %    \begin{macrocode}
-\ifwindows
-  \newcommand{\minted at optlistcl@quote}[2]{%
-    \detokenize{#1="#2"}}
-\else
-  \newcommand{\minted at optlistcl@quote}[2]{%
-    \detokenize{#1='#2'}}
+\newbool{minted at canexec}
+\booltrue{minted at canexec}
+\ifnum\csname c_sys_shell_escape_int\endcsname=0\relax
+  \boolfalse{minted at canexec}
 \fi
-\newcommand{\minted at addto@optlistcl}[3]{%
-  \expandafter\def\expandafter#1\expandafter{#1%
-    \minted at optlistcl@quote{#2}{#3}\space}}
-\newcommand{\minted at addto@optlistcl at lang}[3]{%
-  \expandafter\let\expandafter\minted at tmp\csname #1\endcsname
-  \expandafter\def\expandafter\minted at tmp\expandafter{\minted at tmp%
-    \minted at optlistcl@quote{#2}{#3}\space}%
-  \expandafter\let\csname #1\endcsname\minted at tmp}
-\newcommand{\minted at def@optcl}[4][]{%
-  \ifthenelse{\equal{#1}{}}%
-    {\define at key{minted at opt@g}{#2}{%
-        \minted at addto@optlistcl{\minted at optlistcl@g}{#3}{#4}%
-        \@namedef{minted at opt@g:#2}{#4}}%
-      \define at key{minted at opt@g at i}{#2}{%
-        \minted at addto@optlistcl{\minted at optlistcl@g at i}{#3}{#4}%
-        \@namedef{minted at opt@g at i:#2}{#4}}%
-      \define at key{minted at opt@lang}{#2}{%
-        \minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang:#2}{#4}}%
-      \define at key{minted at opt@lang at i}{#2}{%
-        \minted at addto@optlistcl at lang{%
-          minted at optlistcl@lang\minted at lang @i}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang @i:#2}{#4}}%
-      \define at key{minted at opt@cmd}{#2}{%
-        \minted at addto@optlistcl{\minted at optlistcl@cmd}{#3}{#4}%
-        \@namedef{minted at opt@cmd:#2}{#4}}}%
-    {\define at key{minted at opt@g}{#2}[#1]{%
-        \minted at addto@optlistcl{\minted at optlistcl@g}{#3}{#4}%
-        \@namedef{minted at opt@g:#2}{#4}}%
-      \define at key{minted at opt@g at i}{#2}[#1]{%
-        \minted at addto@optlistcl{\minted at optlistcl@g at i}{#3}{#4}%
-        \@namedef{minted at opt@g at i:#2}{#4}}%
-      \define at key{minted at opt@lang}{#2}[#1]{%
-        \minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang:#2}{#4}}%
-      \define at key{minted at opt@lang at i}{#2}[#1]{%
-        \minted at addto@optlistcl at lang{%
-          minted at optlistcl@lang\minted at lang @i}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang @i:#2}{#4}}%
-      \define at key{minted at opt@cmd}{#2}[#1]{%
-        \minted at addto@optlistcl{\minted at optlistcl@cmd}{#3}{#4}%
-        \@namedef{minted at opt@cmd:#2}{#4}}}%
-}
+\ifbool{minted at frozencache}{\boolfalse{minted at canexec}}{}
+\ifbool{minted at placeholder}{\boolfalse{minted at canexec}}{}
+\ifbool{minted at verbatim}{\boolfalse{minted at canexec}}{}
 %    \end{macrocode}
 % \end{macro}
 %
-% This covers the typical options that must be passed to Pygments.  But some, particularly |escapeinside|, need more work.  Since their arguments may contain escaped characters, expansion rather than detokenization is needed.  Getting expansion to work as desired in a |\write18| context requires the redefinition of some characters.
 %
-% \begin{macro}{\minted at escape}
-% Process (possibly backslash-escaped) characters into a form that will work correctly under expansion for use in |\write18|.  This assumes that only punctuation characters are escaped.  (Otherwise, trailing spaces from |\detokenize| would need to be stripped.)  This is currently only used for |escapeinside|.
+% \begin{macro}{\minted at ShellEscapeMaybeMessages,\minted at ShellEscapeNoMessages}
 %    \begin{macrocode}
-\begingroup
-\catcode`\!=0
-!catcode`!\=12
-!gdef!minted at escape#1{%
-  !expandafter!minted at escape@i!detokenize{#1}\!FV at Sentinel}
-!gdef!minted at escape@i#1\#2!FV at Sentinel{%
-  !if!relax!detokenize{#2}!relax
-    !expandafter!@firstoftwo
-  !else
-    !expandafter!@secondoftwo
-  !fi
-  {#1!minted at escape@end\#2!FV at Sentinel}
-  {#1!minted at escape@esc\#2!FV at Sentinel}}
-!gdef!minted at escape@end#1!FV at Sentinel{}
-!gdef!minted at escape@esc\#1#2!FV at Sentinel{%
-  #1!minted at escape@i#2!FV at Sentinel}
-!endgroup
+\def\minted at ShellEscapeMaybeMessages#1{%
+  \let\minted at exec@warning\relax
+  \let\minted at exec@error\relax
+  \ifbool{minted at canexec}{\ShellEscape{#1}\minted at inputexecmessages}{}}
+\def\minted at ShellEscapeNoMessages#1{%
+  \ifbool{minted at canexec}{\ShellEscape{#1}}{}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at def@optcl at e}
-% Now to define options that involve backslash escapes.
+% \begin{macro}{\minted at execarg@debug,\minted at execarg@timestamp}
 %    \begin{macrocode}
-\newcommand{\minted at addto@optlistcl at e}[3]{%
-  \edef\minted at tmp{\minted at escape{#3}}%
-  \expandafter\minted at addto@optlistcl at e@i\expandafter{\minted at tmp}{#1}{#2}}
-\def\minted at addto@optlistcl at e@i#1#2#3{%
-  \expandafter\def\expandafter#2\expandafter{#2\minted at optlistcl@quote{#3}{#1}\space}}
-\newcommand{\minted at addto@optlistcl at lang@e}[3]{%
-  \edef\minted at tmp{\minted at escape{#3}}%
-  \expandafter\minted at addto@optlistcl at lang@e at i\expandafter{\minted at tmp}{#1}{#2}}
-\def\minted at addto@optlistcl at lang@e at i#1#2#3{%
-  \expandafter\let\expandafter\minted at tmp\csname #2\endcsname
-  \expandafter\def\expandafter\minted at tmp\expandafter{\minted at tmp\minted at optlistcl@quote{#3}{#1}\space}%
-  \expandafter\let\csname #2\endcsname\minted at tmp}
-\newcommand{\minted at def@optcl at e}[4][]{%
-  \ifthenelse{\equal{#1}{}}%
-    {\define at key{minted at opt@g}{#2}{%
-        \minted at addto@optlistcl at e{\minted at optlistcl@g}{#3}{#4}%
-        \@namedef{minted at opt@g:#2}{#4}}%
-      \define at key{minted at opt@g at i}{#2}{%
-        \minted at addto@optlistcl at e{\minted at optlistcl@g at i}{#3}{#4}%
-        \@namedef{minted at opt@g at i:#2}{#4}}%
-      \define at key{minted at opt@lang}{#2}{%
-        \minted at addto@optlistcl at lang@e{minted at optlistcl@lang\minted at lang}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang:#2}{#4}}%
-      \define at key{minted at opt@lang at i}{#2}{%
-        \minted at addto@optlistcl at lang@e{%
-          minted at optlistcl@lang\minted at lang @i}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang @i:#2}{#4}}%
-      \define at key{minted at opt@cmd}{#2}{%
-        \minted at addto@optlistcl at e{\minted at optlistcl@cmd}{#3}{#4}%
-        \@namedef{minted at opt@cmd:#2}{#4}}}%
-    {\define at key{minted at opt@g}{#2}[#1]{%
-        \minted at addto@optlistcl at e{\minted at optlistcl@g}{#3}{#4}%
-        \@namedef{minted at opt@g:#2}{#4}}%
-      \define at key{minted at opt@g at i}{#2}[#1]{%
-        \minted at addto@optlistcl at e{\minted at optlistcl@g at i}{#3}{#4}%
-        \@namedef{minted at opt@g at i:#2}{#4}}%
-      \define at key{minted at opt@lang}{#2}[#1]{%
-        \minted at addto@optlistcl at lang@e{minted at optlistcl@lang\minted at lang}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang:#2}{#4}}%
-      \define at key{minted at opt@lang at i}{#2}[#1]{%
-        \minted at addto@optlistcl at lang@e{%
-          minted at optlistcl@lang\minted at lang @i}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang @i:#2}{#4}}%
-      \define at key{minted at opt@cmd}{#2}[#1]{%
-        \minted at addto@optlistcl at e{\minted at optlistcl@cmd}{#3}{#4}%
-        \@namedef{minted at opt@cmd:#2}{#4}}}%
-}
+\def\minted at execarg@debug{%
+  \ifbool{minted at debug}{\detokenize{ --debug }}{}}
+\def\minted at execarg@timestamp{%
+  \detokenize{ --timestamp }\minted at timestamp\detokenize{ }}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at def@optcl at switch}
-%
-% Define a switch or boolean option that is passed to Pygments, which is |true| when no value is specified.
+% \begin{macro}{\minted at 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}
-\newcommand{\minted at def@optcl at switch}[2]{%
-  \define at booleankey{minted at opt@g}{#1}%
-    {\minted at addto@optlistcl{\minted at optlistcl@g}{#2}{True}%
-      \@namedef{minted at opt@g:#1}{true}}
-    {\minted at addto@optlistcl{\minted at optlistcl@g}{#2}{False}%
-      \@namedef{minted at opt@g:#1}{false}}
-  \define at booleankey{minted at opt@g at i}{#1}%
-    {\minted at addto@optlistcl{\minted at optlistcl@g at i}{#2}{True}%
-      \@namedef{minted at opt@g at i:#1}{true}}
-    {\minted at addto@optlistcl{\minted at optlistcl@g at i}{#2}{False}%
-      \@namedef{minted at opt@g at i:#1}{false}}
-  \define at booleankey{minted at opt@lang}{#1}%
-    {\minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang}{#2}{True}%
-      \@namedef{minted at opt@lang\minted at lang:#1}{true}}
-    {\minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang}{#2}{False}%
-      \@namedef{minted at opt@lang\minted at lang:#1}{false}}
-  \define at booleankey{minted at opt@lang at i}{#1}%
-    {\minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang @i}{#2}{True}%
-      \@namedef{minted at opt@lang\minted at lang @i:#1}{true}}
-    {\minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang @i}{#2}{False}%
-      \@namedef{minted at opt@lang\minted at lang @i:#1}{false}}
-  \define at booleankey{minted at opt@cmd}{#1}%
-      {\minted at addto@optlistcl{\minted at optlistcl@cmd}{#2}{True}%
-        \@namedef{minted at opt@cmd:#1}{true}}
-      {\minted at addto@optlistcl{\minted at optlistcl@cmd}{#2}{False}%
-        \@namedef{minted at opt@cmd:#1}{false}}
-}
+\def\minted at exec@cleanfile#1{%
+  \minted at ShellEscapeNoMessages{%
+    \MintedExecutable\detokenize{ cleanfile }\minted at execarg@debug#1}}
 %    \end{macrocode}
 % \end{macro}
 %
-% Now that all the machinery for Pygments options is in place, we can move on to \texpkg{fancyvrb} options.
 %
-% \begin{macro}{\minted at def@optfv}
+% \begin{macro}{\minted at inputexecmessages}
+% If temp file containing warning and/or error messages exists, |\input| and then delete.
+%   \begin{macrocode}
+\def\minted at inputexecmessages{%
+  \minted at ensureatletter{\InputIfFileExists{\MintedMessageFilename}{}{}}}
+%    \end{macrocode}
+% \end{macro}
 %
-% Define \texpkg{fancyvrb} options.  The |#1={##1}| is needed because any braces enclosing the argument (|##1|) will be stripped during the initial capture, and they need to be reinserted before \texpkg{fancyvrb} gets the argument and sends it through another \texpkg{keyval} processing step.  If there were no braces initially, adding them here doesn't hurt, since they are just stripped off again during processing.
+%
+% \begin{macro}{\minted at exec@batch}
+% Run in batch mode, for |highlightmode=fast| or |highlightmode=fastfirst|.
 %    \begin{macrocode}
-\newcommand{\minted at def@optfv}[1]{%
-  \define at key{minted at opt@g}{#1}{%
-    \expandafter\def\expandafter\minted at optlistfv@g\expandafter{%
-      \minted at optlistfv@g#1={##1},}%
-    \@namedef{minted at opt@g:#1}{##1}}
-  \define at key{minted at opt@g at i}{#1}{%
-    \expandafter\def\expandafter\minted at optlistfv@g at i\expandafter{%
-      \minted at optlistfv@g at i#1={##1},}%
-    \@namedef{minted at opt@g at i:#1}{##1}}
-  \define at key{minted at opt@lang}{#1}{%
-    \expandafter\let\expandafter\minted at tmp%
-      \csname minted at optlistfv@lang\minted at lang\endcsname
-    \expandafter\def\expandafter\minted at tmp\expandafter{%
-      \minted at tmp#1={##1},}%
-    \expandafter\let\csname minted at optlistfv@lang\minted at lang\endcsname%
-      \minted at tmp
-    \@namedef{minted at opt@lang\minted at lang:#1}{##1}}
-  \define at key{minted at opt@lang at i}{#1}{%
-    \expandafter\let\expandafter\minted at tmp%
-      \csname minted at optlistfv@lang\minted at lang @i\endcsname
-    \expandafter\def\expandafter\minted at tmp\expandafter{%
-      \minted at tmp#1={##1},}%
-    \expandafter\let\csname minted at optlistfv@lang\minted at lang @i\endcsname%
-      \minted at tmp
-    \@namedef{minted at opt@lang\minted at lang @i:#1}{##1}}
-  \define at key{minted at opt@cmd}{#1}{%
-    \expandafter\def\expandafter\minted at optlistfv@cmd\expandafter{%
-      \minted at optlistfv@cmd#1={##1},}%
-    \@namedef{minted at opt@cmd:#1}{##1}}
-}
+\def\minted at exec@batch{%
+  \minted at ShellEscapeMaybeMessages{%
+    \MintedExecutable
+    \detokenize{ batch }\minted at execarg@timestamp\minted at execarg@debug
+    \MintedJobnameMdfive}}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\minted at def@optfv at switch}
 %
-% Define \texpkg{fancyvrb} boolean options.
+% \begin{macro}{\minted at exec@config}
+% Detect configuration.
 %    \begin{macrocode}
-\newcommand{\minted at def@optfv at switch}[1]{%
-  \define at booleankey{minted at opt@g}{#1}%
-    {\expandafter\def\expandafter\minted at optlistfv@g\expandafter{%
-      \minted at optlistfv@g#1=true,}%
-     \@namedef{minted at opt@g:#1}{true}}%
-    {\expandafter\def\expandafter\minted at optlistfv@g\expandafter{%
-      \minted at optlistfv@g#1=false,}%
-     \@namedef{minted at opt@g:#1}{false}}%
-  \define at booleankey{minted at opt@g at i}{#1}%
-    {\expandafter\def\expandafter\minted at optlistfv@g at i\expandafter{%
-      \minted at optlistfv@g at i#1=true,}%
-     \@namedef{minted at opt@g at i:#1}{true}}%
-    {\expandafter\def\expandafter\minted at optlistfv@g at i\expandafter{%
-      \minted at optlistfv@g at i#1=false,}%
-     \@namedef{minted at opt@g at i:#1}{false}}%
-  \define at booleankey{minted at opt@lang}{#1}%
-    {\expandafter\let\expandafter\minted at tmp%
-        \csname minted at optlistfv@lang\minted at lang\endcsname
-      \expandafter\def\expandafter\minted at tmp\expandafter{%
-        \minted at tmp#1=true,}%
-      \expandafter\let\csname minted at optlistfv@lang\minted at lang\endcsname%
-        \minted at tmp
-     \@namedef{minted at opt@lang\minted at lang:#1}{true}}%
-    {\expandafter\let\expandafter\minted at tmp%
-        \csname minted at optlistfv@lang\minted at lang\endcsname
-      \expandafter\def\expandafter\minted at tmp\expandafter{%
-        \minted at tmp#1=false,}%
-      \expandafter\let\csname minted at optlistfv@lang\minted at lang\endcsname%
-        \minted at tmp
-     \@namedef{minted at opt@lang\minted at lang:#1}{false}}%
-  \define at booleankey{minted at opt@lang at i}{#1}%
-    {\expandafter\let\expandafter\minted at tmp%
-        \csname minted at optlistfv@lang\minted at lang @i\endcsname
-      \expandafter\def\expandafter\minted at tmp\expandafter{%
-        \minted at tmp#1=true,}%
-      \expandafter\let\csname minted at optlistfv@lang\minted at lang @i\endcsname%
-        \minted at tmp
-     \@namedef{minted at opt@lang\minted at lang @i:#1}{true}}%
-    {\expandafter\let\expandafter\minted at tmp%
-        \csname minted at optlistfv@lang\minted at lang @i\endcsname
-      \expandafter\def\expandafter\minted at tmp\expandafter{%
-        \minted at tmp#1=false,}%
-      \expandafter\let\csname minted at optlistfv@lang\minted at lang @i\endcsname%
-        \minted at tmp
-     \@namedef{minted at opt@lang\minted at lang @i:#1}{false}}%
-  \define at booleankey{minted at opt@cmd}{#1}%
-    {\expandafter\def\expandafter\minted at optlistfv@cmd\expandafter{%
-      \minted at optlistfv@cmd#1=true,}%
-     \@namedef{minted at opt@cmd:#1}{true}}%
-    {\expandafter\def\expandafter\minted at optlistfv@cmd\expandafter{%
-      \minted at optlistfv@cmd#1=false,}%
-     \@namedef{minted at opt@cmd:#1}{false}}%
-}
+\def\minted at exec@config{%
+  \minted at ShellEscapeMaybeMessages{%
+    \MintedExecutable
+    \detokenize{ config }\minted at execarg@timestamp\minted at execarg@debug
+    \MintedJobnameMdfive}}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{minted at isinline}
-% In resolving value precedence when actually using values, we need a way to determine whether we are in an inline context.  This is accomplished via a boolean that is set at the beginning of inline commands.
+%
+% \begin{macro}{\minted at exec@styledef}
+% Create style definition.
 %    \begin{macrocode}
-\newboolean{minted at isinline}
+\def\minted at exec@styledef{%
+  \minted at ShellEscapeMaybeMessages{%
+    \MintedExecutable
+    \detokenize{ styledef }\minted at execarg@timestamp\minted at execarg@debug
+    \MintedJobnameMdfive}}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\minted at fvset}
-% We will need a way to actually use the lists of stored \texpkg{fancyvrb} options later on.
+%
+% \begin{macro}{\minted at exec@highlight}
+% Highlight code.
 %    \begin{macrocode}
-\newcommand{\minted at fvset}{%
-  \expandafter\fvset\expandafter{\minted at optlistfv@g}%
-  \expandafter\let\expandafter\minted at tmp%
-    \csname minted at optlistfv@lang\minted at lang\endcsname
-  \expandafter\fvset\expandafter{\minted at tmp}%
-  \ifthenelse{\boolean{minted at isinline}}%
-   {\expandafter\fvset\expandafter{\minted at optlistfv@g at i}%
-    \expandafter\let\expandafter\minted at tmp%
-      \csname minted at optlistfv@lang\minted at lang @i\endcsname
-    \expandafter\fvset\expandafter{\minted at tmp}}%
-   {}%
-  \expandafter\fvset\expandafter{\minted at optlistfv@cmd}%
-}
+\def\minted at exec@highlight{%
+  \minted at ShellEscapeMaybeMessages{%
+    \MintedExecutable
+    \detokenize{ highlight }\minted at execarg@timestamp\minted at execarg@debug
+    \MintedJobnameMdfive}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% We need a way to define \texpkg{minted}-specific options at multiple levels of hierarchy, as well as a way to retrieve these options.  As with previous types of options, values are stored in macros of the form |\minted at opt@|\meta{level}|:|\meta{key}, since they are not meant to be accessed directly.
+% \begin{macro}{\minted at exec@clean}
+% Clean output directory and cache.
+%    \begin{macrocode}
+\def\minted at exec@clean{%
+  \minted at ShellEscapeNoMessages{%
+    \MintedExecutable
+    \detokenize{ clean }\minted at execarg@timestamp\minted at execarg@debug
+    \MintedJobnameMdfive}}
+%    \end{macrocode}
+% \end{macro}
 %
-% The order of precedence is |cmd|, |lang at i|, |g at i|, |lang|, |g|.  A value specified at the command or environment level should override other settings.  In its absence, a value specified for an inline command should override other settings, if we are indeed in an inline context.  Otherwise, language settings take precedence over global settings.
 %
-% Before actually creating the option-definition macro, we need a few helper macros.
 %
+% \subsection{Config detection}
 %
-% \begin{macro}{\minted at def@opt}
-% Finally, on to the actual option definitions for \texpkg{minted}-specific options.
 %
-% Usage:  |\minted at def@opt[|\meta{initial global value}|]{|\meta{key name}|}|
+% \begin{macro}{minted at diddetectconfig}
 %    \begin{macrocode}
-\newcommand{\minted at def@opt}[2][]{%
-  \define at key{minted at opt@g}{#2}{%
-    \@namedef{minted at opt@g:#2}{##1}}
-  \define at key{minted at opt@g at i}{#2}{%
-    \@namedef{minted at opt@g at i:#2}{##1}}
-  \define at key{minted at opt@lang}{#2}{%
-    \@namedef{minted at opt@lang\minted at lang:#2}{##1}}
-  \define at key{minted at opt@lang at i}{#2}{%
-    \@namedef{minted at opt@lang\minted at lang @i:#2}{##1}}
-  \define at key{minted at opt@cmd}{#2}{%
-    \@namedef{minted at opt@cmd:#2}{##1}}
-  \ifstrempty{#1}{}{\@namedef{minted at opt@g:#2}{#1}}%
-}
+\newbool{minted at diddetectconfig}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at def@opt at detok}
-% Same as |\minted at def@opt|, except wraps argument in |\detokenize|.
+% \begin{macro}{\minted at detectconfig}
+% When the |minted at 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 at 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 at 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}
-\newcommand{\minted at def@opt at detok}[2][]{%
-  \define at key{minted at opt@g}{#2}{%
-    \@namedef{minted at opt@g:#2}{\detokenize{##1}}}
-  \define at key{minted at opt@g at i}{#2}{%
-    \@namedef{minted at opt@g at i:#2}{\detokenize{##1}}}
-  \define at key{minted at opt@lang}{#2}{%
-    \@namedef{minted at opt@lang\minted at lang:#2}{\detokenize{##1}}}
-  \define at key{minted at opt@lang at i}{#2}{%
-    \@namedef{minted at opt@lang\minted at lang @i:#2}{\detokenize{##1}}}
-  \define at key{minted at opt@cmd}{#2}{%
-    \@namedef{minted at opt@cmd:#2}{\detokenize{##1}}}
-  \ifstrempty{#1}{}{\@namedef{minted at opt@g:#2}{\detokenize{#1}}}%
-}
+\def\minted at detectconfig{%
+  \ifbool{minted at diddetectconfig}%
+   {}%
+   {\ifx\minted at cachedir\@empty
+      \gdef\minted at cachepath{}%
+    \else
+      \gdef\minted at cachepath{\minted at cachedir/}%
+    \fi
+    \ifbool{minted at canexec}{\begingroup\minted at detectconfig@i\endgroup}{}%
+    \global\booltrue{minted at diddetectconfig}}}
+\def\minted at detectconfig@i{%
+  \global\let\minted at executable@version\relax
+  \global\let\minted at executable@timestamp\relax
+  \global\let\minted at config@timestamp\relax
+  \pydatasetfilename{\MintedDataFilename}%
+  \pydatawritedictopen
+  \pydatawritekeyvalue{command}{config}%
+  \pydatawritekeyedefvalue{jobname}{\jobname}%
+  \pydatawritekeyedefvalue{timestamp}{\minted at timestamp}%
+  \pydatawritekeyedefvalue{cachedir}{\minted at cachedir}%
+  \pydatawritedictclose
+  \pydataclosefilename{\MintedDataFilename}%
+  \minted at exec@config
+  \minted at ensureatletter{%
+    \InputIfFileExists{\MintedConfigFilename}{}{}}%
+  \ifx\minted at executable@version\relax
+    \expandafter\minted at detectconfig@noexecutable
+  \else
+    \expandafter\minted at detectconfig@ii
+  \fi}
+\def\minted at detectconfig@noexecutable{%
+  \global\boolfalse{minted at canexec}%
+  \ifnum\csname c_sys_shell_escape_int\endcsname=1\relax
+    \minted at error{minted v3+ executable is not installed or is not added to PATH}%
+  \else
+    \minted at error{minted v3+ executable is not installed, is not added to PATH,
+      or is not permitted with restricted shell escape}%
+  \fi}
+\def\minted at detectconfig@ii{%
+  \ifx\minted at timestamp\minted at config@timestamp
+    \expandafter\minted at detectconfig@iii
+  \else
+    \expandafter\minted at detectconfig@wrongtimestamp
+  \fi}
+\def\minted at detectconfig@wrongtimestamp{%
+  \ifx\minted at timestamp\minted at executable@timestamp
+    \minted at exec@cleanfile{\MintedConfigFilename}%
+    \global\boolfalse{minted at canexec}%
+    \minted at 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 at detectconfig@noexecutable
+  \fi}
+\def\minted at detectconfig@iii{%
+  \minted at exec@cleanfile{\MintedConfigFilename}%
+  \ifx\minted at exec@warning\relax
+  \else
+    \expandafter\minted at exec@warning
+  \fi
+  \ifx\minted at exec@error\relax
+    \expandafter\minted at detectconfig@iv
+  \else
+    \expandafter\minted at detectconfig@error
+  \fi}
+\def\minted at detectconfig@error{%
+  \global\boolfalse{minted at canexec}%
+  \minted at exec@error}
+\def\minted at detectconfig@iv{%
+  \expandafter\minted at detectconfig@v\minted at executable@version\relax}
+\begingroup
+\catcode`\.=12
+\gdef\minted at detectconfig@v#1.#2.#3\relax{%
+  \def\minted at executable@major{#1}%
+  \def\minted at executable@minor{#2}%
+  \def\minted at executable@patch{#3}%
+  \minted at detectconfig@vi}
+\endgroup
+\def\minted at detectconfig@vi{%
+  \ifnum\minted at executable@major>\minted at executable@minmajor\relax
+    \global\booltrue{minted at executable@issupported}%
+  \else\ifnum\minted at executable@major=\minted at executable@minmajor\relax
+    \ifnum\minted at executable@minor>\minted at executable@minminor\relax
+      \global\booltrue{minted at executable@issupported}%
+    \else\ifnum\minted at executable@minor=\minted at executable@minminor\relax
+      \ifnum\minted at executable@patch<\minted at executable@minpatch\relax
+      \else
+        \global\booltrue{minted at executable@issupported}%
+      \fi
+    \fi\fi
+  \fi\fi
+  \ifbool{minted at executable@issupported}%
+   {\ifx\minted at config@cachepath\relax
+      \expandafter\@firstoftwo
+    \else
+      \expandafter\@secondoftwo
+    \fi
+    {\global\boolfalse{minted at canexec}%
+      \minted at error{minted Python executable returned incomplete configuration data;
+        this may indicate a bug in minted or file corruption}}%
+    {\global\let\minted at cachepath\minted at config@cachepath
+     \minted at highlightmode@init}}%
+   {\global\boolfalse{minted at canexec}%
+    \minted at error{minted Python executable is version \minted at executable@version,
+      but version \minted at executable@minversion+ is required}}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at generate@PYGdef}
-% Generate Pygments style definition with |pygmentize| if a cached version does not exist.  Load the style definition into a global macro of the form
-%\begin{Verbatim}
-%\csname minted at PYGdef@<style>\endcsname
-%\end{Verbatim}
-% to allow styles to be defined later.  Styles are not defined globally to avoid naming issues with style names that involve punctuation characters and numbers.  Rather, styles are redefined upon every use (within groups), and all styles use macros with a |\PYG| prefix.
 %
-% Takes a single argument that is the detokenized style name.  Getting the detokenized style name here requires expansion (|\edef|) in an earlier macro (currently |\minted at defstyle|) to convert |\minted at get@opt{style}{default}| into detokenized text.  The |style| value is always wrapped in |\detokenize| when it is set, so expansion automatically detokenizes.  Detokenization can be important depending on active characters.  Expansion is important because the style name may be used with caching, so we need the current value retrieved by |\minted at get@opt|, not the value at the end of the document when cache data is written to the |.aux| file.
+% \subsection{Options}
 %
-% Certain catcodes are required when loading Pygments style definitions from file.
+%
+% \subsubsection{Option processing}
+%
+% \begin{macro}{\minted at optcats,\minted at optkeyslist@<optcat>}
+% Option categories, along with lists of keys for each.
 % \begin{itemize}
-% \item At sign |@| would be handled by the |\makeatletter| within the Pygments style definition if the style was 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 |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}
-% |\endlinechar| also requires special handling to avoid introducing unwanted spaces.
-%
-% The |\ifx\PYG\relax| tests detect outdated style definitions from \texpkg{minted} <2.6 and replace them when possible, and also detect missing styles.  Before \texpkg{minted} 2.6, style macros used a |\PYG<style>| prefix and were defined globally.  Starting with 2.6, styles are redefined upon every use (within groups), and all styles use macros with a |\PYG| prefix.  This allows more robust treatment of style names that involve punctuation characters and numbers.
 %    \begin{macrocode}
-\newcommand{\minted at generate@PYGdef}[1]{%
-  \ifthenelse{\boolean{minted at cache}}%
-   {\def\minted at pygstylepath@load{\minted at outputdir\minted at cachedir/#1.pygstyle}%
-    \minted at addcachefile{#1.pygstyle}}%
-   {\def\minted at pygstylepath@load{\minted at outputdir\minted at jobname.out.pyg}}%
-  \ifwindows
-    \StrSubstitute{\minted at pygstylepath@load}%
-      {/}{\@backslashchar}[\minted at pygstylepath@save]%
-  \else
-    \let\minted at pygstylepath@save\minted at pygstylepath@load
-  \fi
-  \IfFileExists{\minted at pygstylepath@load}%
-   {}%
-   {\ifthenelse{\boolean{minted at frozencache}}%
-     {\PackageError{minted}%
-       {Missing style definition for #1 with frozencache}%
-       {Missing style definition for #1 with frozencache}}%
-     {}%
-    \ShellEscape{%
-      \MintedPygmentize\space -S #1 -f latex -P commandprefix=PYG
-      > \minted at pygstylepath@save
-    }%
-   }%
-  \CatchFileDef{\minted at tmp@filecontents}%
-   {\minted at pygstylepath@load}{\catcode`@=11\catcode`\%=14\catcode``=12\endlinechar=-1}%
-  \begingroup
-  \let\PYG\relax
-  \minted at tmp@filecontents
-  \ifx\PYG\relax
-    \ifthenelse{\boolean{minted at frozencache}}%
-     {\PackageError{minted}%
-       {Outdated style definition for #1 with frozencache}%
-       {Outdated style definition for #1 with frozencache}}%
-     {}%
-    \ShellEscape{%
-      \MintedPygmentize\space -S #1 -f latex -P commandprefix=PYG
-      > \minted at pygstylepath@save
-    }%
-    \CatchFileDef{\minted at tmp@filecontents}%
-     {\minted at pygstylepath@load}{\catcode`@=11\catcode`\%=14\catcode``=12\endlinechar=-1}%
-    \minted at tmp@filecontents
-    \ifx\PYG\relax
-      \PackageError{minted}%
-       {Cannot find Pygments style #1}%
-       {Cannot find Pygments style #1}%
-    \fi
-  \fi
-  \expandafter\global\expandafter\let\csname minted at PYGdef@#1\endcsname%
-    \minted at tmp@filecontents
-  \endgroup
-}
+\begingroup
+\catcode`\,=12
+\gdef\minted at optcats{fv,py,tex}
+\endgroup
+\def\minted at do#1{\expandafter\def\csname minted at optkeyslist@#1\endcsname{}}
+\minted at forcsvlist{\minted at do}{\minted at optcats}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at defstyle}
-% Define Pygments style macros.  These are defined locally rather than globally, and redefined upon every use.  Patch single quote macro if needed.
+% \begin{macro}{\minted at optscopes,\minted at optscopes@onlyblock}
+% Scopes for options.  |cmd| scope is the scope of a single command or environment.
 %    \begin{macrocode}
-\newcommand{\minted at defstyle}[1]{%
-  \edef\minted at style{#1}%
-  \ifcsname minted at PYGdef@\minted at style\endcsname\else
-    \expandafter\minted at generate@PYGdef\expandafter{\minted at style}%
-  \fi
-  \csname minted at PYGdef@\minted at style\endcsname
-  \minted at patch@PYGZsq
-  \minted at patch@PYGZhy
-  \ifthenelse{\equal{\minted at get@opt{ignorelexererrors}{true}}{true}}%
-   {\let\PYG at tok@err\relax}{}}
-\ifthenelse{\boolean{minted at draft}}{\renewcommand{\minted at defstyle}[1]{}}{}
+\begingroup
+\catcode`\,=12
+\gdef\minted at optscopes{global,lexer,globalinline,lexerinline,cmd}
+\gdef\minted at optscopes@onlyblock{global,lexer,cmd}
+\endgroup
 %    \end{macrocode}
 % \end{macro}
 %
-%
-% \begin{macro}{\minted at patch@PYGZsq}
-% The single quote macro from \texpkg{Pygments} 1.6+ needs to be patched if the \texpkg{upquote} package is in use.  Patching is done when the default style is created.  Patching is only attempted if the macro exists, so that there is a graceful fallback in the event of a custom \texpkg{Pygments} stylesheet.
+% \begin{macro}{\minted at iflexerscope}
 %    \begin{macrocode}
-\newcommand{\minted at patch@PYGZsq}{%
-  \ifcsname PYGZsq\endcsname
-    \expandafter\ifdefstring\expandafter{\csname PYGZsq\endcsname}{\char`\'}%
-     {\minted at patch@PYGZsq at i}%
-     {}%
+\let\minted at iflexerscope@lexer\relax
+\let\minted at iflexerscope@lexerinline\relax
+\def\minted at iflexerscope#1#2#3{%
+  \ifcsname minted at iflexerscope@#1\endcsname
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
   \fi
-}
-\begingroup
-\catcode`\'=\active
-\gdef\minted at patch@PYGZsq at i{\gdef\PYGZsq{'}}
-\endgroup
+  {#2}{#3}}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\minted at patch@PYGZhy}
-% Redefine the hyphen under LuaTeX to prevent unintended line breaks.
+%
+% \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 at 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}
-\newcommand{\minted at patch@PYGZhy}{%
-  \ifcsname PYGZhy\endcsname
-    \expandafter\ifdefstring\expandafter{\csname PYGZhy\endcsname}{\char`\-}%
-     {\def\PYGZhy{\mbox{-}}}%
-     {}%
+\def\minted at addoptkey#1#2{%
+  \ifcsname minted at optkeyslist@#1\endcsname
+  \else
+    \minted at fatalerror{Defining options under category "#1" is not supported}%
   \fi
-}
+  \expandafter\let\expandafter\minted at tmp\csname minted at optkeyslist@#1\endcsname
+  \ifx\minted at tmp\@empty
+    \def\minted at tmp{#2}%
+  \else
+    \expandafter\def\expandafter\minted at tmp\expandafter{\minted at tmp,#2}%
+  \fi
+  \expandafter\let\csname minted at optkeyslist@#1\endcsname\minted at tmp}
+\newcommand*{\mintedpgfkeyscreate}[3][]{%
+  \mintedpgfkeyscreate at i{#1}{#2}{#3}}
+\begingroup
+\catcode`\==12
+\gdef\mintedpgfkeyscreate at i#1#2#3{%
+  \def\minted at do##1{%
+    \minted at do@i##1=\FV at Sentinel}%
+  \def\minted at do@i##1=##2\FV at Sentinel{%
+    \minted at do@ii##1<>\FV at Sentinel}%
+  \def\minted at do@ii##1<##2>##3\FV at Sentinel{%
+    \minted at addoptkey{#2}{##1}}%
+  \minted at forcsvlist{\minted at do}{#3}%
+  \csname minted at pgfkeyscreate@#2\endcsname{#1}{#3}}
+\endgroup
 %    \end{macrocode}
 % \end{macro}
 %
 %
+% \begin{macro}{\minted at pgfkeyscreate@fv,\minted at fvoptlist@<scope>(@<lexer>)?,\minted at usefvopts,\minted at usefvoptsnopy}
+% Syntax: |\minted at pgfkeyscreate@fv|\marg{key(=value)? list}.
 %
-% \begin{macro}{\minted at def@opt at switch}
-% And we need a switch version.
+% Options are stored in scope-specific lists.  They are applied by passing these lists to |\fvset|.  Individual option values are not retrievable.
 %
-% It would be possible to create a special version of |\minted at get@opt| to work with these, but that would be redundant.  During the key processing, any values other than |true| and |false| are filtered out.  So when using |\minted at get@opt| later, we know that that part has already been taken care of, and we can just use something like |\ifthenelse{\equal{\minted at get@opt{<opt>}{<default>}}{true}}{...}{...}|.  Of course, there is the possibility that a default value has not been set, but  |\minted at def@opt at switch| sets a global default of |false| to avoid this.  And as usual, Pygments values shouldn't be used without considering whether |\minted at get@opt| needs a fallback value.
+% 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 at usefvopts| applies options via |\fvset|.  |\minted at 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}
-\newcommand{\minted at def@opt at switch}[2][false]{%
-  \define at booleankey{minted at opt@g}{#2}%
-    {\@namedef{minted at opt@g:#2}{true}}%
-    {\@namedef{minted at opt@g:#2}{false}}
-  \define at booleankey{minted at opt@g at i}{#2}%
-    {\@namedef{minted at opt@g at i:#2}{true}}%
-    {\@namedef{minted at opt@g at i:#2}{false}}
-  \define at booleankey{minted at opt@lang}{#2}%
-    {\@namedef{minted at opt@lang\minted at lang:#2}{true}}%
-    {\@namedef{minted at opt@lang\minted at lang:#2}{false}}
-  \define at booleankey{minted at opt@lang at i}{#2}%
-    {\@namedef{minted at opt@lang\minted at lang @i:#2}{true}}%
-    {\@namedef{minted at opt@lang\minted at lang @i:#2}{false}}
-  \define at booleankey{minted at opt@cmd}{#2}%
-    {\@namedef{minted at opt@cmd:#2}{true}}%
-    {\@namedef{minted at opt@cmd:#2}{false}}%
-  \@namedef{minted at opt@g:#2}{#1}%
-}
+\def\minted at pgfkeyscreate@fv#1#2{%
+  \if\relax\detokenize{#1}\relax
+  \else
+    \minted at fatalerror{Processor macros are not supported in defining fancyvrb options}%
+  \fi
+  \minted at forcsvlist{\minted at pgfkeycreate@fv}{#2}}
+\begingroup
+\catcode`\==12
+\gdef\minted at pgfkeycreate@fv#1{%
+  \minted at pgfkeycreate@fv at i#1=\FV at Sentinel}
+\gdef\minted at pgfkeycreate@fv at i#1=#2\FV at Sentinel{%
+  \if\relax\detokenize{#2}\relax
+    \expandafter\minted at pgfkeycreate@fv at ii
+  \else
+    \expandafter\minted at pgfkeycreate@fv at iii
+  \fi
+  {#1}#2\FV at Sentinel}
+\gdef\minted at pgfkeycreate@fv at ii#1\FV at Sentinel{%
+  \minted at pgfkeycreate@fv at iv{#1}{\minted at const@pgfkeysnovalue}}
+\gdef\minted at pgfkeycreate@fv at iii#1#2=\FV at Sentinel{%
+  \minted at pgfkeycreate@fv at iv{#1}{#2}}
+\endgroup
+\def\minted at pgfkeycreate@fv at iv#1#2{%
+  \def\minted at do##1{%
+    \minted at iflexerscope{##1}%
+     {\minted at do@i{##1}{@\minted at lexer}}%
+     {\minted at do@i{##1}{}}}%
+  \def\minted at do@i##1##2{%
+    \pgfkeys{%
+      /minted/##1/.cd,
+      #1/.code=
+        \def\minted at tmp{####1}%
+        \ifx\minted at tmp\minted at const@pgfkeysnovalue
+          \begingroup\fvset{#1}\endgroup
+          \minted at apptoprovidecs{minted at fvoptlist@##1##2}{#1,}%
+        \else
+          \begingroup\fvset{#1=####1}\endgroup
+          \minted at apptoprovidecs{minted at fvoptlist@##1##2}{#1=####1,}%
+        \fi,
+    }%
+  }%
+  \minted at forcsvlist{\minted at do}{\minted at optscopes}%
+  \ifx\minted at const@pgfkeysnovalue#2\relax
+  \else
+    \pgfkeys{%
+      /minted/global/.cd,
+      #1=#2,
+    }%
+  \fi}
+\def\minted at usefvopts{%
+  \ifbool{minted at isinline}%
+   {\minted at forcsvlist{\minted at usefvopts@do}{\minted at optscopes}}%
+   {\minted at forcsvlist{\minted at usefvopts@do}{\minted at optscopes@onlyblock}}}
+\def\minted at usefvopts@do#1{%
+  \minted at iflexerscope{#1}%
+   {\ifcsname minted at fvoptlist@#1@\minted at lexer\endcsname
+    \expandafter
+      \let\expandafter\minted at tmp\csname minted at fvoptlist@#1@\minted at lexer\endcsname
+    \expandafter\fvset\expandafter{\minted at tmp}%
+    \fi}%
+   {\ifcsname minted at fvoptlist@#1\endcsname
+    \expandafter
+      \let\expandafter\minted at tmp\csname minted at fvoptlist@#1\endcsname
+    \expandafter\fvset\expandafter{\minted at tmp}%
+    \fi}}
+\def\minted at useadditionalfvoptsnopy{%
+  \edef\minted at tmp{\mintedpyoptvalueof{gobble}}%
+  \ifx\minted at tmp\minted at const@pgfkeysnovalue
+  \else
+    \expandafter\minted at useadditionalfvoptsnopy@fvsetvk
+      \expandafter{\minted at tmp}{gobble}%
+  \fi
+  \edef\minted at tmp{\mintedpyoptvalueof{mathescape}}%
+  \ifx\minted at tmp\minted at const@pgfkeysnovalue
+  \else
+    \expandafter\minted at useadditionalfvoptsnopy@fvsetvk
+      \expandafter{\minted at tmp}{mathescape}%
+  \fi}
+\def\minted at useadditionalfvoptsnopy@fvsetvk#1#2{%
+  \fvset{#2=#1}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at get@opt}
-% We need a way to traverse the hierarchy of values for a given key and return the current value that has precedence.  In doing this, we need to specify a default value to use if no value is found.  When working with \texpkg{minted}-specific values, there should generally be a default value; in those cases, an empty default may be supplied.  But the macro should also work with Pygments settings, which are stored in macros of the same form and will sometimes need to be accessed (for example, |encoding|).  In the Pygments case, there may very well be no default values on the \LaTeX\ side, because we are falling back on Pygments' own built-in defaults.  There is no need to duplicate those when very few Pygments values are ever needed; it is simpler to specify the default fallback when accessing the macro value.
+% \begin{macro}{\minted at pgfkeyscreate@py,\mintedpyoptvalueof}
+% Syntax:  |\minted at pgfkeyscreate@py|\marg{processor}\marg{key(<default>)?=initial value list}.
 %
-% From a programming perspective, the default argument value needs to be mandatory, so that |\minted at get@opt| can be fully expandable. This significantly simplifies accessing options.
+% 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 at get@opt#1#2{%
-  \ifcsname minted at opt@cmd:#1\endcsname
-    \csname minted at opt@cmd:#1\endcsname
+\def\minted at pgfkeyscreate@py#1#2{%
+  \minted at forcsvlist{\minted at pgfkeycreate@py{#1}}{#2}}
+\begingroup
+\catcode`\==12
+\catcode`\<=12
+\catcode`\>=12
+\gdef\minted at pgfkeycreate@py#1#2{%
+  \minted at pgfkeycreate@py at i{#1}#2=\FV at Sentinel}
+\gdef\minted at pgfkeycreate@py at i#1#2=#3\FV at Sentinel{%
+  \if\relax\detokenize{#3}\relax
+    \expandafter\minted at pgfkeycreate@py at ii
   \else
-    \ifminted at isinline
-      \ifcsname minted at opt@lang\minted at lang @i:#1\endcsname
-        \csname minted at opt@lang\minted at lang @i:#1\endcsname
-      \else
-        \ifcsname minted at opt@g at i:#1\endcsname
-          \csname minted at opt@g at i:#1\endcsname
-        \else
-          \ifcsname minted at opt@lang\minted at lang:#1\endcsname
-            \csname minted at opt@lang\minted at lang:#1\endcsname
+    \expandafter\minted at pgfkeycreate@py at iii
+  \fi
+  {#1}{#2}#3\FV at Sentinel}
+\gdef\minted at pgfkeycreate@py at ii#1#2\FV at Sentinel{%
+  \minted at pgfkeycreate@py at iv{#1}{\pgfkeysnovalue}#2<>\FV at Sentinel}
+\gdef\minted at pgfkeycreate@py at iii#1#2#3=\FV at Sentinel{%
+  \minted at pgfkeycreate@py at iv{#1}{#3}#2<>\FV at Sentinel}
+\gdef\minted at pgfkeycreate@py at iv#1#2#3<#4>#5\FV at Sentinel{%
+  \if\relax\detokenize{#4}\relax
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+  {\minted at pgfkeycreate@py at v{#1}{#3}{#2}{\minted at const@pgfkeysnovalue}}%
+  {\minted at pgfkeycreate@py at v{#1}{#3}{#2}{#4}}}
+\endgroup
+\def\minted at pgfkeycreate@py at v#1#2#3#4{%
+  \def\minted at do##1{%
+    \minted at iflexerscope{##1}%
+     {\minted at do@i{##1}{@\minted at lexer}}%
+     {\minted at do@i{##1}{}}}
+  \def\minted at do@i##1##2{%
+    \if\relax\detokenize{#1}\relax
+      \pgfkeys{%
+        /minted/##1/.cd,
+        #2/.code=\expandafter\def\csname minted at pyopt@##1##2@#2\endcsname{####1},
+      }%
+    \else
+      \pgfkeys{%
+        /minted/##1/.cd,
+        #2/.code=
+          \def\minted at tmp{####1}%
+          \ifx\minted at tmp\minted at const@pgfkeysnovalue
+            \expandafter\let\csname minted at pyopt@##1##2@#2\endcsname\minted at tmp
+          \else\ifcsname minted at opthandler@immediate@\string#1\endcsname
+            #1{minted at pyopt@##1##2@#2}{####1}%
           \else
-            \ifcsname minted at opt@g:#1\endcsname
-              \csname minted at opt@g:#1\endcsname
-            \else
-              #2%
-            \fi
-          \fi
-        \fi
-      \fi
+            \expandafter\def\csname minted at pyopt@##1##2@#2\endcsname{#1{####1}}%
+          \fi\fi,
+      }%
+    \fi
+    \ifx\minted at const@pgfkeysnovalue#4\relax
+      \pgfkeys{%
+        /minted/##1/.cd,
+        #2/.value required,
+      }%
     \else
-      \ifcsname minted at opt@lang\minted at lang:#1\endcsname
-        \csname minted at opt@lang\minted at lang:#1\endcsname
-      \else
-        \ifcsname minted at opt@g:#1\endcsname
-          \csname minted at opt@g:#1\endcsname
-        \else
-          #2%
-        \fi
-      \fi
+      \pgfkeys{%
+        /minted/##1/.cd,
+        #2/.default=#4,
+      }%
     \fi
-  \fi
-}%
+  }%
+  \minted at forcsvlist{\minted at do}{\minted at optscopes}%
+  \pgfkeys{%
+    /minted/global/.cd,
+    #2=#3,
+  }}
+\def\mintedpyoptvalueof#1{%
+  \ifbool{minted at isinline}%
+   {\minted at pyoptvalueof@inline{#1}}%
+   {\minted at pyoptvalueof@block{#1}}}
+\def\minted at pyoptvalueof@inline#1{%
+  \ifcsname minted at pyopt@cmd@#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@cmd@#1\endcsname}%
+  \else\ifcsname minted at pyopt@lexerinline@\minted at lexer @#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@lexerinline@\minted at lexer @#1\endcsname}%
+  \else\ifcsname minted at pyopt@globalinline@#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@globalinline@#1\endcsname}%
+  \else\ifcsname minted at pyopt@lexer@\minted at lexer @#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@lexer@\minted at lexer @#1\endcsname}%
+  \else
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@global@#1\endcsname}%
+  \fi\fi\fi\fi}
+\def\minted at pyoptvalueof@block#1{%
+  \ifcsname minted at pyopt@cmd@#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@cmd@#1\endcsname}%
+  \else\ifcsname minted at pyopt@lexer@\minted at lexer @#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@lexer@\minted at lexer @#1\endcsname}%
+  \else
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@global@#1\endcsname}%
+  \fi\fi}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \noindent Actual option definitions.  Some of these must be defined conditionally depending on whether we are in |draft| mode; in |draft| mode, we need to emulate Pygments functionality with \LaTeX, particularly with \texpkg{fancyvrb}, when possible.  For example, gobbling must be performed by Pygments when |draft| is off, but when |draft| is on, \texpkg{fancyvrb} can perform gobbling.
+% \begin{macro}{\minted at pgfkeyscreate@tex,\mintedtexoptvalueof,\minted at usetexoptsnonpygments}
+% Syntax:  |\minted at pgfkeyscreate@tex|\marg{processor}\marg{key=initial value list}.
 %
-% Lexers.
-%    \begin{macrocode}
-\minted at def@optcl{encoding}{-P encoding}{#1}
-\minted at def@optcl{outencoding}{-P outencoding}{#1}
-\minted at def@optcl at e{escapeinside}{-P escapeinside}{#1}
-\minted at def@optcl at switch{stripnl}{-P stripnl}
-\minted at def@optcl at switch{stripall}{-P stripall}
-% Python console
-\minted at def@optcl at switch{python3}{-P python3}
-% PHP
-\minted at def@optcl at switch{funcnamehighlighting}{-P funcnamehighlighting}
-\minted at def@optcl at switch{startinline}{-P startinline}
-%    \end{macrocode}
+% 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|.
 %
-% Filters.
-%    \begin{macrocode}
-\ifthenelse{\boolean{minted at draft}}%
-  {\minted at def@optfv{gobble}}%
-  {\minted at def@optcl{gobble}{-F gobble:n}{#1}}
-\minted at def@optcl{codetagify}{-F codetagify:codetags}{#1}
-\minted at def@optcl{keywordcase}{-F keywordcase:case}{#1}
-%    \end{macrocode}
+% |\mintedtexoptvalueof| is used for retrieving values via |\edef|.
 %
-% \LaTeX\ formatter.
+% |\minted at 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 at 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}
-\minted at def@optcl at switch{texcl}{-P texcomments}
-\minted at def@optcl at switch{texcomments}{-P texcomments}
-\minted at def@optcl at switch{mathescape}{-P mathescape}
-\minted at def@optfv at switch{linenos}
-\minted at def@opt at detok{style}
+\def\minted at pgfkeyscreate@tex#1#2{%
+  \minted at forcsvlist{\minted at pgfkeycreate@tex{#1}}{#2}}
+\begingroup
+\catcode`\==12
+\gdef\minted at pgfkeycreate@tex#1#2{%
+  \minted at pgfkeycreate@tex at i{#1}#2=\FV at Sentinel}
+\gdef\minted at pgfkeycreate@tex at i#1#2=#3\FV at Sentinel{%
+  \if\relax\detokenize{#3}\relax
+    \expandafter\minted at pgfkeycreate@tex at ii
+  \else
+    \expandafter\minted at pgfkeycreate@tex at iii
+  \fi
+  {#1}{#2}#3\FV at Sentinel}
+\gdef\minted at pgfkeycreate@tex at ii#1#2\FV at Sentinel{%
+  \minted at pgfkeycreate@tex at iv{#1}{#2}{\pgfkeysnovalue}}
+\gdef\minted at pgfkeycreate@tex at iii#1#2#3=\FV at Sentinel{%
+  \minted at pgfkeycreate@tex at iv{#1}{#2}{#3}}
+\endgroup
+\def\minted at pgfkeycreate@tex at iv#1#2#3{%
+  \def\minted at do##1{%
+    \minted at iflexerscope{##1}%
+     {\minted at do@i{##1}{@\minted at lexer}}%
+     {\minted at do@i{##1}{}}}
+  \def\minted at do@i##1##2{%
+    \if\relax\detokenize{#1}\relax
+      \pgfkeys{%
+        /minted/##1/.cd,
+        #2/.code=\expandafter\def\csname minted at texopt@##1##2@#2\endcsname{####1},
+        #2/.value required,
+      }%
+    \else
+      \pgfkeys{%
+        /minted/##1/.cd,
+        #2/.code=
+          \def\minted at tmp{####1}%
+          \ifx\minted at tmp\minted at const@pgfkeysnovalue
+            \expandafter\let\csname minted at texopt@##1##2@#2\endcsname\minted at tmp
+          \else\ifcsname minted at opthandler@immediate@\string#1\endcsname
+            #1{minted at texopt@##1##2@#2}{####1}%
+          \else
+            \expandafter\def\csname minted at texopt@##1##2@#2\endcsname{#1{####1}}%
+          \fi\fi,
+        #2/.value required,
+      }%
+    \fi
+  }%
+  \minted at forcsvlist{\minted at do}{\minted at optscopes}%
+  \pgfkeys{%
+    /minted/global/.cd,
+    #2=#3,
+  }}
+\def\mintedtexoptvalueof#1{%
+  \ifbool{minted at isinline}%
+   {\minted at texoptvalueof@inline{#1}}%
+   {\minted at texoptvalueof@block{#1}}}
+\def\minted at texoptvalueof@inline#1{%
+  \ifcsname minted at texopt@cmd@#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@cmd@#1\endcsname}%
+  \else\ifcsname minted at texopt@lexerinline@\minted at lexer @#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@lexerinline@\minted at lexer @#1\endcsname}%
+  \else\ifcsname minted at texopt@globalinline@#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@globalinline@#1\endcsname}%
+  \else\ifcsname minted at texopt@lexer@\minted at lexer @#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@lexer@\minted at lexer @#1\endcsname}%
+  \else
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@global@#1\endcsname}%
+  \fi\fi\fi\fi}
+\def\minted at texoptvalueof@block#1{%
+  \ifcsname minted at texopt@cmd@#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@cmd@#1\endcsname}%
+  \else\ifcsname minted at texopt@lexer@\minted at lexer @#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@lexer@\minted at lexer @#1\endcsname}%
+  \else
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@global@#1\endcsname}%
+  \fi\fi}
+\def\minted at usetexoptsnonpygments{}
 %    \end{macrocode}
+% \end{macro}
 %
-% \texpkg{fancyvrb} and \texpkg{fvextra} options.
-%    \begin{macrocode}
-\minted at def@optfv{frame}
-\minted at def@optfv{framesep}
-\minted at def@optfv{framerule}
-\minted at def@optfv{rulecolor}
-\minted at def@optfv{numbersep}
-\minted at def@optfv{numbers}
-\minted at def@optfv{firstnumber}
-\minted at def@optfv{stepnumber}
-\minted at def@optfv{firstline}
-\minted at def@optfv{lastline}
-\minted at def@optfv{baselinestretch}
-\minted at def@optfv{xleftmargin}
-\minted at def@optfv{xrightmargin}
-\minted at def@optfv{fillcolor}
-\minted at def@optfv{tabsize}
-\minted at def@optfv{fontfamily}
-\minted at def@optfv{fontsize}
-\minted at def@optfv{fontshape}
-\minted at def@optfv{fontseries}
-\minted at def@optfv{formatcom}
-\minted at def@optfv{label}
-\minted at def@optfv{labelposition}
-\minted at def@optfv{highlightlines}
-\minted at def@optfv{highlightcolor}
-\minted at def@optfv{space}
-\minted at def@optfv{spacecolor}
-\minted at def@optfv{tab}
-\minted at def@optfv{tabcolor}
-\minted at def@optfv{highlightcolor}
-\minted at def@optfv at switch{beameroverlays}
-\minted at def@optfv at switch{curlyquotes}
-\minted at def@optfv at switch{numberfirstline}
-\minted at def@optfv at switch{numberblanklines}
-\minted at def@optfv at switch{stepnumberfromfirst}
-\minted at def@optfv at switch{stepnumberoffsetvalues}
-\minted at def@optfv at switch{showspaces}
-\minted at def@optfv at switch{resetmargins}
-\minted at def@optfv at switch{samepage}
-\minted at def@optfv at switch{showtabs}
-\minted at def@optfv at switch{obeytabs}
-\minted at def@optfv at switch{breaklines}
-\minted at def@optfv at switch{breakbytoken}
-\minted at def@optfv at switch{breakbytokenanywhere}
-\minted at def@optfv{breakindent}
-\minted at def@optfv{breakindentnchars}
-\minted at def@optfv at switch{breakautoindent}
-\minted at def@optfv{breaksymbol}
-\minted at def@optfv{breaksymbolsep}
-\minted at def@optfv{breaksymbolsepnchars}
-\minted at def@optfv{breaksymbolindent}
-\minted at def@optfv{breaksymbolindentnchars}
-\minted at def@optfv{breaksymbolleft}
-\minted at def@optfv{breaksymbolsepleft}
-\minted at def@optfv{breaksymbolsepleftnchars}
-\minted at def@optfv{breaksymbolindentleft}
-\minted at def@optfv{breaksymbolindentleftnchars}
-\minted at def@optfv{breaksymbolright}
-\minted at def@optfv{breaksymbolsepright}
-\minted at def@optfv{breaksymbolseprightnchars}
-\minted at def@optfv{breaksymbolindentright}
-\minted at def@optfv{breaksymbolindentrightnchars}
-\minted at def@optfv{breakbefore}
-\minted at def@optfv{breakbeforesymbolpre}
-\minted at def@optfv{breakbeforesymbolpost}
-\minted at def@optfv at switch{breakbeforeinrun}
-\minted at def@optfv{breakafter}
-\minted at def@optfv at switch{breakafterinrun}
-\minted at def@optfv{breakaftersymbolpre}
-\minted at def@optfv{breakaftersymbolpost}
-\minted at def@optfv at switch{breakanywhere}
-\minted at def@optfv{breakanywheresymbolpre}
-\minted at def@optfv{breakanywheresymbolpost}
-\minted at def@optfv{fontencoding}
-%    \end{macrocode}
 %
-% Finally, options specific to \texpkg{minted}.
 %
-% |bgcolor|.  The original, |minipage|- and |\colorbox|-based solution was replaced with a |framed|-based solution in version 2.2.  A dedicated framing package will often be preferable.
-%    \begin{macrocode}
-\minted at def@opt{bgcolor}
-%    \end{macrocode}
+% \subsubsection{Option handlers}
 %
-% Autogobble.  We create an option that governs when Python's |textwrap.dedent()| is used to autogobble code.
-%    \begin{macrocode}
-\minted at def@opt at switch{autogobble}
-%    \end{macrocode}
 %
-% Whether lexer errors are shown.
-%    \begin{macrocode}
-\minted at def@opt at switch{ignorelexererrors}
-%    \end{macrocode}
+% \begin{macro}{\minted at opthandler@deforrestrictedescape}
+% Syntax:  |\minted at opthandler@deforrestrictedescape|\marg{csname}\marg{value}.  \meta{value} is processed and then the result is stored in \meta{csname}.
 %
-% \begin{macro}{\minted at encoding}
-% When working with encoding, we will need access to the current encoding.  That may be done via |\minted at get@opt|, but it is more convenient to go ahead and define a shortcut with an appropriate default
+% 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 at 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}
-\newcommand{\minted at encoding}{\minted at get@opt{encoding}{UTF8}}
+\def\minted at 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 at opthandler@deforrestrictedescape at i
+        \expandafter\@gobble\string#2\FV at Sentinel{#1}{#2}%
+    \else
+      \FVExtraDetokenizeREscVArg{\expandafter\def\csname#1\endcsname}{#2}%
+    \fi
+  \else
+    \FVExtraDetokenizeREscVArg{\expandafter\def\csname#1\endcsname}{#2}%
+  \fi\fi}
+\def\minted at opthandler@deforrestrictedescape at i#1#2\FV at Sentinel#3#4{%
+  \ifcsname minted at isalpha\number`#1\endcsname
+    \expandafter\def\csname#3\endcsname{#4}%
+  \else
+    \FVExtraDetokenizeREscVArg{\expandafter\def\csname#3\endcsname}{#4}%
+  \fi}
+\expandafter\let\csname
+  minted at opthandler@immediate@\string\minted at opthandler@deforrestrictedescape
+  \endcsname\relax
 %    \end{macrocode}
 % \end{macro}
 %
 %
 %
+% \subsubsection{Option definitions}
 %
-% \subsection{Internal helpers}
 %
-% \begin{environment}{minted at snugshade*}
-% Define a custom version of \texpkg{framed}'s |snugshade*| that takes a color as argument.  This avoids the need to redefine |shadecolor|.
+% \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}
-\newenvironment{minted at snugshade*}[1]{%
-  \def\FrameCommand##1{\hskip\@totalleftmargin
-    \colorbox{#1}{##1}%
-    \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
-  \MakeFramed{\advance\hsize-\width
-    \@totalleftmargin\z@ \linewidth\hsize
-    \advance\labelsep\fboxsep
-    \@setminipage}%
- }{\par\unskip\@minipagefalse\endMakeFramed}
+\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}
-% \end{environment}
 %
+% \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 at opthandler@deforrestrictedescape]{py}{
+  codetagify=,
+  escapeinside=,
+  literatecomment=,
+  rangestartstring=,
+  rangestartafterstring=,
+  rangestopstring=,
+  rangestopbeforestring=,
+  rangeregex=,
+}
+\let\minted at tmplexer\minted at lexer
+\def\minted at lexer{php}
+\pgfkeys{
+  /minted/lexerinline/.cd,
+  startinline=true,
+}
+\let\minted at lexer\minted at tmplexer
+%    \end{macrocode}
 %
-% \begin{environment}{\minted at bgbox}
+% \paragraph{\mintedpkg\ (kept in \LaTeX)}
+% \begin{itemize}
+% \item The |\minted at 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 at usetexoptsnonpygments\expandafter{%
+  \minted at usetexoptsnonpygments
+  \edef\minted at literalenvname{\mintedpyoptvalueof{literalenvname}}%
+  \edef\minted at envname{\mintedtexoptvalueof{envname}}%
+  \expandafter\def\expandafter\minted at literalenv\expandafter{%
+    \csname \minted at literalenvname\endcsname}%
+  \expandafter\def\expandafter\minted at endliteralenv\expandafter{%
+    \csname end\minted at literalenvname\endcsname}%
+  \expandafter\expandafter\expandafter
+    \let\expandafter\minted at literalenv\csname \minted at envname\endcsname
+  \expandafter\expandafter\expandafter
+    \let\expandafter\minted at endliteralenv\csname end\minted at envname\endcsname}%
+\ifcsname minted at def@optcl\endcsname
+  \ifx\minted at def@optcl\relax
+    \let\minted at def@optcl\minted at undefined
+  \fi
+\fi
+\providecommand{\minted at def@optcl}[4][]{%
+  \minted at warning{Macro \string\minted at def@optcl\space is deprecated with minted v3
+    and no longer has any effect}}
+%    \end{macrocode}
 %
-% Define an environment that may be wrapped around a |minted| environment to assign a background color.  This is retained as a holdover from version 1.0.  In most cases, it is probably better to use a dedicated framing package, such as \texpkg{tcolorbox} or \texpkg{mdframed}.
 %
-% First, we need to define a new save box.
 %
-%    \begin{macrocode}
-\newsavebox{\minted at bgbox}
-%    \end{macrocode}
+% \subsection{Caching, styles, and highlighting}
 %
-% Now we can define the environment that applies a background color.  Prior to \texpkg{minted} 2.2, this involved a |minipage|.  However, that approach was problematic because it did not allow linebreaks, would be pushed into the margin by immediately preceding text, and had very different whitespace separation from preceding and following text compared to no background color.  In version 2.2, this was replaced with an approach based on \texpkg{framed}.  |\FV at NumberSep| is adjusted by |\fboxsep| to ensure that line numbers remain in the same location in the margin regardless of whether |bgcolor| is used.
 %
-%    \begin{macrocode}
-\newenvironment{minted at colorbg}[1]{%
-  \setlength{\OuterFrameSep}{0pt}%
-  \let\minted at tmp\FV at NumberSep
-  \edef\FV at NumberSep{%
-    \the\numexpr\dimexpr\minted at tmp+\number\fboxsep\relax sp\relax}%
-  \medskip
-  \begin{minted at snugshade*}{#1}}
- {\end{minted at snugshade*}%
-  \medskip\noindent}
-%    \end{macrocode}
-% \end{environment}
 %
+% \subsubsection{Cache management}
 %
-% \begin{macro}{\minted at code}
-% Create a file handle for saving code (and anything else that must be written to temp files).
+%
+% \begin{macro}{\minted at addcachefilename,\minted at cachefile<n>}
+% Track cache files that are used, so that unused files can be removed.
 %    \begin{macrocode}
-\newwrite\minted at code
+\newcounter{minted at numcachefiles}
+\def\minted at addcachefilename#1{%
+  \ifbool{minted at canexec}%
+   {\stepcounter{minted at numcachefiles}%
+    \expandafter
+      \xdef\csname minted at cachefile\arabic{minted at numcachefiles}\endcsname{#1}}%
+   {}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at savecode}
+% \begin{macro}{\minted at 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.
 %
-% Save code to be pygmentized to a file.
-%    \begin{macrocode}
-\newcommand{\minted at savecode}[1]{
-  \immediate\openout\minted at code\minted at jobname.pyg\relax
-  \immediate\write\minted at code{\expandafter\detokenize\expandafter{#1}}%
-  \immediate\closeout\minted at code}
-%    \end{macrocode}
-% \end{macro}
+% 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 at fasthighlightmode@checkend| is placed within the same |\AfterEndDocument| to guarantee correct ordering.
 %
-% \begin{macro}{minted at FancyVerbLineTemp}
-% At various points, we will need a temporary counter for storing and then restoring the value of |FancyVerbLine|.  When using the |langlinenos| option, we need to store the current value of |FancyVerbLine|, then set |FancyVerbLine| to the current value of a language-specific counter, and finally restore |FancyVerbLine| to its initial value after the current chunk of code has been typeset.  In patching |VerbatimOut|, we need to prevent |FancyVerbLine| from being incremented during the write process.
 %    \begin{macrocode}
-\newcounter{minted at FancyVerbLineTemp}
+\def\minted at clean{%
+  \ifbool{minted at canexec}%
+   {\ifbool{minted at diddetectconfig}{\minted at clean@i}{}}%
+   {}}
+\def\minted at clean@i{%
+  \ifnum\value{minted at numcachefiles}>0\relax
+    \expandafter\minted at savecachelist
+  \fi
+  \ifbool{minted at fasthighlightmode}%
+   {}%
+   {\minted at exec@clean
+    \global\boolfalse{minted at canexec}}}
+\def\minted at savecachelist{%
+  \pydatasetfilename{\MintedDataFilename}%
+  \minted at fasthighlightmode@checkstart
+  \pydatawritedictopen
+  \pydatawritekeyvalue{command}{clean}%
+  \pydatawritekeyedefvalue{jobname}{\jobname}%
+  \pydatawritekeyedefvalue{timestamp}{\minted at timestamp}%
+  \pydatawritekeyedefvalue{cachepath}{\minted at cachepath}%
+  \pydatawritekey{cachefiles}%
+  \pydatawritemlvaluestart
+  \pydatawritemlvalueline{[}%
+  \setcounter{minted at tmpcnt}{1}%
+  \loop\unless\ifnum\value{minted at tmpcnt}>\value{minted at numcachefiles}\relax
+    \expandafter\minted at savecachelist@writecachefile\expandafter{%
+      \csname minted at cachefile\arabic{minted at tmpcnt}\endcsname}%
+    \expandafter\global\expandafter
+      \let\csname minted at cachefile\arabic{minted at tmpcnt}\endcsname\minted at undefined
+    \stepcounter{minted at tmpcnt}%
+  \repeat
+  \setcounter{minted at numcachefiles}{0}%
+  \pydatawritemlvalueline{]}%
+  \pydatawritemlvalueend
+  \pydatawritedictclose
+  \ifbool{minted at fasthighlightmode}{}{\pydataclosefilename{\MintedDataFilename}}}
+\begingroup
+\catcode`\"=12
+\catcode`\,=12
+\gdef\minted at savecachelist@writecachefile#1{%
+  \expandafter\pydatawritemlvalueline\expandafter{\expandafter"#1",}}
+\endgroup
+\AfterEndDocument{%
+  \minted at clean
+  \minted at fasthighlightmode@checkend}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at FVB@VerbatimOut}
-% We need a custom version of \texpkg{fancyvrb}'s |\FVB at VerbatimOut| that supports Unicode (everything written to file is |\detokenized|).  We also need to prevent the value of |FancyVerbLine| from being incorrectly incremented.
-%    \begin{macrocode}
-\newcommand{\minted at write@detok}[1]{%
-  \immediate\write\FV at OutFile{\detokenize{#1}}}
-\newcommand{\minted at FVB@VerbatimOut}[1]{%
-  \setcounter{minted at FancyVerbLineTemp}{\value{FancyVerbLine}}%
-  \@bsphack
-  \begingroup
-    \FV at UseKeyValues
-    \FV at DefineWhiteSpace
-    \def\FV at Space{\space}%
-    \FV at DefineTabOut
-    \let\FV at ProcessLine\minted at write@detok
-    \immediate\openout\FV at OutFile #1\relax
-    \let\FV at FontScanPrep\relax
-    \let\@noligs\relax
-    \FV at Scan}
-%    \end{macrocode}
-% \end{macro}
 %
-% \begin{macro}{\minted at FVE@VerbatimOut}
-% Likewise, we need a custom version of |\FVE at VerbatimOut| that completes the protection of |FancyVerbLine| from being incremented.
-%    \begin{macrocode}
-\newcommand{\minted at FVE@VerbatimOut}{%
-  \immediate\closeout\FV at OutFile\endgroup\@esphack
-  \setcounter{FancyVerbLine}{\value{minted at FancyVerbLineTemp}}}%
-%    \end{macrocode}
-% \end{macro}
+% \subsubsection{Style definitions}
 %
 %
-% \begin{macro}{\MintedPygmentize}
-% We need a way to customize the executable/script that is called to perform highlighting.  Typically, we will want |pygmentize|.  But advanced users might wish to use a custom Python script instead.  The command is only defined if it does not exist.  In general, the command should be |\renewcommand|ed after the package is loaded, but this way, it will work if defined before \texpkg{minted} is loaded.
+% \begin{macro}{\minted at 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}
-\ifcsname MintedPygmentize\endcsname\else
-  \newcommand{\MintedPygmentize}{pygmentize}
-\fi
+\def\minted at patch@PygmentsZsq{%
+  \ifcsname\minted at styleprefix Zsq\endcsname
+    \ifcsstring{\minted at styleprefix Zsq}{\char`\'}{\minted at patch@PygmentsZsq at i}{}%
+  \fi}
+\begingroup
+\catcode`\'=\active
+\gdef\minted at patch@PygmentsZsq at i{\def\PYGZsq{'}}
+\endgroup
+\def\minted at patch@PygmentsZhy{%
+  \ifcsname\minted at styleprefix Zhy\endcsname
+    \ifcsstring{\minted at styleprefix Zhy}{\char`\-}{\def\PYGZhy{\mbox{-}}}{}%
+  \fi}
+\def\minted at patch@ignorelexererrors{%
+  \edef\minted at tmp{\mintedtexoptvalueof{ignorelexererrors}}%
+  \ifdefstring{\minted at tmp}{true}%
+   {\expandafter\let\csname\minted at styleprefix @tok at err\endcsname\relax}%
+   {}}
+\def\minted at patch@PygmentsStyledef{%
+  \minted at patch@PygmentsZsq
+  \minted at patch@PygmentsZhy
+  \minted at patch@ignorelexererrors}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{minted at pygmentizecounter}
-% We need a counter to keep track of how many files have been pygmentized.  This is primarily used with |finalizecache| for naming cache files sequentially in |listing<number>.pygtex| form.
+% \begin{macro}{\minted at VerbatimPygments}
+% Enable \texpkg{fancyvrb} features for Pygments macros.
 %    \begin{macrocode}
-\newcounter{minted at pygmentizecounter}
+\def\minted at VerbatimPygments{%
+  \expandafter\minted at VerbatimPygments@i\expandafter{%
+    \csname\minted at styleprefix\endcsname}}
+\def\minted at VerbatimPygments@i#1{%
+  \VerbatimPygments{#1}{#1}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\MintedPython}
-% Python executable to be used for |autogobble|.
+% \begin{macro}{\minted at standardcatcodes}
+% Set standard catcodes.  Used before |\input| of style definitions and in reading the optional argument of environments that wrap Pygments output.
 %    \begin{macrocode}
-\ifwindows
-  \newcommand{\MintedPython}{python}
-\else
-  \newcommand{\MintedPython}{python3}
-\fi
+\def\minted at 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 at check@MintedPython}
-% Check that |\MintedPython| is a valid executable before use.  Swap |python| for |python3| and vice versa depending on what is available.
+% \begin{macro}{\minted at defstyle}
+% Define highlighting style macros.
 %    \begin{macrocode}
-\newcommand{\minted at check@MintedPython}{%
-  \ifcsname minted at MintedPython@\MintedPython\endcsname
+\def\minted at defstyle{%
+  \edef\minted at tmp{\mintedtexoptvalueof{style}}%
+  \expandafter\minted at defstyle@i\expandafter{\minted at tmp}}
+\def\minted at defstyle@i#1{%
+  \minted at ifalphanumhyphenunderscore{#1}%
+   {\minted at defstyle@ii{#1}}%
+   {\minted at 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 at defstyle@ii{default}}}
+\def\minted at defstyle@ii#1{%
+  \ifcsname minted at styledef@#1\endcsname
+    \expandafter\@firstoftwo
   \else
-    \let\minted at altpython\minted at undefined
-    \ifdefstring{\MintedPython}{python}{\def\minted at altpython{python3}}{}%
-    \ifdefstring{\MintedPython}{python3}{\def\minted at altpython{python}}{}%
-    \ifx\minted at altpython\minted at undefined\relax
-      \TestAppExists{\MintedPython}%
-      \ifAppExists
-        \expandafter\global\expandafter\let%
-          \csname minted at MintedPython@\MintedPython\endcsname\relax
-      \else
-        \PackageError{minted}%
-         {Failed to find Python executable \MintedPython;
-          check Python installation (including PATH),
-          or redefine \string\MintedPython}%
-         {Failed to find Python executable \MintedPython;
-          check Python installation (including PATH),
-          or redefine \string\MintedPython}%
-      \fi
-    \else
-      \ifcsname minted at MintedPython@\minted at altpython\endcsname
-        \let\MintedPython\minted at altpython
-      \else
-        \TestAppExists{\MintedPython}%
-        \ifAppExists
-          \expandafter\global\expandafter\let%
-            \csname minted at MintedPython@\MintedPython\endcsname\relax
-        \else
-          \TestAppExists{\minted at altpython}%
-          \ifAppExists
-            \expandafter\global\expandafter\let%
-              \csname minted at MintedPython@\minted at altpython\endcsname\relax
-            \let\MintedPython\minted at altpython
-          \else
-            \PackageError{minted}%
-             {Failed to find Python executables python or python3;
-              check Python installation (including PATH),
-              or redefine \string\MintedPython}%
-             {Failed to find Python executables python or python3;
-              check Python installation (including PATH),
-              or redefine \string\MintedPython}%
-          \fi
-        \fi
-      \fi
-    \fi
+    \expandafter\@secondoftwo
   \fi
-}
+  {\csname minted at styledef@#1\endcsname
+   \minted at patch@PygmentsStyledef
+   \minted at VerbatimPygments}%
+  {\minted at defstyle@load{#1}}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at pygmentize}
+% \begin{macro}{\minted at 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.
 %
-% Pygmentize a file (default: |\minted at outputdir\minted at jobname.pyg|) using the options provided.
-%
-% Unfortunately, the logic for caching is a little complex due to operations that are OS- and engine-dependent.
-%
-% The name of cached files is the result of concatenating the md5 of the code and the md5 of the command.  This results in a filename that is longer than ideal (64 characters plus path and extension).  Unfortunately, this is the only robust approach that is possible using the built-in pdfTeX hashing capabilities.\footnote{It would be possible to use only the cache of the code, but that approach breaks down as soon as the code is used multiple times with different options.  While that may seem unlikely in practice, it occurs in this documentation and may be expected to occur in other docs.}  LuaTeX could do better, by hashing the command and code together.  The Python script that provides XeTeX capabilities simply runs both the command and the code through a single sha1 hasher, but has the additional overhead of the |\write18| call and Python execution.
-%
-% One potential concern is that caching should also keep track of the command from which code originates.  What if identical code is highlighted with identical settings in both the |minted| environment and |\mintinline| command?  In both cases, what is actually saved by Pygments is identical.  The difference in final appearance is due to how the environment and command treat the Pygments output.
-%
-% \textbf{This macro must always be checked carefully whenever it is modified.}  Under no circumstances should |#1| be written to or opened by Python in write mode.  When |\inputminted| is used, |#1| will be an external file that is brought in for highlighting, so it must be left intact.
-%
-% At the very beginning, a check is performed to make sure that style macros exist.  This must be done before the highlighted content is generated, so that temp file names can be shared without accidental overwriting.  Styles are generated here, rather than when a style is set, so that creating the style macros is done as late as possible in case a custom |pygmentize| is in use via |\MintedPygmentize|.
-%
+% The |\begingroup...\endgroup| around |\minted at 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}
-\ifwindows
-  \def\minted at opt@quote#1{\detokenize{"#1"}}
-\else
-  \def\minted at opt@quote#1{\detokenize{'#1'}}
-\fi
-\newcommand{\minted at pygmentize}[2][\minted at outputdir\minted at jobname.pyg]{%
-  \minted at defstyle{\minted at get@opt{style}{default}}%
-  \stepcounter{minted at pygmentizecounter}%
-  \ifthenelse{\equal{\minted at get@opt{autogobble}{false}}{true}}%
-    {\def\minted at codefile{\minted at outputdir\minted at jobname.pyg}}%
-    {\def\minted at codefile{#1}}%
-  \ifthenelse{\boolean{minted at isinline}}%
-    {\def\minted at optlistcl@inlines{%
-      \minted at optlistcl@g at i
-      \csname minted at optlistcl@lang\minted at lang @i\endcsname}}%
-    {\let\minted at optlistcl@inlines\@empty}%
-  \def\minted at cmd{%
-    \ifminted at kpsewhich
-      \ifwindows
-        \detokenize{for /f "usebackq tokens=*"}\space\@percentchar\detokenize{a in (`kpsewhich}\space\minted at codefile\detokenize{`) do}\space
-      \fi
+\def\minted at catchfiledef#1#2{%
+  \CatchFileDef{#1}{#2}{\minted at standardcatcodes\endlinechar=-1}}
+\def\minted at defstyle@load#1{%
+  \minted at detectconfig
+  \ifbool{minted at cache}%
+   {\edef\minted at styledeffilename{#1\detokenize{.style.minted}}%
+    \edef\minted at styledeffilepath{\minted at cachepath\minted at styledeffilename}%
+    \IfFileExists{\minted at styledeffilepath}%
+     {\minted at defstyle@input{#1}}%
+     {\ifbool{minted at canexec}%
+      {\minted at defstyle@generate{#1}}%
+      {\minted at error{Missing definition for highlighting style "#1" (minted executable
+         is unavailable or disabled); attempting to substitute fallback style}%
+       \minted at defstyle@fallback{#1}}}}%
+   {\edef\minted at styledeffilename{%
+      \detokenize{_}\MintedJobnameMdfive\detokenize{.style.minted}}%
+    \let\minted at styledeffilepath\minted at styledeffilename
+    \ifbool{minted at canexec}%
+     {\minted at defstyle@generate{#1}}%
+     {\minted at error{Missing definition for highlighting style "#1" (minted executable
+        is unavailable or disabled); attempting to substitute fallback style}%
+      \minted at defstyle@fallback{#1}}}}
+\def\minted at defstyle@input#1{%
+  \begingroup
+  \minted at catchfiledef{\minted at tmp}{\minted at styledeffilepath}%
+  \minted at tmp
+  \ifcsname\minted at styleprefix\endcsname
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+  {\expandafter\global\expandafter\let\csname minted at styledef@#1\endcsname\minted at tmp
+   \endgroup
+   \ifbool{minted at cache}{\minted at addcachefilename{\minted at styledeffilename}}{}%
+   \csname minted at styledef@#1\endcsname
+   \minted at patch@PygmentsStyledef
+   \minted at VerbatimPygments}%
+  {\endgroup
+   \ifbool{minted at canexec}%
+    {\minted at warning{Invalid or corrupted style definition file
+       "\minted at styledeffilename"; attempting to regenerate}%
+     \minted at defstyle@generate{#1}}%
+    {\minted at error{Invalid or corrupted style definition file
+       "\minted at styledeffilename"; attempting to substitute fallback style
+       (minted executable is unavailable or disabled)}%
+     \minted at defstyle@fallback{#1}}}}
+\def\minted at defstyle@generate#1{%
+  \pydatasetfilename{\MintedDataFilename}%
+  \minted at fasthighlightmode@checkstart
+  \pydatawritedictopen
+  \pydatawritekeyvalue{command}{styledef}%
+  \pydatawritekeyedefvalue{jobname}{\jobname}%
+  \pydatawritekeyedefvalue{timestamp}{\minted at timestamp}%
+  \pydatawritekeyedefvalue{currentfilepath}{\CurrentFilePath}%
+  \pydatawritekeyedefvalue{currentfile}{\CurrentFile}%
+  \pydatawritekeyedefvalue{inputlineno}{\the\inputlineno}%
+  \pydatawritekeyedefvalue{cachepath}{\minted at cachepath}%
+  \pydatawritekeyedefvalue{styledeffilename}{\minted at styledeffilename}%
+  \pydatawritekeyvalue{style}{#1}%
+  \pydatawritekeyedefvalue{commandprefix}{\minted at styleprefix}%
+  \pydatawritedictclose
+  \ifbool{minted at fasthighlightmode}%
+   {\minted at defstyle@fallback{#1}}%
+   {\pydataclosefilename{\MintedDataFilename}%
+    \begingroup
+    \minted at exec@styledef
+    \ifx\minted at exec@warning\relax
+    \else
+      \expandafter\minted at exec@warning
     \fi
-    \MintedPygmentize\space -l \minted at opt@quote{#2}
-    -f latex -P commandprefix=PYG -F tokenmerge
-    \minted at optlistcl@g \csname minted at optlistcl@lang\minted at lang\endcsname
-    \minted at optlistcl@inlines
-    \minted at optlistcl@cmd -o \minted at outputdir\minted at infile\space
-    \ifminted at kpsewhich
-      \ifwindows
-        \@percentchar\detokenize{a}%
-      \else
-        \detokenize{`}kpsewhich \minted at codefile\space
-          \detokenize{||} \minted at codefile\detokenize{`}%
-      \fi
+    \ifx\minted at exec@error\relax
+      \expandafter\minted at defstyle@generate at i
     \else
-      \minted at codefile
-    \fi}%
-  % For debugging, uncomment: %%%%
-  % \immediate\typeout{\minted at cmd}%
-  % %%%%
-  \ifthenelse{\boolean{minted at cache}}%
-    {%
-      \ifminted at frozencache
-      \else
-        \ifthenelse{\equal{\minted at get@opt{autogobble}{false}}{true}}%
-         {\edef\minted at hash{%
-            \pdf at filemdfivesum{#1}%
-            \pdf at mdfivesum{\minted at cmd\space%
-              autogobble(\the\numexpr\FancyVerbStartNum\relax-%
-                         \the\numexpr\FancyVerbStopNum\relax)}}}%
-         {\edef\minted at hash{%
-            \pdf at filemdfivesum{#1}%
-            \pdf at mdfivesum{\minted at cmd}}}%
-        \edef\minted at infile{\minted at cachedir/\minted at hash.pygtex}%
-        \IfFileExists{\minted at infile}{}{%
-          \ifthenelse{\equal{\minted at get@opt{autogobble}{false}}{true}}{%
-            \minted at autogobble{#1}}{}%
-          \ShellEscape{\minted at cmd}}%
-      \fi
-      \ifthenelse{\boolean{minted at finalizecache}}%
-       {%
-          \edef\minted at cachefilename{listing\arabic{minted at pygmentizecounter}.pygtex}%
-          \edef\minted at actualinfile{\minted at cachedir/\minted at cachefilename}%
-          \ifwindows
-            \StrSubstitute{\minted at infile}{/}{\@backslashchar}[\minted at infile@windows]
-            \StrSubstitute{\minted at actualinfile}{/}{\@backslashchar}[\minted at actualinfile@windows]
-            \ShellEscape{move /y \minted at outputdir\minted at infile@windows\space\minted at outputdir\minted at actualinfile@windows}%
-          \else
-            \ShellEscape{mv -f \minted at outputdir\minted at infile\space\minted at outputdir\minted at actualinfile}%
-          \fi
-          \let\minted at infile\minted at actualinfile
-          \expandafter\minted at addcachefile\expandafter{\minted at cachefilename}%
-       }%
-       {\ifthenelse{\boolean{minted at frozencache}}%
-         {%
-            \edef\minted at cachefilename{listing\arabic{minted at pygmentizecounter}.pygtex}%
-            \edef\minted at infile{\minted at cachedir/\minted at cachefilename}%
-            \expandafter\minted at addcachefile\expandafter{\minted at cachefilename}}%
-         {\expandafter\minted at addcachefile\expandafter{\minted at hash.pygtex}}%
-       }%
-      \minted at inputpyg}%
-    {%
-      \ifthenelse{\equal{\minted at get@opt{autogobble}{false}}{true}}{%
-        \minted at autogobble{#1}}{}%
-      \ShellEscape{\minted at cmd}%
-      \minted at inputpyg}%
-}
+      \expandafter\minted at defstyle@generate at error
+    \fi
+    {#1}}}
+\def\minted at defstyle@generate at i#1{%
+  \endgroup
+  \begingroup
+  \minted at catchfiledef{\minted at tmp}{\minted at styledeffilepath}%
+  \minted at tmp
+  \ifcsname\minted at styleprefix\endcsname
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+  {\expandafter\global\expandafter\let\csname minted at styledef@#1\endcsname\minted at tmp
+   \endgroup
+   \ifbool{minted at cache}{\minted at addcachefilename{\minted at styledeffilename}}{}%
+   \csname minted at styledef@#1\endcsname
+   \minted at patch@PygmentsStyledef
+   \minted at VerbatimPygments}%
+  {\endgroup
+   \minted at error{Failed to create style definition file "\minted at styledeffilename"
+     (no error message, see "\MintedErrlogFilename" if it exists);
+     attempting to substitute fallback style}%
+   \minted at defstyle@fallback{#1}}}
+\def\minted at defstyle@generate at error#1{%
+  \minted at exec@error
+  \endgroup
+  \minted at defstyle@fallback{#1}}
+\def\minted at defstyle@fallback#1{%
+  \ifstrequal{#1}{default}%
+   {\expandafter\global\expandafter
+      \let\csname minted at styledef@default\endcsname\minted at styledeffallback}%
+   {\ifcsname minted at styledef@default\endcsname
+    \else
+      \minted at defstyle@load{default}%
+    \fi
+    \expandafter\let\expandafter\minted at tmp\csname minted at styledef@default\endcsname
+    \expandafter\global\expandafter\let\csname minted at styledef@#1\endcsname\minted at tmp}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at autogobble}
-% Remove common leading whitespace.
+% \begin{macro}{\minted at 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 at autogobble#1{%
-  \edef\minted at argone@esc{#1}%
-  \StrSubstitute{\minted at argone@esc}{\@backslashchar}{\@backslashchar\@backslashchar}[\minted at argone@esc]%
-  \StrSubstitute{\minted at argone@esc}{"}{\@backslashchar"}[\minted at argone@esc]%
-  \edef\minted at tmpfname@esc{\minted at outputdir\minted at jobname}%
-  \StrSubstitute{\minted at tmpfname@esc}{\@backslashchar}{\@backslashchar\@backslashchar}[\minted at tmpfname@esc]%
-  \StrSubstitute{\minted at tmpfname@esc}{"}{\@backslashchar"}[\minted at tmpfname@esc]%
-  %Need a version of open() that supports encoding under Python 2
-  \minted at check@MintedPython
-  \edef\minted at autogobblecmd{%
-    \ifminted at kpsewhich
-      \ifwindows
-        \detokenize{for /f "usebackq tokens=*" }\@percentchar\detokenize{a in (`kpsewhich} #1\detokenize{`) do}\space
-      \fi
-    \fi
-    \MintedPython\detokenize{ -c "import sys; import os;
-    import textwrap;
-    from io import open;
-    fname = }%
-      \ifminted at kpsewhich
-        \detokenize{sys.argv[1];}\space
-      \else
-        \detokenize{os.path.expanduser(os.path.expandvars(\"}\minted at argone@esc\detokenize{\"));}\space
-      \fi
-    \detokenize{f = open(fname, \"r\", encoding=\"}\minted at encoding\detokenize{\") if os.path.isfile(fname) else None;
-    t = f.readlines() if f is not None else None;
-    t_opt = t if t is not None else [];
-    f.close() if f is not None else None;
-    tmpfname = os.path.expanduser(os.path.expandvars(\"}\minted at tmpfname@esc.pyg\detokenize{\"));
-    f = open(tmpfname, \"w\", encoding=\"}\minted at encoding\detokenize{\") if t is not None else None;
-    fvstartnum = }\the\numexpr\FancyVerbStartNum\detokenize{;
-    fvstopnum = }\the\numexpr\FancyVerbStopNum\detokenize{;
-    s = max(0, fvstartnum-1);
-    e = max(s, fvstopnum) if fvstopnum > 0 else len(t_opt);
-    [f.write(textwrap.dedent(\"\".join(x))) for x in (t_opt[0:s], t_opt[s:e], t_opt[e:]) if x and t is not None];
-    f.close() if t is not None else os.remove(tmpfname);"}%
-    \ifminted at kpsewhich
-      \ifwindows
-        \space\@percentchar\detokenize{a}%
-      \else
-        \space\detokenize{`}kpsewhich #1\space\detokenize{||} #1\detokenize{`}%
-      \fi
-    \fi
-  }%
-  \ShellEscape{\minted at autogobblecmd}%
-}
+\def\minted at styledeffallback{%
+  \expandafter\def\csname\minted at styleprefix\endcsname##1##2{##2}%
+  \expandafter\def\csname\minted at styleprefix Zbs\endcsname{\char`\\}%
+  \expandafter\def\csname\minted at styleprefix Zus\endcsname{\char`\_}%
+  \expandafter\def\csname\minted at styleprefix Zob\endcsname{\char`\{}%
+  \expandafter\def\csname\minted at styleprefix Zcb\endcsname{\char`\}}%
+  \expandafter\def\csname\minted at styleprefix Zca\endcsname{\char`\^}%
+  \expandafter\def\csname\minted at styleprefix Zam\endcsname{\char`\&}%
+  \expandafter\def\csname\minted at styleprefix Zlt\endcsname{\char`\<}%
+  \expandafter\def\csname\minted at styleprefix Zgt\endcsname{\char`\>}%
+  \expandafter\def\csname\minted at styleprefix Zsh\endcsname{\char`\#}%
+  \expandafter\def\csname\minted at styleprefix Zpc\endcsname{\char`\%}%
+  \expandafter\def\csname\minted at styleprefix Zdl\endcsname{\char`\$}%
+  \expandafter\def\csname\minted at styleprefix Zhy\endcsname{\char`\-}%
+  \expandafter\def\csname\minted at styleprefix Zsq\endcsname{\char`\'}%
+  \expandafter\def\csname\minted at styleprefix Zdq\endcsname{\char`\"}%
+  \expandafter\def\csname\minted at styleprefix Zti\endcsname{\char`\~}%
+  \minted at patch@PygmentsStyledef
+  \minted at VerbatimPygments}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at inputpyg}
-% For increased clarity, the actual |\input| process is separated out into its own macro.
 %
-% At the last possible moment, |\PYG| is |\let| to |\PYG|\meta{style} and redefined to used appropriate line breaking via |\VerbatimPygments| from \texpkg{fvextra}.
+% \subsubsection{Lexer-specific line numbering}
 %
-% The |bgcolor| option needs to be dealt with in different ways depending on whether we are using |\mintinline|.  It is simplest to apply this option here, so that the macro redefinitions may be local and thus do not need to be manually reset later.
+%
+% \begin{macro}{minted at 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}
-\newcommand{\minted at inputpyg}{%
-  \VerbatimPygments{\PYG}{\PYG}%
-  \ifthenelse{\boolean{minted at isinline}}%
-   {\ifthenelse{\equal{\minted at get@opt{breaklines}{false}}{true}}%
-    {\let\FV at BeginVBox\relax
-     \let\FV at EndVBox\relax
-     \def\FV at BProcessLine##1{\FancyVerbFormatLine{##1}}%
-     \minted at inputpyg@inline}%
-    {\minted at inputpyg@inline}}%
-   {\minted at inputpyg@block}%
-}
-\def\minted at inputpyg@inline{%
-  \ifthenelse{\equal{\minted at get@opt{bgcolor}{}}{}}%
-   {\minted at input{\minted at outputdir\minted at infile}}%
-   {\colorbox{\minted at get@opt{bgcolor}{}}{%
-      \minted at input{\minted at outputdir\minted at infile}}}%
-}
-\def\minted at inputpyg@block{%
-  \ifthenelse{\equal{\minted at get@opt{bgcolor}{}}{}}%
-   {\minted at input{\minted at outputdir\minted at infile}}%
-   {\begin{minted at colorbg}{\minted at get@opt{bgcolor}{}}%
-    \minted at input{\minted at outputdir\minted at infile}%
-    \end{minted at colorbg}}}
+\newcounter{minted at FancyVerbLineTemp}
 %    \end{macrocode}
 % \end{macro}
 %
-%
-% We need a way to have line counters on a per-language basis.
-%
-% \begin{macro}{\minted at langlinenoson}
+% \begin{macro}{\minted at lexerlinenoson,\minted at lexerlinenosoff,\minted at inputlexerlinenoson,\minted at inputlexerlinenosoff}
+% Line counters on a per-lexer basis for |minted| and |\mintinline|; line counters on a per-lexer basis for |\inputminted|.
 %    \begin{macrocode}
-\newcommand{\minted at langlinenoson}{%
-  \ifcsname c at minted@lang\minted at lang\endcsname\else
-    \newcounter{minted at lang\minted at lang}%
+\def\minted at lexerlinenoson{%
+  \ifcsname c at minted@lexer\minted at lexer\endcsname
+  \else
+    \newcounter{minted at lexer\minted at lexer}%
   \fi
   \setcounter{minted at FancyVerbLineTemp}{\value{FancyVerbLine}}%
-  \setcounter{FancyVerbLine}{\value{minted at lang\minted at lang}}%
-}
+  \setcounter{FancyVerbLine}{\value{minted at lexer\minted at lexer}}}
+\def\minted at lexerlinenosoff{%
+  \setcounter{minted at lexer\minted at lexer}{\value{FancyVerbLine}}%
+  \setcounter{FancyVerbLine}{\value{minted at FancyVerbLineTemp}}}
+\ifbool{minted at inputlexerlinenos}%
+ {\let\minted at inputlexerlinenoson\minted at lexerlinenoson
+  \let\minted at inputlexerlinenosoff\minted at lexerlinenosoff}%
+ {\let\minted at inputlexerlinenoson\relax
+  \let\minted at inputlexerlinenosoff\relax
+  \ifbool{minted at lexerlinenos}
+   {}%
+   {\let\minted at lexerlinenoson\relax
+    \let\minted at lexerlinenosoff\relax}}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\minted at langlinenosoff}
 %
+% \begin{macro}{\minted at codewrapper}
+% Wrapper around typeset code.  |\minted at inputfilepath| will exist when the code is brought in from an external file.
 %    \begin{macrocode}
-\newcommand{\minted at langlinenosoff}{%
-  \setcounter{minted at lang\minted at lang}{\value{FancyVerbLine}}%
-  \setcounter{FancyVerbLine}{\value{minted at FancyVerbLineTemp}}%
-}
+\def\minted at codewrapper#1{%
+  \ifcsname minted at inputfilepath\endcsname
+    \minted at inputlexerlinenoson
+  \else
+    \minted at lexerlinenoson
+  \fi
+  #1%
+  \ifcsname minted at inputfilepath\endcsname
+    \minted at inputlexerlinenosoff
+  \else
+    \minted at lexerlinenosoff
+  \fi}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% Disable the language-specific settings if the package option isn't used.
-%    \begin{macrocode}
-\ifbool{minted at langlinenos}{}{%
-  \ifbool{minted at inputlanglinenos}{}{%
-    \let\minted at langlinenoson\relax
-    \let\minted at langlinenosoff\relax
-  }
-}
-%    \end{macrocode}
 %
-% \begin{macro}{\minted at inputlanglinenoson}
-% \begin{macro}{\minted at inputlanglinenosoff}
-% Language-specific settings that apply to |\inputminted| in addition to |minted| and |\mintinline|.
+% \subsubsection{Highlighting code}
+%
+%
+% \begin{macro}{\minted at highlight,\minted at highlightinputfile}
+% Highlight code previously stored in buffer |minted at tmpdatabuffer|, or code in an external file.
+%
+% |\minted at defstyle| will invoke |\minted at detectconfig| the first time a style is loaded, so no separate |\minted at detectconfig| is needed.
+%
+% The default |\minted at 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}
-\ifbool{minted at inputlanglinenos}%
- {\def\minted at inputlanglinenoson{\minted at langlinenoson}%
-  \def\minted at inputlanglinenosoff{\minted at langlinenosoff}}%
- {\let\minted at inputlanglinenoson\relax
-  \let\minted at inputlanglinenosoff\relax}
+\def\minted at debug@input{%
+  \ifbool{minted at debug}%
+   {\immediate\typeout{%
+     minted debug: \string\input\space at
+     \ifx\CurrentFile\@empty\else\CurrentFile\space\fi line \the\inputlineno}}%
+   {}}
+\def\minted at highlight{%
+  \minted at defstyle
+  \pydatasetbuffername{minted at tmpdatabuffer}%
+  \pydatabufferkeyvalue{command}{highlight}%
+  \pydatabufferkey{code}%
+  \pydatabuffermlvaluestart
+  \setcounter{minted at tmpcnt}{1}%
+  \loop\unless\ifnum\value{minted at tmpcnt}>\value{minted at tmpcodebufferlength}\relax
+    \expandafter\let\expandafter
+      \minted at tmp\csname minted at tmpcodebufferline\arabic{minted at tmpcnt}\endcsname
+    \expandafter\pydatabuffermlvalueline\expandafter{\minted at tmp}%
+    \stepcounter{minted at tmpcnt}%
+  \repeat
+  \pydatabuffermlvalueend
+  \minted at highlight@i}
+\def\minted at highlightinputfile{%
+  \minted at defstyle
+  \edef\minted at inputfilemdfivesum{\pdf at filemdfivesum{\minted at inputfilepath}}%
+  \ifx\minted at inputfilemdfivesum\@empty
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+  {\minted at error{Cannot find input file "\minted at inputfilepath"; inserting placeholder}%
+   \minted at insertplaceholder}%
+  {\pydatasetbuffername{minted at tmpdatabuffer}%
+   \pydatabufferkeyvalue{command}{highlight}%
+   \pydatabufferkeyedefvalue{inputfilepath}{\minted at inputfilepath}%
+   \pydatabufferkeyedefvalue{inputfilemdfivesum}{\minted at inputfilemdfivesum}%
+   \minted at highlight@i}}
+\def\minted at def@FV at GetKeyValues@standardcatcodes{%
+  \let\minted at FV@GetKeyValues at orig\FV at GetKeyValues
+  \def\FV at GetKeyValues##1{%
+    \begingroup
+    \minted at standardcatcodes
+    \minted at FV@GetKeyValues at i{##1}}%
+  \def\minted at FV@GetKeyValues at i##1[##2]{%
+    \endgroup
+    \let\FV at GetKeyValues\minted at FV@GetKeyValues at orig
+    \let\minted at FV@GetKeyValues at i\minted at undefined
+    \FV at GetKeyValues{##1}[##2]}}
+\def\minted at highlight@i{%
+  \pydatabufferkeyedefvalue{pyopt.lexer}{\minted at lexer}%
+  \pydatabufferkeyedefvalue{pyopt.commandprefix}{\minted at styleprefix}%
+  \minted at forcsvlist{\minted at highlight@bufferpykeys}{\minted at optkeyslist@py}%
+  \ifbool{minted at cache}%
+   {\edef\minted at highlightfilename{\pydatabuffermdfivesum\detokenize{.highlight.minted}}%
+    \edef\minted at highlightfilepath{\minted at cachepath\minted at highlightfilename}%
+    \IfFileExists{\minted at highlightfilepath}%
+     {\minted at codewrapper{%
+        \minted at def@FV at GetKeyValues@standardcatcodes
+        \minted at debug@input
+        \input{\minted at highlightfilepath}}%
+      \minted at addcachefilename{\minted at highlightfilename}}%
+     {\ifbool{minted at canexec}%
+       {\minted at highlight@create}%
+       {\minted at error{Cannot highlight code (minted executable is unavailable or
+          disabled); attempting to typeset without highlighting}%
+        \minted at highlight@fallback}}}%
+   {\edef\minted at highlightfilename{%
+      \detokenize{_}\MintedJobnameMdfive\detokenize{.highlight.minted}}%
+    \let\minted at highlightfilepath\minted at highlightfilename
+    \ifbool{minted at canexec}%
+     {\minted at highlight@create}%
+     {\minted at error{Cannot highlight code (minted executable is unavailable or
+        disabled); attempting to typeset without highlighting}%
+      \minted at highlight@fallback}}%
+  \pydataclearbuffername{minted at tmpdatabuffer}}
+\def\minted at highlight@bufferpykeys#1{%
+  \edef\minted at tmp{\mintedpyoptvalueof{#1}}%
+  \ifx\minted at tmp\minted at const@pgfkeysnovalue
+  \else
+    \pydatabufferkeyedefvalue{pyopt.#1}{\minted at tmp}%
+  \fi}
+\def\minted at highlight@create{%
+  \pydatasetfilename{\MintedDataFilename}%
+  \minted at fasthighlightmode@checkstart
+  \pydatawritedictopen
+  \pydatawritebuffer
+  \pydatawritekeyedefvalue{jobname}{\jobname}%
+  \pydatawritekeyedefvalue{timestamp}{\minted at timestamp}%
+  \pydatawritekeyedefvalue{currentfilepath}{\CurrentFilePath}%
+  \pydatawritekeyedefvalue{currentfile}{\CurrentFile}%
+  \pydatawritekeyedefvalue{inputlineno}{\the\inputlineno}%
+  \pydatawritekeyedefvalue{cachepath}{\minted at cachepath}%
+  \pydatawritekeyedefvalue{highlightfilename}{\minted at highlightfilename}%
+  \pydatawritedictclose
+  \ifbool{minted at fasthighlightmode}%
+   {\minted at insertplaceholder}%
+   {\pydataclosefilename{\MintedDataFilename}%
+    \begingroup
+    \minted at exec@highlight
+    \IfFileExists{\minted at highlightfilepath}%
+     {\ifx\minted at exec@warning\relax
+      \else
+        \expandafter\minted at exec@warning
+      \fi
+      \ifx\minted at exec@error\relax
+      \else
+        \expandafter\minted at exec@error
+      \fi
+      \endgroup
+      \minted at codewrapper{%
+        \minted at def@FV at GetKeyValues@standardcatcodes
+        \minted at debug@input
+        \input{\minted at highlightfilepath}}%
+      \ifbool{minted at cache}{\minted at addcachefilename{\minted at highlightfilename}}{}}%
+     {\ifx\minted at exec@warning\relax
+      \else
+        \expandafter\minted at exec@warning
+      \fi
+      \ifx\minted at exec@error\relax
+        \minted at error{Minted executable failed during syntax highlighting
+          but returned no error message (see if "\MintedErrlogFilename" exists)}%
+      \else
+        \expandafter\minted at exec@error
+      \fi
+      \endgroup
+      \minted at highlight@fallback}}}
+\def\minted at highlight@fallback{%
+  \minted at insertplaceholder}
 %    \end{macrocode}
 % \end{macro}
-% \end{macro}
 %
 %
 %
 % \subsection{Public API}
 %
+%
 % \begin{macro}{\setminted}
-% Set global or language-level options.
+% Set global or lexer-level options.
 %    \begin{macrocode}
 \newcommand{\setminted}[2][]{%
-  \ifthenelse{\equal{#1}{}}%
-    {\setkeys{minted at opt@g}{#2}}%
-    {\minted at configlang{#1}%
-      \setkeys{minted at opt@lang}{#2}}}
+  \ifstrempty{#1}%
+   {\pgfkeys{/minted/global/.cd,#2}}%
+   {\let\minted at tmplexer\minted at lexer
+    \edef\minted at lexer{#1}%
+    \pgfkeys{/minted/lexer/.cd,#2}%
+    \let\minted at lexer\minted at tmplexer}}
 %    \end{macrocode}
 % \end{macro}
 %
+%
 % \begin{macro}{\setmintedinline}
-% Set global or language-level options, but only for inline (|\mintinline|) content.  These settings will override the corresponding |\setminted| settings.
+% 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][]{%
-  \ifthenelse{\equal{#1}{}}%
-    {\setkeys{minted at opt@g at i}{#2}}%
-    {\minted at configlang{#1}%
-      \setkeys{minted at opt@lang at i}{#2}}}
+  \ifstrempty{#1}%
+   {\pgfkeys{/minted/globalinline/.cd,#2}}%
+   {\let\minted at tmplexer\minted at lexer
+    \edef\minted at lexer{#1}%
+    \pgfkeys{/minted/lexerinline/.cd,#2}%
+    \let\minted at lexer\minted at tmplexer}}
 %    \end{macrocode}
 % \end{macro}
 %
-% Now that the settings macros exist, we go ahead and create any needed defaults.
 %
-% PHP should use |startinline| for |\mintinline|.  Visible tabs should have a specified color so that they don't change colors when used to indent multiline strings or comments.  Leading/trailing empty lines should be preserved by default.
-%    \begin{macrocode}
-\setmintedinline[php]{startinline=true}
-\setminted{tabcolor=black}
-\setminted{stripnl=false}
-%    \end{macrocode}
-%
 % \begin{macro}{\usemintedstyle}
-%
-% Set style.  This is a holdover from version 1, since |\setminted| can now accomplish this, and a hierarchy of style settings are now possible.
+% 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}
@@ -3332,37 +3776,12 @@
 % \end{macro}
 %
 %
-% \begin{macro}{\minted at defwhitespace@retok}
-% The |\mint| and |\mintinline| commands need to be able to retokenize the code they collect, particularly in |draft| mode.  Retokenizeation involves expansion combined with |\scantokens|, with active space and tab characters.  The active characters need to expand to the appropriate \texpkg{fancyvrb} macros, but the macros themselves should not be expanded.  We need a macro that will accomplish the appropriate definitions.
-%    \begin{macrocode}
-\begingroup
-\catcode`\ =\active
-\catcode`\^^I=\active
-\gdef\minted at defwhitespace@retok{\def {\noexpand\FV at Space}\def^^I{\noexpand\FV at Tab}}%
-\endgroup
-%    \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\minted at writecmdcode}
-% The |\mintinline| and |\mint| commands will need to write the code they capture to a temporary file for highlighting.  It will be convenient to be able to accomplish this via a simple macro, since that makes it simpler to deal with any expansion of what is to be written.  This isn't needed for the |minted| environment, because the (patched) |VerbatimOut| is used.
-%    \begin{macrocode}
-\newcommand{\minted at writecmdcode}[1]{%
-  \immediate\openout\minted at code\minted at jobname.pyg\relax
-  \immediate\write\minted at code{\detokenize{#1}}%
-  \immediate\closeout\minted at code}
-%    \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.
 %
-% Pygments emits code wrapped in a |Verbatim| environment.  Getting the inline command to work correctly requires redefining |Verbatim| to be \texpkg{fvextra}'s |VerbEnv| temporarily.
-%
 % Everything needs to be within a |\begingroup...\endgroup| to prevent settings from escaping.
 %
-% In the case of |draft| mode, \texpkg{fvextra}'s |\Verb| is used directly.
+% |\RobustMintInlineProcess at 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}
@@ -3372,37 +3791,56 @@
   \ifbool{FVExtraRobustCommandExpanded}%
    {\@ifnextchar\bgroup
      {\FVExtraReadVArg{\RobustMintInlineProcess{#1}{#2}}}%
-     {\PackageError{minted}%
-       {Inline delimiters must be paired curly braces in this context}%
-       {Use curly braces as delimiters}}}%
+     {\minted at error{Inline delimiters must be paired curly braces in this context}}}%
    {\FVExtraReadVArg{\RobustMintInlineProcess{#1}{#2}}}}
-\def\RobustMintInlineProcess#1#2#3{%
+\def\RobustMintInlineProcess at highlight#1#2#3{%
   \begingroup
-  \setboolean{minted at isinline}{true}%
-  \minted at configlang{#2}%
-  \setkeys{minted at opt@cmd}{#1}%
-  \minted at fvset
-  \RobustMintInlineProcess at i{#3}}
-\ifthenelse{\boolean{minted at draft}}%
- {\def\RobustMintInlineProcess at i#1{%
-    \fvset{extra=true}%
-    \Verb{#1}%
-    \endgroup}}%
- {\def\RobustMintInlineProcess at i#1{%
-   \FVExtraDetokenizeVArg{%
-     \FVExtraRetokenizeVArg{\RobustMintInlineProcess at ii}{\FV at CatCodes}}{#1}}
-  \def\RobustMintInlineProcess at ii#1{%
-    \minted at writecmdcode{#1}%
-    \let\Verbatim\VerbEnv
-    \let\endVerbatim\endVerbEnv
-    \expandafter\minted at pygmentize\expandafter{\minted at lang}%
-    \endgroup}}
+  \booltrue{minted at isinline}%
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \minted at usefvopts
+  \minted at usetexoptsnonpygments
+  \FVExtraDetokenizeVArg{%
+     \FVExtraRetokenizeVArg{\RobustMintInlineProcess at highlight@i}{\FV at CatCodes}}{#3}}
+\def\RobustMintInlineProcess at highlight@i#1{%
+  \expandafter\def\csname minted at tmpcodebufferline1\endcsname{#1}%
+  \setcounter{minted at tmpcodebufferlength}{1}%
+  \let\minted at highlight@fallback\RobustMintInlineProcess at highlight@fallback
+  \minted at highlight
+  \setcounter{minted at tmpcodebufferlength}{0}%
+  \endgroup}
+\def\RobustMintInlineProcess at highlight@fallback{%
+  \minted at useadditionalfvoptsnopy
+  \fvset{extra=true}%
+  \minted at codewrapper{%
+    \expandafter\let\expandafter\minted at tmp\csname minted at tmpcodebufferline1\endcsname
+    \expandafter\Verb\expandafter{\minted at tmp}}}
+\def\RobustMintInlineProcess at placeholder#1#2#3{%
+  \begingroup
+  \booltrue{minted at isinline}%
+  \minted at insertplaceholder
+  \endgroup}
+\def\RobustMintInlineProcess at verbatim#1#2#3{%
+  \begingroup
+  \booltrue{minted at isinline}%
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \minted at usefvopts
+  \minted at useadditionalfvoptsnopy
+  \minted at usetexoptsnonpygments
+  \fvset{extra=true}%
+  \minted at codewrapper{\Verb{#3}}%
+  \endgroup}
+\ifbool{minted at placeholder}%
+ {\let\RobustMintInlineProcess\RobustMintInlineProcess at placeholder}%
+ {\ifbool{minted at verbatim}%
+   {\let\RobustMintInlineProcess\RobustMintInlineProcess at verbatim}%
+   {\let\RobustMintInlineProcess\RobustMintInlineProcess at 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{%
@@ -3413,161 +3851,202 @@
   \ifbool{FVExtraRobustCommandExpanded}%
    {\@ifnextchar\bgroup
      {\FVExtraReadVArg{\RobustMintProcess{#1}{#2}}}%
-     {\PackageError{minted}%
-       {Delimiters must be paired curly braces in this context}%
-       {Use curly braces as delimiters}}}%
+     {\minted at error{Delimiters must be paired curly braces in this context}}}%
    {\FVExtraReadVArg{\RobustMintProcess{#1}{#2}}}}
-\def\RobustMintProcess#1#2#3{%
+\def\RobustMintProcess at highlight#1#2#3{%
   \begingroup
-  \minted at configlang{#2}%
-  \setkeys{minted at opt@cmd}{#1}%
-  \minted at fvset
-  \RobustMintProcess at i{#3}}
-\begingroup
-\catcode`\^^M=\active%
-\catcode`\<=1%
-\catcode`\>=2%
-\catcode`\{=12%
-\catcode`\}=12%
-\catcode`\!=0%
-\catcode`\\=12%
-!ifthenelse<!boolean<minted at draft>>%
- <!gdef!RobustMintProcess at i#1<%
-    !FVExtraDetokenizeVArg<%
-      !FVExtraRetokenizeVArg<!RobustMintProcess at ii><!FV at CatCodes>><#1>>%
-  !gdef!RobustMintProcess at ii#1<%
-    !minted at langlinenoson%
-    !scantokens<%
-      \begin{Verbatim}
-      #1
-      \end{Verbatim}
-      !noexpand>%
-    !minted at langlinenosoff%
-    !endgroup!@doendpe>>%
- <!gdef!RobustMintProcess at i#1<%
-    !FVExtraDetokenizeVArg<%
-      !FVExtraRetokenizeVArg<!RobustMintProcess at ii><!FV at CatCodes>><#1>>%
-  !gdef!RobustMintProcess at ii#1<%
-    !minted at writecmdcode<#1>%
-    !minted at langlinenoson%
-    !expandafter!minted at pygmentize!expandafter<!minted at lang>%
-    !minted at langlinenosoff%
-    !endgroup!@doendpe>>%
-!endgroup
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \minted at usefvopts
+  \minted at usetexoptsnonpygments
+  \FVExtraDetokenizeVArg{%
+    \FVExtraRetokenizeVArg{\RobustMintProcess at highlight@i}{\FV at CatCodes}}{#3}}
+\def\RobustMintProcess at highlight@i#1{%
+  \expandafter\def\csname minted at tmpcodebufferline1\endcsname{#1}%
+  \setcounter{minted at tmpcodebufferlength}{1}%
+  \let\minted at highlight@fallback\RobustMintProcess at highlight@fallback
+  \minted at highlight
+  \setcounter{minted at tmpcodebufferlength}{0}%
+  \endgroup}
+\def\RobustMintProcess at highlight@fallback{%
+  \minted at useadditionalfvoptsnopy
+  \minted at codewrapper{%
+    \VerbatimInsertBuffer[buffername=minted at tmpcodebuffer,insertenvname=\minted at envname]}}
+\def\RobustMintProcess at placeholder#1#2#3{%
+  \minted at insertplaceholder}
+\def\RobustMintProcess at verbatim#1#2#3{%
+  \begingroup
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \minted at usefvopts
+  \minted at useadditionalfvoptsnopy
+  \minted at usetexoptsnonpygments
+  \FVExtraDetokenizeVArg{%
+    \FVExtraRetokenizeVArg{\RobustMintProcess at verbatim@i}{\FV at CatCodes}}{#3}}
+\def\RobustMintProcess at verbatim@i#1{%
+  \expandafter\def\csname minted at tmpcodebufferline1\endcsname{#1}%
+  \setcounter{minted at tmpcodebufferlength}{1}%
+  \minted at codewrapper{%
+    \VerbatimInsertBuffer[buffername=minted at tmpcodebuffer,insertenvname=\minted at envname]}%
+  \setcounter{minted at tmpcodebufferlength}{0}%
+  \endgroup}
+\ifbool{minted at placeholder}%
+ {\let\RobustMintProcess\RobustMintProcess at placeholder}%
+ {\ifbool{minted at verbatim}%
+   {\let\RobustMintProcess\RobustMintProcess at verbatim}%
+   {\let\RobustMintProcess\RobustMintProcess at highlight}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
 % \begin{environment}{minted}
-%
 % Highlight a longer piece of code inside a verbatim environment.
 %    \begin{macrocode}
-\ifthenelse{\boolean{minted at draft}}%
-  {\newenvironment{minted}[2][]
-    {\VerbatimEnvironment
-      \minted at configlang{#2}%
-      \setkeys{minted at opt@cmd}{#1}%
-      \minted at fvset
-      \minted at langlinenoson
-      \begin{Verbatim}}%
-    {\end{Verbatim}%
-      \minted at langlinenosoff}}%
-  {\newenvironment{minted}[2][]
-    {\VerbatimEnvironment
-      \let\FVB at VerbatimOut\minted at FVB@VerbatimOut
-      \let\FVE at VerbatimOut\minted at FVE@VerbatimOut
-      \minted at configlang{#2}%
-      \setkeys{minted at opt@cmd}{#1}%
-      \minted at fvset
-      \begin{VerbatimOut}[codes={\catcode`\^^I=12},firstline,lastline]{\minted at jobname.pyg}}%
-    {\end{VerbatimOut}%
-        \minted at langlinenoson
-        \expandafter\minted at pygmentize\expandafter{\minted at lang}%
-        \minted at langlinenosoff}}
+\newenvironment{minted}[2][]%
+ {\VerbatimEnvironment
+  \MintedBegin{#1}{#2}}%
+ {\MintedEnd}
+\def\MintedBegin at highlight#1#2{%
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \minted at usefvopts
+  \minted at usetexoptsnonpygments
+  \begin{VerbatimBuffer}[buffername=minted at tmpcodebuffer,globalbuffer=true]}
+\def\MintedEnd at highlight{%
+  \end{VerbatimBuffer}%
+  \let\minted at highlight@fallback\MintedEnv at highlight@fallback
+  \minted at highlight
+  \VerbatimClearBuffer[buffername=minted at tmpcodebuffer]}
+\def\MintedEnv at highlight@fallback{%
+  \minted at useadditionalfvoptsnopy
+  \minted at codewrapper{%
+    \VerbatimInsertBuffer[buffername=minted at tmpcodebuffer,insertenvname=\minted at envname]}}
+\def\MintedBegin at placeholder#1#2{%
+  \begin{VerbatimBuffer}[buffername=minted at tmpcodebuffer]}
+\def\MintedEnd at placeholder{%
+  \end{VerbatimBuffer}%
+  \minted at insertplaceholder}
+\def\MintedBegin at verbatim#1#2{%
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \minted at usefvopts
+  \minted at useadditionalfvoptsnopy
+  \minted at usetexoptsnonpygments
+  \begin{\minted at envname}}
+\def\MintedEnd at verbatim{%
+  \end{\minted at envname}}
+\ifbool{minted at placeholder}%
+ {\let\MintedBegin\MintedBegin at placeholder
+  \let\MintedEnd\MintedEnd at placeholder}%
+ {\ifbool{minted at verbatim}%
+   {\let\MintedBegin\MintedBegin at verbatim
+    \let\MintedEnd\MintedEnd at verbatim}%
+   {\let\MintedBegin\MintedBegin at highlight
+    \let\MintedEnd\MintedEnd at highlight}}
 %    \end{macrocode}
 % \end{environment}
 %
+%
 % \begin{macro}{\inputminted}
-%
 % Highlight an external source file.
 %    \begin{macrocode}
-\ifthenelse{\boolean{minted at draft}}%
-  {\newcommand{\inputminted}[3][]{%
-    \begingroup
-    \minted at configlang{#2}%
-    \setkeys{minted at opt@cmd}{#1}%
-    \minted at fvset
-    \minted at inputlanglinenoson
-    \VerbatimInput{#3}%
-    \minted at inputlanglinenosoff
-    \endgroup}}%
-  {\newcommand{\inputminted}[3][]{%
-    \begingroup
-    \minted at configlang{#2}%
-    \setkeys{minted at opt@cmd}{#1}%
-    \minted at fvset
-    \minted at inputlanglinenoson
-    \minted at pygmentize[#3]{#2}%
-    \minted at inputlanglinenosoff
-    \endgroup}}
+\def\minted at readinputmintedargs#1#{%
+  \minted at readinputmintedargs@i{#1}}
+\def\minted at readinputmintedargs@i#1#2#3{%
+  \FVExtraAlwaysUnexpanded{\minted at readinputmintedargs#1{#2}{#3}}}
+\FVExtrapdfstringdefDisableCommands{%
+  \makeatletter
+  \def\minted at readinputmintedargs@i#1#2#3{%
+    \detokenize{<input from file "}#3\detokenize{">}}%
+  \makeatother}
+\def\inputminted{%
+  \FVExtraRobustCommand\RobustInputMinted\minted at readinputmintedargs}
+\FVExtrapdfstringdefDisableCommands{%
+  \def\RobustInputMinted{}}
+\newrobustcmd{\RobustInputMinted}[3][]{%
+  \RobustInputMintedProcess{#1}{#2}{#3}}
+\def\RobustInputMintedProcess at highlight#1#2#3{%
+  \begingroup
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \edef\minted at inputfilepath{#3}%
+  \minted at usefvopts
+  \minted at usetexoptsnonpygments
+  \let\minted at highlight@fallback\RobustInputMintedProcess at highlight@fallback
+  \minted at highlightinputfile
+  \endgroup}
+\def\RobustInputMintedProcess at highlight@fallback{%
+  \minted at useadditionalfvoptsnopy
+  \minted at codewrapper{%
+    \csname\minted at envname Input\endcsname{\minted at inputfilepath}}}
+\def\RobustInputMintedProcess at placeholder#1#2#3{%
+  \minted at insertplaceholder}
+\def\RobustInputMintedProcess at verbatim#1#2#3{%
+  \begingroup
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \edef\minted at inputfilepath{#3}%
+  \minted at usefvopts
+  \minted at useadditionalfvoptsnopy
+  \minted at usetexoptsnonpygments
+  \minted at codewrapper{%
+    \csname\minted at envname Input\endcsname{\minted at inputfilepath}}%
+  \endgroup}
+\ifbool{minted at placeholder}%
+ {\let\RobustInputMintedProcess\RobustInputMintedProcess at placeholder}%
+ {\ifbool{minted at verbatim}%
+   {\let\RobustInputMintedProcess\RobustInputMintedProcess at verbatim}%
+   {\let\RobustInputMintedProcess\RobustInputMintedProcess at highlight}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
+%
 % \subsection{Command shortcuts}
 %
-% We allow the user to define shortcuts for the highlighting commands.
+% Allow the user to define shortcuts for the highlighting commands.
 %
 % \begin{macro}{\newminted}
-%
 % Define a new language-specific alias for the |minted| environment.
 %
-%    \begin{macrocode}
-\newcommand{\newminted}[3][]{
-%    \end{macrocode}
+% 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.
 %
-% First, we look whether a custom environment name was given as the first
-% optional argument.
-% If that's not the case, construct it from the language name (append ``|code|'').
-%
+% 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}
-  \ifthenelse{\equal{#1}{}}
-    {\def\minted at envname{#2code}}
-    {\def\minted at envname{#1}}
+\newcommand{\newminted}[3][]{%
+  \ifstrempty{#1}%
+   {\newminted at i{#2code}{#2}{#3}}%
+   {\newminted at i{#1}{#2}{#3}}}
+\begingroup
+\catcode`\^^M=\active%
+\gdef\newminted at i#1#2#3{%
+  \expandafter\def\csname#1 at i\endcsname##1{%
+    \begin{minted}[#3,##1]{#2}^^M}%
+  \newenvironment{#1}%
+   {\VerbatimEnvironment%
+    \FVExtraReadOArgBeforeVEnv{\csname#1 at i\endcsname}}%
+   {\end{minted}}%
+  \newenvironment{#1*}[1]%
+   {\VerbatimEnvironment%
+    \begin{minted}[#3,##1]{#2}}%
+   {\end{minted}}}%
+\endgroup
 %    \end{macrocode}
-%
-% Now, we define two environments.
-% The first takes no further arguments.
-% The second, starred version, takes an extra argument that specifies option
-% overrides.
-%
-%    \begin{macrocode}
-  \newenvironment{\minted at envname}
-    {\VerbatimEnvironment
-      \begin{minted}[#3]{#2}}
-    {\end{minted}}
-  \newenvironment{\minted at envname *}[1]
-    {\VerbatimEnvironment\begin{minted}[#3,##1]{#2}}
-    {\end{minted}}}
-%    \end{macrocode}
 % \end{macro}
 %
 %
 % \begin{macro}{\newmint}
-%
 % Define a new language-specific alias for the |\mint| short form.
 %    \begin{macrocode}
 \newcommand{\newmint}[3][]{%
-  \if\relax\detokenize{#1}\relax
-    \def\minted at shortname{#2}%
-  \else
-    \def\minted at shortname{#1}%
-  \fi
-  \expandafter\newmint at i\expandafter{\minted at shortname}{#2}{#3}}
+  \ifstrempty{#1}%
+   {\edef\minted at tmp{#2}}%
+   {\edef\minted at tmp{#1}}
+  \expandafter\newmint at i\expandafter{\minted at tmp}{#2}{#3}}
 \def\newmint at i#1#2#3{%
   \expandafter\newcommand\csname#1\endcsname{%
     \expandafter\FVExtraRobustCommand\csname RobustNewMint#1\endcsname
-      \FVExtraUnexpandedReadStarOArgBVArg}%
+    \FVExtraUnexpandedReadStarOArgBVArg}%
   \FVExtrapdfstringdefDisableCommands{%
     \expandafter\def\csname RobustNewMint#1\endcsname{}}%
   \expandafter\newrobustcmd\csname RobustNewMint#1\endcsname{%
@@ -3576,9 +4055,7 @@
     \ifbool{FVExtraRobustCommandExpanded}%
      {\@ifnextchar\bgroup
        {\FVExtraReadVArg{\csname RobustNewMint#1 at ii\endcsname{##1}}}%
-       {\PackageError{minted}%
-         {Delimiters must be paired curly braces in this context}%
-         {Use curly braces as delimiters}}}%
+       {\minted at error{Delimiters must be paired curly braces in this context}}}%
      {\FVExtraReadVArg{\csname RobustNewMint#1 at ii\endcsname{##1}}}}
   \expandafter\def\csname RobustNewMint#1 at ii\endcsname##1##2{%
     \RobustMintProcess{#3,##1}{#2}{##2}}}
@@ -3587,24 +4064,31 @@
 %
 %
 % \begin{macro}{\newmintedfile}
-%
 % Define a new language-specific alias for |\inputminted|.
 %    \begin{macrocode}
-\newcommand{\newmintedfile}[3][]{
+\def\minted at readnewmintedfileargs#1#{%
+  \minted at readnewmintedfileargs@i{#1}}
+\def\minted at readnewmintedfileargs@i#1#2{%
+  \FVExtraAlwaysUnexpanded{\minted at readnewmintedfileargs#1{#2}}}
+\FVExtrapdfstringdefDisableCommands{%
+  \makeatletter
+  \def\minted at readnewmintedfileargs@i#1#2{%
+    \detokenize{<input from file "}#2\detokenize{">}}%
+  \makeatother}
+\newcommand{\newmintedfile}[3][]{%
+  \ifstrempty{#1}%
+   {\edef\minted at tmp{#2file}}%
+   {\edef\minted at tmp{#1}}%
+  \expandafter\newmintedfile at i\expandafter{\minted at tmp}{#2}{#3}}
+\def\newmintedfile at i#1#2#3{%
+  \expandafter\newcommand\csname#1\endcsname{%
+    \expandafter\FVExtraRobustCommand\csname RobustNewMintedFile#1\endcsname
+    \minted at readnewmintedfileargs}%
+  \FVExtrapdfstringdefDisableCommands{%
+    \expandafter\def\csname RobustNewMintedFile#1\endcsname{}}%
+  \expandafter\newrobustcmd\csname RobustNewMintedFile#1\endcsname[2][]{%
+    \RobustInputMintedProcess{#3,##1}{#2}{##2}}}
 %    \end{macrocode}
-% Here, the default macro name (if none is provided) appends ``|file|'' to the language name.
-%    \begin{macrocode}
-  \ifthenelse{\equal{#1}{}}
-    {\def\minted at shortname{#2file}}
-    {\def\minted at shortname{#1}}
-%    \end{macrocode}
-%
-% \dots and define the macro.
-%
-%    \begin{macrocode}
-  \expandafter\newcommand\csname\minted at shortname\endcsname[2][]{
-    \inputminted[#3,##1]{#2}{##2}}}
-%    \end{macrocode}
 % \end{macro}
 %
 %
@@ -3612,16 +4096,14 @@
 % Define an alias for |\mintinline|.
 %    \begin{macrocode}
 \newcommand{\newmintinline}[3][]{%
-  \if\relax\detokenize{#1}\relax
-    \def\minted at shortname{#2inline}%
-  \else
-    \def\minted at shortname{#1}%
-  \fi
-  \expandafter\newmintinline at i\expandafter{\minted at shortname}{#2}{#3}}
+  \ifstrempty{#1}%
+   {\edef\minted at tmp{#2inline}}%
+   {\edef\minted at tmp{#1}}%
+  \expandafter\newmintinline at i\expandafter{\minted at tmp}{#2}{#3}}
 \def\newmintinline at i#1#2#3{%
   \expandafter\newcommand\csname#1\endcsname{%
     \expandafter\FVExtraRobustCommand\csname RobustNewMintInline#1\endcsname
-      \FVExtraUnexpandedReadStarOArgBVArg}%
+    \FVExtraUnexpandedReadStarOArgBVArg}%
   \FVExtrapdfstringdefDisableCommands{%
     \expandafter\def\csname RobustNewMintInline#1\endcsname{}}%
   \expandafter\newrobustcmd\csname RobustNewMintInline#1\endcsname{%
@@ -3630,9 +4112,7 @@
     \ifbool{FVExtraRobustCommandExpanded}%
      {\@ifnextchar\bgroup
        {\FVExtraReadVArg{\csname RobustNewMintInline#1 at ii\endcsname{##1}}}%
-       {\PackageError{minted}%
-         {Inline delimiters must be paired curly braces in this context}%
-         {Use curly braces as delimiters}}}%
+       {\minted at error{Inline delimiters must be paired curly braces in this context}}}%
      {\FVExtraReadVArg{\csname RobustNewMintInline#1 at ii\endcsname{##1}}}}
   \expandafter\def\csname RobustNewMintInline#1 at ii\endcsname##1##2{%
     \RobustMintInlineProcess{#3,##1}{#2}{##2}}}
@@ -3640,22 +4120,22 @@
 % \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}
-\ifthenelse{\boolean{minted at newfloat}}%
+\ifbool{minted at newfloat}%
  {\@ifundefined{minted at float@within}%
-    {\DeclareFloatingEnvironment[fileext=lol,placement=tbp]{listing}}%
-    {\def\minted at tmp#1{%
-       \DeclareFloatingEnvironment[fileext=lol,placement=tbp, within=#1]{listing}}%
-     \expandafter\minted at tmp\expandafter{\minted at float@within}}}%
+   {\DeclareFloatingEnvironment[fileext=lol,placement=tbp]{listing}}%
+   {\def\minted at tmp#1{%
+      \DeclareFloatingEnvironment[fileext=lol,placement=tbp,within=#1]{listing}}%
+    \expandafter\minted at tmp\expandafter{\minted at float@within}}}%
  {\@ifundefined{minted at float@within}%
-    {\newfloat{listing}{tbp}{lol}}%
-    {\newfloat{listing}{tbp}{lol}[\minted at float@within]}}
+   {\newfloat{listing}{tbp}{lol}}%
+   {\newfloat{listing}{tbp}{lol}[\minted at float@within]}}
 %    \end{macrocode}
 % \end{environment}
 %
@@ -3665,16 +4145,13 @@
 %    \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}
@@ -3681,9 +4158,7 @@
 % \end{macro}
 %
 % \begin{macro}{\listoflistingscaption}
-%
 % The caption that is displayed for the list of listings.
-%
 %    \begin{macrocode}
 \newcommand{\listoflistingscaption}{List of Listings}
 %    \end{macrocode}
@@ -3690,11 +4165,9 @@
 % \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}
@@ -3705,323 +4178,11 @@
 \fi
 %    \end{macrocode}
 %
-% \subsection{Epilogue}
 %
-% Check whether LaTeX was invoked with |-shell-escape| option, set the default style, and make sure |pygmentize| exists.  Checking for |pygmentize| must wait until the end of the preamble, in case it is specified via |\MintedPygmentize| (which would typically be after the package is loaded).
-%
-%    \begin{macrocode}
-\AtEndOfPackage{%
-  \ifthenelse{\boolean{minted at draft}}%
-   {}%
-   {%
-    \ifthenelse{\boolean{minted at frozencache}}{}{%
-      \ifnum\pdf at shellescape=1\relax\else
-        \PackageError{minted}%
-         {You must invoke LaTeX with the
-          -shell-escape flag}%
-         {Pass the -shell-escape flag to LaTeX. Refer to the minted.sty
-          documentation for more information.}%
-      \fi}%
-   }%
-}
-\AtEndPreamble{%
-  \ifthenelse{\boolean{minted at draft}}%
-   {}%
-   {%
-    \ifthenelse{\boolean{minted at frozencache}}{}{%
-      \TestAppExists{\MintedPygmentize}%
-      \ifAppExists\else
-        \PackageError{minted}%
-         {You must have `pygmentize' installed
-          to use this package}%
-         {Refer to the installation instructions in the minted
-          documentation for more information.}%
-      \fi}%
-  }%
-}
-%    \end{macrocode}
-%
-%
-%
-% \subsection{Final cleanup}
-%
-% Clean up temp files.  What actually needs to be done depends on caching and engine.
-%    \begin{macrocode}
-\AfterEndDocument{%
-  \ifthenelse{\boolean{minted at draft}}%
-   {}%
-   {\ifthenelse{\boolean{minted at frozencache}}%
-     {}
-     {\ifx\XeTeXinterchartoks\minted at undefined
-      \else
-        \DeleteFile[\minted at outputdir]{\minted at jobname.mintedcmd}%
-        \DeleteFile[\minted at outputdir]{\minted at jobname.mintedmd5}%
-      \fi
-      \DeleteFile[\minted at outputdir]{\minted at jobname.pyg}%
-      \DeleteFile[\minted at outputdir]{\minted at jobname.out.pyg}%
-     }%
-   }%
-}
-%    \end{macrocode}
-%
 % \iffalse
 %</package>
 % \fi
 %
 %
-%
-% \section{Implementation of compatibility package}
-% \setcounter{CodelineNo}{0}
-%
-% \iffalse
-%<*packageone>
-% \fi
-%
-% \texpkg{minted} version 2 is designed to be completely compatible with version 1.7.  All of the same options and commands still exist.  As far as most users are concerned, the only difference should be the new commands and options.
-%
-% However, \texpkg{minted} 2 does require some additional packages compared to \texpkg{minted} 1.7.  More importantly, since \texpkg{minted} 2 has almost completely new internal code, user code that accessed the internals of 1.7 will generally not work with 2.0, at least not without some modification.  For these reasons, a copy of \texpkg{minted} 1.7 is supplied as the package \texpkg{minted1}.  This is intended \emph{only} for compatibility cases when using the current version is too inconvenient.
-%
-% The code in \texpkg{minted1} is an exact copy of \texpkg{minted} version 1.7, except for two things:  (1) the package has been renamed, and (2) code has been added that allows \texpkg{minted1} to act as (impersonate) \texpkg{minted}, so that it can cooperate with other packages that require \texpkg{minted} to be loaded.\footnote{The approach used for doing this is described at \url{http://tex.stackexchange.com/a/39418/10742}.}  When \texpkg{minted1} is used, it must be loaded \emph{before} any other packages that would require \texpkg{minted}.
-%
-% All modifications to the original \texpkg{minted} 1.7 source are indicated with comments.  All original code that has been replaced has been commented out rather than deleted.  Any future modifications of \texpkg{minted1} should \emph{only} be for the purpose of allowing it to serve better as a drop-in compatibility substitute for the current release of \texpkg{minted}.
-%
-%    \begin{macrocode}
-\NeedsTeXFormat{LaTeX2e}
-%%%% Begin minted1 modification
-%%\ProvidesPackage{minted}[2011/09/17 v1.7 Yet another Pygments shim for LaTeX]
-\ProvidesPackage{minted1}[2015/01/31 v1.0 minted 1.7 compatibility package]
-%%%% End minted1 modification
-\RequirePackage{keyval}
-\RequirePackage{fancyvrb}
-\RequirePackage{xcolor}
-\RequirePackage{float}
-\RequirePackage{ifthen}
-%%%% Begin minted1 modification
-\newboolean{mintedone at mintedloaded}
-\@ifpackageloaded{minted}%
- {\setboolean{mintedone at mintedloaded}{true}%
-  \PackageError{minted1}{The package "minted1" may not be loaded after
-      ^^J"minted" has already been loaded--load "minted1" only for "minted"
-      ^^Jversion 1.7 compatibility}%
-   {Load "minted1" only when "minted" version 1.7 compatibility is required}}%
- {}
-\ifmintedone at mintedloaded\else
-\@namedef{ver at minted.sty}{2011/09/17 v1.7 Yet another Pygments shim for LaTeX}
-\expandafter\let\expandafter\minted at tmp\csname opt at minted1.sty\endcsname
-\expandafter\let\csname opt at minted.sty\endcsname\minted at tmp
-\let\minted at tmp\relax
-%%%% End minted1 modification
-\RequirePackage{calc}
-\RequirePackage{ifplatform}
-\DeclareOption{chapter}{\def\minted at float@within{chapter}}
-\DeclareOption{section}{\def\minted at float@within{section}}
-\ProcessOptions\relax
-\ifwindows
-  \providecommand\DeleteFile[1]{\immediate\write18{del #1}}
-\else
-  \providecommand\DeleteFile[1]{\immediate\write18{rm #1}}
-\fi
-\newboolean{AppExists}
-\newcommand\TestAppExists[1]{
-  \ifwindows
-    \DeleteFile{\jobname.aex}
-    \immediate\write18{for \string^\@percentchar i in (#1.exe #1.bat #1.cmd)
-      do set >\jobname.aex <nul: /p x=\string^\@percentchar \string~$PATH:i>>\jobname.aex} %$
-    \newread\@appexistsfile
-    \immediate\openin\@appexistsfile\jobname.aex
-    \expandafter\def\expandafter\@tmp at cr\expandafter{\the\endlinechar}
-    \endlinechar=-1\relax
-    \readline\@appexistsfile to \@apppathifexists
-    \endlinechar=\@tmp at cr
-    \ifthenelse{\equal{\@apppathifexists}{}}
-     {\AppExistsfalse}
-     {\AppExiststrue}
-    \immediate\closein\@appexistsfile
-    \DeleteFile{\jobname.aex}
-\immediate\typeout{file deleted}
-  \else
-    \immediate\write18{which #1 && touch \jobname.aex}
-    \IfFileExists{\jobname.aex}
-     {\AppExiststrue
-      \DeleteFile{\jobname.aex}}
-     {\AppExistsfalse}
-  \fi}
-\newcommand\minted at resetoptions{}
-\newcommand\minted at defopt[1]{
-  \expandafter\def\expandafter\minted at resetoptions\expandafter{%
-    \minted at resetoptions
-    \@namedef{minted at opt@#1}{}}}
-\newcommand\minted at opt[1]{
-  \expandafter\detokenize%
-    \expandafter\expandafter\expandafter{\csname minted at opt@#1\endcsname}}
-\newcommand\minted at define@opt[3][]{
-  \minted at defopt{#2}
-  \ifthenelse{\equal{#1}{}}{
-    \define at key{minted at opt}{#2}{\@namedef{minted at opt@#2}{#3}}}
-   {\define at key{minted at opt}{#2}[#1]{\@namedef{minted at opt@#2}{#3}}}}
-\newcommand\minted at define@switch[3][]{
-  \minted at defopt{#2}
-  \define at booleankey{minted at opt}{#2}
-   {\@namedef{minted at opt@#2}{#3}}
-   {\@namedef{minted at opt@#2}{#1}}}
-\minted at defopt{extra}
-\newcommand\minted at define@extra[1]{
-  \define at key{minted at opt}{#1}{
-    \expandafter\def\expandafter\minted at opt@extra\expandafter{%
-      \minted at opt@extra,#1=##1}}}
-\newcommand\minted at define@extra at switch[1]{
-  \define at booleankey{minted at opt}{#1}
-   {\expandafter\def\expandafter\minted at opt@extra\expandafter{%
-      \minted at opt@extra,#1}}
-   {\expandafter\def\expandafter\minted at opt@extra\expandafter{%
-      \minted at opt@extra,#1=false}}}
-\minted at define@switch{texcl}{-P texcomments}
-\minted at define@switch{mathescape}{-P mathescape}
-\minted at define@switch{linenos}{-P linenos}
-\minted at define@switch{startinline}{-P startinline}
-\minted at define@switch[-P funcnamehighlighting=False]%
-  {funcnamehighlighting}{-P funcnamehighlighting}
-\minted at define@opt{gobble}{-F gobble:n=#1}
-\minted at define@opt{bgcolor}{#1}
-\minted at define@extra{frame}
-\minted at define@extra{framesep}
-\minted at define@extra{framerule}
-\minted at define@extra{rulecolor}
-\minted at define@extra{numbersep}
-\minted at define@extra{firstnumber}
-\minted at define@extra{stepnumber}
-\minted at define@extra{firstline}
-\minted at define@extra{lastline}
-\minted at define@extra{baselinestretch}
-\minted at define@extra{xleftmargin}
-\minted at define@extra{xrightmargin}
-\minted at define@extra{fillcolor}
-\minted at define@extra{tabsize}
-\minted at define@extra{fontfamily}
-\minted at define@extra{fontsize}
-\minted at define@extra{fontshape}
-\minted at define@extra{fontseries}
-\minted at define@extra{formatcom}
-\minted at define@extra{label}
-\minted at define@extra at switch{numberblanklines}
-\minted at define@extra at switch{showspaces}
-\minted at define@extra at switch{resetmargins}
-\minted at define@extra at switch{samepage}
-\minted at define@extra at switch{showtabs}
-\minted at define@extra at switch{obeytabs}
-\newsavebox{\minted at bgbox}
-\newenvironment{minted at colorbg}[1]{
-  \def\minted at bgcol{#1}
-  \noindent
-  \begin{lrbox}{\minted at bgbox}
-  \begin{minipage}{\linewidth-2\fboxsep}}
- {\end{minipage}
-  \end{lrbox}%
-  \colorbox{\minted at bgcol}{\usebox{\minted at bgbox}}}
-\newwrite\minted at code
-\newcommand\minted at savecode[1]{
-  \immediate\openout\minted at code\jobname.pyg
-  \immediate\write\minted at code{#1}
-  \immediate\closeout\minted at code}
-\newcommand\minted at pygmentize[2][\jobname.pyg]{
-  \def\minted at cmd{pygmentize -l #2 -f latex -F tokenmerge
-    \minted at opt{gobble} \minted at opt{texcl} \minted at opt{mathescape}
-    \minted at opt{startinline} \minted at opt{funcnamehighlighting}
-    \minted at opt{linenos} -P "verboptions=\minted at opt{extra}"
-    -o \jobname.out.pyg #1}
-  \immediate\write18{\minted at cmd}
-  % For debugging, uncomment:
-  %\immediate\typeout{\minted at cmd}
-  \ifthenelse{\equal{\minted at opt@bgcolor}{}}
-   {}
-   {\begin{minted at colorbg}{\minted at opt@bgcolor}}
-  \input{\jobname.out.pyg}
-  \ifthenelse{\equal{\minted at opt@bgcolor}{}}
-   {}
-   {\end{minted at colorbg}}
-  \DeleteFile{\jobname.out.pyg}}
-\newcommand\minted at usedefaultstyle{\usemintedstyle{default}}
-\newcommand\usemintedstyle[1]{
-  \renewcommand\minted at usedefaultstyle{}
-  \immediate\write18{pygmentize -S #1 -f latex > \jobname.pyg}
-  \input{\jobname.pyg}}
-\newcommand\mint[3][]{
-  \DefineShortVerb{#3}
-  \minted at resetoptions
-  \setkeys{minted at opt}{#1}
-  \SaveVerb[aftersave={
-    \UndefineShortVerb{#3}
-    \minted at savecode{\FV at SV@minted at verb}
-    \minted at pygmentize{#2}
-    \DeleteFile{\jobname.pyg}}]{minted at verb}#3}
-\newcommand\minted at proglang[1]{}
-\newenvironment{minted}[2][]
- {\VerbatimEnvironment
-  \renewcommand{\minted at proglang}[1]{#2}
-  \minted at resetoptions
-  \setkeys{minted at opt}{#1}
-  \begin{VerbatimOut}[codes={\catcode`\^^I=12}]{\jobname.pyg}}%
- {\end{VerbatimOut}
-  \minted at pygmentize{\minted at proglang{}}
-  \DeleteFile{\jobname.pyg}}
-\newcommand\inputminted[3][]{
-  \minted at resetoptions
-  \setkeys{minted at opt}{#1}
-  \minted at pygmentize[#3]{#2}}
-\newcommand\newminted[3][]{
-  \ifthenelse{\equal{#1}{}}
-   {\def\minted at envname{#2code}}
-   {\def\minted at envname{#1}}
-  \newenvironment{\minted at envname}
-   {\VerbatimEnvironment\begin{minted}[#3]{#2}}
-   {\end{minted}}
-  \newenvironment{\minted at envname *}[1]
-   {\VerbatimEnvironment\begin{minted}[#3,##1]{#2}}
-   {\end{minted}}}
-\newcommand\newmint[3][]{
-  \ifthenelse{\equal{#1}{}}
-   {\def\minted at shortname{#2}}
-   {\def\minted at shortname{#1}}
-  \expandafter\newcommand\csname\minted at shortname\endcsname[2][]{
-    \mint[#3,##1]{#2}##2}}
-\newcommand\newmintedfile[3][]{
-  \ifthenelse{\equal{#1}{}}
-   {\def\minted at shortname{#2file}}
-   {\def\minted at shortname{#1}}
-  \expandafter\newcommand\csname\minted at shortname\endcsname[2][]{
-    \inputminted[#3,##1]{#2}{##2}}}
-\@ifundefined{minted at float@within}
- {\newfloat{listing}{h}{lol}}
- {\newfloat{listing}{h}{lol}[\minted at float@within]}
-\newcommand\listingscaption{Listing}
-\floatname{listing}{\listingscaption}
-\newcommand\listoflistingscaption{List of listings}
-\providecommand\listoflistings{\listof{listing}{\listoflistingscaption}}
-\AtBeginDocument{
-  \minted at usedefaultstyle}
-\AtEndOfPackage{
-  \ifnum\pdf at shellescape=1\relax\else
-    \PackageError{minted}
-     {You must invoke LaTeX with the
-      -shell-escape flag}
-     {Pass the -shell-escape flag to LaTeX. Refer to the minted.sty
-      documentation for more information.}\fi
-  \TestAppExists{pygmentize}
-  \ifAppExists\else
-    \PackageError{minted}
-     {You must have `pygmentize' installed
-      to use this package}
-     {Refer to the installation instructions in the minted
-      documentation for more information.}
-  \fi}
-%%%% Begin minted1 modification
-\fi
-%%%% End minted1 modification
-%    \end{macrocode}
-% \iffalse
-%</packageone>
-% \fi
-%
 % \Finale
 \endinput
-

Modified: trunk/Master/texmf-dist/source/latex/minted/minted.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/minted/minted.ins	2024-09-23 21:20:10 UTC (rev 72362)
+++ trunk/Master/texmf-dist/source/latex/minted/minted.ins	2024-09-23 21:20:32 UTC (rev 72363)
@@ -3,20 +3,18 @@
 \askforoverwritefalse
 
 \preamble
-Copyright 2013--2022 Geoffrey M. Poore
-Copyright 2010--2011 Konrad Rudolph
 
+Copyright (C) 2013-2024 by Geoffrey M. Poore <gpoore at gmail.com>
+Copyright (C) 2010-2011 by Konrad Rudolph <konrad_rudolph at madrat.net>
+--------------------------------------------------------------------------
 This work may be distributed and/or modified under the
-conditions of the LaTeX Project Public License, either version 1.3
+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
-  http://www.latex-project.org/lppl.txt
-and version 1.3 or later is part of all distributions of LaTeX
-version 2005/12/01 or later.
+  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.
 
-Additionally, the project may be distributed under the terms of the new BSD
-license.
-
 This work has the LPPL maintenance status `maintained'.
 
 The Current Maintainer of this work is Geoffrey Poore.
@@ -23,6 +21,7 @@
 
 This work consists of the files minted.dtx and minted.ins
 and the derived file minted.sty.
+
 \endpreamble
 
 \usedir{tex/latex/minted}
@@ -29,8 +28,6 @@
 
 \generate{%
     \file{minted.sty}{\from{minted.dtx}{package}}%
-    \file{minted1.sty}{\from{minted.dtx}{packageone}}%
 }
 
 \endbatchfile
-% vim: ft=tex

Added: trunk/Master/texmf-dist/tex/latex/minted/latexminted.py
===================================================================
--- trunk/Master/texmf-dist/tex/latex/minted/latexminted.py	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/minted/latexminted.py	2024-09-23 21:20:32 UTC (rev 72363)
@@ -0,0 +1,359 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2024, Geoffrey M. Poore
+# All rights reserved.
+#
+# Licensed under the LaTeX Project Public License version 1.3c:
+# https://www.latex-project.org/lppl.txt
+#
+
+
+'''
+This Python executable is intended for installation within a TeX distribution,
+along with Python wheels for the following Python packages:
+
+  * latexminted:  https://pypi.org/project/latexminted/
+
+  * latexrestricted:  https://pypi.org/project/latexrestricted/
+
+  * latex2pydata:  https://pypi.org/project/latex2pydata/
+
+  * Pygments:  https://pypi.org/project/Pygments/
+
+The combined executable plus wheels provide everything that is needed for the
+Python side of the minted LaTeX package.  No additional Python libraries are
+required.
+
+The wheels require Python >= 3.8.  If this executable is launched with an
+earlier Python version, then it will attempt to locate a more recent Python
+installation and run itself with that Python version in a subprocess.  The
+search for more recent Python versions looks for executables of the form
+`python3.x` on PATH.
+
+If the latexminted Python package is installed separately, outside TeX, then
+it will create a separate `latexminted` executable as part of the installation
+process.  That makes it possible to install latexminted and dependencies
+separately and then customize Pygments with additional packages that provide
+plugins.  However, running that separate `latexminted` executable is not
+straightforward under Windows.  Under Windows, if this executable finds a
+suitable `latexminted` executable elsewhere, outside a TeX installation, then
+this executable will run that separate `latexminted` executable in a
+subprocess and exit.  There are two reasons for this approach:
+
+ 1. Under Windows with TeX Live, the default restricted shell escape can only
+    run executables such as `latexminted` that are part of the TeX
+    installation; the executable that runs is not the first executable on
+    PATH.  That is part of TeX Live's security measures to prevent running
+    executables in the current working directory, which is typically writable
+    by LaTeX and is the first place Windows checks when searching for
+    executables.  This script and the latexrestricted Python package enforce
+    equivalent security, but do so in a less restrictive manner by expanding
+    executable names into executable paths with Python's `shutil.which()` and
+    then comparing the result with locations writable by LaTeX.
+
+ 2. Under non-Windows operating systems, it is possible to modify PATH so that
+    the desired `latexminted` executable is first.  Under Windows, the system
+    PATH is prepended to the user PATH, so a system-wide TeX installation will
+    prevent a user-installed `latexminted` executable from being accessible.
+
+Requirements for locating and running a separate `latexminted` executable
+under Windows:
+
+  * The separate executable must be the first `latexminted.exe` found on PATH,
+    or it must be the first `latexminted.exe` on PATH that is located under
+    the user home directory.
+
+  * The separate executable must be outside a TeX installation.  There is a
+    check for a `tex.exe` executable in the same directory as
+    `latexminted.exe`.  There is a check for the case-insensitive strings
+    "texlive", "miktex", and "tinytex" in the path to the `latexminted`
+    executable.  With TeX Live, the path to the `latexminted` executable is
+    also compared to the environment variable `SELFAUTOLOC`.
+
+  * The separate executable must be outside the current working directory,
+    TEXMFOUTPUT, and TEXMF_OUTPUT_DIRECTORY.
+
+  * The current directory, TEXMFOUTPUT, and TEXMF_OUTPUT_DIRECTORY cannot be
+    subdirectories of the directory in which the executable is located.
+'''
+
+
+__version__ = '0.1.0'
+
+
+import os
+import pathlib
+import platform
+import shutil
+import subprocess
+import sys
+
+
+
+
+# This is an abbreviated variant of `AnyPath` from latexrestricted:
+# https://github.com/gpoore/latexrestricted/blob/main/latexrestricted/_anypath.py
+class Path(type(pathlib.Path())):
+    __slots__ = (
+        '_cache_key',
+    )
+
+    if sys.version_info[:2] < (3, 9):
+        def is_relative_to(self, other):
+            try:
+                self.relative_to(other)
+                return True
+            except ValueError:
+                return False
+
+    @property
+    def cache_key(self):
+        try:
+            return self._cache_key
+        except AttributeError:
+            self._cache_key = (type(self), self)
+            return self._cache_key
+
+    _resolved_set = set()
+
+    def resolve(self):
+        resolved = super().resolve()
+        self._resolved_set.add(resolved.cache_key)
+        return resolved
+
+    def is_resolved(self) -> bool:
+        return self.cache_key in self._resolved_set
+
+
+
+
+# Define function that determines whether subprocess executable paths are
+# permitted.
+prohibited_path_roots = set()
+prohibited_path_roots.add(Path.cwd())
+env_TEXMFOUTPUT = os.getenv('TEXMFOUTPUT')
+env_TEXMF_OUTPUT_DIRECTORY = os.getenv('TEXMF_OUTPUT_DIRECTORY')
+for env_var in (env_TEXMFOUTPUT, env_TEXMF_OUTPUT_DIRECTORY):
+    if env_var:
+        env_var_path = Path(env_var)
+        prohibited_path_roots.add(env_var_path)
+        prohibited_path_roots.add(env_var_path.resolve())
+
+def is_permitted_executable_path(executable_path, executable_path_resolved):
+    if not executable_path_resolved.is_resolved():
+        raise Exception('Second argument must be resolved path')
+    if any(e.is_relative_to(p) or p.is_relative_to(e)
+           for e in set([executable_path.parent, executable_path_resolved.parent])
+           for p in prohibited_path_roots):
+        return False
+    return True
+
+# TeX Live allows setting `TEXMFOUTPUT` in LaTeX configuration.
+# Retrieving that value with kpsewhich follows the approach in latexrestricted:
+# https://github.com/gpoore/latexrestricted/blob/main/latexrestricted/_latex_config.py
+env_SELFAUTOLOC = os.getenv('SELFAUTOLOC')
+env_TEXSYSTEM = os.getenv('TEXSYSTEM')
+if not env_TEXMFOUTPUT and env_SELFAUTOLOC and (not env_TEXSYSTEM or env_TEXSYSTEM.lower() != 'miktex'):
+    if platform.system() == 'Windows':
+        # Under Windows, shell escape executables will often be launched with
+        # the TeX Live `runscript.exe` executable wrapper.  This overwrites
+        # `SELFAUTOLOC` from TeX with the location of the wrapper, so
+        # `SELFAUTOLOC` may not be correct.
+        which_tlmgr = shutil.which('tlmgr')  # No `.exe`; likely `.bat`
+        if not which_tlmgr:
+            sys.exit('Failed to find TeX Live "tlmgr" executable on PATH')
+        which_tlmgr_resolved = Path(which_tlmgr).resolve()
+        texlive_bin_path = which_tlmgr_resolved.parent
+        # Make sure executable is *.exe, not *.bat or *.cmd:
+        # https://docs.python.org/3/library/subprocess.html#security-considerations
+        which_kpsewhich = shutil.which('kpsewhich.exe', path=str(texlive_bin_path))
+        if not which_kpsewhich:
+            sys.exit('Failed to find a TeX Live "tlmgr" executable with accompanying "kpsewhich" executable on PATH')
+        which_kpsewhich_path = Path(which_kpsewhich)
+        which_kpsewhich_resolved = which_kpsewhich_path.resolve()
+        if not texlive_bin_path == which_kpsewhich_resolved.parent:
+            sys.exit(' '.join([
+                '"tlmgr" executable from PATH resolved to "{}" '.format(which_tlmgr_resolved.as_posix()),
+                'while "kpsewhich" resolved to "{}";'.format(which_kpsewhich_resolved.as_posix()),
+                '"tlmgr" and "kpsewhich" should be in the same location',
+            ]))
+        if not which_kpsewhich_resolved.name.lower().endswith('.exe'):
+            sys.exit(' '.join([
+                'Executable "kpsewhich" resolved to "{}",'.format(which_kpsewhich_resolved.as_posix()),
+                'but *.exe is required',
+            ]))
+    else:
+        which_kpsewhich = shutil.which('kpsewhich', path=env_SELFAUTOLOC)
+        if not which_kpsewhich:
+            sys.exit(' '.join([
+                'Environment variable SELFAUTOLOC has value "{}",'.format(env_SELFAUTOLOC),
+                'but a "kpsewhich" executable was not found at that location',
+            ]))
+        which_kpsewhich_path = Path(which_kpsewhich)
+        which_kpsewhich_resolved = which_kpsewhich_path.resolve()
+    if not is_permitted_executable_path(which_kpsewhich_path, which_kpsewhich_resolved):
+        # As in the latexrestricted case, this doesn't initially check for the
+        # TeX Live scenario where `TEXMFOUTPUT` is set in a `texmf.cnf` config
+        # file to a location that includes the `kpsewhich` executable.  There
+        # isn't a good way to get the value of `TEXMFOUTPUT` without running
+        # `kpsewhich` in that case.
+        sys.exit(
+            'Executable "kpsewhich" is located under the current directory, TEXMFOUTPUT, or '
+            'TEXMF_OUTPUT_DIRECTORY, or one of these locations is under the same directory as the executable'
+        )
+    kpsewhich_cmd = [which_kpsewhich_resolved.as_posix(), '--var-value', 'TEXMFOUTPUT']
+    try:
+        kpsewhich_proc = subprocess.run(kpsewhich_cmd, shell=False, capture_output=True)
+    except PermissionError:
+        sys.exit('Insufficient permission to run "{}"'.format(which_kpsewhich_resolved.as_posix()))
+    kpsewhich_TEXMFOUTPUT = kpsewhich_proc.stdout.decode(sys.stdout.encoding) or None
+    if kpsewhich_TEXMFOUTPUT:
+        kpsewhich_TEXMFOUTPUT_path = Path(kpsewhich_TEXMFOUTPUT)
+        prohibited_path_roots.add(kpsewhich_TEXMFOUTPUT_path)
+        prohibited_path_roots.add(kpsewhich_TEXMFOUTPUT_path.resolve())
+    if not is_permitted_executable_path(which_kpsewhich_path, which_kpsewhich_resolved):
+        # It is now possible to check for the TeX Live scenario where
+        # `TEXMFOUTPUT` is set in a `texmf.cnf` config file to a location that
+        # includes the `kpsewhich` executable.  Giving an error message after
+        # already running `kpsewhich` isn't ideal, but there isn't a good
+        # alternative.  As in the latexrestricted case, the impact on overall
+        # security is negligible because an unsafe value of `TEXMFOUTPUT`
+        # means that all TeX-related executables are potentially compromised.
+        sys.exit(
+            'Executable "kpsewhich" is located under the current directory, TEXMFOUTPUT, or '
+            'TEXMF_OUTPUT_DIRECTORY, or one of these locations is under the same directory as the executable'
+        )
+
+
+
+
+# If Python version is < 3.8, try to locate a more recent version and then
+# relaunch this script with that Python version in a subprocess.
+if sys.version_info[:2] < (3, 8):
+    for minor_version in range(13, 7, -1):
+        if platform.system() == 'Windows':
+            # Batch files must be prohibited:
+            # https://docs.python.org/3/library/subprocess.html#security-considerations
+            which_python = shutil.which('python3.{}.exe'.format(minor_version))
+        else:
+            which_python = shutil.which('python3.{}'.format(minor_version))
+        if which_python:
+            which_python_path = Path(which_python)
+            which_python_resolved = which_python_path.resolve()
+            if platform.system() == 'Windows' and not which_python_resolved.name.lower().endswith('.exe'):
+                continue
+            if is_permitted_executable_path(which_python_path, which_python_resolved):
+                python_cmd = [which_python_resolved.as_posix(), __file__] + sys.argv[1:]
+                python_proc = subprocess.run(python_cmd, shell=False, capture_output=True)
+                sys.stderr.buffer.write(python_proc.stderr)
+                sys.stdout.buffer.write(python_proc.stdout)
+                sys.exit(python_proc.returncode)
+    sys.exit('latexminted requires Python >= 3.8, but a compatible Python executable was not found on PATH')
+
+
+
+
+# Check for required wheel dependencies and add them to Python's `sys.path`.
+script_resolved = Path(__file__).resolve()
+required_wheel_packages = (
+    'latexminted',
+    'latexrestricted',
+    'latex2pydata',
+    'pygments',
+)
+wheel_paths = [p for p in script_resolved.parent.glob('*.whl') if p.name.startswith(required_wheel_packages)]
+if not wheel_paths:
+    sys.exit('latexminted failed to find bundled wheels *.whl')
+for pkg in required_wheel_packages:
+    if not any(whl.name.startswith(pkg) for whl in wheel_paths):
+        sys.exit('latexminted failed to find all required bundled wheels *.whl')
+for wheel_path in wheel_paths:
+    sys.path.insert(0, wheel_path.as_posix())
+
+
+
+
+# Under Windows, check PATH for a `latexminted` executable outside a TeX
+# installation.  If a `latexminted` executable is found in a suitable location
+# with sufficient precedence, run it in a subprocess and exit.
+#
+# The environment variable `LATEXMINTED_SUBPROCESS` is used to prevent an
+# endless recursion of subprocesses in the event that a `latexminted`
+# executable *inside* a TeX installation somehow manages to pass the tests for
+# an executable *outside* a TeX installation.
+if platform.system() == 'Windows' and not os.getenv('LATEXMINTED_SUBPROCESS'):
+    os.environ['LATEXMINTED_SUBPROCESS'] = '1'
+    fallback_path_search = True
+    if env_SELFAUTOLOC:
+        env_SELFAUTOLOC_resolved = Path(env_SELFAUTOLOC).resolve()
+    else:
+        env_SELFAUTOLOC_resolved = None
+    which_latexminted = shutil.which('latexminted.exe')
+    if which_latexminted:
+        which_latexminted_path = Path(which_latexminted)
+        which_latexminted_resolved = which_latexminted_path.resolve()
+        if not which_latexminted_resolved.name.lower().endswith('.exe'):
+            sys.exit(' '.join([
+                'Executable "latexminted" resolved to "{}",'.format(which_latexminted_resolved.as_posix()),
+                'but *.exe is required',
+            ]))
+        if which_latexminted_resolved == script_resolved:
+            pass
+        elif (which_latexminted_resolved.parent / 'tex.exe').exists():
+            pass
+        elif any(x in which_latexminted_resolved.as_posix().lower() for x in ('texlive', 'miktex', 'tinytex')):
+            pass
+        elif env_SELFAUTOLOC_resolved and which_latexminted_resolved.is_relative_to(env_SELFAUTOLOC_resolved):
+            pass
+        elif is_permitted_executable_path(which_latexminted_path, which_latexminted_resolved):
+            latexminted_cmd = [which_latexminted_resolved.as_posix()] + sys.argv[1:]
+            latexminted_proc = subprocess.run(latexminted_cmd, shell=False, capture_output=True)
+            sys.stderr.buffer.write(latexminted_proc.stderr)
+            sys.stdout.buffer.write(latexminted_proc.stdout)
+            sys.exit(latexminted_proc.returncode)
+        else:
+            # If there was a `latexminted` executable on PATH outside a TeX
+            # installation, but it wasn't permitted due to its location, don't
+            # perform fallback search.
+            fallback_path_search = False
+    if fallback_path_search:
+        # Windows appends user PATH to system PATH, so the system PATH may
+        # prevent finding a user installation of `latexminted`.  Search
+        # through PATH elements under user home directory to check for
+        # `latexminted.exe` outside a TeX installation.
+        home_path = Path.home()
+        env_PATH = os.environ.get('PATH', '')
+        for path_elem in env_PATH.split(os.pathsep):
+            if not path_elem or not Path(path_elem).is_relative_to(home_path):
+                continue
+            which_latexminted = shutil.which('latexminted.exe', path=path_elem)
+            if not which_latexminted:
+                continue
+            which_latexminted_path = Path(which_latexminted)
+            which_latexminted_resolved = which_latexminted_path.resolve()
+            if which_latexminted_resolved == script_resolved:
+                break
+            elif (which_latexminted_resolved.parent / 'tex.exe').exists():
+                break
+            elif any(x in which_latexminted_resolved.as_posix().lower() for x in ('texlive', 'miktex', 'tinytex')):
+                break
+            elif env_SELFAUTOLOC_resolved and which_latexminted_resolved.is_relative_to(env_SELFAUTOLOC_resolved):
+                break
+            elif is_permitted_executable_path(which_latexminted_path, which_latexminted_resolved):
+                latexminted_cmd = [which_latexminted_resolved.as_posix()] + sys.argv[1:]
+                try:
+                    latexminted_proc = subprocess.run(latexminted_cmd, shell=False, capture_output=True)
+                except PermissionError:
+                    break
+                sys.stderr.buffer.write(latexminted_proc.stderr)
+                sys.stdout.buffer.write(latexminted_proc.stdout)
+                sys.exit(latexminted_proc.returncode)
+            else:
+                break
+
+
+
+
+from latexminted.cmdline import main
+main()


Property changes on: trunk/Master/texmf-dist/tex/latex/minted/latexminted.py
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/minted/minted.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/minted/minted.sty	2024-09-23 21:20:10 UTC (rev 72362)
+++ trunk/Master/texmf-dist/tex/latex/minted/minted.sty	2024-09-23 21:20:32 UTC (rev 72363)
@@ -5,20 +5,18 @@
 %% The original source files were:
 %%
 %% minted.dtx  (with options: `package')
-%% Copyright 2013--2022 Geoffrey M. Poore
-%% Copyright 2010--2011 Konrad Rudolph
 %% 
+%% Copyright (C) 2013-2024 by Geoffrey M. Poore <gpoore at gmail.com>
+%% Copyright (C) 2010-2011 by Konrad Rudolph <konrad_rudolph at madrat.net>
+%% --------------------------------------------------------------------------
 %% This work may be distributed and/or modified under the
-%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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
-%%   http://www.latex-project.org/lppl.txt
-%% and version 1.3 or later is part of all distributions of LaTeX
-%% version 2005/12/01 or later.
+%%   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.
 %% 
-%% Additionally, the project may be distributed under the terms of the new BSD
-%% license.
-%% 
 %% This work has the LPPL maintenance status `maintained'.
 %% 
 %% The Current Maintainer of this work is Geoffrey Poore.
@@ -25,1001 +23,1406 @@
 %% 
 %% This work consists of the files minted.dtx and minted.ins
 %% and the derived file minted.sty.
+%% 
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{minted}
-    [2023/12/18 v2.9 Yet another Pygments shim for LaTeX]
-\RequirePackage{keyval}
-\RequirePackage{kvoptions}
-\RequirePackage{fvextra}[2022/11/30]
-\RequirePackage{ifthen}
-\IfFileExists{shellesc.sty}
- {\RequirePackage{shellesc}
-  \@ifpackagelater{shellesc}{2016/04/29}
-   {}
-   {\protected\def\ShellEscape{\immediate\write18 }}}
- {\protected\def\ShellEscape{\immediate\write18 }}
-\RequirePackage{ifplatform}
+    [2024/09/22 v3.0.0 Yet another Pygments shim for LaTeX]
+\RequirePackage{catchfile}
+\RequirePackage{etoolbox}
+\RequirePackage{fvextra}[2024/09/05]
+\RequirePackage{latex2pydata}[2024/05/16]
 \RequirePackage{pdftexcmds}
-\RequirePackage{etoolbox}
-\RequirePackage{xstring}
-\RequirePackage{lineno}
-\RequirePackage{framed}
-\RequirePackage{catchfile}
+\RequirePackage{pgfkeys}
+\RequirePackage{pgfopts}
+\RequirePackage{shellesc}
 \AtEndPreamble{%
-  \@ifpackageloaded{color}{}{%
-    \@ifpackageloaded{xcolor}{}{\RequirePackage{xcolor}}}%
-}
-\DeclareVoidOption{chapter}{\def\minted at float@within{chapter}}
-\DeclareVoidOption{section}{\def\minted at float@within{section}}
-\DeclareBoolOption{newfloat}
-\DeclareBoolOption[true]{cache}
-\StrSubstitute{\jobname}{ }{_}[\minted at jobname]
-\StrSubstitute{\minted at jobname}{*}{_}[\minted at jobname]
-\StrSubstitute{\minted at jobname}{"}{}[\minted at jobname]
-\StrSubstitute{\minted at jobname}{'}{_}[\minted at jobname]
-\newcommand{\minted at cachedir}{\detokenize{_}minted-\minted at jobname}
-\let\minted at cachedir@windows\minted at cachedir
-\define at key{minted}{cachedir}{%
-  \@namedef{minted at cachedir}{#1}%
-  \StrSubstitute{\minted at cachedir}{/}{\@backslashchar}[\minted at cachedir@windows]}
-\DeclareBoolOption{finalizecache}
-\DeclareBoolOption{frozencache}
-\let\minted at outputdir\@empty
-\let\minted at outputdir@windows\@empty
-\define at key{minted}{outputdir}{%
-  \@namedef{minted at outputdir}{#1/}%
-  \StrSubstitute{\minted at outputdir}{/}%
-    {\@backslashchar}[\minted at outputdir@windows]}
-\DeclareBoolOption{inputlanglinenos}
-\DeclareBoolOption{kpsewhich}
-\DeclareBoolOption{langlinenos}
-\DeclareBoolOption{draft}
-\DeclareComplementaryOption{final}{draft}
-\ProcessKeyvalOptions*
-\ifthenelse{\boolean{minted at newfloat}}{\RequirePackage{newfloat}}{\RequirePackage{float}}
-\ifcsname tikzifexternalizing\endcsname
-  \tikzifexternalizing{\minted at drafttrue\minted at cachefalse}{}
+  \IfPackageLoadedTF{color}%
+   {}%
+   {\IfPackageLoadedTF{xcolor}{}{\RequirePackage{xcolor}}}}
+\def\minted at error#1{\PackageError{minted}{#1}{}}
+\def\minted at fatalerror#1{%
+  \minted at error{#1}%
+  \batchmode\read -1 to \minted at fatalerror@exitnow}
+\def\minted at warning#1{\PackageWarning{minted}{#1}}
+\edef\MintedExecutable{\detokenize{latexminted}}
+\edef\minted at executable@minversion{\detokenize{0.1.0}}
+\def\minted at executable@setminversioncomponents{%
+  \expandafter\minted at executable@setminversioncomponents at i
+    \minted at executable@minversion\relax}
+\begingroup
+\catcode`\.=12
+\gdef\minted at executable@setminversioncomponents at i#1.#2.#3\relax{%
+  \def\minted at executable@minmajor{#1}%
+  \def\minted at executable@minminor{#2}%
+  \def\minted at executable@minpatch{#3}}
+\endgroup
+\minted at executable@setminversioncomponents
+\let\minted at executable@version\relax
+\newbool{minted at executable@exists}
+\newbool{minted at executable@issupported}
+\begingroup
+\catcode`\-=12
+\catcode`\+=12
+\catcode`\:=12
+\def\minted at creationdatetotimestamp#1{%
+  \expandafter\minted at creationdatetotimestamp@i#1-\relax}
+\def\minted at creationdatetotimestamp@i#1:#2-#3\relax{%
+  \minted at creationdatetotimestamp@ii#2+\relax}
+\def\minted at creationdatetotimestamp@ii#1+#2\relax{%
+  #1}
+\expandafter\ifx\csname pdftexversion\endcsname\relax
 \else
-  \ifcsname tikzexternalrealjob\endcsname
-    \minted at drafttrue
-    \minted at cachefalse
-  \else
-  \fi
+  \xdef\minted at timestamp{\minted at creationdatetotimestamp{\pdfcreationdate}}
 \fi
-\ifthenelse{\boolean{minted at finalizecache}}%
- {\ifthenelse{\boolean{minted at frozencache}}%
-   {\PackageError{minted}%
-     {Options "finalizecache" and "frozencache" are not compatible}%
-     {Options "finalizecache" and "frozencache" are not compatible}}%
-   {}}%
- {}
-\ifthenelse{\boolean{minted at cache}}%
- {\ifthenelse{\boolean{minted at frozencache}}%
-   {}%
-   {\AtEndOfPackage{\ProvideDirectory{\minted at outputdir\minted at cachedir}}}}%
- {}
-\newcommand{\minted at input}[1]{%
-  \IfFileExists{#1}%
-   {\input{#1}}%
-   {\PackageError{minted}{Missing Pygments output; \string\inputminted\space
-     was^^Jprobably given a file that does not exist--otherwise, you may need
-     ^^Jthe outputdir package option, or may be using an incompatible build
-     tool,^^Jor may be using frozencache with a missing file}%
-    {This could be caused by using -output-directory or -aux-directory
-     ^^Jwithout setting minted's outputdir, or by using a build tool that
-     ^^Jchanges paths in ways minted cannot detect,
-     ^^Jor using frozencache with a missing file.}}%
-}
-\newcommand{\minted at infile}{\minted at jobname.out.pyg}
-\newcommand{\minted at cachelist}{}
-\newcommand{\minted at addcachefile}[1]{%
-  \expandafter\long\expandafter\gdef\expandafter\minted at cachelist\expandafter{%
-    \minted at cachelist,^^J%
-    \space\space#1}%
-  \expandafter\gdef\csname minted at cached@#1\endcsname{}%
-}
-\newcommand{\minted at savecachelist}{%
-  \ifdefempty{\minted at cachelist}{}{%
-    \immediate\write\@mainaux{%
-      \string\gdef\string\minted at oldcachelist\string{%
-        \minted at cachelist\string}}%
-  }%
-}
-\newcommand{\minted at cleancache}{%
-  \ifcsname minted at oldcachelist\endcsname
-    \def\do##1{%
-      \ifthenelse{\equal{##1}{}}{}{%
-        \ifcsname minted at cached@##1\endcsname\else
-          \DeleteFile[\minted at outputdir\minted at cachedir]{##1}%
-        \fi
-      }%
-    }%
-    \expandafter\docsvlist\expandafter{\minted at oldcachelist}%
-  \else
-  \fi
-}
-\ifthenelse{\boolean{minted at draft}}%
- {\AtEndDocument{%
-    \ifcsname minted at oldcachelist\endcsname
-      \StrSubstitute{\minted at oldcachelist}{,}{,^^J }[\minted at cachelist]
-      \minted at savecachelist
-    \fi}}%
- {\ifthenelse{\boolean{minted at frozencache}}%
-   {\AtEndDocument{%
-      \ifcsname minted at oldcachelist\endcsname
-        \StrSubstitute{\minted at oldcachelist}{,}{,^^J }[\minted at cachelist]
-        \minted at savecachelist
-      \fi}}%
-   {\AtEndDocument{%
-    \minted at savecachelist
-    \minted at cleancache}}}%
-\ifwindows
-  \providecommand{\DeleteFile}[2][]{%
-    \ifthenelse{\equal{#1}{}}%
-      {\IfFileExists{#2}{\ShellEscape{del #2}}{}}%
-      {\IfFileExists{#1/#2}{%
-        \StrSubstitute{#1}{/}{\@backslashchar}[\minted at windir]
-        \ShellEscape{del \minted at windir\@backslashchar #2}}{}}}
+\expandafter\ifx\csname XeTeXrevision\endcsname\relax
 \else
-  \providecommand{\DeleteFile}[2][]{%
-    \ifthenelse{\equal{#1}{}}%
-      {\IfFileExists{#2}{\ShellEscape{rm #2}}{}}%
-      {\IfFileExists{#1/#2}{\ShellEscape{rm #1/#2}}{}}}
+  \xdef\minted at timestamp{\minted at creationdatetotimestamp{\creationdate}}
 \fi
-\ifwindows
-  \newcommand{\ProvideDirectory}[1]{%
-    \StrSubstitute{#1}{/}{\@backslashchar}[\minted at windir]
-    \ShellEscape{if not exist \minted at windir\space mkdir \minted at windir}}
+\expandafter\ifx\csname directlua\endcsname\relax
 \else
-  \newcommand{\ProvideDirectory}[1]{%
-    \ShellEscape{mkdir -p #1}}
+  \xdef\minted at timestamp{\minted at creationdatetotimestamp{\pdffeedback creationdate}}
 \fi
-\newboolean{AppExists}
-\newread\minted at appexistsfile
-\newcommand{\TestAppExists}[1]{%
-  \ifwindows
-    \DeleteFile{\minted at jobname.aex}%
-    \ShellEscape{for \string^\@percentchar i in (#1.exe #1.bat #1.cmd)
-      do set > \minted at jobname.aex <nul: /p
-      x=\string^\@percentchar \string~$PATH:i>> \minted at jobname.aex}%
-    %$ <- balance syntax highlighting
-    \immediate\openin\minted at appexistsfile\minted at jobname.aex
-    \expandafter\def\expandafter\@tmp at cr\expandafter{\the\endlinechar}%
-    \endlinechar=-1\relax
-    \readline\minted at appexistsfile to \minted at apppathifexists
-    \endlinechar=\@tmp at cr
-    \ifthenelse{\equal{\minted at apppathifexists}{}}%
-     {\AppExistsfalse}%
-     {\AppExiststrue}%
-    \immediate\closein\minted at appexistsfile
-    \DeleteFile{\minted at jobname.aex}%
+\endgroup
+\ifcsname minted at timestamp\endcsname
+\else
+  \begingroup
+  \newcounter{minted at timestamp@hr}
+  \newcounter{minted at timestamp@min}
+  \setcounter{minted at timestamp@min}{\number\time}
+  \loop\unless\ifnum\value{minted at timestamp@min}<60\relax
+    \addtocounter{minted at timestamp@hr}{1}
+    \addtocounter{minted at timestamp@min}{-60}
+  \repeat
+  \xdef\minted at timestamp{%
+    \the\year
+    \ifnum\month<10 0\fi\the\month
+    \ifnum\day<10 0\fi\the\day
+    \ifnum\value{minted at timestamp@hr}<10 0\fi\theminted at timestamp@hr
+    \ifnum\value{minted at timestamp@min}<10 0\fi\theminted at timestamp@min}
+  \endgroup
+\fi
+\begingroup
+\catcode`\"=12
+\catcode`\'=12
+\gdef\minted at setjobnamemdfive#1#2\FV at Sentinel{%
+  \ifx#1"\relax
+    \let\minted at next\minted at setjobnamemdfive@dquoted
+  \else\ifx#1'\relax
+    \let\minted at next\minted at setjobnamemdfive@squoted
   \else
-    \ShellEscape{command -v #1 && touch \minted at jobname.aex}%
-    \IfFileExists{\minted at jobname.aex}%
-      {\AppExiststrue
-        \DeleteFile{\minted at jobname.aex}}%
-      {\AppExistsfalse}%
-  \fi
+    \let\minted at next\minted at setjobnamemdfive@uquoted
+  \fi\fi
+  \minted at next#1#2\FV at Sentinel}
+\gdef\minted at setjobnamemdfive@dquoted#1#2\FV at Sentinel{%
+  \minted at setjobnamemdfive@dquoted at i#2"\FV at Sentinel}
+\gdef\minted at setjobnamemdfive@dquoted at i#1"#2\FV at Sentinel{%
+  \if\relax\detokenize{#2}\relax
+    \edef\MintedJobnameMdfive{\pdf at mdfivesum{\jobname}}%
+  \else\if\relax\detokenize\expandafter{\@gobble#2}\relax
+    \edef\MintedJobnameMdfive{\pdf at mdfivesum{#1}}%
+  \else
+    \edef\MintedJobnameMdfive{\pdf at mdfivesum{\jobname}}%
+  \fi\fi}
+\gdef\minted at setjobnamemdfive@squoted#1#2\FV at Sentinel{%
+  \minted at setjobnamemdfive@squoted at i#2'\FV at Sentinel}
+\gdef\minted at setjobnamemdfive@squoted at i#1'#2\FV at Sentinel{%
+  \if\relax\detokenize{#2}\relax
+    \edef\MintedJobnameMdfive{\pdf at mdfivesum{\jobname}}%
+  \else\if\relax\detokenize\expandafter{\@gobble#2}\relax
+    \edef\MintedJobnameMdfive{\pdf at mdfivesum{#1}}%
+  \else
+    \edef\MintedJobnameMdfive{\pdf at mdfivesum{\jobname}}%
+  \fi\fi}
+\gdef\minted at setjobnamemdfive@uquoted#1\FV at Sentinel{%
+  \edef\MintedJobnameMdfive{\pdf at mdfivesum{#1}}}
+\endgroup
+\expandafter\minted at setjobnamemdfive\jobname\FV at Sentinel
+\edef\MintedCacheIndexFilename{%
+  \detokenize{_}\MintedJobnameMdfive\detokenize{.index.minted}}
+\edef\MintedConfigFilename{%
+  \detokenize{_}\MintedJobnameMdfive\detokenize{.config.minted}}
+\edef\MintedDataFilename{%
+  \detokenize{_}\MintedJobnameMdfive\detokenize{.data.minted}}
+\edef\MintedErrlogFilename{%
+  \detokenize{_}\MintedJobnameMdfive\detokenize{.errlog.minted}}
+\edef\MintedMessageFilename{%
+  \detokenize{_}\MintedJobnameMdfive\detokenize{.message.minted}}
+\def\minted at pgfopts#1{%
+  \pgfkeys{/minted/pkg/.cd,#1}}
+\minted at pgfopts{
+  chapter/.code=\def\minted at float@within{chapter},
+  chapter/.value forbidden,
+  section/.code=\def\minted at float@within{section},
+  section/.value forbidden,
 }
-\newcommand{\minted at optlistcl@g}{}
-\newcommand{\minted at optlistcl@g at i}{}
-\let\minted at lang\@empty
-\newcommand{\minted at optlistcl@lang}{}
-\newcommand{\minted at optlistcl@lang at i}{}
-\newcommand{\minted at optlistcl@cmd}{}
-\newcommand{\minted at optlistfv@g}{}
-\newcommand{\minted at optlistfv@g at i}{}
-\newcommand{\minted at optlistfv@lang}{}
-\newcommand{\minted at optlistfv@lang at i}{}
-\newcommand{\minted at optlistfv@cmd}{}
-\newcommand{\minted at configlang}[1]{%
-  \def\minted at lang{#1}%
-  \ifcsname minted at optlistcl@lang\minted at lang\endcsname\else
-    \expandafter\gdef\csname minted at optlistcl@lang\minted at lang\endcsname{}%
-  \fi
-  \ifcsname minted at optlistcl@lang\minted at lang @i\endcsname\else
-    \expandafter\gdef\csname minted at optlistcl@lang\minted at lang @i\endcsname{}%
-  \fi
-  \ifcsname minted at optlistfv@lang\minted at lang\endcsname\else
-    \expandafter\gdef\csname minted at optlistfv@lang\minted at lang\endcsname{}%
-  \fi
-  \ifcsname minted at optlistfv@lang\minted at lang @i\endcsname\else
-    \expandafter\gdef\csname minted at optlistfv@lang\minted at lang @i\endcsname{}%
-  \fi
+\newbool{minted at newfloat}
+\minted at pgfopts{
+  newfloat/.is if=minted at newfloat,
 }
-\ifwindows
-  \newcommand{\minted at optlistcl@quote}[2]{%
-    \detokenize{#1="#2"}}
-\else
-  \newcommand{\minted at optlistcl@quote}[2]{%
-    \detokenize{#1='#2'}}
-\fi
-\newcommand{\minted at addto@optlistcl}[3]{%
-  \expandafter\def\expandafter#1\expandafter{#1%
-    \minted at optlistcl@quote{#2}{#3}\space}}
-\newcommand{\minted at addto@optlistcl at lang}[3]{%
-  \expandafter\let\expandafter\minted at tmp\csname #1\endcsname
-  \expandafter\def\expandafter\minted at tmp\expandafter{\minted at tmp%
-    \minted at optlistcl@quote{#2}{#3}\space}%
-  \expandafter\let\csname #1\endcsname\minted at tmp}
-\newcommand{\minted at def@optcl}[4][]{%
-  \ifthenelse{\equal{#1}{}}%
-    {\define at key{minted at opt@g}{#2}{%
-        \minted at addto@optlistcl{\minted at optlistcl@g}{#3}{#4}%
-        \@namedef{minted at opt@g:#2}{#4}}%
-      \define at key{minted at opt@g at i}{#2}{%
-        \minted at addto@optlistcl{\minted at optlistcl@g at i}{#3}{#4}%
-        \@namedef{minted at opt@g at i:#2}{#4}}%
-      \define at key{minted at opt@lang}{#2}{%
-        \minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang:#2}{#4}}%
-      \define at key{minted at opt@lang at i}{#2}{%
-        \minted at addto@optlistcl at lang{%
-          minted at optlistcl@lang\minted at lang @i}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang @i:#2}{#4}}%
-      \define at key{minted at opt@cmd}{#2}{%
-        \minted at addto@optlistcl{\minted at optlistcl@cmd}{#3}{#4}%
-        \@namedef{minted at opt@cmd:#2}{#4}}}%
-    {\define at key{minted at opt@g}{#2}[#1]{%
-        \minted at addto@optlistcl{\minted at optlistcl@g}{#3}{#4}%
-        \@namedef{minted at opt@g:#2}{#4}}%
-      \define at key{minted at opt@g at i}{#2}[#1]{%
-        \minted at addto@optlistcl{\minted at optlistcl@g at i}{#3}{#4}%
-        \@namedef{minted at opt@g at i:#2}{#4}}%
-      \define at key{minted at opt@lang}{#2}[#1]{%
-        \minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang:#2}{#4}}%
-      \define at key{minted at opt@lang at i}{#2}[#1]{%
-        \minted at addto@optlistcl at lang{%
-          minted at optlistcl@lang\minted at lang @i}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang @i:#2}{#4}}%
-      \define at key{minted at opt@cmd}{#2}[#1]{%
-        \minted at addto@optlistcl{\minted at optlistcl@cmd}{#3}{#4}%
-        \@namedef{minted at opt@cmd:#2}{#4}}}%
+\newbool{minted at debug}
+\minted at pgfopts{
+  debug/.is if=minted at debug,
 }
-\begingroup
-\catcode`\!=0
-!catcode`!\=12
-!gdef!minted at escape#1{%
-  !expandafter!minted at escape@i!detokenize{#1}\!FV at Sentinel}
-!gdef!minted at escape@i#1\#2!FV at Sentinel{%
-  !if!relax!detokenize{#2}!relax
-    !expandafter!@firstoftwo
-  !else
-    !expandafter!@secondoftwo
-  !fi
-  {#1!minted at escape@end\#2!FV at Sentinel}
-  {#1!minted at escape@esc\#2!FV at Sentinel}}
-!gdef!minted at escape@end#1!FV at Sentinel{}
-!gdef!minted at escape@esc\#1#2!FV at Sentinel{%
-  #1!minted at escape@i#2!FV at Sentinel}
-!endgroup
-\newcommand{\minted at addto@optlistcl at e}[3]{%
-  \edef\minted at tmp{\minted at escape{#3}}%
-  \expandafter\minted at addto@optlistcl at e@i\expandafter{\minted at tmp}{#1}{#2}}
-\def\minted at addto@optlistcl at e@i#1#2#3{%
-  \expandafter\def\expandafter#2\expandafter{#2\minted at optlistcl@quote{#3}{#1}\space}}
-\newcommand{\minted at addto@optlistcl at lang@e}[3]{%
-  \edef\minted at tmp{\minted at escape{#3}}%
-  \expandafter\minted at addto@optlistcl at lang@e at i\expandafter{\minted at tmp}{#1}{#2}}
-\def\minted at addto@optlistcl at lang@e at i#1#2#3{%
-  \expandafter\let\expandafter\minted at tmp\csname #2\endcsname
-  \expandafter\def\expandafter\minted at tmp\expandafter{\minted at tmp\minted at optlistcl@quote{#3}{#1}\space}%
-  \expandafter\let\csname #2\endcsname\minted at tmp}
-\newcommand{\minted at def@optcl at e}[4][]{%
-  \ifthenelse{\equal{#1}{}}%
-    {\define at key{minted at opt@g}{#2}{%
-        \minted at addto@optlistcl at e{\minted at optlistcl@g}{#3}{#4}%
-        \@namedef{minted at opt@g:#2}{#4}}%
-      \define at key{minted at opt@g at i}{#2}{%
-        \minted at addto@optlistcl at e{\minted at optlistcl@g at i}{#3}{#4}%
-        \@namedef{minted at opt@g at i:#2}{#4}}%
-      \define at key{minted at opt@lang}{#2}{%
-        \minted at addto@optlistcl at lang@e{minted at optlistcl@lang\minted at lang}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang:#2}{#4}}%
-      \define at key{minted at opt@lang at i}{#2}{%
-        \minted at addto@optlistcl at lang@e{%
-          minted at optlistcl@lang\minted at lang @i}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang @i:#2}{#4}}%
-      \define at key{minted at opt@cmd}{#2}{%
-        \minted at addto@optlistcl at e{\minted at optlistcl@cmd}{#3}{#4}%
-        \@namedef{minted at opt@cmd:#2}{#4}}}%
-    {\define at key{minted at opt@g}{#2}[#1]{%
-        \minted at addto@optlistcl at e{\minted at optlistcl@g}{#3}{#4}%
-        \@namedef{minted at opt@g:#2}{#4}}%
-      \define at key{minted at opt@g at i}{#2}[#1]{%
-        \minted at addto@optlistcl at e{\minted at optlistcl@g at i}{#3}{#4}%
-        \@namedef{minted at opt@g at i:#2}{#4}}%
-      \define at key{minted at opt@lang}{#2}[#1]{%
-        \minted at addto@optlistcl at lang@e{minted at optlistcl@lang\minted at lang}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang:#2}{#4}}%
-      \define at key{minted at opt@lang at i}{#2}[#1]{%
-        \minted at addto@optlistcl at lang@e{%
-          minted at optlistcl@lang\minted at lang @i}{#3}{#4}%
-        \@namedef{minted at opt@lang\minted at lang @i:#2}{#4}}%
-      \define at key{minted at opt@cmd}{#2}[#1]{%
-        \minted at addto@optlistcl at e{\minted at optlistcl@cmd}{#3}{#4}%
-        \@namedef{minted at opt@cmd:#2}{#4}}}%
+\newbool{minted at cache}
+\booltrue{minted at cache}
+\minted at pgfopts{
+  cache/.is if=minted at cache,
 }
-\newcommand{\minted at def@optcl at switch}[2]{%
-  \define at booleankey{minted at opt@g}{#1}%
-    {\minted at addto@optlistcl{\minted at optlistcl@g}{#2}{True}%
-      \@namedef{minted at opt@g:#1}{true}}
-    {\minted at addto@optlistcl{\minted at optlistcl@g}{#2}{False}%
-      \@namedef{minted at opt@g:#1}{false}}
-  \define at booleankey{minted at opt@g at i}{#1}%
-    {\minted at addto@optlistcl{\minted at optlistcl@g at i}{#2}{True}%
-      \@namedef{minted at opt@g at i:#1}{true}}
-    {\minted at addto@optlistcl{\minted at optlistcl@g at i}{#2}{False}%
-      \@namedef{minted at opt@g at i:#1}{false}}
-  \define at booleankey{minted at opt@lang}{#1}%
-    {\minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang}{#2}{True}%
-      \@namedef{minted at opt@lang\minted at lang:#1}{true}}
-    {\minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang}{#2}{False}%
-      \@namedef{minted at opt@lang\minted at lang:#1}{false}}
-  \define at booleankey{minted at opt@lang at i}{#1}%
-    {\minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang @i}{#2}{True}%
-      \@namedef{minted at opt@lang\minted at lang @i:#1}{true}}
-    {\minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang @i}{#2}{False}%
-      \@namedef{minted at opt@lang\minted at lang @i:#1}{false}}
-  \define at booleankey{minted at opt@cmd}{#1}%
-      {\minted at addto@optlistcl{\minted at optlistcl@cmd}{#2}{True}%
-        \@namedef{minted at opt@cmd:#1}{true}}
-      {\minted at addto@optlistcl{\minted at optlistcl@cmd}{#2}{False}%
-        \@namedef{minted at opt@cmd:#1}{false}}
+\edef\minted at cachedir{\detokenize{_minted}}
+\minted at pgfopts{
+  cachedir/.estore in=\minted at cachedir,
 }
-\newcommand{\minted at def@optfv}[1]{%
-  \define at key{minted at opt@g}{#1}{%
-    \expandafter\def\expandafter\minted at optlistfv@g\expandafter{%
-      \minted at optlistfv@g#1={##1},}%
-    \@namedef{minted at opt@g:#1}{##1}}
-  \define at key{minted at opt@g at i}{#1}{%
-    \expandafter\def\expandafter\minted at optlistfv@g at i\expandafter{%
-      \minted at optlistfv@g at i#1={##1},}%
-    \@namedef{minted at opt@g at i:#1}{##1}}
-  \define at key{minted at opt@lang}{#1}{%
-    \expandafter\let\expandafter\minted at tmp%
-      \csname minted at optlistfv@lang\minted at lang\endcsname
-    \expandafter\def\expandafter\minted at tmp\expandafter{%
-      \minted at tmp#1={##1},}%
-    \expandafter\let\csname minted at optlistfv@lang\minted at lang\endcsname%
-      \minted at tmp
-    \@namedef{minted at opt@lang\minted at lang:#1}{##1}}
-  \define at key{minted at opt@lang at i}{#1}{%
-    \expandafter\let\expandafter\minted at tmp%
-      \csname minted at optlistfv@lang\minted at lang @i\endcsname
-    \expandafter\def\expandafter\minted at tmp\expandafter{%
-      \minted at tmp#1={##1},}%
-    \expandafter\let\csname minted at optlistfv@lang\minted at lang @i\endcsname%
-      \minted at tmp
-    \@namedef{minted at opt@lang\minted at lang @i:#1}{##1}}
-  \define at key{minted at opt@cmd}{#1}{%
-    \expandafter\def\expandafter\minted at optlistfv@cmd\expandafter{%
-      \minted at optlistfv@cmd#1={##1},}%
-    \@namedef{minted at opt@cmd:#1}{##1}}
+\newbool{minted at frozencache}
+\minted at pgfopts{
+  frozencache/.is if=minted at frozencache,
 }
-\newcommand{\minted at def@optfv at switch}[1]{%
-  \define at booleankey{minted at opt@g}{#1}%
-    {\expandafter\def\expandafter\minted at optlistfv@g\expandafter{%
-      \minted at optlistfv@g#1=true,}%
-     \@namedef{minted at opt@g:#1}{true}}%
-    {\expandafter\def\expandafter\minted at optlistfv@g\expandafter{%
-      \minted at optlistfv@g#1=false,}%
-     \@namedef{minted at opt@g:#1}{false}}%
-  \define at booleankey{minted at opt@g at i}{#1}%
-    {\expandafter\def\expandafter\minted at optlistfv@g at i\expandafter{%
-      \minted at optlistfv@g at i#1=true,}%
-     \@namedef{minted at opt@g at i:#1}{true}}%
-    {\expandafter\def\expandafter\minted at optlistfv@g at i\expandafter{%
-      \minted at optlistfv@g at i#1=false,}%
-     \@namedef{minted at opt@g at i:#1}{false}}%
-  \define at booleankey{minted at opt@lang}{#1}%
-    {\expandafter\let\expandafter\minted at tmp%
-        \csname minted at optlistfv@lang\minted at lang\endcsname
-      \expandafter\def\expandafter\minted at tmp\expandafter{%
-        \minted at tmp#1=true,}%
-      \expandafter\let\csname minted at optlistfv@lang\minted at lang\endcsname%
-        \minted at tmp
-     \@namedef{minted at opt@lang\minted at lang:#1}{true}}%
-    {\expandafter\let\expandafter\minted at tmp%
-        \csname minted at optlistfv@lang\minted at lang\endcsname
-      \expandafter\def\expandafter\minted at tmp\expandafter{%
-        \minted at tmp#1=false,}%
-      \expandafter\let\csname minted at optlistfv@lang\minted at lang\endcsname%
-        \minted at tmp
-     \@namedef{minted at opt@lang\minted at lang:#1}{false}}%
-  \define at booleankey{minted at opt@lang at i}{#1}%
-    {\expandafter\let\expandafter\minted at tmp%
-        \csname minted at optlistfv@lang\minted at lang @i\endcsname
-      \expandafter\def\expandafter\minted at tmp\expandafter{%
-        \minted at tmp#1=true,}%
-      \expandafter\let\csname minted at optlistfv@lang\minted at lang @i\endcsname%
-        \minted at tmp
-     \@namedef{minted at opt@lang\minted at lang @i:#1}{true}}%
-    {\expandafter\let\expandafter\minted at tmp%
-        \csname minted at optlistfv@lang\minted at lang @i\endcsname
-      \expandafter\def\expandafter\minted at tmp\expandafter{%
-        \minted at tmp#1=false,}%
-      \expandafter\let\csname minted at optlistfv@lang\minted at lang @i\endcsname%
-        \minted at tmp
-     \@namedef{minted at opt@lang\minted at lang @i:#1}{false}}%
-  \define at booleankey{minted at opt@cmd}{#1}%
-    {\expandafter\def\expandafter\minted at optlistfv@cmd\expandafter{%
-      \minted at optlistfv@cmd#1=true,}%
-     \@namedef{minted at opt@cmd:#1}{true}}%
-    {\expandafter\def\expandafter\minted at optlistfv@cmd\expandafter{%
-      \minted at optlistfv@cmd#1=false,}%
-     \@namedef{minted at opt@cmd:#1}{false}}%
+\newbool{minted at lexerlinenos}
+\minted at pgfopts{
+  lexerlinenos/.is if=minted at lexerlinenos,
+  langlinenos/.is if=minted at lexerlinenos,
 }
-\newboolean{minted at isinline}
-\newcommand{\minted at fvset}{%
-  \expandafter\fvset\expandafter{\minted at optlistfv@g}%
-  \expandafter\let\expandafter\minted at tmp%
-    \csname minted at optlistfv@lang\minted at lang\endcsname
-  \expandafter\fvset\expandafter{\minted at tmp}%
-  \ifthenelse{\boolean{minted at isinline}}%
-   {\expandafter\fvset\expandafter{\minted at optlistfv@g at i}%
-    \expandafter\let\expandafter\minted at tmp%
-      \csname minted at optlistfv@lang\minted at lang @i\endcsname
-    \expandafter\fvset\expandafter{\minted at tmp}}%
+\newbool{minted at inputlexerlinenos}
+\minted at pgfopts{
+  inputlexerlinenos/.is if=minted at inputlexerlinenos,
+  inputlanglinenos/.is if=minted at inputlexerlinenos,
+}
+\newbool{minted at placeholder}
+\minted at pgfopts{
+  placeholder/.is if=minted at placeholder,
+}
+\gdef\minted at insertplaceholder{%
+  \ifbool{minted at 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}}%
+\newbool{minted at verbatim}
+\minted at pgfopts{
+  verbatim/.is if=minted at verbatim,
+}
+\newbool{minted at fasthighlightmode}
+\newbool{minted at fasthighlightmode@open}
+\minted at pgfopts{
+  highlightmode/.is choice,
+  highlightmode/fast/.code=
+    \let\minted at highlightmode@init\minted at highlightmode@init at fast,
+  highlightmode/fastfirst/.code=
+    \let\minted at highlightmode@init\minted at highlightmode@init at fastfirst,
+  highlightmode/immediate/.code=
+    \let\minted at highlightmode@init\minted at highlightmode@init at immediate,
+}
+\def\minted at highlightmode@init at fast{%
+  \global\booltrue{minted at fasthighlightmode}}
+\def\minted at highlightmode@init at fastfirst{%
+  \IfFileExists{\minted at cachepath\MintedCacheIndexFilename}%
+   {\global\boolfalse{minted at fasthighlightmode}}
+   {\global\booltrue{minted at fasthighlightmode}}}
+\def\minted at highlightmode@init at immediate{%
+  \global\boolfalse{minted at fasthighlightmode}}
+\let\minted at highlightmode@init\minted at highlightmode@init at fastfirst
+\def\minted at fasthighlightmode@checkstart{%
+  \ifbool{minted at fasthighlightmode}%
+   {\pydatawritelistopen
+    \global\booltrue{minted at fasthighlightmode@open}}%
    {}%
-  \expandafter\fvset\expandafter{\minted at optlistfv@cmd}%
+  \global\let\minted at fasthighlightmode@checkstart\relax}
+\def\minted at fasthighlightmode@checkend{%
+  \ifbool{minted at fasthighlightmode@open}%
+   {\pydatasetfilename{\MintedDataFilename}%
+    \pydatawritelistclose
+    \pydataclosefilename{\MintedDataFilename}%
+    \global\boolfalse{minted at fasthighlightmode@open}%
+    \global\boolfalse{minted at fasthighlightmode}%
+    \begingroup
+    \minted at exec@batch
+    \ifx\minted at exec@warning\relax
+    \else
+      \expandafter\minted at exec@warning
+    \fi
+    \ifx\minted at exec@error\relax
+    \else
+      \expandafter\minted at exec@error
+    \fi
+    \endgroup
+    \global\boolfalse{minted at canexec}}%
+   {}%
+  \global\let\minted at fasthighlightmode@checkend\relax}
+\minted at pgfopts{
+  finalizecache/.code=\minted at error{%
+    Package option "finalizecache" is no longer needed with minted v3+},
 }
-\newcommand{\minted at def@opt}[2][]{%
-  \define at key{minted at opt@g}{#2}{%
-    \@namedef{minted at opt@g:#2}{##1}}
-  \define at key{minted at opt@g at i}{#2}{%
-    \@namedef{minted at opt@g at i:#2}{##1}}
-  \define at key{minted at opt@lang}{#2}{%
-    \@namedef{minted at opt@lang\minted at lang:#2}{##1}}
-  \define at key{minted at opt@lang at i}{#2}{%
-    \@namedef{minted at opt@lang\minted at lang @i:#2}{##1}}
-  \define at key{minted at opt@cmd}{#2}{%
-    \@namedef{minted at opt@cmd:#2}{##1}}
-  \ifstrempty{#1}{}{\@namedef{minted at opt@g:#2}{#1}}%
+\minted at pgfopts{
+  kpsewhich/.code=\minted at error{%
+    Package option "kpsewhich" is no longer needed with minted v3+},
 }
-\newcommand{\minted at def@opt at detok}[2][]{%
-  \define at key{minted at opt@g}{#2}{%
-    \@namedef{minted at opt@g:#2}{\detokenize{##1}}}
-  \define at key{minted at opt@g at i}{#2}{%
-    \@namedef{minted at opt@g at i:#2}{\detokenize{##1}}}
-  \define at key{minted at opt@lang}{#2}{%
-    \@namedef{minted at opt@lang\minted at lang:#2}{\detokenize{##1}}}
-  \define at key{minted at opt@lang at i}{#2}{%
-    \@namedef{minted at opt@lang\minted at lang @i:#2}{\detokenize{##1}}}
-  \define at key{minted at opt@cmd}{#2}{%
-    \@namedef{minted at opt@cmd:#2}{\detokenize{##1}}}
-  \ifstrempty{#1}{}{\@namedef{minted at opt@g:#2}{\detokenize{#1}}}%
+\minted at pgfopts{
+  outputdir/.code=\minted at 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},
 }
-\newcommand{\minted at generate@PYGdef}[1]{%
-  \ifthenelse{\boolean{minted at cache}}%
-   {\def\minted at pygstylepath@load{\minted at outputdir\minted at cachedir/#1.pygstyle}%
-    \minted at addcachefile{#1.pygstyle}}%
-   {\def\minted at pygstylepath@load{\minted at outputdir\minted at jobname.out.pyg}}%
-  \ifwindows
-    \StrSubstitute{\minted at pygstylepath@load}%
-      {/}{\@backslashchar}[\minted at pygstylepath@save]%
+\def\minted at outputdir{}
+\minted at pgfopts{
+  draft/.code=\minted at warning{%
+    Package option "draft" no longer has any effect with minted v3+},
+}
+\minted at pgfopts{
+  final/.code=\minted at warning{%
+    Package option "final" no longer has any effect with minted v3+},
+}
+\ProcessPgfOptions{/minted/pkg}
+\ifbool{minted at cache}{}{\def\minted at cachedir{}}%
+\ifbool{minted at newfloat}{\RequirePackage{newfloat}}{\RequirePackage{float}}
+\ifcsname tikzifexternalizing\endcsname
+  \ifx\tikzifexternalizing\relax
   \else
-    \let\minted at pygstylepath@save\minted at pygstylepath@load
+    \tikzifexternalizing{\booltrue{minted at placeholder}}{}
   \fi
-  \IfFileExists{\minted at pygstylepath@load}%
+\fi
+\def\minted at styleprefix{PYG}
+\newcounter{minted at tmpcnt}
+\def\minted at forcsvlist#1#2{%
+  \if\relax\detokenize\expandafter{\@gobble#2}\relax
+    \expandafter\minted at forcsvlist@exp
+  \else
+    \expandafter\minted at forcsvlist@i
+  \fi
+  {#2}{#1}}
+\def\minted at forcsvlist@exp#1#2{%
+  \expandafter\minted at forcsvlist@i\expandafter{#1}{#2}}
+\def\minted at forcsvlist@i#1#2{%
+  \forcsvlist{#2}{#1}}
+\def\minted at apptoprovidecs#1#2{%
+  \ifcsname#1\endcsname
+  \else
+    \expandafter\def\csname#1\endcsname{}%
+  \fi
+  \expandafter\let\expandafter\minted at tmp\csname#1\endcsname
+  \expandafter\def\expandafter\minted at tmp\expandafter{\minted at tmp#2}%
+  \expandafter\let\csname#1\endcsname\minted at tmp}
+\def\minted at const@pgfkeysnovalue{\pgfkeysnovalue}
+\def\minted at ensureatletter#1{%
+  \edef\minted at tmpatcat{\the\catcode`\@}%
+  \catcode`\@=11\relax
+  #1%
+  \catcode`\@=\minted at tmpatcat\relax}
+\setcounter{minted at tmpcnt}{48}
+\loop\unless\ifnum\value{minted at tmpcnt}>57\relax
+  \expandafter\let\csname minted at isnum\arabic{minted at tmpcnt}\endcsname\relax
+  \expandafter\let\csname minted at isalphanum\arabic{minted at tmpcnt}\endcsname\relax
+  \expandafter\let
+    \csname minted at isalphanumhyphenunderscore\arabic{minted at tmpcnt}\endcsname\relax
+  \stepcounter{minted at tmpcnt}
+\repeat
+\setcounter{minted at tmpcnt}{65}
+\loop\unless\ifnum\value{minted at tmpcnt}>90\relax
+  \expandafter\let\csname minted at isalpha\arabic{minted at tmpcnt}\endcsname\relax
+  \expandafter\let\csname minted at isalphanum\arabic{minted at tmpcnt}\endcsname\relax
+  \expandafter\let
+    \csname minted at isalphanumhyphenunderscore\arabic{minted at tmpcnt}\endcsname\relax
+  \stepcounter{minted at tmpcnt}
+\repeat
+\setcounter{minted at tmpcnt}{97}
+\loop\unless\ifnum\value{minted at tmpcnt}>122\relax
+  \expandafter\let\csname minted at isalpha\arabic{minted at tmpcnt}\endcsname\relax
+  \expandafter\let\csname minted at isalphanum\arabic{minted at tmpcnt}\endcsname\relax
+  \expandafter\let
+    \csname minted at isalphanumhyphenunderscore\arabic{minted at tmpcnt}\endcsname\relax
+  \stepcounter{minted at tmpcnt}
+\repeat
+\expandafter\let\csname minted at isalphanumhyphenunderscore45\endcsname\relax
+\expandafter\let\csname minted at isalphanumhyphenunderscore95\endcsname\relax
+\def\minted at ifalphanumhyphenunderscore#1#2#3{%
+  \if\relax\detokenize{#1}\relax
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+  {#3}%
+  {\expandafter\minted at ifalphanumhyphenunderscore@i\detokenize{#1}\FV at Sentinel{#2}{#3}}}
+\def\minted at ifalphanumhyphenunderscore@i#1#2\FV at Sentinel{%
+  \if\relax#2\relax
+    \expandafter\minted at ifalphanumhyphenunderscore@iii
+  \else
+    \expandafter\minted at ifalphanumhyphenunderscore@ii
+  \fi
+  #1#2\FV at Sentinel}
+\def\minted at ifalphanumhyphenunderscore@ii#1#2\FV at Sentinel{%
+  \ifcsname minted at isalphanumhyphenunderscore\number`#1\endcsname
+    \expandafter\minted at ifalphanumhyphenunderscore@i
+  \else
+    \expandafter\minted at ifalphanumhyphenunderscore@false
+  \fi
+  #2\FV at Sentinel}
+\def\minted at ifalphanumhyphenunderscore@iii#1\FV at Sentinel{%
+  \ifcsname minted at isalphanumhyphenunderscore\number`#1\endcsname
+    \expandafter\minted at ifalphanumhyphenunderscore@true
+  \else
+    \expandafter\minted at ifalphanumhyphenunderscore@false
+  \fi
+  \FV at Sentinel}
+\def\minted at ifalphanumhyphenunderscore@true\FV at Sentinel#1#2{#1}
+\def\minted at ifalphanumhyphenunderscore@false#1\FV at Sentinel#2#3{#3}
+\let\minted at lexer\@empty
+\newbool{minted at isinline}
+\newcounter{minted at tmpcodebufferlength}
+\newbool{minted at canexec}
+\booltrue{minted at canexec}
+\ifnum\csname c_sys_shell_escape_int\endcsname=0\relax
+  \boolfalse{minted at canexec}
+\fi
+\ifbool{minted at frozencache}{\boolfalse{minted at canexec}}{}
+\ifbool{minted at placeholder}{\boolfalse{minted at canexec}}{}
+\ifbool{minted at verbatim}{\boolfalse{minted at canexec}}{}
+\def\minted at ShellEscapeMaybeMessages#1{%
+  \let\minted at exec@warning\relax
+  \let\minted at exec@error\relax
+  \ifbool{minted at canexec}{\ShellEscape{#1}\minted at inputexecmessages}{}}
+\def\minted at ShellEscapeNoMessages#1{%
+  \ifbool{minted at canexec}{\ShellEscape{#1}}{}}
+\def\minted at execarg@debug{%
+  \ifbool{minted at debug}{\detokenize{ --debug }}{}}
+\def\minted at execarg@timestamp{%
+  \detokenize{ --timestamp }\minted at timestamp\detokenize{ }}
+\def\minted at exec@cleanfile#1{%
+  \minted at ShellEscapeNoMessages{%
+    \MintedExecutable\detokenize{ cleanfile }\minted at execarg@debug#1}}
+\def\minted at inputexecmessages{%
+  \minted at ensureatletter{\InputIfFileExists{\MintedMessageFilename}{}{}}}
+\def\minted at exec@batch{%
+  \minted at ShellEscapeMaybeMessages{%
+    \MintedExecutable
+    \detokenize{ batch }\minted at execarg@timestamp\minted at execarg@debug
+    \MintedJobnameMdfive}}
+\def\minted at exec@config{%
+  \minted at ShellEscapeMaybeMessages{%
+    \MintedExecutable
+    \detokenize{ config }\minted at execarg@timestamp\minted at execarg@debug
+    \MintedJobnameMdfive}}
+\def\minted at exec@styledef{%
+  \minted at ShellEscapeMaybeMessages{%
+    \MintedExecutable
+    \detokenize{ styledef }\minted at execarg@timestamp\minted at execarg@debug
+    \MintedJobnameMdfive}}
+\def\minted at exec@highlight{%
+  \minted at ShellEscapeMaybeMessages{%
+    \MintedExecutable
+    \detokenize{ highlight }\minted at execarg@timestamp\minted at execarg@debug
+    \MintedJobnameMdfive}}
+\def\minted at exec@clean{%
+  \minted at ShellEscapeNoMessages{%
+    \MintedExecutable
+    \detokenize{ clean }\minted at execarg@timestamp\minted at execarg@debug
+    \MintedJobnameMdfive}}
+\newbool{minted at diddetectconfig}
+\def\minted at detectconfig{%
+  \ifbool{minted at diddetectconfig}%
    {}%
-   {\ifthenelse{\boolean{minted at frozencache}}%
-     {\PackageError{minted}%
-       {Missing style definition for #1 with frozencache}%
-       {Missing style definition for #1 with frozencache}}%
-     {}%
-    \ShellEscape{%
-      \MintedPygmentize\space -S #1 -f latex -P commandprefix=PYG
-      > \minted at pygstylepath@save
+   {\ifx\minted at cachedir\@empty
+      \gdef\minted at cachepath{}%
+    \else
+      \gdef\minted at cachepath{\minted at cachedir/}%
+    \fi
+    \ifbool{minted at canexec}{\begingroup\minted at detectconfig@i\endgroup}{}%
+    \global\booltrue{minted at diddetectconfig}}}
+\def\minted at detectconfig@i{%
+  \global\let\minted at executable@version\relax
+  \global\let\minted at executable@timestamp\relax
+  \global\let\minted at config@timestamp\relax
+  \pydatasetfilename{\MintedDataFilename}%
+  \pydatawritedictopen
+  \pydatawritekeyvalue{command}{config}%
+  \pydatawritekeyedefvalue{jobname}{\jobname}%
+  \pydatawritekeyedefvalue{timestamp}{\minted at timestamp}%
+  \pydatawritekeyedefvalue{cachedir}{\minted at cachedir}%
+  \pydatawritedictclose
+  \pydataclosefilename{\MintedDataFilename}%
+  \minted at exec@config
+  \minted at ensureatletter{%
+    \InputIfFileExists{\MintedConfigFilename}{}{}}%
+  \ifx\minted at executable@version\relax
+    \expandafter\minted at detectconfig@noexecutable
+  \else
+    \expandafter\minted at detectconfig@ii
+  \fi}
+\def\minted at detectconfig@noexecutable{%
+  \global\boolfalse{minted at canexec}%
+  \ifnum\csname c_sys_shell_escape_int\endcsname=1\relax
+    \minted at error{minted v3+ executable is not installed or is not added to PATH}%
+  \else
+    \minted at error{minted v3+ executable is not installed, is not added to PATH,
+      or is not permitted with restricted shell escape}%
+  \fi}
+\def\minted at detectconfig@ii{%
+  \ifx\minted at timestamp\minted at config@timestamp
+    \expandafter\minted at detectconfig@iii
+  \else
+    \expandafter\minted at detectconfig@wrongtimestamp
+  \fi}
+\def\minted at detectconfig@wrongtimestamp{%
+  \ifx\minted at timestamp\minted at executable@timestamp
+    \minted at exec@cleanfile{\MintedConfigFilename}%
+    \global\boolfalse{minted at canexec}%
+    \minted at 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 at detectconfig@noexecutable
+  \fi}
+\def\minted at detectconfig@iii{%
+  \minted at exec@cleanfile{\MintedConfigFilename}%
+  \ifx\minted at exec@warning\relax
+  \else
+    \expandafter\minted at exec@warning
+  \fi
+  \ifx\minted at exec@error\relax
+    \expandafter\minted at detectconfig@iv
+  \else
+    \expandafter\minted at detectconfig@error
+  \fi}
+\def\minted at detectconfig@error{%
+  \global\boolfalse{minted at canexec}%
+  \minted at exec@error}
+\def\minted at detectconfig@iv{%
+  \expandafter\minted at detectconfig@v\minted at executable@version\relax}
+\begingroup
+\catcode`\.=12
+\gdef\minted at detectconfig@v#1.#2.#3\relax{%
+  \def\minted at executable@major{#1}%
+  \def\minted at executable@minor{#2}%
+  \def\minted at executable@patch{#3}%
+  \minted at detectconfig@vi}
+\endgroup
+\def\minted at detectconfig@vi{%
+  \ifnum\minted at executable@major>\minted at executable@minmajor\relax
+    \global\booltrue{minted at executable@issupported}%
+  \else\ifnum\minted at executable@major=\minted at executable@minmajor\relax
+    \ifnum\minted at executable@minor>\minted at executable@minminor\relax
+      \global\booltrue{minted at executable@issupported}%
+    \else\ifnum\minted at executable@minor=\minted at executable@minminor\relax
+      \ifnum\minted at executable@patch<\minted at executable@minpatch\relax
+      \else
+        \global\booltrue{minted at executable@issupported}%
+      \fi
+    \fi\fi
+  \fi\fi
+  \ifbool{minted at executable@issupported}%
+   {\ifx\minted at config@cachepath\relax
+      \expandafter\@firstoftwo
+    \else
+      \expandafter\@secondoftwo
+    \fi
+    {\global\boolfalse{minted at canexec}%
+      \minted at error{minted Python executable returned incomplete configuration data;
+        this may indicate a bug in minted or file corruption}}%
+    {\global\let\minted at cachepath\minted at config@cachepath
+     \minted at highlightmode@init}}%
+   {\global\boolfalse{minted at canexec}%
+    \minted at error{minted Python executable is version \minted at executable@version,
+      but version \minted at executable@minversion+ is required}}}
+\begingroup
+\catcode`\,=12
+\gdef\minted at optcats{fv,py,tex}
+\endgroup
+\def\minted at do#1{\expandafter\def\csname minted at optkeyslist@#1\endcsname{}}
+\minted at forcsvlist{\minted at do}{\minted at optcats}
+\begingroup
+\catcode`\,=12
+\gdef\minted at optscopes{global,lexer,globalinline,lexerinline,cmd}
+\gdef\minted at optscopes@onlyblock{global,lexer,cmd}
+\endgroup
+\let\minted at iflexerscope@lexer\relax
+\let\minted at iflexerscope@lexerinline\relax
+\def\minted at iflexerscope#1#2#3{%
+  \ifcsname minted at iflexerscope@#1\endcsname
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+  {#2}{#3}}
+\def\minted at addoptkey#1#2{%
+  \ifcsname minted at optkeyslist@#1\endcsname
+  \else
+    \minted at fatalerror{Defining options under category "#1" is not supported}%
+  \fi
+  \expandafter\let\expandafter\minted at tmp\csname minted at optkeyslist@#1\endcsname
+  \ifx\minted at tmp\@empty
+    \def\minted at tmp{#2}%
+  \else
+    \expandafter\def\expandafter\minted at tmp\expandafter{\minted at tmp,#2}%
+  \fi
+  \expandafter\let\csname minted at optkeyslist@#1\endcsname\minted at tmp}
+\newcommand*{\mintedpgfkeyscreate}[3][]{%
+  \mintedpgfkeyscreate at i{#1}{#2}{#3}}
+\begingroup
+\catcode`\==12
+\gdef\mintedpgfkeyscreate at i#1#2#3{%
+  \def\minted at do##1{%
+    \minted at do@i##1=\FV at Sentinel}%
+  \def\minted at do@i##1=##2\FV at Sentinel{%
+    \minted at do@ii##1<>\FV at Sentinel}%
+  \def\minted at do@ii##1<##2>##3\FV at Sentinel{%
+    \minted at addoptkey{#2}{##1}}%
+  \minted at forcsvlist{\minted at do}{#3}%
+  \csname minted at pgfkeyscreate@#2\endcsname{#1}{#3}}
+\endgroup
+\def\minted at pgfkeyscreate@fv#1#2{%
+  \if\relax\detokenize{#1}\relax
+  \else
+    \minted at fatalerror{Processor macros are not supported in defining fancyvrb options}%
+  \fi
+  \minted at forcsvlist{\minted at pgfkeycreate@fv}{#2}}
+\begingroup
+\catcode`\==12
+\gdef\minted at pgfkeycreate@fv#1{%
+  \minted at pgfkeycreate@fv at i#1=\FV at Sentinel}
+\gdef\minted at pgfkeycreate@fv at i#1=#2\FV at Sentinel{%
+  \if\relax\detokenize{#2}\relax
+    \expandafter\minted at pgfkeycreate@fv at ii
+  \else
+    \expandafter\minted at pgfkeycreate@fv at iii
+  \fi
+  {#1}#2\FV at Sentinel}
+\gdef\minted at pgfkeycreate@fv at ii#1\FV at Sentinel{%
+  \minted at pgfkeycreate@fv at iv{#1}{\minted at const@pgfkeysnovalue}}
+\gdef\minted at pgfkeycreate@fv at iii#1#2=\FV at Sentinel{%
+  \minted at pgfkeycreate@fv at iv{#1}{#2}}
+\endgroup
+\def\minted at pgfkeycreate@fv at iv#1#2{%
+  \def\minted at do##1{%
+    \minted at iflexerscope{##1}%
+     {\minted at do@i{##1}{@\minted at lexer}}%
+     {\minted at do@i{##1}{}}}%
+  \def\minted at do@i##1##2{%
+    \pgfkeys{%
+      /minted/##1/.cd,
+      #1/.code=
+        \def\minted at tmp{####1}%
+        \ifx\minted at tmp\minted at const@pgfkeysnovalue
+          \begingroup\fvset{#1}\endgroup
+          \minted at apptoprovidecs{minted at fvoptlist@##1##2}{#1,}%
+        \else
+          \begingroup\fvset{#1=####1}\endgroup
+          \minted at apptoprovidecs{minted at fvoptlist@##1##2}{#1=####1,}%
+        \fi,
     }%
-   }%
-  \CatchFileDef{\minted at tmp@filecontents}%
-   {\minted at pygstylepath@load}{\catcode`@=11\catcode`\%=14\catcode``=12\endlinechar=-1}%
-  \begingroup
-  \let\PYG\relax
-  \minted at tmp@filecontents
-  \ifx\PYG\relax
-    \ifthenelse{\boolean{minted at frozencache}}%
-     {\PackageError{minted}%
-       {Outdated style definition for #1 with frozencache}%
-       {Outdated style definition for #1 with frozencache}}%
-     {}%
-    \ShellEscape{%
-      \MintedPygmentize\space -S #1 -f latex -P commandprefix=PYG
-      > \minted at pygstylepath@save
+  }%
+  \minted at forcsvlist{\minted at do}{\minted at optscopes}%
+  \ifx\minted at const@pgfkeysnovalue#2\relax
+  \else
+    \pgfkeys{%
+      /minted/global/.cd,
+      #1=#2,
     }%
-    \CatchFileDef{\minted at tmp@filecontents}%
-     {\minted at pygstylepath@load}{\catcode`@=11\catcode`\%=14\catcode``=12\endlinechar=-1}%
-    \minted at tmp@filecontents
-    \ifx\PYG\relax
-      \PackageError{minted}%
-       {Cannot find Pygments style #1}%
-       {Cannot find Pygments style #1}%
+  \fi}
+\def\minted at usefvopts{%
+  \ifbool{minted at isinline}%
+   {\minted at forcsvlist{\minted at usefvopts@do}{\minted at optscopes}}%
+   {\minted at forcsvlist{\minted at usefvopts@do}{\minted at optscopes@onlyblock}}}
+\def\minted at usefvopts@do#1{%
+  \minted at iflexerscope{#1}%
+   {\ifcsname minted at fvoptlist@#1@\minted at lexer\endcsname
+    \expandafter
+      \let\expandafter\minted at tmp\csname minted at fvoptlist@#1@\minted at lexer\endcsname
+    \expandafter\fvset\expandafter{\minted at tmp}%
+    \fi}%
+   {\ifcsname minted at fvoptlist@#1\endcsname
+    \expandafter
+      \let\expandafter\minted at tmp\csname minted at fvoptlist@#1\endcsname
+    \expandafter\fvset\expandafter{\minted at tmp}%
+    \fi}}
+\def\minted at useadditionalfvoptsnopy{%
+  \edef\minted at tmp{\mintedpyoptvalueof{gobble}}%
+  \ifx\minted at tmp\minted at const@pgfkeysnovalue
+  \else
+    \expandafter\minted at useadditionalfvoptsnopy@fvsetvk
+      \expandafter{\minted at tmp}{gobble}%
+  \fi
+  \edef\minted at tmp{\mintedpyoptvalueof{mathescape}}%
+  \ifx\minted at tmp\minted at const@pgfkeysnovalue
+  \else
+    \expandafter\minted at useadditionalfvoptsnopy@fvsetvk
+      \expandafter{\minted at tmp}{mathescape}%
+  \fi}
+\def\minted at useadditionalfvoptsnopy@fvsetvk#1#2{%
+  \fvset{#2=#1}}
+\def\minted at pgfkeyscreate@py#1#2{%
+  \minted at forcsvlist{\minted at pgfkeycreate@py{#1}}{#2}}
+\begingroup
+\catcode`\==12
+\catcode`\<=12
+\catcode`\>=12
+\gdef\minted at pgfkeycreate@py#1#2{%
+  \minted at pgfkeycreate@py at i{#1}#2=\FV at Sentinel}
+\gdef\minted at pgfkeycreate@py at i#1#2=#3\FV at Sentinel{%
+  \if\relax\detokenize{#3}\relax
+    \expandafter\minted at pgfkeycreate@py at ii
+  \else
+    \expandafter\minted at pgfkeycreate@py at iii
+  \fi
+  {#1}{#2}#3\FV at Sentinel}
+\gdef\minted at pgfkeycreate@py at ii#1#2\FV at Sentinel{%
+  \minted at pgfkeycreate@py at iv{#1}{\pgfkeysnovalue}#2<>\FV at Sentinel}
+\gdef\minted at pgfkeycreate@py at iii#1#2#3=\FV at Sentinel{%
+  \minted at pgfkeycreate@py at iv{#1}{#3}#2<>\FV at Sentinel}
+\gdef\minted at pgfkeycreate@py at iv#1#2#3<#4>#5\FV at Sentinel{%
+  \if\relax\detokenize{#4}\relax
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+  {\minted at pgfkeycreate@py at v{#1}{#3}{#2}{\minted at const@pgfkeysnovalue}}%
+  {\minted at pgfkeycreate@py at v{#1}{#3}{#2}{#4}}}
+\endgroup
+\def\minted at pgfkeycreate@py at v#1#2#3#4{%
+  \def\minted at do##1{%
+    \minted at iflexerscope{##1}%
+     {\minted at do@i{##1}{@\minted at lexer}}%
+     {\minted at do@i{##1}{}}}
+  \def\minted at do@i##1##2{%
+    \if\relax\detokenize{#1}\relax
+      \pgfkeys{%
+        /minted/##1/.cd,
+        #2/.code=\expandafter\def\csname minted at pyopt@##1##2@#2\endcsname{####1},
+      }%
+    \else
+      \pgfkeys{%
+        /minted/##1/.cd,
+        #2/.code=
+          \def\minted at tmp{####1}%
+          \ifx\minted at tmp\minted at const@pgfkeysnovalue
+            \expandafter\let\csname minted at pyopt@##1##2@#2\endcsname\minted at tmp
+          \else\ifcsname minted at opthandler@immediate@\string#1\endcsname
+            #1{minted at pyopt@##1##2@#2}{####1}%
+          \else
+            \expandafter\def\csname minted at pyopt@##1##2@#2\endcsname{#1{####1}}%
+          \fi\fi,
+      }%
     \fi
+    \ifx\minted at const@pgfkeysnovalue#4\relax
+      \pgfkeys{%
+        /minted/##1/.cd,
+        #2/.value required,
+      }%
+    \else
+      \pgfkeys{%
+        /minted/##1/.cd,
+        #2/.default=#4,
+      }%
+    \fi
+  }%
+  \minted at forcsvlist{\minted at do}{\minted at optscopes}%
+  \pgfkeys{%
+    /minted/global/.cd,
+    #2=#3,
+  }}
+\def\mintedpyoptvalueof#1{%
+  \ifbool{minted at isinline}%
+   {\minted at pyoptvalueof@inline{#1}}%
+   {\minted at pyoptvalueof@block{#1}}}
+\def\minted at pyoptvalueof@inline#1{%
+  \ifcsname minted at pyopt@cmd@#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@cmd@#1\endcsname}%
+  \else\ifcsname minted at pyopt@lexerinline@\minted at lexer @#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@lexerinline@\minted at lexer @#1\endcsname}%
+  \else\ifcsname minted at pyopt@globalinline@#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@globalinline@#1\endcsname}%
+  \else\ifcsname minted at pyopt@lexer@\minted at lexer @#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@lexer@\minted at lexer @#1\endcsname}%
+  \else
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@global@#1\endcsname}%
+  \fi\fi\fi\fi}
+\def\minted at pyoptvalueof@block#1{%
+  \ifcsname minted at pyopt@cmd@#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@cmd@#1\endcsname}%
+  \else\ifcsname minted at pyopt@lexer@\minted at lexer @#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@lexer@\minted at lexer @#1\endcsname}%
+  \else
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at pyopt@global@#1\endcsname}%
+  \fi\fi}
+\def\minted at pgfkeyscreate@tex#1#2{%
+  \minted at forcsvlist{\minted at pgfkeycreate@tex{#1}}{#2}}
+\begingroup
+\catcode`\==12
+\gdef\minted at pgfkeycreate@tex#1#2{%
+  \minted at pgfkeycreate@tex at i{#1}#2=\FV at Sentinel}
+\gdef\minted at pgfkeycreate@tex at i#1#2=#3\FV at Sentinel{%
+  \if\relax\detokenize{#3}\relax
+    \expandafter\minted at pgfkeycreate@tex at ii
+  \else
+    \expandafter\minted at pgfkeycreate@tex at iii
   \fi
-  \expandafter\global\expandafter\let\csname minted at PYGdef@#1\endcsname%
-    \minted at tmp@filecontents
-  \endgroup
+  {#1}{#2}#3\FV at Sentinel}
+\gdef\minted at pgfkeycreate@tex at ii#1#2\FV at Sentinel{%
+  \minted at pgfkeycreate@tex at iv{#1}{#2}{\pgfkeysnovalue}}
+\gdef\minted at pgfkeycreate@tex at iii#1#2#3=\FV at Sentinel{%
+  \minted at pgfkeycreate@tex at iv{#1}{#2}{#3}}
+\endgroup
+\def\minted at pgfkeycreate@tex at iv#1#2#3{%
+  \def\minted at do##1{%
+    \minted at iflexerscope{##1}%
+     {\minted at do@i{##1}{@\minted at lexer}}%
+     {\minted at do@i{##1}{}}}
+  \def\minted at do@i##1##2{%
+    \if\relax\detokenize{#1}\relax
+      \pgfkeys{%
+        /minted/##1/.cd,
+        #2/.code=\expandafter\def\csname minted at texopt@##1##2@#2\endcsname{####1},
+        #2/.value required,
+      }%
+    \else
+      \pgfkeys{%
+        /minted/##1/.cd,
+        #2/.code=
+          \def\minted at tmp{####1}%
+          \ifx\minted at tmp\minted at const@pgfkeysnovalue
+            \expandafter\let\csname minted at texopt@##1##2@#2\endcsname\minted at tmp
+          \else\ifcsname minted at opthandler@immediate@\string#1\endcsname
+            #1{minted at texopt@##1##2@#2}{####1}%
+          \else
+            \expandafter\def\csname minted at texopt@##1##2@#2\endcsname{#1{####1}}%
+          \fi\fi,
+        #2/.value required,
+      }%
+    \fi
+  }%
+  \minted at forcsvlist{\minted at do}{\minted at optscopes}%
+  \pgfkeys{%
+    /minted/global/.cd,
+    #2=#3,
+  }}
+\def\mintedtexoptvalueof#1{%
+  \ifbool{minted at isinline}%
+   {\minted at texoptvalueof@inline{#1}}%
+   {\minted at texoptvalueof@block{#1}}}
+\def\minted at texoptvalueof@inline#1{%
+  \ifcsname minted at texopt@cmd@#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@cmd@#1\endcsname}%
+  \else\ifcsname minted at texopt@lexerinline@\minted at lexer @#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@lexerinline@\minted at lexer @#1\endcsname}%
+  \else\ifcsname minted at texopt@globalinline@#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@globalinline@#1\endcsname}%
+  \else\ifcsname minted at texopt@lexer@\minted at lexer @#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@lexer@\minted at lexer @#1\endcsname}%
+  \else
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@global@#1\endcsname}%
+  \fi\fi\fi\fi}
+\def\minted at texoptvalueof@block#1{%
+  \ifcsname minted at texopt@cmd@#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@cmd@#1\endcsname}%
+  \else\ifcsname minted at texopt@lexer@\minted at lexer @#1\endcsname
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@lexer@\minted at lexer @#1\endcsname}%
+  \else
+    \unexpanded\expandafter\expandafter\expandafter{%
+      \csname minted at texopt@global@#1\endcsname}%
+  \fi\fi}
+\def\minted at usetexoptsnonpygments{}
+\def\minted at 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 at opthandler@deforrestrictedescape at i
+        \expandafter\@gobble\string#2\FV at Sentinel{#1}{#2}%
+    \else
+      \FVExtraDetokenizeREscVArg{\expandafter\def\csname#1\endcsname}{#2}%
+    \fi
+  \else
+    \FVExtraDetokenizeREscVArg{\expandafter\def\csname#1\endcsname}{#2}%
+  \fi\fi}
+\def\minted at opthandler@deforrestrictedescape at i#1#2\FV at Sentinel#3#4{%
+  \ifcsname minted at isalpha\number`#1\endcsname
+    \expandafter\def\csname#3\endcsname{#4}%
+  \else
+    \FVExtraDetokenizeREscVArg{\expandafter\def\csname#3\endcsname}{#4}%
+  \fi}
+\expandafter\let\csname
+  minted at opthandler@immediate@\string\minted at opthandler@deforrestrictedescape
+  \endcsname\relax
+\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,
 }
-\newcommand{\minted at defstyle}[1]{%
-  \edef\minted at style{#1}%
-  \ifcsname minted at PYGdef@\minted at style\endcsname\else
-    \expandafter\minted at generate@PYGdef\expandafter{\minted at style}%
+\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 at opthandler@deforrestrictedescape]{py}{
+  codetagify=,
+  escapeinside=,
+  literatecomment=,
+  rangestartstring=,
+  rangestartafterstring=,
+  rangestopstring=,
+  rangestopbeforestring=,
+  rangeregex=,
+}
+\let\minted at tmplexer\minted at lexer
+\def\minted at lexer{php}
+\pgfkeys{
+  /minted/lexerinline/.cd,
+  startinline=true,
+}
+\let\minted at lexer\minted at tmplexer
+\mintedpgfkeyscreate{tex}{
+  envname=Verbatim,
+  ignorelexererrors=false,
+  style=default,
+}
+\pgfkeys{
+  /minted/globalinline/.cd,
+  envname=VerbEnv,
+}
+\expandafter\def\expandafter\minted at usetexoptsnonpygments\expandafter{%
+  \minted at usetexoptsnonpygments
+  \edef\minted at literalenvname{\mintedpyoptvalueof{literalenvname}}%
+  \edef\minted at envname{\mintedtexoptvalueof{envname}}%
+  \expandafter\def\expandafter\minted at literalenv\expandafter{%
+    \csname \minted at literalenvname\endcsname}%
+  \expandafter\def\expandafter\minted at endliteralenv\expandafter{%
+    \csname end\minted at literalenvname\endcsname}%
+  \expandafter\expandafter\expandafter
+    \let\expandafter\minted at literalenv\csname \minted at envname\endcsname
+  \expandafter\expandafter\expandafter
+    \let\expandafter\minted at endliteralenv\csname end\minted at envname\endcsname}%
+\ifcsname minted at def@optcl\endcsname
+  \ifx\minted at def@optcl\relax
+    \let\minted at def@optcl\minted at undefined
   \fi
-  \csname minted at PYGdef@\minted at style\endcsname
-  \minted at patch@PYGZsq
-  \minted at patch@PYGZhy
-  \ifthenelse{\equal{\minted at get@opt{ignorelexererrors}{true}}{true}}%
-   {\let\PYG at tok@err\relax}{}}
-\ifthenelse{\boolean{minted at draft}}{\renewcommand{\minted at defstyle}[1]{}}{}
-\newcommand{\minted at patch@PYGZsq}{%
-  \ifcsname PYGZsq\endcsname
-    \expandafter\ifdefstring\expandafter{\csname PYGZsq\endcsname}{\char`\'}%
-     {\minted at patch@PYGZsq at i}%
-     {}%
+\fi
+\providecommand{\minted at def@optcl}[4][]{%
+  \minted at warning{Macro \string\minted at def@optcl\space is deprecated with minted v3
+    and no longer has any effect}}
+\newcounter{minted at numcachefiles}
+\def\minted at addcachefilename#1{%
+  \ifbool{minted at canexec}%
+   {\stepcounter{minted at numcachefiles}%
+    \expandafter
+      \xdef\csname minted at cachefile\arabic{minted at numcachefiles}\endcsname{#1}}%
+   {}}
+\def\minted at clean{%
+  \ifbool{minted at canexec}%
+   {\ifbool{minted at diddetectconfig}{\minted at clean@i}{}}%
+   {}}
+\def\minted at clean@i{%
+  \ifnum\value{minted at numcachefiles}>0\relax
+    \expandafter\minted at savecachelist
   \fi
-}
+  \ifbool{minted at fasthighlightmode}%
+   {}%
+   {\minted at exec@clean
+    \global\boolfalse{minted at canexec}}}
+\def\minted at savecachelist{%
+  \pydatasetfilename{\MintedDataFilename}%
+  \minted at fasthighlightmode@checkstart
+  \pydatawritedictopen
+  \pydatawritekeyvalue{command}{clean}%
+  \pydatawritekeyedefvalue{jobname}{\jobname}%
+  \pydatawritekeyedefvalue{timestamp}{\minted at timestamp}%
+  \pydatawritekeyedefvalue{cachepath}{\minted at cachepath}%
+  \pydatawritekey{cachefiles}%
+  \pydatawritemlvaluestart
+  \pydatawritemlvalueline{[}%
+  \setcounter{minted at tmpcnt}{1}%
+  \loop\unless\ifnum\value{minted at tmpcnt}>\value{minted at numcachefiles}\relax
+    \expandafter\minted at savecachelist@writecachefile\expandafter{%
+      \csname minted at cachefile\arabic{minted at tmpcnt}\endcsname}%
+    \expandafter\global\expandafter
+      \let\csname minted at cachefile\arabic{minted at tmpcnt}\endcsname\minted at undefined
+    \stepcounter{minted at tmpcnt}%
+  \repeat
+  \setcounter{minted at numcachefiles}{0}%
+  \pydatawritemlvalueline{]}%
+  \pydatawritemlvalueend
+  \pydatawritedictclose
+  \ifbool{minted at fasthighlightmode}{}{\pydataclosefilename{\MintedDataFilename}}}
 \begingroup
+\catcode`\"=12
+\catcode`\,=12
+\gdef\minted at savecachelist@writecachefile#1{%
+  \expandafter\pydatawritemlvalueline\expandafter{\expandafter"#1",}}
+\endgroup
+\AfterEndDocument{%
+  \minted at clean
+  \minted at fasthighlightmode@checkend}
+\def\minted at patch@PygmentsZsq{%
+  \ifcsname\minted at styleprefix Zsq\endcsname
+    \ifcsstring{\minted at styleprefix Zsq}{\char`\'}{\minted at patch@PygmentsZsq at i}{}%
+  \fi}
+\begingroup
 \catcode`\'=\active
-\gdef\minted at patch@PYGZsq at i{\gdef\PYGZsq{'}}
+\gdef\minted at patch@PygmentsZsq at i{\def\PYGZsq{'}}
 \endgroup
-\newcommand{\minted at patch@PYGZhy}{%
-  \ifcsname PYGZhy\endcsname
-    \expandafter\ifdefstring\expandafter{\csname PYGZhy\endcsname}{\char`\-}%
-     {\def\PYGZhy{\mbox{-}}}%
-     {}%
+\def\minted at patch@PygmentsZhy{%
+  \ifcsname\minted at styleprefix Zhy\endcsname
+    \ifcsstring{\minted at styleprefix Zhy}{\char`\-}{\def\PYGZhy{\mbox{-}}}{}%
+  \fi}
+\def\minted at patch@ignorelexererrors{%
+  \edef\minted at tmp{\mintedtexoptvalueof{ignorelexererrors}}%
+  \ifdefstring{\minted at tmp}{true}%
+   {\expandafter\let\csname\minted at styleprefix @tok at err\endcsname\relax}%
+   {}}
+\def\minted at patch@PygmentsStyledef{%
+  \minted at patch@PygmentsZsq
+  \minted at patch@PygmentsZhy
+  \minted at patch@ignorelexererrors}
+\def\minted at VerbatimPygments{%
+  \expandafter\minted at VerbatimPygments@i\expandafter{%
+    \csname\minted at styleprefix\endcsname}}
+\def\minted at VerbatimPygments@i#1{%
+  \VerbatimPygments{#1}{#1}}
+\def\minted at 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}
+\def\minted at defstyle{%
+  \edef\minted at tmp{\mintedtexoptvalueof{style}}%
+  \expandafter\minted at defstyle@i\expandafter{\minted at tmp}}
+\def\minted at defstyle@i#1{%
+  \minted at ifalphanumhyphenunderscore{#1}%
+   {\minted at defstyle@ii{#1}}%
+   {\minted at 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 at defstyle@ii{default}}}
+\def\minted at defstyle@ii#1{%
+  \ifcsname minted at styledef@#1\endcsname
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
   \fi
-}
-\newcommand{\minted at def@opt at switch}[2][false]{%
-  \define at booleankey{minted at opt@g}{#2}%
-    {\@namedef{minted at opt@g:#2}{true}}%
-    {\@namedef{minted at opt@g:#2}{false}}
-  \define at booleankey{minted at opt@g at i}{#2}%
-    {\@namedef{minted at opt@g at i:#2}{true}}%
-    {\@namedef{minted at opt@g at i:#2}{false}}
-  \define at booleankey{minted at opt@lang}{#2}%
-    {\@namedef{minted at opt@lang\minted at lang:#2}{true}}%
-    {\@namedef{minted at opt@lang\minted at lang:#2}{false}}
-  \define at booleankey{minted at opt@lang at i}{#2}%
-    {\@namedef{minted at opt@lang\minted at lang @i:#2}{true}}%
-    {\@namedef{minted at opt@lang\minted at lang @i:#2}{false}}
-  \define at booleankey{minted at opt@cmd}{#2}%
-    {\@namedef{minted at opt@cmd:#2}{true}}%
-    {\@namedef{minted at opt@cmd:#2}{false}}%
-  \@namedef{minted at opt@g:#2}{#1}%
-}
-\def\minted at get@opt#1#2{%
-  \ifcsname minted at opt@cmd:#1\endcsname
-    \csname minted at opt@cmd:#1\endcsname
+  {\csname minted at styledef@#1\endcsname
+   \minted at patch@PygmentsStyledef
+   \minted at VerbatimPygments}%
+  {\minted at defstyle@load{#1}}}
+\def\minted at catchfiledef#1#2{%
+  \CatchFileDef{#1}{#2}{\minted at standardcatcodes\endlinechar=-1}}
+\def\minted at defstyle@load#1{%
+  \minted at detectconfig
+  \ifbool{minted at cache}%
+   {\edef\minted at styledeffilename{#1\detokenize{.style.minted}}%
+    \edef\minted at styledeffilepath{\minted at cachepath\minted at styledeffilename}%
+    \IfFileExists{\minted at styledeffilepath}%
+     {\minted at defstyle@input{#1}}%
+     {\ifbool{minted at canexec}%
+      {\minted at defstyle@generate{#1}}%
+      {\minted at error{Missing definition for highlighting style "#1" (minted executable
+         is unavailable or disabled); attempting to substitute fallback style}%
+       \minted at defstyle@fallback{#1}}}}%
+   {\edef\minted at styledeffilename{%
+      \detokenize{_}\MintedJobnameMdfive\detokenize{.style.minted}}%
+    \let\minted at styledeffilepath\minted at styledeffilename
+    \ifbool{minted at canexec}%
+     {\minted at defstyle@generate{#1}}%
+     {\minted at error{Missing definition for highlighting style "#1" (minted executable
+        is unavailable or disabled); attempting to substitute fallback style}%
+      \minted at defstyle@fallback{#1}}}}
+\def\minted at defstyle@input#1{%
+  \begingroup
+  \minted at catchfiledef{\minted at tmp}{\minted at styledeffilepath}%
+  \minted at tmp
+  \ifcsname\minted at styleprefix\endcsname
+    \expandafter\@firstoftwo
   \else
-    \ifminted at isinline
-      \ifcsname minted at opt@lang\minted at lang @i:#1\endcsname
-        \csname minted at opt@lang\minted at lang @i:#1\endcsname
-      \else
-        \ifcsname minted at opt@g at i:#1\endcsname
-          \csname minted at opt@g at i:#1\endcsname
-        \else
-          \ifcsname minted at opt@lang\minted at lang:#1\endcsname
-            \csname minted at opt@lang\minted at lang:#1\endcsname
-          \else
-            \ifcsname minted at opt@g:#1\endcsname
-              \csname minted at opt@g:#1\endcsname
-            \else
-              #2%
-            \fi
-          \fi
-        \fi
-      \fi
+    \expandafter\@secondoftwo
+  \fi
+  {\expandafter\global\expandafter\let\csname minted at styledef@#1\endcsname\minted at tmp
+   \endgroup
+   \ifbool{minted at cache}{\minted at addcachefilename{\minted at styledeffilename}}{}%
+   \csname minted at styledef@#1\endcsname
+   \minted at patch@PygmentsStyledef
+   \minted at VerbatimPygments}%
+  {\endgroup
+   \ifbool{minted at canexec}%
+    {\minted at warning{Invalid or corrupted style definition file
+       "\minted at styledeffilename"; attempting to regenerate}%
+     \minted at defstyle@generate{#1}}%
+    {\minted at error{Invalid or corrupted style definition file
+       "\minted at styledeffilename"; attempting to substitute fallback style
+       (minted executable is unavailable or disabled)}%
+     \minted at defstyle@fallback{#1}}}}
+\def\minted at defstyle@generate#1{%
+  \pydatasetfilename{\MintedDataFilename}%
+  \minted at fasthighlightmode@checkstart
+  \pydatawritedictopen
+  \pydatawritekeyvalue{command}{styledef}%
+  \pydatawritekeyedefvalue{jobname}{\jobname}%
+  \pydatawritekeyedefvalue{timestamp}{\minted at timestamp}%
+  \pydatawritekeyedefvalue{currentfilepath}{\CurrentFilePath}%
+  \pydatawritekeyedefvalue{currentfile}{\CurrentFile}%
+  \pydatawritekeyedefvalue{inputlineno}{\the\inputlineno}%
+  \pydatawritekeyedefvalue{cachepath}{\minted at cachepath}%
+  \pydatawritekeyedefvalue{styledeffilename}{\minted at styledeffilename}%
+  \pydatawritekeyvalue{style}{#1}%
+  \pydatawritekeyedefvalue{commandprefix}{\minted at styleprefix}%
+  \pydatawritedictclose
+  \ifbool{minted at fasthighlightmode}%
+   {\minted at defstyle@fallback{#1}}%
+   {\pydataclosefilename{\MintedDataFilename}%
+    \begingroup
+    \minted at exec@styledef
+    \ifx\minted at exec@warning\relax
     \else
-      \ifcsname minted at opt@lang\minted at lang:#1\endcsname
-        \csname minted at opt@lang\minted at lang:#1\endcsname
-      \else
-        \ifcsname minted at opt@g:#1\endcsname
-          \csname minted at opt@g:#1\endcsname
-        \else
-          #2%
-        \fi
-      \fi
+      \expandafter\minted at exec@warning
     \fi
-  \fi
-}%
-\minted at def@optcl{encoding}{-P encoding}{#1}
-\minted at def@optcl{outencoding}{-P outencoding}{#1}
-\minted at def@optcl at e{escapeinside}{-P escapeinside}{#1}
-\minted at def@optcl at switch{stripnl}{-P stripnl}
-\minted at def@optcl at switch{stripall}{-P stripall}
-\minted at def@optcl at switch{python3}{-P python3}
-\minted at def@optcl at switch{funcnamehighlighting}{-P funcnamehighlighting}
-\minted at def@optcl at switch{startinline}{-P startinline}
-\ifthenelse{\boolean{minted at draft}}%
-  {\minted at def@optfv{gobble}}%
-  {\minted at def@optcl{gobble}{-F gobble:n}{#1}}
-\minted at def@optcl{codetagify}{-F codetagify:codetags}{#1}
-\minted at def@optcl{keywordcase}{-F keywordcase:case}{#1}
-\minted at def@optcl at switch{texcl}{-P texcomments}
-\minted at def@optcl at switch{texcomments}{-P texcomments}
-\minted at def@optcl at switch{mathescape}{-P mathescape}
-\minted at def@optfv at switch{linenos}
-\minted at def@opt at detok{style}
-\minted at def@optfv{frame}
-\minted at def@optfv{framesep}
-\minted at def@optfv{framerule}
-\minted at def@optfv{rulecolor}
-\minted at def@optfv{numbersep}
-\minted at def@optfv{numbers}
-\minted at def@optfv{firstnumber}
-\minted at def@optfv{stepnumber}
-\minted at def@optfv{firstline}
-\minted at def@optfv{lastline}
-\minted at def@optfv{baselinestretch}
-\minted at def@optfv{xleftmargin}
-\minted at def@optfv{xrightmargin}
-\minted at def@optfv{fillcolor}
-\minted at def@optfv{tabsize}
-\minted at def@optfv{fontfamily}
-\minted at def@optfv{fontsize}
-\minted at def@optfv{fontshape}
-\minted at def@optfv{fontseries}
-\minted at def@optfv{formatcom}
-\minted at def@optfv{label}
-\minted at def@optfv{labelposition}
-\minted at def@optfv{highlightlines}
-\minted at def@optfv{highlightcolor}
-\minted at def@optfv{space}
-\minted at def@optfv{spacecolor}
-\minted at def@optfv{tab}
-\minted at def@optfv{tabcolor}
-\minted at def@optfv{highlightcolor}
-\minted at def@optfv at switch{beameroverlays}
-\minted at def@optfv at switch{curlyquotes}
-\minted at def@optfv at switch{numberfirstline}
-\minted at def@optfv at switch{numberblanklines}
-\minted at def@optfv at switch{stepnumberfromfirst}
-\minted at def@optfv at switch{stepnumberoffsetvalues}
-\minted at def@optfv at switch{showspaces}
-\minted at def@optfv at switch{resetmargins}
-\minted at def@optfv at switch{samepage}
-\minted at def@optfv at switch{showtabs}
-\minted at def@optfv at switch{obeytabs}
-\minted at def@optfv at switch{breaklines}
-\minted at def@optfv at switch{breakbytoken}
-\minted at def@optfv at switch{breakbytokenanywhere}
-\minted at def@optfv{breakindent}
-\minted at def@optfv{breakindentnchars}
-\minted at def@optfv at switch{breakautoindent}
-\minted at def@optfv{breaksymbol}
-\minted at def@optfv{breaksymbolsep}
-\minted at def@optfv{breaksymbolsepnchars}
-\minted at def@optfv{breaksymbolindent}
-\minted at def@optfv{breaksymbolindentnchars}
-\minted at def@optfv{breaksymbolleft}
-\minted at def@optfv{breaksymbolsepleft}
-\minted at def@optfv{breaksymbolsepleftnchars}
-\minted at def@optfv{breaksymbolindentleft}
-\minted at def@optfv{breaksymbolindentleftnchars}
-\minted at def@optfv{breaksymbolright}
-\minted at def@optfv{breaksymbolsepright}
-\minted at def@optfv{breaksymbolseprightnchars}
-\minted at def@optfv{breaksymbolindentright}
-\minted at def@optfv{breaksymbolindentrightnchars}
-\minted at def@optfv{breakbefore}
-\minted at def@optfv{breakbeforesymbolpre}
-\minted at def@optfv{breakbeforesymbolpost}
-\minted at def@optfv at switch{breakbeforeinrun}
-\minted at def@optfv{breakafter}
-\minted at def@optfv at switch{breakafterinrun}
-\minted at def@optfv{breakaftersymbolpre}
-\minted at def@optfv{breakaftersymbolpost}
-\minted at def@optfv at switch{breakanywhere}
-\minted at def@optfv{breakanywheresymbolpre}
-\minted at def@optfv{breakanywheresymbolpost}
-\minted at def@optfv{fontencoding}
-\minted at def@opt{bgcolor}
-\minted at def@opt at switch{autogobble}
-\minted at def@opt at switch{ignorelexererrors}
-\newcommand{\minted at encoding}{\minted at get@opt{encoding}{UTF8}}
-\newenvironment{minted at snugshade*}[1]{%
-  \def\FrameCommand##1{\hskip\@totalleftmargin
-    \colorbox{#1}{##1}%
-    \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
-  \MakeFramed{\advance\hsize-\width
-    \@totalleftmargin\z@ \linewidth\hsize
-    \advance\labelsep\fboxsep
-    \@setminipage}%
- }{\par\unskip\@minipagefalse\endMakeFramed}
-\newsavebox{\minted at bgbox}
-\newenvironment{minted at colorbg}[1]{%
-  \setlength{\OuterFrameSep}{0pt}%
-  \let\minted at tmp\FV at NumberSep
-  \edef\FV at NumberSep{%
-    \the\numexpr\dimexpr\minted at tmp+\number\fboxsep\relax sp\relax}%
-  \medskip
-  \begin{minted at snugshade*}{#1}}
- {\end{minted at snugshade*}%
-  \medskip\noindent}
-\newwrite\minted at code
-\newcommand{\minted at savecode}[1]{
-  \immediate\openout\minted at code\minted at jobname.pyg\relax
-  \immediate\write\minted at code{\expandafter\detokenize\expandafter{#1}}%
-  \immediate\closeout\minted at code}
-\newcounter{minted at FancyVerbLineTemp}
-\newcommand{\minted at write@detok}[1]{%
-  \immediate\write\FV at OutFile{\detokenize{#1}}}
-\newcommand{\minted at FVB@VerbatimOut}[1]{%
-  \setcounter{minted at FancyVerbLineTemp}{\value{FancyVerbLine}}%
-  \@bsphack
+    \ifx\minted at exec@error\relax
+      \expandafter\minted at defstyle@generate at i
+    \else
+      \expandafter\minted at defstyle@generate at error
+    \fi
+    {#1}}}
+\def\minted at defstyle@generate at i#1{%
+  \endgroup
   \begingroup
-    \FV at UseKeyValues
-    \FV at DefineWhiteSpace
-    \def\FV at Space{\space}%
-    \FV at DefineTabOut
-    \let\FV at ProcessLine\minted at write@detok
-    \immediate\openout\FV at OutFile #1\relax
-    \let\FV at FontScanPrep\relax
-    \let\@noligs\relax
-    \FV at Scan}
-\newcommand{\minted at FVE@VerbatimOut}{%
-  \immediate\closeout\FV at OutFile\endgroup\@esphack
-  \setcounter{FancyVerbLine}{\value{minted at FancyVerbLineTemp}}}%
-\ifcsname MintedPygmentize\endcsname\else
-  \newcommand{\MintedPygmentize}{pygmentize}
-\fi
-\newcounter{minted at pygmentizecounter}
-\ifwindows
-  \newcommand{\MintedPython}{python}
-\else
-  \newcommand{\MintedPython}{python3}
-\fi
-\newcommand{\minted at check@MintedPython}{%
-  \ifcsname minted at MintedPython@\MintedPython\endcsname
+  \minted at catchfiledef{\minted at tmp}{\minted at styledeffilepath}%
+  \minted at tmp
+  \ifcsname\minted at styleprefix\endcsname
+    \expandafter\@firstoftwo
   \else
-    \let\minted at altpython\minted at undefined
-    \ifdefstring{\MintedPython}{python}{\def\minted at altpython{python3}}{}%
-    \ifdefstring{\MintedPython}{python3}{\def\minted at altpython{python}}{}%
-    \ifx\minted at altpython\minted at undefined\relax
-      \TestAppExists{\MintedPython}%
-      \ifAppExists
-        \expandafter\global\expandafter\let%
-          \csname minted at MintedPython@\MintedPython\endcsname\relax
-      \else
-        \PackageError{minted}%
-         {Failed to find Python executable \MintedPython;
-          check Python installation (including PATH),
-          or redefine \string\MintedPython}%
-         {Failed to find Python executable \MintedPython;
-          check Python installation (including PATH),
-          or redefine \string\MintedPython}%
-      \fi
+    \expandafter\@secondoftwo
+  \fi
+  {\expandafter\global\expandafter\let\csname minted at styledef@#1\endcsname\minted at tmp
+   \endgroup
+   \ifbool{minted at cache}{\minted at addcachefilename{\minted at styledeffilename}}{}%
+   \csname minted at styledef@#1\endcsname
+   \minted at patch@PygmentsStyledef
+   \minted at VerbatimPygments}%
+  {\endgroup
+   \minted at error{Failed to create style definition file "\minted at styledeffilename"
+     (no error message, see "\MintedErrlogFilename" if it exists);
+     attempting to substitute fallback style}%
+   \minted at defstyle@fallback{#1}}}
+\def\minted at defstyle@generate at error#1{%
+  \minted at exec@error
+  \endgroup
+  \minted at defstyle@fallback{#1}}
+\def\minted at defstyle@fallback#1{%
+  \ifstrequal{#1}{default}%
+   {\expandafter\global\expandafter
+      \let\csname minted at styledef@default\endcsname\minted at styledeffallback}%
+   {\ifcsname minted at styledef@default\endcsname
     \else
-      \ifcsname minted at MintedPython@\minted at altpython\endcsname
-        \let\MintedPython\minted at altpython
-      \else
-        \TestAppExists{\MintedPython}%
-        \ifAppExists
-          \expandafter\global\expandafter\let%
-            \csname minted at MintedPython@\MintedPython\endcsname\relax
-        \else
-          \TestAppExists{\minted at altpython}%
-          \ifAppExists
-            \expandafter\global\expandafter\let%
-              \csname minted at MintedPython@\minted at altpython\endcsname\relax
-            \let\MintedPython\minted at altpython
-          \else
-            \PackageError{minted}%
-             {Failed to find Python executables python or python3;
-              check Python installation (including PATH),
-              or redefine \string\MintedPython}%
-             {Failed to find Python executables python or python3;
-              check Python installation (including PATH),
-              or redefine \string\MintedPython}%
-          \fi
-        \fi
-      \fi
+      \minted at defstyle@load{default}%
     \fi
+    \expandafter\let\expandafter\minted at tmp\csname minted at styledef@default\endcsname
+    \expandafter\global\expandafter\let\csname minted at styledef@#1\endcsname\minted at tmp}}
+\def\minted at styledeffallback{%
+  \expandafter\def\csname\minted at styleprefix\endcsname##1##2{##2}%
+  \expandafter\def\csname\minted at styleprefix Zbs\endcsname{\char`\\}%
+  \expandafter\def\csname\minted at styleprefix Zus\endcsname{\char`\_}%
+  \expandafter\def\csname\minted at styleprefix Zob\endcsname{\char`\{}%
+  \expandafter\def\csname\minted at styleprefix Zcb\endcsname{\char`\}}%
+  \expandafter\def\csname\minted at styleprefix Zca\endcsname{\char`\^}%
+  \expandafter\def\csname\minted at styleprefix Zam\endcsname{\char`\&}%
+  \expandafter\def\csname\minted at styleprefix Zlt\endcsname{\char`\<}%
+  \expandafter\def\csname\minted at styleprefix Zgt\endcsname{\char`\>}%
+  \expandafter\def\csname\minted at styleprefix Zsh\endcsname{\char`\#}%
+  \expandafter\def\csname\minted at styleprefix Zpc\endcsname{\char`\%}%
+  \expandafter\def\csname\minted at styleprefix Zdl\endcsname{\char`\$}%
+  \expandafter\def\csname\minted at styleprefix Zhy\endcsname{\char`\-}%
+  \expandafter\def\csname\minted at styleprefix Zsq\endcsname{\char`\'}%
+  \expandafter\def\csname\minted at styleprefix Zdq\endcsname{\char`\"}%
+  \expandafter\def\csname\minted at styleprefix Zti\endcsname{\char`\~}%
+  \minted at patch@PygmentsStyledef
+  \minted at VerbatimPygments}
+\newcounter{minted at FancyVerbLineTemp}
+\def\minted at lexerlinenoson{%
+  \ifcsname c at minted@lexer\minted at lexer\endcsname
+  \else
+    \newcounter{minted at lexer\minted at lexer}%
   \fi
-}
-\ifwindows
-  \def\minted at opt@quote#1{\detokenize{"#1"}}
-\else
-  \def\minted at opt@quote#1{\detokenize{'#1'}}
-\fi
-\newcommand{\minted at pygmentize}[2][\minted at outputdir\minted at jobname.pyg]{%
-  \minted at defstyle{\minted at get@opt{style}{default}}%
-  \stepcounter{minted at pygmentizecounter}%
-  \ifthenelse{\equal{\minted at get@opt{autogobble}{false}}{true}}%
-    {\def\minted at codefile{\minted at outputdir\minted at jobname.pyg}}%
-    {\def\minted at codefile{#1}}%
-  \ifthenelse{\boolean{minted at isinline}}%
-    {\def\minted at optlistcl@inlines{%
-      \minted at optlistcl@g at i
-      \csname minted at optlistcl@lang\minted at lang @i\endcsname}}%
-    {\let\minted at optlistcl@inlines\@empty}%
-  \def\minted at cmd{%
-    \ifminted at kpsewhich
-      \ifwindows
-        \detokenize{for /f "usebackq tokens=*"}\space\@percentchar\detokenize{a in (`kpsewhich}\space\minted at codefile\detokenize{`) do}\space
-      \fi
-    \fi
-    \MintedPygmentize\space -l \minted at opt@quote{#2}
-    -f latex -P commandprefix=PYG -F tokenmerge
-    \minted at optlistcl@g \csname minted at optlistcl@lang\minted at lang\endcsname
-    \minted at optlistcl@inlines
-    \minted at optlistcl@cmd -o \minted at outputdir\minted at infile\space
-    \ifminted at kpsewhich
-      \ifwindows
-        \@percentchar\detokenize{a}%
+  \setcounter{minted at FancyVerbLineTemp}{\value{FancyVerbLine}}%
+  \setcounter{FancyVerbLine}{\value{minted at lexer\minted at lexer}}}
+\def\minted at lexerlinenosoff{%
+  \setcounter{minted at lexer\minted at lexer}{\value{FancyVerbLine}}%
+  \setcounter{FancyVerbLine}{\value{minted at FancyVerbLineTemp}}}
+\ifbool{minted at inputlexerlinenos}%
+ {\let\minted at inputlexerlinenoson\minted at lexerlinenoson
+  \let\minted at inputlexerlinenosoff\minted at lexerlinenosoff}%
+ {\let\minted at inputlexerlinenoson\relax
+  \let\minted at inputlexerlinenosoff\relax
+  \ifbool{minted at lexerlinenos}
+   {}%
+   {\let\minted at lexerlinenoson\relax
+    \let\minted at lexerlinenosoff\relax}}
+\def\minted at codewrapper#1{%
+  \ifcsname minted at inputfilepath\endcsname
+    \minted at inputlexerlinenoson
+  \else
+    \minted at lexerlinenoson
+  \fi
+  #1%
+  \ifcsname minted at inputfilepath\endcsname
+    \minted at inputlexerlinenosoff
+  \else
+    \minted at lexerlinenosoff
+  \fi}
+\def\minted at debug@input{%
+  \ifbool{minted at debug}%
+   {\immediate\typeout{%
+     minted debug: \string\input\space at
+     \ifx\CurrentFile\@empty\else\CurrentFile\space\fi line \the\inputlineno}}%
+   {}}
+\def\minted at highlight{%
+  \minted at defstyle
+  \pydatasetbuffername{minted at tmpdatabuffer}%
+  \pydatabufferkeyvalue{command}{highlight}%
+  \pydatabufferkey{code}%
+  \pydatabuffermlvaluestart
+  \setcounter{minted at tmpcnt}{1}%
+  \loop\unless\ifnum\value{minted at tmpcnt}>\value{minted at tmpcodebufferlength}\relax
+    \expandafter\let\expandafter
+      \minted at tmp\csname minted at tmpcodebufferline\arabic{minted at tmpcnt}\endcsname
+    \expandafter\pydatabuffermlvalueline\expandafter{\minted at tmp}%
+    \stepcounter{minted at tmpcnt}%
+  \repeat
+  \pydatabuffermlvalueend
+  \minted at highlight@i}
+\def\minted at highlightinputfile{%
+  \minted at defstyle
+  \edef\minted at inputfilemdfivesum{\pdf at filemdfivesum{\minted at inputfilepath}}%
+  \ifx\minted at inputfilemdfivesum\@empty
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+  {\minted at error{Cannot find input file "\minted at inputfilepath"; inserting placeholder}%
+   \minted at insertplaceholder}%
+  {\pydatasetbuffername{minted at tmpdatabuffer}%
+   \pydatabufferkeyvalue{command}{highlight}%
+   \pydatabufferkeyedefvalue{inputfilepath}{\minted at inputfilepath}%
+   \pydatabufferkeyedefvalue{inputfilemdfivesum}{\minted at inputfilemdfivesum}%
+   \minted at highlight@i}}
+\def\minted at def@FV at GetKeyValues@standardcatcodes{%
+  \let\minted at FV@GetKeyValues at orig\FV at GetKeyValues
+  \def\FV at GetKeyValues##1{%
+    \begingroup
+    \minted at standardcatcodes
+    \minted at FV@GetKeyValues at i{##1}}%
+  \def\minted at FV@GetKeyValues at i##1[##2]{%
+    \endgroup
+    \let\FV at GetKeyValues\minted at FV@GetKeyValues at orig
+    \let\minted at FV@GetKeyValues at i\minted at undefined
+    \FV at GetKeyValues{##1}[##2]}}
+\def\minted at highlight@i{%
+  \pydatabufferkeyedefvalue{pyopt.lexer}{\minted at lexer}%
+  \pydatabufferkeyedefvalue{pyopt.commandprefix}{\minted at styleprefix}%
+  \minted at forcsvlist{\minted at highlight@bufferpykeys}{\minted at optkeyslist@py}%
+  \ifbool{minted at cache}%
+   {\edef\minted at highlightfilename{\pydatabuffermdfivesum\detokenize{.highlight.minted}}%
+    \edef\minted at highlightfilepath{\minted at cachepath\minted at highlightfilename}%
+    \IfFileExists{\minted at highlightfilepath}%
+     {\minted at codewrapper{%
+        \minted at def@FV at GetKeyValues@standardcatcodes
+        \minted at debug@input
+        \input{\minted at highlightfilepath}}%
+      \minted at addcachefilename{\minted at highlightfilename}}%
+     {\ifbool{minted at canexec}%
+       {\minted at highlight@create}%
+       {\minted at error{Cannot highlight code (minted executable is unavailable or
+          disabled); attempting to typeset without highlighting}%
+        \minted at highlight@fallback}}}%
+   {\edef\minted at highlightfilename{%
+      \detokenize{_}\MintedJobnameMdfive\detokenize{.highlight.minted}}%
+    \let\minted at highlightfilepath\minted at highlightfilename
+    \ifbool{minted at canexec}%
+     {\minted at highlight@create}%
+     {\minted at error{Cannot highlight code (minted executable is unavailable or
+        disabled); attempting to typeset without highlighting}%
+      \minted at highlight@fallback}}%
+  \pydataclearbuffername{minted at tmpdatabuffer}}
+\def\minted at highlight@bufferpykeys#1{%
+  \edef\minted at tmp{\mintedpyoptvalueof{#1}}%
+  \ifx\minted at tmp\minted at const@pgfkeysnovalue
+  \else
+    \pydatabufferkeyedefvalue{pyopt.#1}{\minted at tmp}%
+  \fi}
+\def\minted at highlight@create{%
+  \pydatasetfilename{\MintedDataFilename}%
+  \minted at fasthighlightmode@checkstart
+  \pydatawritedictopen
+  \pydatawritebuffer
+  \pydatawritekeyedefvalue{jobname}{\jobname}%
+  \pydatawritekeyedefvalue{timestamp}{\minted at timestamp}%
+  \pydatawritekeyedefvalue{currentfilepath}{\CurrentFilePath}%
+  \pydatawritekeyedefvalue{currentfile}{\CurrentFile}%
+  \pydatawritekeyedefvalue{inputlineno}{\the\inputlineno}%
+  \pydatawritekeyedefvalue{cachepath}{\minted at cachepath}%
+  \pydatawritekeyedefvalue{highlightfilename}{\minted at highlightfilename}%
+  \pydatawritedictclose
+  \ifbool{minted at fasthighlightmode}%
+   {\minted at insertplaceholder}%
+   {\pydataclosefilename{\MintedDataFilename}%
+    \begingroup
+    \minted at exec@highlight
+    \IfFileExists{\minted at highlightfilepath}%
+     {\ifx\minted at exec@warning\relax
       \else
-        \detokenize{`}kpsewhich \minted at codefile\space
-          \detokenize{||} \minted at codefile\detokenize{`}%
+        \expandafter\minted at exec@warning
       \fi
-    \else
-      \minted at codefile
-    \fi}%
-  % For debugging, uncomment: %%%%
-  % \immediate\typeout{\minted at cmd}%
-  % %%%%
-  \ifthenelse{\boolean{minted at cache}}%
-    {%
-      \ifminted at frozencache
+      \ifx\minted at exec@error\relax
       \else
-        \ifthenelse{\equal{\minted at get@opt{autogobble}{false}}{true}}%
-         {\edef\minted at hash{%
-            \pdf at filemdfivesum{#1}%
-            \pdf at mdfivesum{\minted at cmd\space%
-              autogobble(\the\numexpr\FancyVerbStartNum\relax-%
-                         \the\numexpr\FancyVerbStopNum\relax)}}}%
-         {\edef\minted at hash{%
-            \pdf at filemdfivesum{#1}%
-            \pdf at mdfivesum{\minted at cmd}}}%
-        \edef\minted at infile{\minted at cachedir/\minted at hash.pygtex}%
-        \IfFileExists{\minted at infile}{}{%
-          \ifthenelse{\equal{\minted at get@opt{autogobble}{false}}{true}}{%
-            \minted at autogobble{#1}}{}%
-          \ShellEscape{\minted at cmd}}%
+        \expandafter\minted at exec@error
       \fi
-      \ifthenelse{\boolean{minted at finalizecache}}%
-       {%
-          \edef\minted at cachefilename{listing\arabic{minted at pygmentizecounter}.pygtex}%
-          \edef\minted at actualinfile{\minted at cachedir/\minted at cachefilename}%
-          \ifwindows
-            \StrSubstitute{\minted at infile}{/}{\@backslashchar}[\minted at infile@windows]
-            \StrSubstitute{\minted at actualinfile}{/}{\@backslashchar}[\minted at actualinfile@windows]
-            \ShellEscape{move /y \minted at outputdir\minted at infile@windows\space\minted at outputdir\minted at actualinfile@windows}%
-          \else
-            \ShellEscape{mv -f \minted at outputdir\minted at infile\space\minted at outputdir\minted at actualinfile}%
-          \fi
-          \let\minted at infile\minted at actualinfile
-          \expandafter\minted at addcachefile\expandafter{\minted at cachefilename}%
-       }%
-       {\ifthenelse{\boolean{minted at frozencache}}%
-         {%
-            \edef\minted at cachefilename{listing\arabic{minted at pygmentizecounter}.pygtex}%
-            \edef\minted at infile{\minted at cachedir/\minted at cachefilename}%
-            \expandafter\minted at addcachefile\expandafter{\minted at cachefilename}}%
-         {\expandafter\minted at addcachefile\expandafter{\minted at hash.pygtex}}%
-       }%
-      \minted at inputpyg}%
-    {%
-      \ifthenelse{\equal{\minted at get@opt{autogobble}{false}}{true}}{%
-        \minted at autogobble{#1}}{}%
-      \ShellEscape{\minted at cmd}%
-      \minted at inputpyg}%
-}
-\def\minted at autogobble#1{%
-  \edef\minted at argone@esc{#1}%
-  \StrSubstitute{\minted at argone@esc}{\@backslashchar}{\@backslashchar\@backslashchar}[\minted at argone@esc]%
-  \StrSubstitute{\minted at argone@esc}{"}{\@backslashchar"}[\minted at argone@esc]%
-  \edef\minted at tmpfname@esc{\minted at outputdir\minted at jobname}%
-  \StrSubstitute{\minted at tmpfname@esc}{\@backslashchar}{\@backslashchar\@backslashchar}[\minted at tmpfname@esc]%
-  \StrSubstitute{\minted at tmpfname@esc}{"}{\@backslashchar"}[\minted at tmpfname@esc]%
-  %Need a version of open() that supports encoding under Python 2
-  \minted at check@MintedPython
-  \edef\minted at autogobblecmd{%
-    \ifminted at kpsewhich
-      \ifwindows
-        \detokenize{for /f "usebackq tokens=*" }\@percentchar\detokenize{a in (`kpsewhich} #1\detokenize{`) do}\space
-      \fi
-    \fi
-    \MintedPython\detokenize{ -c "import sys; import os;
-    import textwrap;
-    from io import open;
-    fname = }%
-      \ifminted at kpsewhich
-        \detokenize{sys.argv[1];}\space
+      \endgroup
+      \minted at codewrapper{%
+        \minted at def@FV at GetKeyValues@standardcatcodes
+        \minted at debug@input
+        \input{\minted at highlightfilepath}}%
+      \ifbool{minted at cache}{\minted at addcachefilename{\minted at highlightfilename}}{}}%
+     {\ifx\minted at exec@warning\relax
       \else
-        \detokenize{os.path.expanduser(os.path.expandvars(\"}\minted at argone@esc\detokenize{\"));}\space
+        \expandafter\minted at exec@warning
       \fi
-    \detokenize{f = open(fname, \"r\", encoding=\"}\minted at encoding\detokenize{\") if os.path.isfile(fname) else None;
-    t = f.readlines() if f is not None else None;
-    t_opt = t if t is not None else [];
-    f.close() if f is not None else None;
-    tmpfname = os.path.expanduser(os.path.expandvars(\"}\minted at tmpfname@esc.pyg\detokenize{\"));
-    f = open(tmpfname, \"w\", encoding=\"}\minted at encoding\detokenize{\") if t is not None else None;
-    fvstartnum = }\the\numexpr\FancyVerbStartNum\detokenize{;
-    fvstopnum = }\the\numexpr\FancyVerbStopNum\detokenize{;
-    s = max(0, fvstartnum-1);
-    e = max(s, fvstopnum) if fvstopnum > 0 else len(t_opt);
-    [f.write(textwrap.dedent(\"\".join(x))) for x in (t_opt[0:s], t_opt[s:e], t_opt[e:]) if x and t is not None];
-    f.close() if t is not None else os.remove(tmpfname);"}%
-    \ifminted at kpsewhich
-      \ifwindows
-        \space\@percentchar\detokenize{a}%
+      \ifx\minted at exec@error\relax
+        \minted at error{Minted executable failed during syntax highlighting
+          but returned no error message (see if "\MintedErrlogFilename" exists)}%
       \else
-        \space\detokenize{`}kpsewhich #1\space\detokenize{||} #1\detokenize{`}%
+        \expandafter\minted at exec@error
       \fi
-    \fi
-  }%
-  \ShellEscape{\minted at autogobblecmd}%
-}
-\newcommand{\minted at inputpyg}{%
-  \VerbatimPygments{\PYG}{\PYG}%
-  \ifthenelse{\boolean{minted at isinline}}%
-   {\ifthenelse{\equal{\minted at get@opt{breaklines}{false}}{true}}%
-    {\let\FV at BeginVBox\relax
-     \let\FV at EndVBox\relax
-     \def\FV at BProcessLine##1{\FancyVerbFormatLine{##1}}%
-     \minted at inputpyg@inline}%
-    {\minted at inputpyg@inline}}%
-   {\minted at inputpyg@block}%
-}
-\def\minted at inputpyg@inline{%
-  \ifthenelse{\equal{\minted at get@opt{bgcolor}{}}{}}%
-   {\minted at input{\minted at outputdir\minted at infile}}%
-   {\colorbox{\minted at get@opt{bgcolor}{}}{%
-      \minted at input{\minted at outputdir\minted at infile}}}%
-}
-\def\minted at inputpyg@block{%
-  \ifthenelse{\equal{\minted at get@opt{bgcolor}{}}{}}%
-   {\minted at input{\minted at outputdir\minted at infile}}%
-   {\begin{minted at colorbg}{\minted at get@opt{bgcolor}{}}%
-    \minted at input{\minted at outputdir\minted at infile}%
-    \end{minted at colorbg}}}
-\newcommand{\minted at langlinenoson}{%
-  \ifcsname c at minted@lang\minted at lang\endcsname\else
-    \newcounter{minted at lang\minted at lang}%
-  \fi
-  \setcounter{minted at FancyVerbLineTemp}{\value{FancyVerbLine}}%
-  \setcounter{FancyVerbLine}{\value{minted at lang\minted at lang}}%
-}
-\newcommand{\minted at langlinenosoff}{%
-  \setcounter{minted at lang\minted at lang}{\value{FancyVerbLine}}%
-  \setcounter{FancyVerbLine}{\value{minted at FancyVerbLineTemp}}%
-}
-\ifbool{minted at langlinenos}{}{%
-  \ifbool{minted at inputlanglinenos}{}{%
-    \let\minted at langlinenoson\relax
-    \let\minted at langlinenosoff\relax
-  }
-}
-\ifbool{minted at inputlanglinenos}%
- {\def\minted at inputlanglinenoson{\minted at langlinenoson}%
-  \def\minted at inputlanglinenosoff{\minted at langlinenosoff}}%
- {\let\minted at inputlanglinenoson\relax
-  \let\minted at inputlanglinenosoff\relax}
+      \endgroup
+      \minted at highlight@fallback}}}
+\def\minted at highlight@fallback{%
+  \minted at insertplaceholder}
 \newcommand{\setminted}[2][]{%
-  \ifthenelse{\equal{#1}{}}%
-    {\setkeys{minted at opt@g}{#2}}%
-    {\minted at configlang{#1}%
-      \setkeys{minted at opt@lang}{#2}}}
+  \ifstrempty{#1}%
+   {\pgfkeys{/minted/global/.cd,#2}}%
+   {\let\minted at tmplexer\minted at lexer
+    \edef\minted at lexer{#1}%
+    \pgfkeys{/minted/lexer/.cd,#2}%
+    \let\minted at lexer\minted at tmplexer}}
 \newcommand{\setmintedinline}[2][]{%
-  \ifthenelse{\equal{#1}{}}%
-    {\setkeys{minted at opt@g at i}{#2}}%
-    {\minted at configlang{#1}%
-      \setkeys{minted at opt@lang at i}{#2}}}
-\setmintedinline[php]{startinline=true}
-\setminted{tabcolor=black}
-\setminted{stripnl=false}
+  \ifstrempty{#1}%
+   {\pgfkeys{/minted/globalinline/.cd,#2}}%
+   {\let\minted at tmplexer\minted at lexer
+    \edef\minted at lexer{#1}%
+    \pgfkeys{/minted/lexerinline/.cd,#2}%
+    \let\minted at lexer\minted at tmplexer}}
 \newcommand{\usemintedstyle}[2][]{\setminted[#1]{style=#2}}
-\begingroup
-\catcode`\ =\active
-\catcode`\^^I=\active
-\gdef\minted at defwhitespace@retok{\def {\noexpand\FV at Space}\def^^I{\noexpand\FV at Tab}}%
-\endgroup
-\newcommand{\minted at writecmdcode}[1]{%
-  \immediate\openout\minted at code\minted at jobname.pyg\relax
-  \immediate\write\minted at code{\detokenize{#1}}%
-  \immediate\closeout\minted at code}
 \def\mintinline{%
   \FVExtraRobustCommand\RobustMintInline\FVExtraUnexpandedReadStarOArgMArgBVArg}
 \FVExtrapdfstringdefDisableCommands{%
@@ -1028,31 +1431,51 @@
   \ifbool{FVExtraRobustCommandExpanded}%
    {\@ifnextchar\bgroup
      {\FVExtraReadVArg{\RobustMintInlineProcess{#1}{#2}}}%
-     {\PackageError{minted}%
-       {Inline delimiters must be paired curly braces in this context}%
-       {Use curly braces as delimiters}}}%
+     {\minted at error{Inline delimiters must be paired curly braces in this context}}}%
    {\FVExtraReadVArg{\RobustMintInlineProcess{#1}{#2}}}}
-\def\RobustMintInlineProcess#1#2#3{%
+\def\RobustMintInlineProcess at highlight#1#2#3{%
   \begingroup
-  \setboolean{minted at isinline}{true}%
-  \minted at configlang{#2}%
-  \setkeys{minted at opt@cmd}{#1}%
-  \minted at fvset
-  \RobustMintInlineProcess at i{#3}}
-\ifthenelse{\boolean{minted at draft}}%
- {\def\RobustMintInlineProcess at i#1{%
-    \fvset{extra=true}%
-    \Verb{#1}%
-    \endgroup}}%
- {\def\RobustMintInlineProcess at i#1{%
-   \FVExtraDetokenizeVArg{%
-     \FVExtraRetokenizeVArg{\RobustMintInlineProcess at ii}{\FV at CatCodes}}{#1}}
-  \def\RobustMintInlineProcess at ii#1{%
-    \minted at writecmdcode{#1}%
-    \let\Verbatim\VerbEnv
-    \let\endVerbatim\endVerbEnv
-    \expandafter\minted at pygmentize\expandafter{\minted at lang}%
-    \endgroup}}
+  \booltrue{minted at isinline}%
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \minted at usefvopts
+  \minted at usetexoptsnonpygments
+  \FVExtraDetokenizeVArg{%
+     \FVExtraRetokenizeVArg{\RobustMintInlineProcess at highlight@i}{\FV at CatCodes}}{#3}}
+\def\RobustMintInlineProcess at highlight@i#1{%
+  \expandafter\def\csname minted at tmpcodebufferline1\endcsname{#1}%
+  \setcounter{minted at tmpcodebufferlength}{1}%
+  \let\minted at highlight@fallback\RobustMintInlineProcess at highlight@fallback
+  \minted at highlight
+  \setcounter{minted at tmpcodebufferlength}{0}%
+  \endgroup}
+\def\RobustMintInlineProcess at highlight@fallback{%
+  \minted at useadditionalfvoptsnopy
+  \fvset{extra=true}%
+  \minted at codewrapper{%
+    \expandafter\let\expandafter\minted at tmp\csname minted at tmpcodebufferline1\endcsname
+    \expandafter\Verb\expandafter{\minted at tmp}}}
+\def\RobustMintInlineProcess at placeholder#1#2#3{%
+  \begingroup
+  \booltrue{minted at isinline}%
+  \minted at insertplaceholder
+  \endgroup}
+\def\RobustMintInlineProcess at verbatim#1#2#3{%
+  \begingroup
+  \booltrue{minted at isinline}%
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \minted at usefvopts
+  \minted at useadditionalfvoptsnopy
+  \minted at usetexoptsnonpygments
+  \fvset{extra=true}%
+  \minted at codewrapper{\Verb{#3}}%
+  \endgroup}
+\ifbool{minted at placeholder}%
+ {\let\RobustMintInlineProcess\RobustMintInlineProcess at placeholder}%
+ {\ifbool{minted at verbatim}%
+   {\let\RobustMintInlineProcess\RobustMintInlineProcess at verbatim}%
+   {\let\RobustMintInlineProcess\RobustMintInlineProcess at highlight}}
 \def\mint{%
   \FVExtraRobustCommand\RobustMint\FVExtraUnexpandedReadStarOArgMArgBVArg}
 \FVExtrapdfstringdefDisableCommands{%
@@ -1061,110 +1484,165 @@
   \ifbool{FVExtraRobustCommandExpanded}%
    {\@ifnextchar\bgroup
      {\FVExtraReadVArg{\RobustMintProcess{#1}{#2}}}%
-     {\PackageError{minted}%
-       {Delimiters must be paired curly braces in this context}%
-       {Use curly braces as delimiters}}}%
+     {\minted at error{Delimiters must be paired curly braces in this context}}}%
    {\FVExtraReadVArg{\RobustMintProcess{#1}{#2}}}}
-\def\RobustMintProcess#1#2#3{%
+\def\RobustMintProcess at highlight#1#2#3{%
   \begingroup
-  \minted at configlang{#2}%
-  \setkeys{minted at opt@cmd}{#1}%
-  \minted at fvset
-  \RobustMintProcess at i{#3}}
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \minted at usefvopts
+  \minted at usetexoptsnonpygments
+  \FVExtraDetokenizeVArg{%
+    \FVExtraRetokenizeVArg{\RobustMintProcess at highlight@i}{\FV at CatCodes}}{#3}}
+\def\RobustMintProcess at highlight@i#1{%
+  \expandafter\def\csname minted at tmpcodebufferline1\endcsname{#1}%
+  \setcounter{minted at tmpcodebufferlength}{1}%
+  \let\minted at highlight@fallback\RobustMintProcess at highlight@fallback
+  \minted at highlight
+  \setcounter{minted at tmpcodebufferlength}{0}%
+  \endgroup}
+\def\RobustMintProcess at highlight@fallback{%
+  \minted at useadditionalfvoptsnopy
+  \minted at codewrapper{%
+    \VerbatimInsertBuffer[buffername=minted at tmpcodebuffer,insertenvname=\minted at envname]}}
+\def\RobustMintProcess at placeholder#1#2#3{%
+  \minted at insertplaceholder}
+\def\RobustMintProcess at verbatim#1#2#3{%
+  \begingroup
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \minted at usefvopts
+  \minted at useadditionalfvoptsnopy
+  \minted at usetexoptsnonpygments
+  \FVExtraDetokenizeVArg{%
+    \FVExtraRetokenizeVArg{\RobustMintProcess at verbatim@i}{\FV at CatCodes}}{#3}}
+\def\RobustMintProcess at verbatim@i#1{%
+  \expandafter\def\csname minted at tmpcodebufferline1\endcsname{#1}%
+  \setcounter{minted at tmpcodebufferlength}{1}%
+  \minted at codewrapper{%
+    \VerbatimInsertBuffer[buffername=minted at tmpcodebuffer,insertenvname=\minted at envname]}%
+  \setcounter{minted at tmpcodebufferlength}{0}%
+  \endgroup}
+\ifbool{minted at placeholder}%
+ {\let\RobustMintProcess\RobustMintProcess at placeholder}%
+ {\ifbool{minted at verbatim}%
+   {\let\RobustMintProcess\RobustMintProcess at verbatim}%
+   {\let\RobustMintProcess\RobustMintProcess at highlight}}
+\newenvironment{minted}[2][]%
+ {\VerbatimEnvironment
+  \MintedBegin{#1}{#2}}%
+ {\MintedEnd}
+\def\MintedBegin at highlight#1#2{%
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \minted at usefvopts
+  \minted at usetexoptsnonpygments
+  \begin{VerbatimBuffer}[buffername=minted at tmpcodebuffer,globalbuffer=true]}
+\def\MintedEnd at highlight{%
+  \end{VerbatimBuffer}%
+  \let\minted at highlight@fallback\MintedEnv at highlight@fallback
+  \minted at highlight
+  \VerbatimClearBuffer[buffername=minted at tmpcodebuffer]}
+\def\MintedEnv at highlight@fallback{%
+  \minted at useadditionalfvoptsnopy
+  \minted at codewrapper{%
+    \VerbatimInsertBuffer[buffername=minted at tmpcodebuffer,insertenvname=\minted at envname]}}
+\def\MintedBegin at placeholder#1#2{%
+  \begin{VerbatimBuffer}[buffername=minted at tmpcodebuffer]}
+\def\MintedEnd at placeholder{%
+  \end{VerbatimBuffer}%
+  \minted at insertplaceholder}
+\def\MintedBegin at verbatim#1#2{%
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \minted at usefvopts
+  \minted at useadditionalfvoptsnopy
+  \minted at usetexoptsnonpygments
+  \begin{\minted at envname}}
+\def\MintedEnd at verbatim{%
+  \end{\minted at envname}}
+\ifbool{minted at placeholder}%
+ {\let\MintedBegin\MintedBegin at placeholder
+  \let\MintedEnd\MintedEnd at placeholder}%
+ {\ifbool{minted at verbatim}%
+   {\let\MintedBegin\MintedBegin at verbatim
+    \let\MintedEnd\MintedEnd at verbatim}%
+   {\let\MintedBegin\MintedBegin at highlight
+    \let\MintedEnd\MintedEnd at highlight}}
+\def\minted at readinputmintedargs#1#{%
+  \minted at readinputmintedargs@i{#1}}
+\def\minted at readinputmintedargs@i#1#2#3{%
+  \FVExtraAlwaysUnexpanded{\minted at readinputmintedargs#1{#2}{#3}}}
+\FVExtrapdfstringdefDisableCommands{%
+  \makeatletter
+  \def\minted at readinputmintedargs@i#1#2#3{%
+    \detokenize{<input from file "}#3\detokenize{">}}%
+  \makeatother}
+\def\inputminted{%
+  \FVExtraRobustCommand\RobustInputMinted\minted at readinputmintedargs}
+\FVExtrapdfstringdefDisableCommands{%
+  \def\RobustInputMinted{}}
+\newrobustcmd{\RobustInputMinted}[3][]{%
+  \RobustInputMintedProcess{#1}{#2}{#3}}
+\def\RobustInputMintedProcess at highlight#1#2#3{%
+  \begingroup
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \edef\minted at inputfilepath{#3}%
+  \minted at usefvopts
+  \minted at usetexoptsnonpygments
+  \let\minted at highlight@fallback\RobustInputMintedProcess at highlight@fallback
+  \minted at highlightinputfile
+  \endgroup}
+\def\RobustInputMintedProcess at highlight@fallback{%
+  \minted at useadditionalfvoptsnopy
+  \minted at codewrapper{%
+    \csname\minted at envname Input\endcsname{\minted at inputfilepath}}}
+\def\RobustInputMintedProcess at placeholder#1#2#3{%
+  \minted at insertplaceholder}
+\def\RobustInputMintedProcess at verbatim#1#2#3{%
+  \begingroup
+  \ifstrempty{#1}{}{\pgfkeys{/minted/cmd/.cd,#1}}%
+  \edef\minted at lexer{#2}%
+  \edef\minted at inputfilepath{#3}%
+  \minted at usefvopts
+  \minted at useadditionalfvoptsnopy
+  \minted at usetexoptsnonpygments
+  \minted at codewrapper{%
+    \csname\minted at envname Input\endcsname{\minted at inputfilepath}}%
+  \endgroup}
+\ifbool{minted at placeholder}%
+ {\let\RobustInputMintedProcess\RobustInputMintedProcess at placeholder}%
+ {\ifbool{minted at verbatim}%
+   {\let\RobustInputMintedProcess\RobustInputMintedProcess at verbatim}%
+   {\let\RobustInputMintedProcess\RobustInputMintedProcess at highlight}}
+\newcommand{\newminted}[3][]{%
+  \ifstrempty{#1}%
+   {\newminted at i{#2code}{#2}{#3}}%
+   {\newminted at i{#1}{#2}{#3}}}
 \begingroup
 \catcode`\^^M=\active%
-\catcode`\<=1%
-\catcode`\>=2%
-\catcode`\{=12%
-\catcode`\}=12%
-\catcode`\!=0%
-\catcode`\\=12%
-!ifthenelse<!boolean<minted at draft>>%
- <!gdef!RobustMintProcess at i#1<%
-    !FVExtraDetokenizeVArg<%
-      !FVExtraRetokenizeVArg<!RobustMintProcess at ii><!FV at CatCodes>><#1>>%
-  !gdef!RobustMintProcess at ii#1<%
-    !minted at langlinenoson%
-    !scantokens<%
-      \begin{Verbatim}
-      #1
-      \end{Verbatim}
-      !noexpand>%
-    !minted at langlinenosoff%
-    !endgroup!@doendpe>>%
- <!gdef!RobustMintProcess at i#1<%
-    !FVExtraDetokenizeVArg<%
-      !FVExtraRetokenizeVArg<!RobustMintProcess at ii><!FV at CatCodes>><#1>>%
-  !gdef!RobustMintProcess at ii#1<%
-    !minted at writecmdcode<#1>%
-    !minted at langlinenoson%
-    !expandafter!minted at pygmentize!expandafter<!minted at lang>%
-    !minted at langlinenosoff%
-    !endgroup!@doendpe>>%
-!endgroup
-\ifthenelse{\boolean{minted at draft}}%
-  {\newenvironment{minted}[2][]
-    {\VerbatimEnvironment
-      \minted at configlang{#2}%
-      \setkeys{minted at opt@cmd}{#1}%
-      \minted at fvset
-      \minted at langlinenoson
-      \begin{Verbatim}}%
-    {\end{Verbatim}%
-      \minted at langlinenosoff}}%
-  {\newenvironment{minted}[2][]
-    {\VerbatimEnvironment
-      \let\FVB at VerbatimOut\minted at FVB@VerbatimOut
-      \let\FVE at VerbatimOut\minted at FVE@VerbatimOut
-      \minted at configlang{#2}%
-      \setkeys{minted at opt@cmd}{#1}%
-      \minted at fvset
-      \begin{VerbatimOut}[codes={\catcode`\^^I=12},firstline,lastline]{\minted at jobname.pyg}}%
-    {\end{VerbatimOut}%
-        \minted at langlinenoson
-        \expandafter\minted at pygmentize\expandafter{\minted at lang}%
-        \minted at langlinenosoff}}
-\ifthenelse{\boolean{minted at draft}}%
-  {\newcommand{\inputminted}[3][]{%
-    \begingroup
-    \minted at configlang{#2}%
-    \setkeys{minted at opt@cmd}{#1}%
-    \minted at fvset
-    \minted at inputlanglinenoson
-    \VerbatimInput{#3}%
-    \minted at inputlanglinenosoff
-    \endgroup}}%
-  {\newcommand{\inputminted}[3][]{%
-    \begingroup
-    \minted at configlang{#2}%
-    \setkeys{minted at opt@cmd}{#1}%
-    \minted at fvset
-    \minted at inputlanglinenoson
-    \minted at pygmentize[#3]{#2}%
-    \minted at inputlanglinenosoff
-    \endgroup}}
-\newcommand{\newminted}[3][]{
-  \ifthenelse{\equal{#1}{}}
-    {\def\minted at envname{#2code}}
-    {\def\minted at envname{#1}}
-  \newenvironment{\minted at envname}
-    {\VerbatimEnvironment
-      \begin{minted}[#3]{#2}}
-    {\end{minted}}
-  \newenvironment{\minted at envname *}[1]
-    {\VerbatimEnvironment\begin{minted}[#3,##1]{#2}}
-    {\end{minted}}}
+\gdef\newminted at i#1#2#3{%
+  \expandafter\def\csname#1 at i\endcsname##1{%
+    \begin{minted}[#3,##1]{#2}^^M}%
+  \newenvironment{#1}%
+   {\VerbatimEnvironment%
+    \FVExtraReadOArgBeforeVEnv{\csname#1 at i\endcsname}}%
+   {\end{minted}}%
+  \newenvironment{#1*}[1]%
+   {\VerbatimEnvironment%
+    \begin{minted}[#3,##1]{#2}}%
+   {\end{minted}}}%
+\endgroup
 \newcommand{\newmint}[3][]{%
-  \if\relax\detokenize{#1}\relax
-    \def\minted at shortname{#2}%
-  \else
-    \def\minted at shortname{#1}%
-  \fi
-  \expandafter\newmint at i\expandafter{\minted at shortname}{#2}{#3}}
+  \ifstrempty{#1}%
+   {\edef\minted at tmp{#2}}%
+   {\edef\minted at tmp{#1}}
+  \expandafter\newmint at i\expandafter{\minted at tmp}{#2}{#3}}
 \def\newmint at i#1#2#3{%
   \expandafter\newcommand\csname#1\endcsname{%
     \expandafter\FVExtraRobustCommand\csname RobustNewMint#1\endcsname
-      \FVExtraUnexpandedReadStarOArgBVArg}%
+    \FVExtraUnexpandedReadStarOArgBVArg}%
   \FVExtrapdfstringdefDisableCommands{%
     \expandafter\def\csname RobustNewMint#1\endcsname{}}%
   \expandafter\newrobustcmd\csname RobustNewMint#1\endcsname{%
@@ -1173,29 +1651,41 @@
     \ifbool{FVExtraRobustCommandExpanded}%
      {\@ifnextchar\bgroup
        {\FVExtraReadVArg{\csname RobustNewMint#1 at ii\endcsname{##1}}}%
-       {\PackageError{minted}%
-         {Delimiters must be paired curly braces in this context}%
-         {Use curly braces as delimiters}}}%
+       {\minted at error{Delimiters must be paired curly braces in this context}}}%
      {\FVExtraReadVArg{\csname RobustNewMint#1 at ii\endcsname{##1}}}}
   \expandafter\def\csname RobustNewMint#1 at ii\endcsname##1##2{%
     \RobustMintProcess{#3,##1}{#2}{##2}}}
-\newcommand{\newmintedfile}[3][]{
-  \ifthenelse{\equal{#1}{}}
-    {\def\minted at shortname{#2file}}
-    {\def\minted at shortname{#1}}
-  \expandafter\newcommand\csname\minted at shortname\endcsname[2][]{
-    \inputminted[#3,##1]{#2}{##2}}}
+\def\minted at readnewmintedfileargs#1#{%
+  \minted at readnewmintedfileargs@i{#1}}
+\def\minted at readnewmintedfileargs@i#1#2{%
+  \FVExtraAlwaysUnexpanded{\minted at readnewmintedfileargs#1{#2}}}
+\FVExtrapdfstringdefDisableCommands{%
+  \makeatletter
+  \def\minted at readnewmintedfileargs@i#1#2{%
+    \detokenize{<input from file "}#2\detokenize{">}}%
+  \makeatother}
+\newcommand{\newmintedfile}[3][]{%
+  \ifstrempty{#1}%
+   {\edef\minted at tmp{#2file}}%
+   {\edef\minted at tmp{#1}}%
+  \expandafter\newmintedfile at i\expandafter{\minted at tmp}{#2}{#3}}
+\def\newmintedfile at i#1#2#3{%
+  \expandafter\newcommand\csname#1\endcsname{%
+    \expandafter\FVExtraRobustCommand\csname RobustNewMintedFile#1\endcsname
+    \minted at readnewmintedfileargs}%
+  \FVExtrapdfstringdefDisableCommands{%
+    \expandafter\def\csname RobustNewMintedFile#1\endcsname{}}%
+  \expandafter\newrobustcmd\csname RobustNewMintedFile#1\endcsname[2][]{%
+    \RobustInputMintedProcess{#3,##1}{#2}{##2}}}
 \newcommand{\newmintinline}[3][]{%
-  \if\relax\detokenize{#1}\relax
-    \def\minted at shortname{#2inline}%
-  \else
-    \def\minted at shortname{#1}%
-  \fi
-  \expandafter\newmintinline at i\expandafter{\minted at shortname}{#2}{#3}}
+  \ifstrempty{#1}%
+   {\edef\minted at tmp{#2inline}}%
+   {\edef\minted at tmp{#1}}%
+  \expandafter\newmintinline at i\expandafter{\minted at tmp}{#2}{#3}}
 \def\newmintinline at i#1#2#3{%
   \expandafter\newcommand\csname#1\endcsname{%
     \expandafter\FVExtraRobustCommand\csname RobustNewMintInline#1\endcsname
-      \FVExtraUnexpandedReadStarOArgBVArg}%
+    \FVExtraUnexpandedReadStarOArgBVArg}%
   \FVExtrapdfstringdefDisableCommands{%
     \expandafter\def\csname RobustNewMintInline#1\endcsname{}}%
   \expandafter\newrobustcmd\csname RobustNewMintInline#1\endcsname{%
@@ -1204,21 +1694,19 @@
     \ifbool{FVExtraRobustCommandExpanded}%
      {\@ifnextchar\bgroup
        {\FVExtraReadVArg{\csname RobustNewMintInline#1 at ii\endcsname{##1}}}%
-       {\PackageError{minted}%
-         {Inline delimiters must be paired curly braces in this context}%
-         {Use curly braces as delimiters}}}%
+       {\minted at error{Inline delimiters must be paired curly braces in this context}}}%
      {\FVExtraReadVArg{\csname RobustNewMintInline#1 at ii\endcsname{##1}}}}
   \expandafter\def\csname RobustNewMintInline#1 at ii\endcsname##1##2{%
     \RobustMintInlineProcess{#3,##1}{#2}{##2}}}
-\ifthenelse{\boolean{minted at newfloat}}%
+\ifbool{minted at newfloat}%
  {\@ifundefined{minted at float@within}%
-    {\DeclareFloatingEnvironment[fileext=lol,placement=tbp]{listing}}%
-    {\def\minted at tmp#1{%
-       \DeclareFloatingEnvironment[fileext=lol,placement=tbp, within=#1]{listing}}%
-     \expandafter\minted at tmp\expandafter{\minted at float@within}}}%
+   {\DeclareFloatingEnvironment[fileext=lol,placement=tbp]{listing}}%
+   {\def\minted at tmp#1{%
+      \DeclareFloatingEnvironment[fileext=lol,placement=tbp,within=#1]{listing}}%
+    \expandafter\minted at tmp\expandafter{\minted at float@within}}}%
  {\@ifundefined{minted at float@within}%
-    {\newfloat{listing}{tbp}{lol}}%
-    {\newfloat{listing}{tbp}{lol}[\minted at float@within]}}
+   {\newfloat{listing}{tbp}{lol}}%
+   {\newfloat{listing}{tbp}{lol}[\minted at float@within]}}
 \ifminted at newfloat\else
 \newcommand{\listingscaption}{Listing}
 \floatname{listing}{\listingscaption}
@@ -1225,50 +1713,6 @@
 \newcommand{\listoflistingscaption}{List of Listings}
 \providecommand{\listoflistings}{\listof{listing}{\listoflistingscaption}}
 \fi
-\AtEndOfPackage{%
-  \ifthenelse{\boolean{minted at draft}}%
-   {}%
-   {%
-    \ifthenelse{\boolean{minted at frozencache}}{}{%
-      \ifnum\pdf at shellescape=1\relax\else
-        \PackageError{minted}%
-         {You must invoke LaTeX with the
-          -shell-escape flag}%
-         {Pass the -shell-escape flag to LaTeX. Refer to the minted.sty
-          documentation for more information.}%
-      \fi}%
-   }%
-}
-\AtEndPreamble{%
-  \ifthenelse{\boolean{minted at draft}}%
-   {}%
-   {%
-    \ifthenelse{\boolean{minted at frozencache}}{}{%
-      \TestAppExists{\MintedPygmentize}%
-      \ifAppExists\else
-        \PackageError{minted}%
-         {You must have `pygmentize' installed
-          to use this package}%
-         {Refer to the installation instructions in the minted
-          documentation for more information.}%
-      \fi}%
-  }%
-}
-\AfterEndDocument{%
-  \ifthenelse{\boolean{minted at draft}}%
-   {}%
-   {\ifthenelse{\boolean{minted at frozencache}}%
-     {}
-     {\ifx\XeTeXinterchartoks\minted at undefined
-      \else
-        \DeleteFile[\minted at outputdir]{\minted at jobname.mintedcmd}%
-        \DeleteFile[\minted at outputdir]{\minted at jobname.mintedmd5}%
-      \fi
-      \DeleteFile[\minted at outputdir]{\minted at jobname.pyg}%
-      \DeleteFile[\minted at outputdir]{\minted at jobname.out.pyg}%
-     }%
-   }%
-}
 \endinput
 %%
 %% End of file `minted.sty'.

Added: trunk/Master/texmf-dist/tex/latex/minted/minted2.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/minted/minted2.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/minted/minted2.sty	2024-09-23 21:20:32 UTC (rev 72363)
@@ -0,0 +1,1285 @@
+%%
+%% This is file `minted2.sty'.
+%%
+%% Copyright 2013--2024 Geoffrey M. Poore
+%% Copyright 2010--2011 Konrad Rudolph
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%%   http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% Additionally, the project may be distributed under the terms of the new BSD
+%% license.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Geoffrey Poore.
+%%
+%% This work consists of the file minted2.sty.
+\NeedsTeXFormat{LaTeX2e}
+%%%% Begin minted2 modification
+%% \ProvidesPackage{minted}
+%%     [2023/12/18 v2.9 Yet another Pygments shim for LaTeX]
+\ProvidesPackage{minted2}
+    [2024/05/09 v2.9 Yet another Pygments shim for LaTeX]
+\IfPackageLoadedTF{minted}%
+ {\PackageError{minted2}%
+   {Packages minted and minted2 cannot be loaded at the same time}{}%
+  \endinput}%
+ {}
+\@namedef{ver at minted.sty}{2023/12/18 v2.9 Yet another Pygments shim for LaTeX}
+\expandafter\let\expandafter\minted at tmp\csname opt at minted2.sty\endcsname
+\expandafter\let\csname opt at minted.sty\endcsname\minted at tmp
+\let\minted at tmp\relax
+%%%% End minted2 modification
+\RequirePackage{keyval}
+\RequirePackage{kvoptions}
+%%%% Begin minted2 modification
+\SetupKeyvalOptions{family=minted, prefix=minted@}
+%%%% End minted2 modification
+\RequirePackage{fvextra}[2022/11/30]
+\RequirePackage{ifthen}
+\IfFileExists{shellesc.sty}
+ {\RequirePackage{shellesc}
+  \@ifpackagelater{shellesc}{2016/04/29}
+   {}
+   {\protected\def\ShellEscape{\immediate\write18 }}}
+ {\protected\def\ShellEscape{\immediate\write18 }}
+\RequirePackage{ifplatform}
+\RequirePackage{pdftexcmds}
+\RequirePackage{etoolbox}
+\RequirePackage{xstring}
+\RequirePackage{lineno}
+\RequirePackage{framed}
+\RequirePackage{catchfile}
+\AtEndPreamble{%
+  \@ifpackageloaded{color}{}{%
+    \@ifpackageloaded{xcolor}{}{\RequirePackage{xcolor}}}%
+}
+\DeclareVoidOption{chapter}{\def\minted at float@within{chapter}}
+\DeclareVoidOption{section}{\def\minted at float@within{section}}
+\DeclareBoolOption{newfloat}
+\DeclareBoolOption[true]{cache}
+\StrSubstitute{\jobname}{ }{_}[\minted at jobname]
+\StrSubstitute{\minted at jobname}{*}{_}[\minted at jobname]
+\StrSubstitute{\minted at jobname}{"}{}[\minted at jobname]
+\StrSubstitute{\minted at jobname}{'}{_}[\minted at jobname]
+\newcommand{\minted at cachedir}{\detokenize{_}minted-\minted at jobname}
+\let\minted at cachedir@windows\minted at cachedir
+\define at key{minted}{cachedir}{%
+  \@namedef{minted at cachedir}{#1}%
+  \StrSubstitute{\minted at cachedir}{/}{\@backslashchar}[\minted at cachedir@windows]}
+\DeclareBoolOption{finalizecache}
+\DeclareBoolOption{frozencache}
+\let\minted at outputdir\@empty
+\let\minted at outputdir@windows\@empty
+\define at key{minted}{outputdir}{%
+  \@namedef{minted at outputdir}{#1/}%
+  \StrSubstitute{\minted at outputdir}{/}%
+    {\@backslashchar}[\minted at outputdir@windows]}
+\DeclareBoolOption{inputlanglinenos}
+\DeclareBoolOption{kpsewhich}
+\DeclareBoolOption{langlinenos}
+\DeclareBoolOption{draft}
+\DeclareComplementaryOption{final}{draft}
+\ProcessKeyvalOptions*
+\ifthenelse{\boolean{minted at newfloat}}{\RequirePackage{newfloat}}{\RequirePackage{float}}
+\ifcsname tikzifexternalizing\endcsname
+  \tikzifexternalizing{\minted at drafttrue\minted at cachefalse}{}
+\else
+  \ifcsname tikzexternalrealjob\endcsname
+    \minted at drafttrue
+    \minted at cachefalse
+  \else
+  \fi
+\fi
+\ifthenelse{\boolean{minted at finalizecache}}%
+ {\ifthenelse{\boolean{minted at frozencache}}%
+   {\PackageError{minted}%
+     {Options "finalizecache" and "frozencache" are not compatible}%
+     {Options "finalizecache" and "frozencache" are not compatible}}%
+   {}}%
+ {}
+\ifthenelse{\boolean{minted at cache}}%
+ {\ifthenelse{\boolean{minted at frozencache}}%
+   {}%
+   {\AtEndOfPackage{\ProvideDirectory{\minted at outputdir\minted at cachedir}}}}%
+ {}
+\newcommand{\minted at input}[1]{%
+  \IfFileExists{#1}%
+   {\input{#1}}%
+   {\PackageError{minted}{Missing Pygments output; \string\inputminted\space
+     was^^Jprobably given a file that does not exist--otherwise, you may need
+     ^^Jthe outputdir package option, or may be using an incompatible build
+     tool,^^Jor may be using frozencache with a missing file}%
+    {This could be caused by using -output-directory or -aux-directory
+     ^^Jwithout setting minted's outputdir, or by using a build tool that
+     ^^Jchanges paths in ways minted cannot detect,
+     ^^Jor using frozencache with a missing file.}}%
+}
+\newcommand{\minted at infile}{\minted at jobname.out.pyg}
+\newcommand{\minted at cachelist}{}
+\newcommand{\minted at addcachefile}[1]{%
+  \expandafter\long\expandafter\gdef\expandafter\minted at cachelist\expandafter{%
+    \minted at cachelist,^^J%
+    \space\space#1}%
+  \expandafter\gdef\csname minted at cached@#1\endcsname{}%
+}
+\newcommand{\minted at savecachelist}{%
+  \ifdefempty{\minted at cachelist}{}{%
+    \immediate\write\@mainaux{%
+      \string\gdef\string\minted at oldcachelist\string{%
+        \minted at cachelist\string}}%
+  }%
+}
+\newcommand{\minted at cleancache}{%
+  \ifcsname minted at oldcachelist\endcsname
+    \def\do##1{%
+      \ifthenelse{\equal{##1}{}}{}{%
+        \ifcsname minted at cached@##1\endcsname\else
+          \DeleteFile[\minted at outputdir\minted at cachedir]{##1}%
+        \fi
+      }%
+    }%
+    \expandafter\docsvlist\expandafter{\minted at oldcachelist}%
+  \else
+  \fi
+}
+\ifthenelse{\boolean{minted at draft}}%
+ {\AtEndDocument{%
+    \ifcsname minted at oldcachelist\endcsname
+      \StrSubstitute{\minted at oldcachelist}{,}{,^^J }[\minted at cachelist]
+      \minted at savecachelist
+    \fi}}%
+ {\ifthenelse{\boolean{minted at frozencache}}%
+   {\AtEndDocument{%
+      \ifcsname minted at oldcachelist\endcsname
+        \StrSubstitute{\minted at oldcachelist}{,}{,^^J }[\minted at cachelist]
+        \minted at savecachelist
+      \fi}}%
+   {\AtEndDocument{%
+    \minted at savecachelist
+    \minted at cleancache}}}%
+\ifwindows
+  \providecommand{\DeleteFile}[2][]{%
+    \ifthenelse{\equal{#1}{}}%
+      {\IfFileExists{#2}{\ShellEscape{del #2}}{}}%
+      {\IfFileExists{#1/#2}{%
+        \StrSubstitute{#1}{/}{\@backslashchar}[\minted at windir]
+        \ShellEscape{del \minted at windir\@backslashchar #2}}{}}}
+\else
+  \providecommand{\DeleteFile}[2][]{%
+    \ifthenelse{\equal{#1}{}}%
+      {\IfFileExists{#2}{\ShellEscape{rm #2}}{}}%
+      {\IfFileExists{#1/#2}{\ShellEscape{rm #1/#2}}{}}}
+\fi
+\ifwindows
+  \newcommand{\ProvideDirectory}[1]{%
+    \StrSubstitute{#1}{/}{\@backslashchar}[\minted at windir]
+    \ShellEscape{if not exist \minted at windir\space mkdir \minted at windir}}
+\else
+  \newcommand{\ProvideDirectory}[1]{%
+    \ShellEscape{mkdir -p #1}}
+\fi
+\newboolean{AppExists}
+\newread\minted at appexistsfile
+\newcommand{\TestAppExists}[1]{%
+  \ifwindows
+    \DeleteFile{\minted at jobname.aex}%
+    \ShellEscape{for \string^\@percentchar i in (#1.exe #1.bat #1.cmd)
+      do set > \minted at jobname.aex <nul: /p
+      x=\string^\@percentchar \string~$PATH:i>> \minted at jobname.aex}%
+    %$ <- balance syntax highlighting
+    \immediate\openin\minted at appexistsfile\minted at jobname.aex
+    \expandafter\def\expandafter\@tmp at cr\expandafter{\the\endlinechar}%
+    \endlinechar=-1\relax
+    \readline\minted at appexistsfile to \minted at apppathifexists
+    \endlinechar=\@tmp at cr
+    \ifthenelse{\equal{\minted at apppathifexists}{}}%
+     {\AppExistsfalse}%
+     {\AppExiststrue}%
+    \immediate\closein\minted at appexistsfile
+    \DeleteFile{\minted at jobname.aex}%
+  \else
+    \ShellEscape{command -v #1 && touch \minted at jobname.aex}%
+    \IfFileExists{\minted at jobname.aex}%
+      {\AppExiststrue
+        \DeleteFile{\minted at jobname.aex}}%
+      {\AppExistsfalse}%
+  \fi
+}
+\newcommand{\minted at optlistcl@g}{}
+\newcommand{\minted at optlistcl@g at i}{}
+\let\minted at lang\@empty
+\newcommand{\minted at optlistcl@lang}{}
+\newcommand{\minted at optlistcl@lang at i}{}
+\newcommand{\minted at optlistcl@cmd}{}
+\newcommand{\minted at optlistfv@g}{}
+\newcommand{\minted at optlistfv@g at i}{}
+\newcommand{\minted at optlistfv@lang}{}
+\newcommand{\minted at optlistfv@lang at i}{}
+\newcommand{\minted at optlistfv@cmd}{}
+\newcommand{\minted at configlang}[1]{%
+  \def\minted at lang{#1}%
+  \ifcsname minted at optlistcl@lang\minted at lang\endcsname\else
+    \expandafter\gdef\csname minted at optlistcl@lang\minted at lang\endcsname{}%
+  \fi
+  \ifcsname minted at optlistcl@lang\minted at lang @i\endcsname\else
+    \expandafter\gdef\csname minted at optlistcl@lang\minted at lang @i\endcsname{}%
+  \fi
+  \ifcsname minted at optlistfv@lang\minted at lang\endcsname\else
+    \expandafter\gdef\csname minted at optlistfv@lang\minted at lang\endcsname{}%
+  \fi
+  \ifcsname minted at optlistfv@lang\minted at lang @i\endcsname\else
+    \expandafter\gdef\csname minted at optlistfv@lang\minted at lang @i\endcsname{}%
+  \fi
+}
+\ifwindows
+  \newcommand{\minted at optlistcl@quote}[2]{%
+    \detokenize{#1="#2"}}
+\else
+  \newcommand{\minted at optlistcl@quote}[2]{%
+    \detokenize{#1='#2'}}
+\fi
+\newcommand{\minted at addto@optlistcl}[3]{%
+  \expandafter\def\expandafter#1\expandafter{#1%
+    \minted at optlistcl@quote{#2}{#3}\space}}
+\newcommand{\minted at addto@optlistcl at lang}[3]{%
+  \expandafter\let\expandafter\minted at tmp\csname #1\endcsname
+  \expandafter\def\expandafter\minted at tmp\expandafter{\minted at tmp%
+    \minted at optlistcl@quote{#2}{#3}\space}%
+  \expandafter\let\csname #1\endcsname\minted at tmp}
+\newcommand{\minted at def@optcl}[4][]{%
+  \ifthenelse{\equal{#1}{}}%
+    {\define at key{minted at opt@g}{#2}{%
+        \minted at addto@optlistcl{\minted at optlistcl@g}{#3}{#4}%
+        \@namedef{minted at opt@g:#2}{#4}}%
+      \define at key{minted at opt@g at i}{#2}{%
+        \minted at addto@optlistcl{\minted at optlistcl@g at i}{#3}{#4}%
+        \@namedef{minted at opt@g at i:#2}{#4}}%
+      \define at key{minted at opt@lang}{#2}{%
+        \minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang}{#3}{#4}%
+        \@namedef{minted at opt@lang\minted at lang:#2}{#4}}%
+      \define at key{minted at opt@lang at i}{#2}{%
+        \minted at addto@optlistcl at lang{%
+          minted at optlistcl@lang\minted at lang @i}{#3}{#4}%
+        \@namedef{minted at opt@lang\minted at lang @i:#2}{#4}}%
+      \define at key{minted at opt@cmd}{#2}{%
+        \minted at addto@optlistcl{\minted at optlistcl@cmd}{#3}{#4}%
+        \@namedef{minted at opt@cmd:#2}{#4}}}%
+    {\define at key{minted at opt@g}{#2}[#1]{%
+        \minted at addto@optlistcl{\minted at optlistcl@g}{#3}{#4}%
+        \@namedef{minted at opt@g:#2}{#4}}%
+      \define at key{minted at opt@g at i}{#2}[#1]{%
+        \minted at addto@optlistcl{\minted at optlistcl@g at i}{#3}{#4}%
+        \@namedef{minted at opt@g at i:#2}{#4}}%
+      \define at key{minted at opt@lang}{#2}[#1]{%
+        \minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang}{#3}{#4}%
+        \@namedef{minted at opt@lang\minted at lang:#2}{#4}}%
+      \define at key{minted at opt@lang at i}{#2}[#1]{%
+        \minted at addto@optlistcl at lang{%
+          minted at optlistcl@lang\minted at lang @i}{#3}{#4}%
+        \@namedef{minted at opt@lang\minted at lang @i:#2}{#4}}%
+      \define at key{minted at opt@cmd}{#2}[#1]{%
+        \minted at addto@optlistcl{\minted at optlistcl@cmd}{#3}{#4}%
+        \@namedef{minted at opt@cmd:#2}{#4}}}%
+}
+\begingroup
+\catcode`\!=0
+!catcode`!\=12
+!gdef!minted at escape#1{%
+  !expandafter!minted at escape@i!detokenize{#1}\!FV at Sentinel}
+!gdef!minted at escape@i#1\#2!FV at Sentinel{%
+  !if!relax!detokenize{#2}!relax
+    !expandafter!@firstoftwo
+  !else
+    !expandafter!@secondoftwo
+  !fi
+  {#1!minted at escape@end\#2!FV at Sentinel}
+  {#1!minted at escape@esc\#2!FV at Sentinel}}
+!gdef!minted at escape@end#1!FV at Sentinel{}
+!gdef!minted at escape@esc\#1#2!FV at Sentinel{%
+  #1!minted at escape@i#2!FV at Sentinel}
+!endgroup
+\newcommand{\minted at addto@optlistcl at e}[3]{%
+  \edef\minted at tmp{\minted at escape{#3}}%
+  \expandafter\minted at addto@optlistcl at e@i\expandafter{\minted at tmp}{#1}{#2}}
+\def\minted at addto@optlistcl at e@i#1#2#3{%
+  \expandafter\def\expandafter#2\expandafter{#2\minted at optlistcl@quote{#3}{#1}\space}}
+\newcommand{\minted at addto@optlistcl at lang@e}[3]{%
+  \edef\minted at tmp{\minted at escape{#3}}%
+  \expandafter\minted at addto@optlistcl at lang@e at i\expandafter{\minted at tmp}{#1}{#2}}
+\def\minted at addto@optlistcl at lang@e at i#1#2#3{%
+  \expandafter\let\expandafter\minted at tmp\csname #2\endcsname
+  \expandafter\def\expandafter\minted at tmp\expandafter{\minted at tmp\minted at optlistcl@quote{#3}{#1}\space}%
+  \expandafter\let\csname #2\endcsname\minted at tmp}
+\newcommand{\minted at def@optcl at e}[4][]{%
+  \ifthenelse{\equal{#1}{}}%
+    {\define at key{minted at opt@g}{#2}{%
+        \minted at addto@optlistcl at e{\minted at optlistcl@g}{#3}{#4}%
+        \@namedef{minted at opt@g:#2}{#4}}%
+      \define at key{minted at opt@g at i}{#2}{%
+        \minted at addto@optlistcl at e{\minted at optlistcl@g at i}{#3}{#4}%
+        \@namedef{minted at opt@g at i:#2}{#4}}%
+      \define at key{minted at opt@lang}{#2}{%
+        \minted at addto@optlistcl at lang@e{minted at optlistcl@lang\minted at lang}{#3}{#4}%
+        \@namedef{minted at opt@lang\minted at lang:#2}{#4}}%
+      \define at key{minted at opt@lang at i}{#2}{%
+        \minted at addto@optlistcl at lang@e{%
+          minted at optlistcl@lang\minted at lang @i}{#3}{#4}%
+        \@namedef{minted at opt@lang\minted at lang @i:#2}{#4}}%
+      \define at key{minted at opt@cmd}{#2}{%
+        \minted at addto@optlistcl at e{\minted at optlistcl@cmd}{#3}{#4}%
+        \@namedef{minted at opt@cmd:#2}{#4}}}%
+    {\define at key{minted at opt@g}{#2}[#1]{%
+        \minted at addto@optlistcl at e{\minted at optlistcl@g}{#3}{#4}%
+        \@namedef{minted at opt@g:#2}{#4}}%
+      \define at key{minted at opt@g at i}{#2}[#1]{%
+        \minted at addto@optlistcl at e{\minted at optlistcl@g at i}{#3}{#4}%
+        \@namedef{minted at opt@g at i:#2}{#4}}%
+      \define at key{minted at opt@lang}{#2}[#1]{%
+        \minted at addto@optlistcl at lang@e{minted at optlistcl@lang\minted at lang}{#3}{#4}%
+        \@namedef{minted at opt@lang\minted at lang:#2}{#4}}%
+      \define at key{minted at opt@lang at i}{#2}[#1]{%
+        \minted at addto@optlistcl at lang@e{%
+          minted at optlistcl@lang\minted at lang @i}{#3}{#4}%
+        \@namedef{minted at opt@lang\minted at lang @i:#2}{#4}}%
+      \define at key{minted at opt@cmd}{#2}[#1]{%
+        \minted at addto@optlistcl at e{\minted at optlistcl@cmd}{#3}{#4}%
+        \@namedef{minted at opt@cmd:#2}{#4}}}%
+}
+\newcommand{\minted at def@optcl at switch}[2]{%
+  \define at booleankey{minted at opt@g}{#1}%
+    {\minted at addto@optlistcl{\minted at optlistcl@g}{#2}{True}%
+      \@namedef{minted at opt@g:#1}{true}}
+    {\minted at addto@optlistcl{\minted at optlistcl@g}{#2}{False}%
+      \@namedef{minted at opt@g:#1}{false}}
+  \define at booleankey{minted at opt@g at i}{#1}%
+    {\minted at addto@optlistcl{\minted at optlistcl@g at i}{#2}{True}%
+      \@namedef{minted at opt@g at i:#1}{true}}
+    {\minted at addto@optlistcl{\minted at optlistcl@g at i}{#2}{False}%
+      \@namedef{minted at opt@g at i:#1}{false}}
+  \define at booleankey{minted at opt@lang}{#1}%
+    {\minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang}{#2}{True}%
+      \@namedef{minted at opt@lang\minted at lang:#1}{true}}
+    {\minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang}{#2}{False}%
+      \@namedef{minted at opt@lang\minted at lang:#1}{false}}
+  \define at booleankey{minted at opt@lang at i}{#1}%
+    {\minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang @i}{#2}{True}%
+      \@namedef{minted at opt@lang\minted at lang @i:#1}{true}}
+    {\minted at addto@optlistcl at lang{minted at optlistcl@lang\minted at lang @i}{#2}{False}%
+      \@namedef{minted at opt@lang\minted at lang @i:#1}{false}}
+  \define at booleankey{minted at opt@cmd}{#1}%
+      {\minted at addto@optlistcl{\minted at optlistcl@cmd}{#2}{True}%
+        \@namedef{minted at opt@cmd:#1}{true}}
+      {\minted at addto@optlistcl{\minted at optlistcl@cmd}{#2}{False}%
+        \@namedef{minted at opt@cmd:#1}{false}}
+}
+\newcommand{\minted at def@optfv}[1]{%
+  \define at key{minted at opt@g}{#1}{%
+    \expandafter\def\expandafter\minted at optlistfv@g\expandafter{%
+      \minted at optlistfv@g#1={##1},}%
+    \@namedef{minted at opt@g:#1}{##1}}
+  \define at key{minted at opt@g at i}{#1}{%
+    \expandafter\def\expandafter\minted at optlistfv@g at i\expandafter{%
+      \minted at optlistfv@g at i#1={##1},}%
+    \@namedef{minted at opt@g at i:#1}{##1}}
+  \define at key{minted at opt@lang}{#1}{%
+    \expandafter\let\expandafter\minted at tmp%
+      \csname minted at optlistfv@lang\minted at lang\endcsname
+    \expandafter\def\expandafter\minted at tmp\expandafter{%
+      \minted at tmp#1={##1},}%
+    \expandafter\let\csname minted at optlistfv@lang\minted at lang\endcsname%
+      \minted at tmp
+    \@namedef{minted at opt@lang\minted at lang:#1}{##1}}
+  \define at key{minted at opt@lang at i}{#1}{%
+    \expandafter\let\expandafter\minted at tmp%
+      \csname minted at optlistfv@lang\minted at lang @i\endcsname
+    \expandafter\def\expandafter\minted at tmp\expandafter{%
+      \minted at tmp#1={##1},}%
+    \expandafter\let\csname minted at optlistfv@lang\minted at lang @i\endcsname%
+      \minted at tmp
+    \@namedef{minted at opt@lang\minted at lang @i:#1}{##1}}
+  \define at key{minted at opt@cmd}{#1}{%
+    \expandafter\def\expandafter\minted at optlistfv@cmd\expandafter{%
+      \minted at optlistfv@cmd#1={##1},}%
+    \@namedef{minted at opt@cmd:#1}{##1}}
+}
+\newcommand{\minted at def@optfv at switch}[1]{%
+  \define at booleankey{minted at opt@g}{#1}%
+    {\expandafter\def\expandafter\minted at optlistfv@g\expandafter{%
+      \minted at optlistfv@g#1=true,}%
+     \@namedef{minted at opt@g:#1}{true}}%
+    {\expandafter\def\expandafter\minted at optlistfv@g\expandafter{%
+      \minted at optlistfv@g#1=false,}%
+     \@namedef{minted at opt@g:#1}{false}}%
+  \define at booleankey{minted at opt@g at i}{#1}%
+    {\expandafter\def\expandafter\minted at optlistfv@g at i\expandafter{%
+      \minted at optlistfv@g at i#1=true,}%
+     \@namedef{minted at opt@g at i:#1}{true}}%
+    {\expandafter\def\expandafter\minted at optlistfv@g at i\expandafter{%
+      \minted at optlistfv@g at i#1=false,}%
+     \@namedef{minted at opt@g at i:#1}{false}}%
+  \define at booleankey{minted at opt@lang}{#1}%
+    {\expandafter\let\expandafter\minted at tmp%
+        \csname minted at optlistfv@lang\minted at lang\endcsname
+      \expandafter\def\expandafter\minted at tmp\expandafter{%
+        \minted at tmp#1=true,}%
+      \expandafter\let\csname minted at optlistfv@lang\minted at lang\endcsname%
+        \minted at tmp
+     \@namedef{minted at opt@lang\minted at lang:#1}{true}}%
+    {\expandafter\let\expandafter\minted at tmp%
+        \csname minted at optlistfv@lang\minted at lang\endcsname
+      \expandafter\def\expandafter\minted at tmp\expandafter{%
+        \minted at tmp#1=false,}%
+      \expandafter\let\csname minted at optlistfv@lang\minted at lang\endcsname%
+        \minted at tmp
+     \@namedef{minted at opt@lang\minted at lang:#1}{false}}%
+  \define at booleankey{minted at opt@lang at i}{#1}%
+    {\expandafter\let\expandafter\minted at tmp%
+        \csname minted at optlistfv@lang\minted at lang @i\endcsname
+      \expandafter\def\expandafter\minted at tmp\expandafter{%
+        \minted at tmp#1=true,}%
+      \expandafter\let\csname minted at optlistfv@lang\minted at lang @i\endcsname%
+        \minted at tmp
+     \@namedef{minted at opt@lang\minted at lang @i:#1}{true}}%
+    {\expandafter\let\expandafter\minted at tmp%
+        \csname minted at optlistfv@lang\minted at lang @i\endcsname
+      \expandafter\def\expandafter\minted at tmp\expandafter{%
+        \minted at tmp#1=false,}%
+      \expandafter\let\csname minted at optlistfv@lang\minted at lang @i\endcsname%
+        \minted at tmp
+     \@namedef{minted at opt@lang\minted at lang @i:#1}{false}}%
+  \define at booleankey{minted at opt@cmd}{#1}%
+    {\expandafter\def\expandafter\minted at optlistfv@cmd\expandafter{%
+      \minted at optlistfv@cmd#1=true,}%
+     \@namedef{minted at opt@cmd:#1}{true}}%
+    {\expandafter\def\expandafter\minted at optlistfv@cmd\expandafter{%
+      \minted at optlistfv@cmd#1=false,}%
+     \@namedef{minted at opt@cmd:#1}{false}}%
+}
+\newboolean{minted at isinline}
+\newcommand{\minted at fvset}{%
+  \expandafter\fvset\expandafter{\minted at optlistfv@g}%
+  \expandafter\let\expandafter\minted at tmp%
+    \csname minted at optlistfv@lang\minted at lang\endcsname
+  \expandafter\fvset\expandafter{\minted at tmp}%
+  \ifthenelse{\boolean{minted at isinline}}%
+   {\expandafter\fvset\expandafter{\minted at optlistfv@g at i}%
+    \expandafter\let\expandafter\minted at tmp%
+      \csname minted at optlistfv@lang\minted at lang @i\endcsname
+    \expandafter\fvset\expandafter{\minted at tmp}}%
+   {}%
+  \expandafter\fvset\expandafter{\minted at optlistfv@cmd}%
+}
+\newcommand{\minted at def@opt}[2][]{%
+  \define at key{minted at opt@g}{#2}{%
+    \@namedef{minted at opt@g:#2}{##1}}
+  \define at key{minted at opt@g at i}{#2}{%
+    \@namedef{minted at opt@g at i:#2}{##1}}
+  \define at key{minted at opt@lang}{#2}{%
+    \@namedef{minted at opt@lang\minted at lang:#2}{##1}}
+  \define at key{minted at opt@lang at i}{#2}{%
+    \@namedef{minted at opt@lang\minted at lang @i:#2}{##1}}
+  \define at key{minted at opt@cmd}{#2}{%
+    \@namedef{minted at opt@cmd:#2}{##1}}
+  \ifstrempty{#1}{}{\@namedef{minted at opt@g:#2}{#1}}%
+}
+\newcommand{\minted at def@opt at detok}[2][]{%
+  \define at key{minted at opt@g}{#2}{%
+    \@namedef{minted at opt@g:#2}{\detokenize{##1}}}
+  \define at key{minted at opt@g at i}{#2}{%
+    \@namedef{minted at opt@g at i:#2}{\detokenize{##1}}}
+  \define at key{minted at opt@lang}{#2}{%
+    \@namedef{minted at opt@lang\minted at lang:#2}{\detokenize{##1}}}
+  \define at key{minted at opt@lang at i}{#2}{%
+    \@namedef{minted at opt@lang\minted at lang @i:#2}{\detokenize{##1}}}
+  \define at key{minted at opt@cmd}{#2}{%
+    \@namedef{minted at opt@cmd:#2}{\detokenize{##1}}}
+  \ifstrempty{#1}{}{\@namedef{minted at opt@g:#2}{\detokenize{#1}}}%
+}
+\newcommand{\minted at generate@PYGdef}[1]{%
+  \ifthenelse{\boolean{minted at cache}}%
+   {\def\minted at pygstylepath@load{\minted at outputdir\minted at cachedir/#1.pygstyle}%
+    \minted at addcachefile{#1.pygstyle}}%
+   {\def\minted at pygstylepath@load{\minted at outputdir\minted at jobname.out.pyg}}%
+  \ifwindows
+    \StrSubstitute{\minted at pygstylepath@load}%
+      {/}{\@backslashchar}[\minted at pygstylepath@save]%
+  \else
+    \let\minted at pygstylepath@save\minted at pygstylepath@load
+  \fi
+  \IfFileExists{\minted at pygstylepath@load}%
+   {}%
+   {\ifthenelse{\boolean{minted at frozencache}}%
+     {\PackageError{minted}%
+       {Missing style definition for #1 with frozencache}%
+       {Missing style definition for #1 with frozencache}}%
+     {}%
+    \ShellEscape{%
+      \MintedPygmentize\space -S #1 -f latex -P commandprefix=PYG
+      > \minted at pygstylepath@save
+    }%
+   }%
+  \CatchFileDef{\minted at tmp@filecontents}%
+   {\minted at pygstylepath@load}{\catcode`@=11\catcode`\%=14\catcode``=12\endlinechar=-1}%
+  \begingroup
+  \let\PYG\relax
+  \minted at tmp@filecontents
+  \ifx\PYG\relax
+    \ifthenelse{\boolean{minted at frozencache}}%
+     {\PackageError{minted}%
+       {Outdated style definition for #1 with frozencache}%
+       {Outdated style definition for #1 with frozencache}}%
+     {}%
+    \ShellEscape{%
+      \MintedPygmentize\space -S #1 -f latex -P commandprefix=PYG
+      > \minted at pygstylepath@save
+    }%
+    \CatchFileDef{\minted at tmp@filecontents}%
+     {\minted at pygstylepath@load}{\catcode`@=11\catcode`\%=14\catcode``=12\endlinechar=-1}%
+    \minted at tmp@filecontents
+    \ifx\PYG\relax
+      \PackageError{minted}%
+       {Cannot find Pygments style #1}%
+       {Cannot find Pygments style #1}%
+    \fi
+  \fi
+  \expandafter\global\expandafter\let\csname minted at PYGdef@#1\endcsname%
+    \minted at tmp@filecontents
+  \endgroup
+}
+\newcommand{\minted at defstyle}[1]{%
+  \edef\minted at style{#1}%
+  \ifcsname minted at PYGdef@\minted at style\endcsname\else
+    \expandafter\minted at generate@PYGdef\expandafter{\minted at style}%
+  \fi
+  \csname minted at PYGdef@\minted at style\endcsname
+  \minted at patch@PYGZsq
+  \minted at patch@PYGZhy
+  \ifthenelse{\equal{\minted at get@opt{ignorelexererrors}{true}}{true}}%
+   {\let\PYG at tok@err\relax}{}}
+\ifthenelse{\boolean{minted at draft}}{\renewcommand{\minted at defstyle}[1]{}}{}
+\newcommand{\minted at patch@PYGZsq}{%
+  \ifcsname PYGZsq\endcsname
+    \expandafter\ifdefstring\expandafter{\csname PYGZsq\endcsname}{\char`\'}%
+     {\minted at patch@PYGZsq at i}%
+     {}%
+  \fi
+}
+\begingroup
+\catcode`\'=\active
+\gdef\minted at patch@PYGZsq at i{\gdef\PYGZsq{'}}
+\endgroup
+\newcommand{\minted at patch@PYGZhy}{%
+  \ifcsname PYGZhy\endcsname
+    \expandafter\ifdefstring\expandafter{\csname PYGZhy\endcsname}{\char`\-}%
+     {\def\PYGZhy{\mbox{-}}}%
+     {}%
+  \fi
+}
+\newcommand{\minted at def@opt at switch}[2][false]{%
+  \define at booleankey{minted at opt@g}{#2}%
+    {\@namedef{minted at opt@g:#2}{true}}%
+    {\@namedef{minted at opt@g:#2}{false}}
+  \define at booleankey{minted at opt@g at i}{#2}%
+    {\@namedef{minted at opt@g at i:#2}{true}}%
+    {\@namedef{minted at opt@g at i:#2}{false}}
+  \define at booleankey{minted at opt@lang}{#2}%
+    {\@namedef{minted at opt@lang\minted at lang:#2}{true}}%
+    {\@namedef{minted at opt@lang\minted at lang:#2}{false}}
+  \define at booleankey{minted at opt@lang at i}{#2}%
+    {\@namedef{minted at opt@lang\minted at lang @i:#2}{true}}%
+    {\@namedef{minted at opt@lang\minted at lang @i:#2}{false}}
+  \define at booleankey{minted at opt@cmd}{#2}%
+    {\@namedef{minted at opt@cmd:#2}{true}}%
+    {\@namedef{minted at opt@cmd:#2}{false}}%
+  \@namedef{minted at opt@g:#2}{#1}%
+}
+\def\minted at get@opt#1#2{%
+  \ifcsname minted at opt@cmd:#1\endcsname
+    \csname minted at opt@cmd:#1\endcsname
+  \else
+    \ifminted at isinline
+      \ifcsname minted at opt@lang\minted at lang @i:#1\endcsname
+        \csname minted at opt@lang\minted at lang @i:#1\endcsname
+      \else
+        \ifcsname minted at opt@g at i:#1\endcsname
+          \csname minted at opt@g at i:#1\endcsname
+        \else
+          \ifcsname minted at opt@lang\minted at lang:#1\endcsname
+            \csname minted at opt@lang\minted at lang:#1\endcsname
+          \else
+            \ifcsname minted at opt@g:#1\endcsname
+              \csname minted at opt@g:#1\endcsname
+            \else
+              #2%
+            \fi
+          \fi
+        \fi
+      \fi
+    \else
+      \ifcsname minted at opt@lang\minted at lang:#1\endcsname
+        \csname minted at opt@lang\minted at lang:#1\endcsname
+      \else
+        \ifcsname minted at opt@g:#1\endcsname
+          \csname minted at opt@g:#1\endcsname
+        \else
+          #2%
+        \fi
+      \fi
+    \fi
+  \fi
+}%
+\minted at def@optcl{encoding}{-P encoding}{#1}
+\minted at def@optcl{outencoding}{-P outencoding}{#1}
+\minted at def@optcl at e{escapeinside}{-P escapeinside}{#1}
+\minted at def@optcl at switch{stripnl}{-P stripnl}
+\minted at def@optcl at switch{stripall}{-P stripall}
+\minted at def@optcl at switch{python3}{-P python3}
+\minted at def@optcl at switch{funcnamehighlighting}{-P funcnamehighlighting}
+\minted at def@optcl at switch{startinline}{-P startinline}
+\ifthenelse{\boolean{minted at draft}}%
+  {\minted at def@optfv{gobble}}%
+  {\minted at def@optcl{gobble}{-F gobble:n}{#1}}
+\minted at def@optcl{codetagify}{-F codetagify:codetags}{#1}
+\minted at def@optcl{keywordcase}{-F keywordcase:case}{#1}
+\minted at def@optcl at switch{texcl}{-P texcomments}
+\minted at def@optcl at switch{texcomments}{-P texcomments}
+\minted at def@optcl at switch{mathescape}{-P mathescape}
+\minted at def@optfv at switch{linenos}
+\minted at def@opt at detok{style}
+\minted at def@optfv{frame}
+\minted at def@optfv{framesep}
+\minted at def@optfv{framerule}
+\minted at def@optfv{rulecolor}
+\minted at def@optfv{numbersep}
+\minted at def@optfv{numbers}
+\minted at def@optfv{firstnumber}
+\minted at def@optfv{stepnumber}
+\minted at def@optfv{firstline}
+\minted at def@optfv{lastline}
+\minted at def@optfv{baselinestretch}
+\minted at def@optfv{xleftmargin}
+\minted at def@optfv{xrightmargin}
+\minted at def@optfv{fillcolor}
+\minted at def@optfv{tabsize}
+\minted at def@optfv{fontfamily}
+\minted at def@optfv{fontsize}
+\minted at def@optfv{fontshape}
+\minted at def@optfv{fontseries}
+\minted at def@optfv{formatcom}
+\minted at def@optfv{label}
+\minted at def@optfv{labelposition}
+\minted at def@optfv{highlightlines}
+\minted at def@optfv{highlightcolor}
+\minted at def@optfv{space}
+\minted at def@optfv{spacecolor}
+\minted at def@optfv{tab}
+\minted at def@optfv{tabcolor}
+\minted at def@optfv{highlightcolor}
+\minted at def@optfv at switch{beameroverlays}
+\minted at def@optfv at switch{curlyquotes}
+\minted at def@optfv at switch{numberfirstline}
+\minted at def@optfv at switch{numberblanklines}
+\minted at def@optfv at switch{stepnumberfromfirst}
+\minted at def@optfv at switch{stepnumberoffsetvalues}
+\minted at def@optfv at switch{showspaces}
+\minted at def@optfv at switch{resetmargins}
+\minted at def@optfv at switch{samepage}
+\minted at def@optfv at switch{showtabs}
+\minted at def@optfv at switch{obeytabs}
+\minted at def@optfv at switch{breaklines}
+\minted at def@optfv at switch{breakbytoken}
+\minted at def@optfv at switch{breakbytokenanywhere}
+\minted at def@optfv{breakindent}
+\minted at def@optfv{breakindentnchars}
+\minted at def@optfv at switch{breakautoindent}
+\minted at def@optfv{breaksymbol}
+\minted at def@optfv{breaksymbolsep}
+\minted at def@optfv{breaksymbolsepnchars}
+\minted at def@optfv{breaksymbolindent}
+\minted at def@optfv{breaksymbolindentnchars}
+\minted at def@optfv{breaksymbolleft}
+\minted at def@optfv{breaksymbolsepleft}
+\minted at def@optfv{breaksymbolsepleftnchars}
+\minted at def@optfv{breaksymbolindentleft}
+\minted at def@optfv{breaksymbolindentleftnchars}
+\minted at def@optfv{breaksymbolright}
+\minted at def@optfv{breaksymbolsepright}
+\minted at def@optfv{breaksymbolseprightnchars}
+\minted at def@optfv{breaksymbolindentright}
+\minted at def@optfv{breaksymbolindentrightnchars}
+\minted at def@optfv{breakbefore}
+\minted at def@optfv{breakbeforesymbolpre}
+\minted at def@optfv{breakbeforesymbolpost}
+\minted at def@optfv at switch{breakbeforeinrun}
+\minted at def@optfv{breakafter}
+\minted at def@optfv at switch{breakafterinrun}
+\minted at def@optfv{breakaftersymbolpre}
+\minted at def@optfv{breakaftersymbolpost}
+\minted at def@optfv at switch{breakanywhere}
+\minted at def@optfv{breakanywheresymbolpre}
+\minted at def@optfv{breakanywheresymbolpost}
+\minted at def@optfv{fontencoding}
+\minted at def@opt{bgcolor}
+\minted at def@opt at switch{autogobble}
+\minted at def@opt at switch{ignorelexererrors}
+\newcommand{\minted at encoding}{\minted at get@opt{encoding}{UTF8}}
+\newenvironment{minted at snugshade*}[1]{%
+  \def\FrameCommand##1{\hskip\@totalleftmargin
+    \colorbox{#1}{##1}%
+    \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
+  \MakeFramed{\advance\hsize-\width
+    \@totalleftmargin\z@ \linewidth\hsize
+    \advance\labelsep\fboxsep
+    \@setminipage}%
+ }{\par\unskip\@minipagefalse\endMakeFramed}
+\newsavebox{\minted at bgbox}
+\newenvironment{minted at colorbg}[1]{%
+  \setlength{\OuterFrameSep}{0pt}%
+  \let\minted at tmp\FV at NumberSep
+  \edef\FV at NumberSep{%
+    \the\numexpr\dimexpr\minted at tmp+\number\fboxsep\relax sp\relax}%
+  \medskip
+  \begin{minted at snugshade*}{#1}}
+ {\end{minted at snugshade*}%
+  \medskip\noindent}
+\newwrite\minted at code
+\newcommand{\minted at savecode}[1]{
+  \immediate\openout\minted at code\minted at jobname.pyg\relax
+  \immediate\write\minted at code{\expandafter\detokenize\expandafter{#1}}%
+  \immediate\closeout\minted at code}
+\newcounter{minted at FancyVerbLineTemp}
+\newcommand{\minted at write@detok}[1]{%
+  \immediate\write\FV at OutFile{\detokenize{#1}}}
+\newcommand{\minted at FVB@VerbatimOut}[1]{%
+  \setcounter{minted at FancyVerbLineTemp}{\value{FancyVerbLine}}%
+  \@bsphack
+  \begingroup
+    \FV at UseKeyValues
+    \FV at DefineWhiteSpace
+    \def\FV at Space{\space}%
+    \FV at DefineTabOut
+    \let\FV at ProcessLine\minted at write@detok
+    \immediate\openout\FV at OutFile #1\relax
+    \let\FV at FontScanPrep\relax
+    \let\@noligs\relax
+    \FV at Scan}
+\newcommand{\minted at FVE@VerbatimOut}{%
+  \immediate\closeout\FV at OutFile\endgroup\@esphack
+  \setcounter{FancyVerbLine}{\value{minted at FancyVerbLineTemp}}}%
+\ifcsname MintedPygmentize\endcsname\else
+  \newcommand{\MintedPygmentize}{pygmentize}
+\fi
+\newcounter{minted at pygmentizecounter}
+\ifwindows
+  \newcommand{\MintedPython}{python}
+\else
+  \newcommand{\MintedPython}{python3}
+\fi
+\newcommand{\minted at check@MintedPython}{%
+  \ifcsname minted at MintedPython@\MintedPython\endcsname
+  \else
+    \let\minted at altpython\minted at undefined
+    \ifdefstring{\MintedPython}{python}{\def\minted at altpython{python3}}{}%
+    \ifdefstring{\MintedPython}{python3}{\def\minted at altpython{python}}{}%
+    \ifx\minted at altpython\minted at undefined\relax
+      \TestAppExists{\MintedPython}%
+      \ifAppExists
+        \expandafter\global\expandafter\let%
+          \csname minted at MintedPython@\MintedPython\endcsname\relax
+      \else
+        \PackageError{minted}%
+         {Failed to find Python executable \MintedPython;
+          check Python installation (including PATH),
+          or redefine \string\MintedPython}%
+         {Failed to find Python executable \MintedPython;
+          check Python installation (including PATH),
+          or redefine \string\MintedPython}%
+      \fi
+    \else
+      \ifcsname minted at MintedPython@\minted at altpython\endcsname
+        \let\MintedPython\minted at altpython
+      \else
+        \TestAppExists{\MintedPython}%
+        \ifAppExists
+          \expandafter\global\expandafter\let%
+            \csname minted at MintedPython@\MintedPython\endcsname\relax
+        \else
+          \TestAppExists{\minted at altpython}%
+          \ifAppExists
+            \expandafter\global\expandafter\let%
+              \csname minted at MintedPython@\minted at altpython\endcsname\relax
+            \let\MintedPython\minted at altpython
+          \else
+            \PackageError{minted}%
+             {Failed to find Python executables python or python3;
+              check Python installation (including PATH),
+              or redefine \string\MintedPython}%
+             {Failed to find Python executables python or python3;
+              check Python installation (including PATH),
+              or redefine \string\MintedPython}%
+          \fi
+        \fi
+      \fi
+    \fi
+  \fi
+}
+\ifwindows
+  \def\minted at opt@quote#1{\detokenize{"#1"}}
+\else
+  \def\minted at opt@quote#1{\detokenize{'#1'}}
+\fi
+\newcommand{\minted at pygmentize}[2][\minted at outputdir\minted at jobname.pyg]{%
+  \minted at defstyle{\minted at get@opt{style}{default}}%
+  \stepcounter{minted at pygmentizecounter}%
+  \ifthenelse{\equal{\minted at get@opt{autogobble}{false}}{true}}%
+    {\def\minted at codefile{\minted at outputdir\minted at jobname.pyg}}%
+    {\def\minted at codefile{#1}}%
+  \ifthenelse{\boolean{minted at isinline}}%
+    {\def\minted at optlistcl@inlines{%
+      \minted at optlistcl@g at i
+      \csname minted at optlistcl@lang\minted at lang @i\endcsname}}%
+    {\let\minted at optlistcl@inlines\@empty}%
+  \def\minted at cmd{%
+    \ifminted at kpsewhich
+      \ifwindows
+        \detokenize{for /f "usebackq tokens=*"}\space\@percentchar\detokenize{a in (`kpsewhich}\space\minted at codefile\detokenize{`) do}\space
+      \fi
+    \fi
+    \MintedPygmentize\space -l \minted at opt@quote{#2}
+    -f latex -P commandprefix=PYG -F tokenmerge
+    \minted at optlistcl@g \csname minted at optlistcl@lang\minted at lang\endcsname
+    \minted at optlistcl@inlines
+    \minted at optlistcl@cmd -o \minted at outputdir\minted at infile\space
+    \ifminted at kpsewhich
+      \ifwindows
+        \@percentchar\detokenize{a}%
+      \else
+        \detokenize{`}kpsewhich \minted at codefile\space
+          \detokenize{||} \minted at codefile\detokenize{`}%
+      \fi
+    \else
+      \minted at codefile
+    \fi}%
+  % For debugging, uncomment: %%%%
+  % \immediate\typeout{\minted at cmd}%
+  % %%%%
+  \ifthenelse{\boolean{minted at cache}}%
+    {%
+      \ifminted at frozencache
+      \else
+        \ifthenelse{\equal{\minted at get@opt{autogobble}{false}}{true}}%
+         {\edef\minted at hash{%
+            \pdf at filemdfivesum{#1}%
+            \pdf at mdfivesum{\minted at cmd\space%
+              autogobble(\the\numexpr\FancyVerbStartNum\relax-%
+                         \the\numexpr\FancyVerbStopNum\relax)}}}%
+         {\edef\minted at hash{%
+            \pdf at filemdfivesum{#1}%
+            \pdf at mdfivesum{\minted at cmd}}}%
+        \edef\minted at infile{\minted at cachedir/\minted at hash.pygtex}%
+        \IfFileExists{\minted at infile}{}{%
+          \ifthenelse{\equal{\minted at get@opt{autogobble}{false}}{true}}{%
+            \minted at autogobble{#1}}{}%
+          \ShellEscape{\minted at cmd}}%
+      \fi
+      \ifthenelse{\boolean{minted at finalizecache}}%
+       {%
+          \edef\minted at cachefilename{listing\arabic{minted at pygmentizecounter}.pygtex}%
+          \edef\minted at actualinfile{\minted at cachedir/\minted at cachefilename}%
+          \ifwindows
+            \StrSubstitute{\minted at infile}{/}{\@backslashchar}[\minted at infile@windows]
+            \StrSubstitute{\minted at actualinfile}{/}{\@backslashchar}[\minted at actualinfile@windows]
+            \ShellEscape{move /y \minted at outputdir\minted at infile@windows\space\minted at outputdir\minted at actualinfile@windows}%
+          \else
+            \ShellEscape{mv -f \minted at outputdir\minted at infile\space\minted at outputdir\minted at actualinfile}%
+          \fi
+          \let\minted at infile\minted at actualinfile
+          \expandafter\minted at addcachefile\expandafter{\minted at cachefilename}%
+       }%
+       {\ifthenelse{\boolean{minted at frozencache}}%
+         {%
+            \edef\minted at cachefilename{listing\arabic{minted at pygmentizecounter}.pygtex}%
+            \edef\minted at infile{\minted at cachedir/\minted at cachefilename}%
+            \expandafter\minted at addcachefile\expandafter{\minted at cachefilename}}%
+         {\expandafter\minted at addcachefile\expandafter{\minted at hash.pygtex}}%
+       }%
+      \minted at inputpyg}%
+    {%
+      \ifthenelse{\equal{\minted at get@opt{autogobble}{false}}{true}}{%
+        \minted at autogobble{#1}}{}%
+      \ShellEscape{\minted at cmd}%
+      \minted at inputpyg}%
+}
+\def\minted at autogobble#1{%
+  \edef\minted at argone@esc{#1}%
+  \StrSubstitute{\minted at argone@esc}{\@backslashchar}{\@backslashchar\@backslashchar}[\minted at argone@esc]%
+  \StrSubstitute{\minted at argone@esc}{"}{\@backslashchar"}[\minted at argone@esc]%
+  \edef\minted at tmpfname@esc{\minted at outputdir\minted at jobname}%
+  \StrSubstitute{\minted at tmpfname@esc}{\@backslashchar}{\@backslashchar\@backslashchar}[\minted at tmpfname@esc]%
+  \StrSubstitute{\minted at tmpfname@esc}{"}{\@backslashchar"}[\minted at tmpfname@esc]%
+  %Need a version of open() that supports encoding under Python 2
+  \minted at check@MintedPython
+  \edef\minted at autogobblecmd{%
+    \ifminted at kpsewhich
+      \ifwindows
+        \detokenize{for /f "usebackq tokens=*" }\@percentchar\detokenize{a in (`kpsewhich} #1\detokenize{`) do}\space
+      \fi
+    \fi
+    \MintedPython\detokenize{ -c "import sys; import os;
+    import textwrap;
+    from io import open;
+    fname = }%
+      \ifminted at kpsewhich
+        \detokenize{sys.argv[1];}\space
+      \else
+        \detokenize{os.path.expanduser(os.path.expandvars(\"}\minted at argone@esc\detokenize{\"));}\space
+      \fi
+    \detokenize{f = open(fname, \"r\", encoding=\"}\minted at encoding\detokenize{\") if os.path.isfile(fname) else None;
+    t = f.readlines() if f is not None else None;
+    t_opt = t if t is not None else [];
+    f.close() if f is not None else None;
+    tmpfname = os.path.expanduser(os.path.expandvars(\"}\minted at tmpfname@esc.pyg\detokenize{\"));
+    f = open(tmpfname, \"w\", encoding=\"}\minted at encoding\detokenize{\") if t is not None else None;
+    fvstartnum = }\the\numexpr\FancyVerbStartNum\detokenize{;
+    fvstopnum = }\the\numexpr\FancyVerbStopNum\detokenize{;
+    s = max(0, fvstartnum-1);
+    e = max(s, fvstopnum) if fvstopnum > 0 else len(t_opt);
+    [f.write(textwrap.dedent(\"\".join(x))) for x in (t_opt[0:s], t_opt[s:e], t_opt[e:]) if x and t is not None];
+    f.close() if t is not None else os.remove(tmpfname);"}%
+    \ifminted at kpsewhich
+      \ifwindows
+        \space\@percentchar\detokenize{a}%
+      \else
+        \space\detokenize{`}kpsewhich #1\space\detokenize{||} #1\detokenize{`}%
+      \fi
+    \fi
+  }%
+  \ShellEscape{\minted at autogobblecmd}%
+}
+\newcommand{\minted at inputpyg}{%
+  \VerbatimPygments{\PYG}{\PYG}%
+  \ifthenelse{\boolean{minted at isinline}}%
+   {\ifthenelse{\equal{\minted at get@opt{breaklines}{false}}{true}}%
+    {\let\FV at BeginVBox\relax
+     \let\FV at EndVBox\relax
+     \def\FV at BProcessLine##1{\FancyVerbFormatLine{##1}}%
+     \minted at inputpyg@inline}%
+    {\minted at inputpyg@inline}}%
+   {\minted at inputpyg@block}%
+}
+\def\minted at inputpyg@inline{%
+  \ifthenelse{\equal{\minted at get@opt{bgcolor}{}}{}}%
+   {\minted at input{\minted at outputdir\minted at infile}}%
+   {\colorbox{\minted at get@opt{bgcolor}{}}{%
+      \minted at input{\minted at outputdir\minted at infile}}}%
+}
+\def\minted at inputpyg@block{%
+  \ifthenelse{\equal{\minted at get@opt{bgcolor}{}}{}}%
+   {\minted at input{\minted at outputdir\minted at infile}}%
+   {\begin{minted at colorbg}{\minted at get@opt{bgcolor}{}}%
+    \minted at input{\minted at outputdir\minted at infile}%
+    \end{minted at colorbg}}}
+\newcommand{\minted at langlinenoson}{%
+  \ifcsname c at minted@lang\minted at lang\endcsname\else
+    \newcounter{minted at lang\minted at lang}%
+  \fi
+  \setcounter{minted at FancyVerbLineTemp}{\value{FancyVerbLine}}%
+  \setcounter{FancyVerbLine}{\value{minted at lang\minted at lang}}%
+}
+\newcommand{\minted at langlinenosoff}{%
+  \setcounter{minted at lang\minted at lang}{\value{FancyVerbLine}}%
+  \setcounter{FancyVerbLine}{\value{minted at FancyVerbLineTemp}}%
+}
+\ifbool{minted at langlinenos}{}{%
+  \ifbool{minted at inputlanglinenos}{}{%
+    \let\minted at langlinenoson\relax
+    \let\minted at langlinenosoff\relax
+  }
+}
+\ifbool{minted at inputlanglinenos}%
+ {\def\minted at inputlanglinenoson{\minted at langlinenoson}%
+  \def\minted at inputlanglinenosoff{\minted at langlinenosoff}}%
+ {\let\minted at inputlanglinenoson\relax
+  \let\minted at inputlanglinenosoff\relax}
+\newcommand{\setminted}[2][]{%
+  \ifthenelse{\equal{#1}{}}%
+    {\setkeys{minted at opt@g}{#2}}%
+    {\minted at configlang{#1}%
+      \setkeys{minted at opt@lang}{#2}}}
+\newcommand{\setmintedinline}[2][]{%
+  \ifthenelse{\equal{#1}{}}%
+    {\setkeys{minted at opt@g at i}{#2}}%
+    {\minted at configlang{#1}%
+      \setkeys{minted at opt@lang at i}{#2}}}
+\setmintedinline[php]{startinline=true}
+\setminted{tabcolor=black}
+\setminted{stripnl=false}
+\newcommand{\usemintedstyle}[2][]{\setminted[#1]{style=#2}}
+\begingroup
+\catcode`\ =\active
+\catcode`\^^I=\active
+\gdef\minted at defwhitespace@retok{\def {\noexpand\FV at Space}\def^^I{\noexpand\FV at Tab}}%
+\endgroup
+\newcommand{\minted at writecmdcode}[1]{%
+  \immediate\openout\minted at code\minted at jobname.pyg\relax
+  \immediate\write\minted at code{\detokenize{#1}}%
+  \immediate\closeout\minted at code}
+\def\mintinline{%
+  \FVExtraRobustCommand\RobustMintInline\FVExtraUnexpandedReadStarOArgMArgBVArg}
+\FVExtrapdfstringdefDisableCommands{%
+  \def\RobustMintInline{}}
+\newrobustcmd{\RobustMintInline}[2][]{%
+  \ifbool{FVExtraRobustCommandExpanded}%
+   {\@ifnextchar\bgroup
+     {\FVExtraReadVArg{\RobustMintInlineProcess{#1}{#2}}}%
+     {\PackageError{minted}%
+       {Inline delimiters must be paired curly braces in this context}%
+       {Use curly braces as delimiters}}}%
+   {\FVExtraReadVArg{\RobustMintInlineProcess{#1}{#2}}}}
+\def\RobustMintInlineProcess#1#2#3{%
+  \begingroup
+  \setboolean{minted at isinline}{true}%
+  \minted at configlang{#2}%
+  \setkeys{minted at opt@cmd}{#1}%
+  \minted at fvset
+  \RobustMintInlineProcess at i{#3}}
+\ifthenelse{\boolean{minted at draft}}%
+ {\def\RobustMintInlineProcess at i#1{%
+    \fvset{extra=true}%
+    \Verb{#1}%
+    \endgroup}}%
+ {\def\RobustMintInlineProcess at i#1{%
+   \FVExtraDetokenizeVArg{%
+     \FVExtraRetokenizeVArg{\RobustMintInlineProcess at ii}{\FV at CatCodes}}{#1}}
+  \def\RobustMintInlineProcess at ii#1{%
+    \minted at writecmdcode{#1}%
+    \let\Verbatim\VerbEnv
+    \let\endVerbatim\endVerbEnv
+    \expandafter\minted at pygmentize\expandafter{\minted at lang}%
+    \endgroup}}
+\def\mint{%
+  \FVExtraRobustCommand\RobustMint\FVExtraUnexpandedReadStarOArgMArgBVArg}
+\FVExtrapdfstringdefDisableCommands{%
+  \def\RobustMint{}}
+\newrobustcmd{\RobustMint}[2][]{%
+  \ifbool{FVExtraRobustCommandExpanded}%
+   {\@ifnextchar\bgroup
+     {\FVExtraReadVArg{\RobustMintProcess{#1}{#2}}}%
+     {\PackageError{minted}%
+       {Delimiters must be paired curly braces in this context}%
+       {Use curly braces as delimiters}}}%
+   {\FVExtraReadVArg{\RobustMintProcess{#1}{#2}}}}
+\def\RobustMintProcess#1#2#3{%
+  \begingroup
+  \minted at configlang{#2}%
+  \setkeys{minted at opt@cmd}{#1}%
+  \minted at fvset
+  \RobustMintProcess at i{#3}}
+\begingroup
+\catcode`\^^M=\active%
+\catcode`\<=1%
+\catcode`\>=2%
+\catcode`\{=12%
+\catcode`\}=12%
+\catcode`\!=0%
+\catcode`\\=12%
+!ifthenelse<!boolean<minted at draft>>%
+ <!gdef!RobustMintProcess at i#1<%
+    !FVExtraDetokenizeVArg<%
+      !FVExtraRetokenizeVArg<!RobustMintProcess at ii><!FV at CatCodes>><#1>>%
+  !gdef!RobustMintProcess at ii#1<%
+    !minted at langlinenoson%
+    !scantokens<%
+      \begin{Verbatim}
+      #1
+      \end{Verbatim}
+      !noexpand>%
+    !minted at langlinenosoff%
+    !endgroup!@doendpe>>%
+ <!gdef!RobustMintProcess at i#1<%
+    !FVExtraDetokenizeVArg<%
+      !FVExtraRetokenizeVArg<!RobustMintProcess at ii><!FV at CatCodes>><#1>>%
+  !gdef!RobustMintProcess at ii#1<%
+    !minted at writecmdcode<#1>%
+    !minted at langlinenoson%
+    !expandafter!minted at pygmentize!expandafter<!minted at lang>%
+    !minted at langlinenosoff%
+    !endgroup!@doendpe>>%
+!endgroup
+\ifthenelse{\boolean{minted at draft}}%
+  {\newenvironment{minted}[2][]
+    {\VerbatimEnvironment
+      \minted at configlang{#2}%
+      \setkeys{minted at opt@cmd}{#1}%
+      \minted at fvset
+      \minted at langlinenoson
+      \begin{Verbatim}}%
+    {\end{Verbatim}%
+      \minted at langlinenosoff}}%
+  {\newenvironment{minted}[2][]
+    {\VerbatimEnvironment
+      \let\FVB at VerbatimOut\minted at FVB@VerbatimOut
+      \let\FVE at VerbatimOut\minted at FVE@VerbatimOut
+      \minted at configlang{#2}%
+      \setkeys{minted at opt@cmd}{#1}%
+      \minted at fvset
+      \begin{VerbatimOut}[codes={\catcode`\^^I=12},firstline,lastline]{\minted at jobname.pyg}}%
+    {\end{VerbatimOut}%
+        \minted at langlinenoson
+        \expandafter\minted at pygmentize\expandafter{\minted at lang}%
+        \minted at langlinenosoff}}
+\ifthenelse{\boolean{minted at draft}}%
+  {\newcommand{\inputminted}[3][]{%
+    \begingroup
+    \minted at configlang{#2}%
+    \setkeys{minted at opt@cmd}{#1}%
+    \minted at fvset
+    \minted at inputlanglinenoson
+    \VerbatimInput{#3}%
+    \minted at inputlanglinenosoff
+    \endgroup}}%
+  {\newcommand{\inputminted}[3][]{%
+    \begingroup
+    \minted at configlang{#2}%
+    \setkeys{minted at opt@cmd}{#1}%
+    \minted at fvset
+    \minted at inputlanglinenoson
+    \minted at pygmentize[#3]{#2}%
+    \minted at inputlanglinenosoff
+    \endgroup}}
+\newcommand{\newminted}[3][]{
+  \ifthenelse{\equal{#1}{}}
+    {\def\minted at envname{#2code}}
+    {\def\minted at envname{#1}}
+  \newenvironment{\minted at envname}
+    {\VerbatimEnvironment
+      \begin{minted}[#3]{#2}}
+    {\end{minted}}
+  \newenvironment{\minted at envname *}[1]
+    {\VerbatimEnvironment\begin{minted}[#3,##1]{#2}}
+    {\end{minted}}}
+\newcommand{\newmint}[3][]{%
+  \if\relax\detokenize{#1}\relax
+    \def\minted at shortname{#2}%
+  \else
+    \def\minted at shortname{#1}%
+  \fi
+  \expandafter\newmint at i\expandafter{\minted at shortname}{#2}{#3}}
+\def\newmint at 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 at i\endcsname}}%
+  \expandafter\def\csname RobustNewMint#1 at i\endcsname##1{%
+    \ifbool{FVExtraRobustCommandExpanded}%
+     {\@ifnextchar\bgroup
+       {\FVExtraReadVArg{\csname RobustNewMint#1 at ii\endcsname{##1}}}%
+       {\PackageError{minted}%
+         {Delimiters must be paired curly braces in this context}%
+         {Use curly braces as delimiters}}}%
+     {\FVExtraReadVArg{\csname RobustNewMint#1 at ii\endcsname{##1}}}}
+  \expandafter\def\csname RobustNewMint#1 at ii\endcsname##1##2{%
+    \RobustMintProcess{#3,##1}{#2}{##2}}}
+\newcommand{\newmintedfile}[3][]{
+  \ifthenelse{\equal{#1}{}}
+    {\def\minted at shortname{#2file}}
+    {\def\minted at shortname{#1}}
+  \expandafter\newcommand\csname\minted at shortname\endcsname[2][]{
+    \inputminted[#3,##1]{#2}{##2}}}
+\newcommand{\newmintinline}[3][]{%
+  \if\relax\detokenize{#1}\relax
+    \def\minted at shortname{#2inline}%
+  \else
+    \def\minted at shortname{#1}%
+  \fi
+  \expandafter\newmintinline at i\expandafter{\minted at shortname}{#2}{#3}}
+\def\newmintinline at 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 at i\endcsname}}%
+  \expandafter\def\csname RobustNewMintInline#1 at i\endcsname##1{%
+    \ifbool{FVExtraRobustCommandExpanded}%
+     {\@ifnextchar\bgroup
+       {\FVExtraReadVArg{\csname RobustNewMintInline#1 at ii\endcsname{##1}}}%
+       {\PackageError{minted}%
+         {Inline delimiters must be paired curly braces in this context}%
+         {Use curly braces as delimiters}}}%
+     {\FVExtraReadVArg{\csname RobustNewMintInline#1 at ii\endcsname{##1}}}}
+  \expandafter\def\csname RobustNewMintInline#1 at ii\endcsname##1##2{%
+    \RobustMintInlineProcess{#3,##1}{#2}{##2}}}
+\ifthenelse{\boolean{minted at newfloat}}%
+ {\@ifundefined{minted at float@within}%
+    {\DeclareFloatingEnvironment[fileext=lol,placement=tbp]{listing}}%
+    {\def\minted at tmp#1{%
+       \DeclareFloatingEnvironment[fileext=lol,placement=tbp, within=#1]{listing}}%
+     \expandafter\minted at tmp\expandafter{\minted at float@within}}}%
+ {\@ifundefined{minted at float@within}%
+    {\newfloat{listing}{tbp}{lol}}%
+    {\newfloat{listing}{tbp}{lol}[\minted at float@within]}}
+\ifminted at newfloat\else
+\newcommand{\listingscaption}{Listing}
+\floatname{listing}{\listingscaption}
+\newcommand{\listoflistingscaption}{List of Listings}
+\providecommand{\listoflistings}{\listof{listing}{\listoflistingscaption}}
+\fi
+\AtEndOfPackage{%
+  \ifthenelse{\boolean{minted at draft}}%
+   {}%
+   {%
+    \ifthenelse{\boolean{minted at frozencache}}{}{%
+      \ifnum\pdf at shellescape=1\relax\else
+        \PackageError{minted}%
+         {You must invoke LaTeX with the
+          -shell-escape flag}%
+         {Pass the -shell-escape flag to LaTeX. Refer to the minted.sty
+          documentation for more information.}%
+      \fi}%
+   }%
+}
+\AtEndPreamble{%
+  \ifthenelse{\boolean{minted at draft}}%
+   {}%
+   {%
+    \ifthenelse{\boolean{minted at frozencache}}{}{%
+      \TestAppExists{\MintedPygmentize}%
+      \ifAppExists\else
+        \PackageError{minted}%
+         {You must have `pygmentize' installed
+          to use this package}%
+         {Refer to the installation instructions in the minted
+          documentation for more information.}%
+      \fi}%
+  }%
+}
+\AfterEndDocument{%
+  \ifthenelse{\boolean{minted at draft}}%
+   {}%
+   {\ifthenelse{\boolean{minted at frozencache}}%
+     {}
+     {\ifx\XeTeXinterchartoks\minted at undefined
+      \else
+        \DeleteFile[\minted at outputdir]{\minted at jobname.mintedcmd}%
+        \DeleteFile[\minted at outputdir]{\minted at jobname.mintedmd5}%
+      \fi
+      \DeleteFile[\minted at outputdir]{\minted at jobname.pyg}%
+      \DeleteFile[\minted at outputdir]{\minted at jobname.out.pyg}%
+     }%
+   }%
+}
+\endinput
+%%
+%% End of file `minted2.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/minted/minted2.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property


More information about the tex-live-commits mailing list.