texlive[65158] Master: fvextra (1dec22)

commits+karl at tug.org commits+karl at tug.org
Thu Dec 1 21:34:07 CET 2022


Revision: 65158
          http://tug.org/svn/texlive?view=revision&revision=65158
Author:   karl
Date:     2022-12-01 21:34:06 +0100 (Thu, 01 Dec 2022)
Log Message:
-----------
fvextra (1dec22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/fvextra/fvextra.pdf
    trunk/Master/texmf-dist/source/latex/fvextra/fvextra.dtx
    trunk/Master/texmf-dist/source/latex/fvextra/fvextra.ins
    trunk/Master/texmf-dist/tex/latex/fvextra/fvextra.sty
    trunk/Master/tlpkg/libexec/ctan2tds

Modified: trunk/Master/texmf-dist/doc/latex/fvextra/fvextra.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/fvextra/fvextra.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/fvextra/fvextra.dtx	2022-12-01 10:50:03 UTC (rev 65157)
+++ trunk/Master/texmf-dist/source/latex/fvextra/fvextra.dtx	2022-12-01 20:34:06 UTC (rev 65158)
@@ -1,6 +1,6 @@
 % \iffalse meta-comment
 %
-% Copyright (C) 2016-2019 by Geoffrey M. Poore <gpoore at gmail.com>
+% Copyright (C) 2016-2022 by Geoffrey M. Poore <gpoore at gmail.com>
 % ---------------------------------------------------------------------------
 % This work may be distributed and/or modified under the
 % conditions of the LaTeX Project Public License, either version 1.3
@@ -26,7 +26,7 @@
 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
 %<package>\ProvidesPackage{fvextra}
 %<*package>
-    [2019/02/04 v1.4 fvextra - extensions and patches for fancyvrb]
+    [2022/11/30 v1.5 fvextra - extensions and patches for fancyvrb]
 %</package>
 %
 %<*driver>
@@ -230,7 +230,7 @@
 %</driver>
 % \fi
 %
-% \CheckSum{4882}
+% \CheckSum{5254}
 %
 % \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
@@ -249,6 +249,19 @@
 %   Right brace   \}     Tilde         \~}
 %
 %
+% \begin{changelog}{v1.5}{2022/11/30}
+% \item Added \cmd{\FancyVerbFormatInline} for customizing the formatting of inline verbatim, such as \cmd{\Verb}.  This parallels \cmd{\FancyVerbFormatLine} and \cmd{\FancyVerbFormatText}.
+% \item Added line breaking option \Verb{breaknonspaceingroup}.  When \cmd{commandchars} is used to allow macros within verbatim, this inserts breaks within groups \Verb{{...}}.
+% \item Added \cmd{\FVExtraUnexpandedReadStarOArgMArgBVArg} to support reimplementation of \cmd{\mintinline} for \pkg{minted}.
+% \item Added \cmd{VerbEnv} environment, which is an environment variant of \cmd{\Verb}.  This supports reimplementation of \cmd{\mintinline} for \pkg{minted}.
+% \item \cmd{breakbefore} and \cmd{breakafter} now support the escaped comma \cmd{\,} (\#15).
+% \item Fixed unintended line breaks after hyphens under LuaTeX (\#14).
+% \item Added documentation on Pandoc compatibility (\#11).
+% \item Replaced \Verb{breakbeforegroup} with \Verb{breakbeforeinrun}, and replaced \Verb{breakaftergroup} with \Verb{breakafterinrun}.  With the introduction of \Verb{breaknonspaceingroup}, ``\Verb{group}'' is now reserved for referring to TeX groups \Verb{{...}}.
+% \item Removed dependency on \Verb{ifthen} package.
+% \item \Verb{breakautoindent} now works correctly with Pygments output that treats leading whitespace as a separate token or as part of a token.
+% \end{changelog}
+%
 % \begin{changelog}{v1.4}{2019/02/04}
 % \item Reimplemented \texttt{\string\Verb}.  It now works as expected inside other commands (with a few limitations), including in movable arguments, and is compatible with \texttt{hyperref} for things like PDF bookmarks.  It now supports \texttt{breaklines} and relevant line-breaking options.
 % \item Reimplemented \texttt{\string\SaveVerb} and \texttt{\string\UseVerb} to be equivalent to the new \texttt{\string\Verb}.  The new option \texttt{retokenize} allows saved verbatim material to be retokenized under new \texttt{commandchars} and \texttt{codes} when it is inserted with \texttt{\string\UseVerb}.
@@ -353,13 +366,41 @@
 %
 % \fvextra\ may be used as a drop-in replacement for \fancyvrb.  It will load \fancyvrb\ if it has not yet been loaded, and then proceeds to patch \fancyvrb\ and define additional features.
 %
-% The \pkg{upquote} package is loaded to give correct backticks (\texttt{\textasciigrave}) and typewriter single quotation marks (\texttt{\textquotesingle}).  When this is not desirable within a given environment, use the option |curlyquotes|.  \fvextra\ modifies the behavior of these and other symbols in typeset math within verbatim, so that they will behave as expected (\cref{sec:patch:math}).  \fvextra\ uses the \pkg{lineno} package for working with automatic line breaks.  \pkg{lineno} gives a warning when the \pkg{csquotes} package is loaded before it, so \fvextra\ should be loaded before \pkg{csquotes}.  The \pkg{ifthen} and \pkg{etoolbox} packages are required.  \pkg{color} or \pkg{xcolor} should be loaded manually to use color-dependent features.
+% The \pkg{upquote} package is loaded to give correct backticks (\texttt{\textasciigrave}) and typewriter single quotation marks (\texttt{\textquotesingle}).  When this is not desirable within a given environment, use the option |curlyquotes|.  \fvextra\ modifies the behavior of these and other symbols in typeset math within verbatim, so that they will behave as expected (\cref{sec:patch:math}).  \fvextra\ uses the \pkg{lineno} package for working with automatic line breaks.  \pkg{lineno} gives a warning when the \pkg{csquotes} package is loaded before it, so \fvextra\ should be loaded before \pkg{csquotes}.  The \pkg{etoolbox} package is required.  \pkg{color} or \pkg{xcolor} should be loaded manually to use color-dependent features.
 %
 % While \fvextra\ attempts to minimize changes to the \fancyvrb\ internals, in some cases it completely overwrites \fancyvrb\ macros with new definitions.  New definitions typically follow the original definitions as much as possible, but code that depends on the details of the original \fancyvrb\ implementation may be incompatible with \fvextra.
 %
 %
+% \subsection{Pandoc compatibility}
+% 
+% \pkg{fvextra} supports line breaking in \href{https://pandoc.org/}{Pandoc} \LaTeX\ output that includes highlighted source code.  Enabling basic line breaking at spaces is as simple as adding |\usepackage{fvextra}| and |\fvset{breaklines}| to the Pandoc Markdown |header-includes|.
 %
+% By default, more advanced line breaking features such as |breakanywhere|, |breakbefore|, and |breakafter| will not work with Pandoc highlighted output, due to the presence of the syntax highlighting macros.  This can be fixed by using |breaknonspaceingroup|, which enables all line breaking features within macros.  For example, the following YAML metadata in a Markdown document would redefine the Pandoc |Highlighting| environment to enable line breaking anywhere.
 %
+%\vspace{2ex}
+%\hrule
+%\vspace{2ex}
+%\noindent\begin{minipage}{\linewidth}
+%\begin{Verbatim}[gobble=1]
+%---
+%header-includes:
+% -  |
+%    ```{=latex}
+%    \usepackage{fvextra}
+%    \DefineVerbatimEnvironment{Highlighting}{Verbatim}{
+%      commandchars=\\\{\},
+%      breaklines, breaknonspaceingroup, breakanywhere}
+%    ```
+%---
+%\end{Verbatim}
+%\end{minipage}
+%\vspace{2ex}
+%\hrule
+%\vspace{2ex}
+%
+%
+%
+%
 % \section{General options}
 % \label{sec:general-options}
 %
@@ -571,7 +612,7 @@
 %
 % \section{General commands}
 %
-% \subsection{Inline formatting with \cmd{\fvinlineset}}
+% \subsection{Inline-only settings with \cmd{\fvinlineset}}
 % \DescribeMacro{\fvinlineset\marg{options}}
 %
 % This is like \cmd{\fvset}, except that options only apply to commands that typeset inline verbatim, like \cmd{\Verb} and \cmd{\EscVerb}.  Settings from \cmd{\fvinlineset} override those from \cmd{\fvset}.
@@ -579,12 +620,21 @@
 % Note that \cmd{\fvinlineset} only works with commands that are reimplemented, patched, or defined by \fvextra; it is not compatible with the original \fancyvrb\ definitions.  
 %
 %
-% \subsection{Line and text formatting}
+% \subsection{Custom formatting for inline commands like \cmd{\Verb} with \cmd{\FancyVerbFormatInline}}
 %
+% \DescribeMacro{\FancyVerbFormatInline}
+% 
+% This can be used to apply custom formatting to inline verbatim text created with commands like \cmd{\Verb}.  It only works with commands that are reimplemented, patched, or defined by \fvextra; it is not compatible with the original \fancyvrb\ definitions.  The default definition does nothing; it is equivalent to |\newcommand{\FancyVerbFormatInline}[1]{#1}|.
+%
+% This is the inline equivalent of \cmd{\FancyVerbFormatLine} and \cmd{\FancyVerbFormatText}.  In the inline context, there is no need to distinguish between entire line formatting and only text formatting, so only \cmd{\FancyVerbFormatInline} exists.
+%
+%
+% \subsection{Custom formatting for environments like \cmd{Verbatim} with \cmd{\FancyVerbFormatLine} and \cmd{\FancyVerbFormatText}}
+%
 % \DescribeMacro{\FancyVerbFormatLine}
 % \DescribeMacro{\FancyVerbFormatText}
 %
-% \fancyvrb\ defines |\FancyVerbFormatLine|, which can be used to apply custom formatting to each individual line of text.  By default, it takes a line as an argument and inserts it with no modification.  This is equivalent to |\newcommand{\FancyVerbFormatLine}[1]{#1}|.\footnote{The actual definition in \fancyvrb\ is |\def\FancyVerbFormatLine#1{\FV at ObeyTabs{#1}}|.  This is problematic because redefining the macro could easily eliminate |\FV at ObeyTabs|, which governs tab expansion.  \fvextra\ redefines the macro to |\def\FancyVerbFormatLine#1{#1}| and patches all parts of \fancyvrb\ that use |\FancyVerbFormatLine| so that |\FV at ObeyTabs| is explicitly inserted at the appropriate points.}
+% \fancyvrb\ defines |\FancyVerbFormatLine|, which can be used to apply custom formatting to each individual line of text in environments like \cmd{Verbatim}.  By default, it takes a line as an argument and inserts it with no modification.  This is equivalent to |\newcommand{\FancyVerbFormatLine}[1]{#1}|.\footnote{The actual definition in \fancyvrb\ is |\def\FancyVerbFormatLine#1{\FV at ObeyTabs{#1}}|.  This is problematic because redefining the macro could easily eliminate |\FV at ObeyTabs|, which governs tab expansion.  \fvextra\ redefines the macro to |\def\FancyVerbFormatLine#1{#1}| and patches all parts of \fancyvrb\ that use |\FancyVerbFormatLine| so that |\FV at ObeyTabs| is explicitly inserted at the appropriate points.}
 %
 % \fvextra\ introduces line breaking, which complicates line formatting.  We might want to apply formatting to the entire line, including line breaks, line continuation symbols, and all indentation, including any extra indentation provided by line breaking.  Or we might want to apply formatting only to the actual text of the line.  \fvextra\ leaves |\FancyVerbFormatLine| as applying to the entire line, and introduces a new command |\FancyVerbFormatText| that only applies to the text part of the line.\footnote{When |breaklines=true|, each line is wrapped in a |\parbox|.  |\FancyVerbFormatLine| is outside the |\parbox|, and |\FancyVerbFormatText| is inside.}   By default, |\FancyVerbFormatText| inserts the text unmodified.  When it is customized, it should not use boxes that do not allow line breaks to avoid conflicts with line breaking code.
 %
@@ -637,7 +687,7 @@
 %
 % \subsection{\cmd{\SaveVerb}}
 %
-% \DescribeMacro{\SaveVerb*\oarg{options}\marg{name}\meta{delim~char~or~\{}\meta{text}\meta{delim~char~or~\}}}
+% \DescribeMacro{\SaveVerb\oarg{options}\marg{name}\meta{delim~char~or~\{}\meta{text}\meta{delim~char~or~\}}}
 %
 % \cmd{\SaveVerb} is reimplemented so that it is equivalent to the reimplemented \cmd{\Verb}.  Like the new \cmd{\Verb}, it accepts \meta{text} delimited by a pair of curly braces |{...}|.  It supports \cmd{\fvinlineset}.  It also adds support for the new |retokenize| option for \cmd{\UseVerb}.
 %
@@ -688,16 +738,29 @@
 % \end{description}
 %
 %
+% \subsection{\cmd{VerbEnv}}
+% \DescribeMacro{\begin\{VerbEnv\}\oarg{options}\\$\langle$\textit{single line}$\rangle$\\\cmd{\end{VerbEnv}}}
 %
+% This is an environment variant of \cmd{\Verb}.  The environment must contain only a single line of text, and the closing \cmd{\end{VerbEnv}} must be on a line by itself.  The $\langle$\textit{options}$\rangle$ and $\langle$\textit{single line}$\rangle$ are read and then passed on to \cmd{\Verb} internally for actual typesetting.
 %
+% While \cmd{VerbEnv} can be used by document authors, it is primarily intended for package creators.  For example, it is used in \pkg{minted} to implement \cmd{\mintinline}.  In that case, highlighted code is always generated within a \cmd{Verbatim} environment.  It is possible to process this as inline rather than block verbatim by \cmd{\let}ting \cmd{\Verbatim} to \cmd{\VerbEnv}.
 %
+% \begin{example}
+%   BEFORE\begin{VerbEnv}
+%   _inline_
+%   \end{VerbEnv}
+%   AFTER
+% \end{example}
 %
+%
 % \section{Line breaking}
 % \label{sec:breaklines}
 %
 % Automatic line breaking may be turned on with |breaklines=true|.  By default, breaks only occur at spaces.  Breaks may be allowed anywhere with |breakanywhere|, or only before or after specified characters with |breakbefore| and |breakafter|.  Many options are provided for customizing breaks.  A good place to start is the description of |breaklines|.
 %
+% When a line is broken, the result must fit on a single page.  There is no support for breaking a line across multiple pages.
 %
+%
 % \subsection{Line breaking options}
 %
 % Options are provided for customizing typical line breaking features.  See \cref{sec:breaklines:advanced} for details about low-level customization of break behavior.
@@ -705,9 +768,9 @@
 % \begin{optionlist}
 %
 % \item[breakafter (string) (\meta{none})]
-% Break lines after specified characters, not just at spaces, when |breaklines=true|.  For example, |breakafter=-/| would allow breaks after any hyphens or slashes.  Special characters given to |breakafter| should be backslash-escaped (usually |#|, |{|, |}|, |%|, |[|, |]|; the backslash |\| may be obtained via |\\| and the space via |\space|).\footnote{|breakafter| expands each token it is given once, so when it is given a macro like |\%|, the macro should expand to a literal character that will appear in the text to be typeset.  \fvextra\ defines special character escapes that are activated for |breakafter| so that this will work with common escapes.  The only exception to token expansion is non-ASCII characters under pdfTeX; these should appear literally.  |breakafter| is not catcode-sensitive.}
+% Break lines after specified characters, not just at spaces, when |breaklines=true|.  For example, |breakafter=-/| would allow breaks after any hyphens or slashes.  Special characters given to |breakafter| should be backslash-escaped (usually |#|, |{|, |}|, |%|, |[|, |]|, and the comma |,|; the backslash |\| may be obtained via |\\| and the space via |\space|).\footnote{|breakafter| expands each token it is given once, so when it is given a macro like |\%|, the macro should expand to a literal character that will appear in the text to be typeset.  \fvextra\ defines special character escapes that are activated for |breakafter| so that this will work with common escapes.  The only exception to token expansion is non-ASCII characters under pdfTeX; these should appear literally.  |breakafter| is not catcode-sensitive.}
 %
-% For an alternative, see |breakbefore|.  When |breakbefore| and |breakafter| are used for the same character, |breakbeforegroup| and |breakaftergroup| must both have the same setting.
+% For an alternative, see |breakbefore|.  When |breakbefore| and |breakafter| are used for the same character, |breakbeforeinrun| and |breakafterinrun| must both have the same setting.
 %
 % Note that when |commandchars| or |codes| are used to include macros within verbatim content, breaks will not occur within mandatory macro arguments by default.  Depending on settings, macros that take optional arguments may not work unless the entire macro including arguments is wrapped in a group (curly braces |{}|, or other characters specified with |commandchars|).  See \cref{sec:breaklines:advanced} for details.
 %
@@ -718,8 +781,8 @@
 % \end{longexample}
 %
 %
-% \item[breakaftergroup (boolean) (true)]
-% When |breakafter| is used, group all adjacent identical characters together, and only allow a break after the last character.  When |breakbefore| and |breakafter| are used for the same character, |breakbeforegroup| and |breakaftergroup| must both have the same setting.
+% \item[breakafterinrun (boolean) (false)]
+% When |breakafter| is used, insert breaks within runs of identical characters.  If |false|, treat sequences of identical characters as a unit that cannot contain breaks.  When |breakbefore| and |breakafter| are used for the same character, |breakbeforeinrun| and |breakafterinrun| must both have the same setting.
 %
 %
 % \item[breakaftersymbolpre (string) (\string\,\string\footnotesize\string\ensuremath\{\_\string\rfloor\}, \,\footnotesize\ensuremath{_\rfloor})]
@@ -755,9 +818,9 @@
 %
 %
 % \item[breakbefore (string) (\meta{none})]
-% Break lines before specified characters, not just at spaces, when |breaklines=true|.  For example, |breakbefore=A| would allow breaks before capital A's.  Special characters given to |breakbefore| should be backslash-escaped (usually |#|, |{|, |}|, |%|, |[|, |]|; the backslash |\| may be obtained via |\\| and the space via |\space|).\footnote{|breakbefore| expands each token it is given once, so when it is given a macro like |\%|, the macro should expand to a literal character that will appear in the text to be typeset.  \fvextra\ defines special character escapes that are activated for |breakbefore| so that this will work with common escapes.  The only exception to token expansion is non-ASCII characters under pdfTeX; these should appear literally.  |breakbefore| is not catcode-sensitive.}
+% Break lines before specified characters, not just at spaces, when |breaklines=true|.  For example, |breakbefore=A| would allow breaks before capital A's.  Special characters given to |breakbefore| should be backslash-escaped (usually |#|, |{|, |}|, |%|, |[|, |]|, and the comma |,|; the backslash |\| may be obtained via |\\| and the space via |\space|).\footnote{|breakbefore| expands each token it is given once, so when it is given a macro like |\%|, the macro should expand to a literal character that will appear in the text to be typeset.  \fvextra\ defines special character escapes that are activated for |breakbefore| so that this will work with common escapes.  The only exception to token expansion is non-ASCII characters under pdfTeX; these should appear literally.  |breakbefore| is not catcode-sensitive.}
 %
-% For an alternative, see |breakafter|.  When |breakbefore| and |breakafter| are used for the same character, |breakbeforegroup| and |breakaftergroup| must both have the same setting.
+% For an alternative, see |breakafter|.  When |breakbefore| and |breakafter| are used for the same character, |breakbeforeinrun| and |breakafterinrun| must both have the same setting.
 %
 % Note that when |commandchars| or |codes| are used to include macros within verbatim content, breaks will not occur within mandatory macro arguments by default.  Depending on settings, macros that take optional arguments may not work unless the entire macro including arguments is wrapped in a group (curly braces |{}|, or other characters specified with |commandchars|).  See \cref{sec:breaklines:advanced} for details.
 %
@@ -768,8 +831,8 @@
 % \end{longexample}
 %
 %
-% \item[breakbeforegroup (boolean) (true)]
-% When |breakbefore| is used, group all adjacent identical characters together, and only allow a break before the first character.  When |breakbefore| and |breakafter| are used for the same character, |breakbeforegroup| and |breakaftergroup| must both have the same setting.
+% \item[breakbeforeinrun (boolean) (false)]
+% When |breakbefore| is used, insert breaks within runs of identical characters.  If |false|, treat sequences of identical characters as a unit that cannot contain breaks.  When |breakbefore| and |breakafter| are used for the same character, |breakbeforeinrun| and |breakafterinrun| must both have the same setting.
 %
 %
 % \item[breakbeforesymbolpre (string) (\string\,\string\footnotesize\string\ensuremath\{\_\string\rfloor\}, \,\footnotesize\ensuremath{_\rfloor})]
@@ -788,7 +851,7 @@
 %
 %
 % \item[breaklines (boolean) (false)]
-% Automatically break long lines.
+% Automatically break long lines.  When a line is broken, the result must fit on a single page.  There is no support for breaking a line across multiple pages.\footnote{Following the implementation in \pkg{fancyvrb}, each line is typeset within an |\hbox|, so page breaks are not possible.}
 %
 % By default, automatic breaks occur at spaces.  Use |breakanywhere| to enable breaking anywhere; use |breakbefore| and |breakafter| for more fine-tuned breaking.
 %
@@ -831,6 +894,12 @@
 % \end{longexample}
 %
 %
+% \item[breaknonspaceingroup (boolean) (false)]
+% By using |commandchars|, it is possible to include \LaTeX\ commands within otherwise verbatim text.  In these cases, there can be groups (typically |{...}| but depends on |commandchars|) within verbatim.  Spaces within groups are treated as potential line break locations when |breaklines=true|, but by default no other break locations are inserted (|breakbefore|, |breakafter|, |breakanywhere|).  This is because inserting non-space break locations can interfere with command functionality.  For example, in |\textcolor{red}{text}|, breaks shouldn't be inserted within |red|. 
+%
+% |breaknonspaceingroup| allows non-space breaks to be inserted within groups.  This option should only be used when |commandchars| is including \LaTeX\ commands that do not take optional arguments and only take mandatory arguments that are typeset.  Something like |\textit{text}| is fine, but |\textcolor{red}{text}| is not because one of the mandatory arguments is not typeset but rather provides a setting.  For more complex commands, it is typically better to redefine them to insert breaks in appropriate locations using |\FancyVerbBreakStart...\FancyVerbBreakStop|.
+%
+%
 % \item[breaksymbol (string) (breaksymbolleft)]
 % Alias for |breaksymbolleft|.
 %
@@ -1255,7 +1324,6 @@
 % \subsection{Required packages}
 % The \pkg{upquote} package performs some font checks when it is loaded to determine whether \pkg{textcomp} is needed, but errors can result if the font is changed later in the preamble, so duplicate the package's font check at the end of the preamble.  Also check for a package order issue with \pkg{lineno} and \pkg{csquotes}.
 %    \begin{macrocode}
-\RequirePackage{ifthen}
 \RequirePackage{etoolbox}
 \RequirePackage{fancyvrb}
 \RequirePackage{upquote}
@@ -1547,6 +1615,25 @@
 %
 % \subsubsection{Tokenization and lookahead}
 %
+%
+% \begin{macro}{\FVExtra at ifnextcharAny}
+% A version of |\@ifnextchar| that can detect any character, including catcode 10 spaces.  This is an exact copy of the definition from |latex.ltx|, modified with the ``|\let\reserved at d= #1%|'' (note space!) trick from \pkg{amsgen}.
+%    \begin{macrocode}
+\long\def\FVExtra at ifnextcharAny#1#2#3{%
+  \let\reserved at d= #1%
+  \def\reserved at a{#2}%
+  \def\reserved at b{#3}%
+  \futurelet\@let at token\FVExtra at ifnchAny}
+\def\FVExtra at ifnchAny{%
+  \ifx\@let at token\reserved at d
+    \expandafter\reserved at a
+  \else
+    \expandafter\reserved at b
+  \fi}
+%    \end{macrocode}
+% \end{macro}
+
+%
 % \begin{macro}{\FVExtra at ifnextcharVArg}
 % This is a wrapper for \cmd{\@ifnextchar} from |latex.ltx| (|ltdefns.dtx|) that tokenizes lookaheads under a mostly verbatim catcode regime rather than the current catcode regime.  This is important when looking ahead for stars |*| and optional argument delimiters~|[|, because if these are not present when looking ahead for a verbatim argument, then the first thing tokenized will be the verbatim argument's delimiting character.  Ideally, the delimiter should be tokenized under a verbatim catcode regime.  This is necessary for instance if the delimiter is \cmd{\active} and \cmd{\outer}.
 %
@@ -1597,19 +1684,9 @@
 %
 %
 % \begin{macro}{\FVExtraReadOArgBeforeVEnv}
-% Read an optional argument that comes before the contents of a verbatim environment, after the |\begin{|\meta{environment}|}| but before the start of the next line where the verbatim content begins.  Note that this is not needed when an environment takes a mandatory argument that follows the optional argument.
+% Read an optional argument at the start of a verbatim environment, after the |\begin{|\meta{environment}|}| but before the start of the next line where the verbatim content begins.  Check for extraneous content after the optional argument and discard the following newline.  Note that this is not needed when an environment takes a mandatory argument that follows the optional argument.
 %
-% The case with only an optional argument is tricky because the default behavior of \cmd{\@ifnextchar} is to read into the next line looking for the optional argument.  Setting |^^M| \cmd{\active} prevents this.  That does mean, though, that the end-of-line token will have to be read and removed later as an \cmd{\active} |^^M|.  See the definition of \cmd{\FV at BeginScanning} in \fancyvrb\ for an example of doing this:
-% \begin{quote}
-%\begin{verbatim}
-%\begingroup
-%\catcode`\^^M=\active
-%  \gdef\FV at BeginScanning#1^^M{%
-%    \def\@tempa{#1}\ifx\@tempa\@empty\else\FV at BadBeginError\fi%
-%    \FV at GetLine}%
-%\endgroup
-%\end{verbatim}
-% \end{quote}
+% The case with only an optional argument is tricky because the default behavior of \cmd{\@ifnextchar} is to read into the next line looking for the optional argument.  Setting |^^M| as \cmd{\active} prevents this.  That does mean, though, that the end-of-line token will have to be read and removed later as an \cmd{\active} |^^M|.
 %
 % \cmd{\@ifnextchar} is used instead of \cmd{\FVExtra at ifnextcharVArg} because the latter is not needed since there is an explicit, required delimiter (|^^M|) before the actual start of verbatim content.  Lookahead can never tokenize verbatim content under an incorrect catcode regime.
 %    \begin{macrocode}
@@ -1617,8 +1694,26 @@
   \begingroup
   \catcode`\^^M=\active
   \@ifnextchar[%
-   {\endgroup\FV at ReadOArgContinue{#2}}%
-   {\endgroup\FV at ReadOArgContinue{#2}[#1]}}
+   {\endgroup\FVExtraReadOArgBeforeVEnv at i{#2}}%
+   {\endgroup\FVExtraReadOArgBeforeVEnv at i{#2}[#1]}}
+\def\FVExtraReadOArgBeforeVEnv at i#1[#2]{%
+  \begingroup
+  \catcode`\^^M=\active
+  \FVExtraReadOArgBeforeVEnv at ii{#1}{#2}}
+\begingroup
+\catcode`\^^M=\active%
+\gdef\FVExtraReadOArgBeforeVEnv at ii#1#2#3^^M{%
+  \endgroup%
+  \FVExtraReadOArgBeforeVEnv at iii{#1}{#2}{#3}}%
+\endgroup%
+\def\FVExtraReadOArgBeforeVEnv at iii#1#2#3{%
+  \if\relax\detokenize{#3}\relax
+  \else
+    \PackageError{fvextra}%
+     {Discarded invalid text while checking for optional argument of verbatim environment}%
+     {Discarded invalid text while checking for optional argument of verbatim environment}%
+  \fi
+  #1{#2}}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1906,8 +2001,24 @@
 % \end{macro}
 %
 %
+% \begin{macro}{\FVExtraUnexpandedReadStarOArgMArgBVArg}
+% Read arguments for a command that has a mandatory argument before a verbatim argument, such as \pkg{minted}'s \cmd{\mintinline}.
+%    \begin{macrocode}
+\def\FVExtraUnexpandedReadStarOArgMArgBVArg#1#{%
+  \FV at UnexpandedReadStarOArgMArgBVArg@i{#1}}
+\def\FV at UnexpandedReadStarOArgMArgBVArg@i#1#2#3{%
+  \FVExtraAlwaysUnexpanded{\FVExtraUnexpandedReadStarOArgMArgBVArg#1{#2}{#3}}}
+\FVExtrapdfstringdefDisableCommands{%
+  \makeatletter
+  \def\FV at UnexpandedReadStarOArgMArgBVArg@i#1#2#3{%
+    \FVExtraPDFStringVerbatimDetokenize{#3}}%
+  \makeatother}
+%    \end{macrocode}
+% \end{macro}
 %
 %
+%
+%
 % \subsubsection{Converting detokenized tokens into PDF strings}
 %
 % At times it will be convenient to convert detokenized tokens into PDF strings, such as bookmarks.  Define macros to escape such detokenized content so that it is in a suitable form.
@@ -3063,9 +3174,11 @@
 \edef\FV at dollarchar{\string$}
 \edef\FV at ampchar{\string&}
 \edef\FV at underscorechar{\string_}
+\edef\FV at caretchar{\string^}
 \edef\FV at tildechar{\string~}
 \edef\FV at leftsquarebracket{\string[}
 \edef\FV at rightsquarebracket{\string]}
+\edef\FV at commachar{\string,}
 \newcommand{\FV at EscChars}{%
   \let\#\FV at hashchar
   \let\%\@percentchar
@@ -3074,11 +3187,13 @@
   \let\$\FV at dollarchar
   \let\&\FV at ampchar
   \let\_\FV at underscorechar
+  \let\^\FV at caretchar
   \let\\\@backslashchar
   \let~\FV at tildechar
   \let\~\FV at tildechar
   \let\[\FV at leftsquarebracket
   \let\]\FV at rightsquarebracket
+  \let\,\FV at commachar
 } %$ <- highlighting
 %    \end{macrocode}
 % \end{macro}
@@ -3136,6 +3251,15 @@
 % \end{macro}
 %
 %
+% \subsubsection{\cmd{\FancyVerbFormatInline}}
+% This allows customization of inline verbatim material.  It is the inline equivalent of \cmd{\FancyVerbFormatLine} and \cmd{\FancyVerbFormatText}.
+% \begin{macro}{\FancyVerbFormatInline}
+%    \begin{macrocode}
+\def\FancyVerbFormatInline#1{#1}
+%    \end{macrocode}
+% \end{macro}
+%
+%
 % \subsubsection{\texttt{\textbackslash Verb}}
 %
 % \cmd{\Verb} is reimplemented so that it functions as well as possible when used within other commands.
@@ -3212,12 +3336,12 @@
 % \begin{macro}{\FVC at Verb@Extra at ii}
 %    \begin{macrocode}
 \def\FVC at Verb@Extra at ii#1{%
-  \ifFV at BreakLines
+  \ifFV at breaklines
     \expandafter\@firstoftwo
   \else
     \expandafter\@secondoftwo
   \fi
-  {\FancyVerbBreakStart#1\FancyVerbBreakStop}%
+  {\FV at InsertBreaks{\FancyVerbFormatInline}{#1}}%
   {\mbox{#1}}%
   \endgroup}
 %    \end{macrocode}
@@ -3362,12 +3486,12 @@
 % \begin{macro}{\FV at UseVerb@Extra}
 %    \begin{macrocode}
 \def\FV at UseVerb@Extra#1{%
-  \ifFV at BreakLines
+  \ifFV at breaklines
     \expandafter\@firstoftwo
   \else
     \expandafter\@secondoftwo
   \fi
-  {\FancyVerbBreakStart#1\FancyVerbBreakStop}%
+  {\FV at InsertBreaks{\FancyVerbFormatInline}{#1}}%
   {\mbox{#1}}%
   \endgroup}
 %    \end{macrocode}
@@ -3425,12 +3549,12 @@
 % \begin{macro}{\FVC at EscVerb@ii}
 %    \begin{macrocode}
 \def\FVC at EscVerb@ii#1{%
-  \ifFV at BreakLines
+  \ifFV at breaklines
     \expandafter\@firstoftwo
   \else
     \expandafter\@secondoftwo
   \fi
-  {\FancyVerbBreakStart#1\FancyVerbBreakStop}%
+  {\FV at InsertBreaks{\FancyVerbFormatInline}{#1}}%
   {\mbox{#1}}%
   \endgroup}
 %    \end{macrocode}
@@ -3437,8 +3561,117 @@
 % \end{macro}
 %
 %
+% \subsubsection{\cmd{VerbEnv}}
+% Environment variant of \cmd{\Verb}.  Depending on how this is used in the future, it may be worth improving error message and error recovery functionality, using techniques from \pkg{fancyvrb}.
+% \begin{macro}{\VerbEnv}
+%    \begin{macrocode}
+\def\VerbEnv{%
+  \ifcsname @currenvir\endcsname
+    \ifx\@currenvir\@empty
+      \PackageError{fvextra}{VerbEnv is an environment}{VerbEnv is an environment}%
+    \else
+      \ifx\@currenvir\relax
+        \PackageError{fvextra}{VerbEnv is an environment}{VerbEnv is an environment}%
+      \fi
+    \fi
+  \else
+    \PackageError{fvextra}{VerbEnv is an environment}{VerbEnv is an environment}%
+  \fi
+  \VerbatimEnvironment
+  \FVExtraReadOArgBeforeVEnv{\expandafter\VerbEnv at i\expandafter{\FV at EnvironName}}}
+\def\VerbEnv at i#1#2{%
+  \begingroup
+  \let\do\@makeother\FVExtraDoSpecials
+  \catcode`\ =\active
+  \catcode`\^^I=\active
+  \catcode`\^^M=\active
+  \VerbEnv at ii{#1}{#2}}
+\begingroup
+\catcode`\!=0
+\catcode`\<=1
+\catcode`\>=2
+!catcode`!\=12
+!catcode`!{=12
+!catcode`!}=12
+!catcode`!^^M=!active%
+!gdef!VerbEnv at ii#1#2#3^^M<%
+  !endgroup%
+  !def!VerbEnv at CheckLine##1\end{#1}##2!FV at Sentinel<%
+    !if!relax!detokenize<##2>!relax%
+    !else%
+      !PackageError<fvextra><Missing environment contents><Missing environment contents>%
+      !let!VerbEnv at iii!VerbEnv at iii@Error%
+    !fi>%
+  !VerbEnv at CheckLine#3\end{#1}!FV at Sentinel%
+  !VerbEnv at iii<#1><#2><#3>>%
+!endgroup%
+\def\VerbEnv at iii@Error#1#2#3{}
+\def\VerbEnv at iii#1#2#3{%
+  \begingroup
+  \let\do\@makeother\FVExtraDoSpecials
+  \catcode`\ =10\relax
+  \catcode`\^^M=\active
+  \VerbEnv at iv{#1}{#2}{#3}}
+\begingroup
+\catcode`\!=0
+\catcode`\<=1
+\catcode`\>=2
+!catcode`!\=12
+!catcode`!{=12
+!catcode`!}=12
+!catcode`!^^M=!active%
+!gdef!VerbEnv at iv#1#2#3#4^^M<%
+  !endgroup%
+  !def!VerbEnv at CheckEndDelim##1\end{#1}##2!FV at Sentinel<%
+    !if!relax!detokenize<##2>!relax%
+      !PackageError<fvextra><Missing end for environment !FV at EnvironName><Add environment end>%
+      !let!VerbEnv at v!VerbEnv at v@Error%
+    !else%
+      !VerbEnv at CheckEndLeading##1!FV at Sentinel%
+      !VerbEnv at CheckEndTrailing##2!FV at Sentinel%
+    !fi>%
+  !def!VerbEnv at CheckEndTrailing##1\end{#1}!FV at Sentinel<%
+    !if!relax!detokenize<##1>!relax%
+    !else%
+      !PackageError<fvextra>%
+       <Discarded text after end of environment !FV at EnvironName>%
+       <Discarded text after end of environment !FV at EnvironName>%
+      !let!VerbEnv at v!VerbEnv at v@Error%
+    !fi>%
+  !VerbEnv at CheckEndDelim#4\end{#1}!FV at Sentinel%
+  !VerbEnv at v<#2><#3>>%
+!endgroup
+\def\VerbEnv at CheckEndLeading{%
+  \FVExtra at ifnextcharAny\@sptoken%
+   {\VerbEnv at CheckEndLeading@Continue}%
+   {\ifx\@let at token\FV at Sentinel
+      \expandafter\VerbEnv at CheckEndLeading@End
+    \else
+      \expandafter\VerbEnv at CheckEndLeading@EndError
+    \fi}}
+\def\VerbEnv at CheckEndLeading@Continue#1{%
+  \VerbEnv at CheckEndLeading}
+\def\VerbEnv at CheckEndLeading@End#1\FV at Sentinel{}
+\def\VerbEnv at CheckEndLeading@EndError{%
+  \PackageError{fvextra}%
+   {Discarded text before end of environment \FV at EnvironName}%
+   {Discarded text before end of environment \FV at EnvironName}%
+  \let\VerbEnv at v\VerbEnv at v@Error}
+\def\VerbEnv at v@Error#1#2{}
+\def\VerbEnv at v#1#2{%
+  \Verb[#1]{#2}%
+  \expandafter\end\expandafter{\FV at EnvironName}}
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\endVerbEnv}
+%    \begin{macrocode}
+\def\endVerbEnv{\global\let\FV at EnvironName\relax}
+%    \end{macrocode}
+% \end{macro}
 %
 %
+%
+%
 % \subsection{Patches}
 % \label{sec:impl:patches}
 %
@@ -3608,7 +3841,7 @@
 % \begin{macro}{FV at ObeyTabs@Whitespace at Tab}
 % In a group where runs of whitespace characters are collected, we need to keep track of whether a tab has been found, so we can avoid expansion and the associated |\hbox| for spaces without tabs.
 %    \begin{macrocode}
-\newboolean{FV at ObeyTabs@Whitespace at Tab}
+\newbool{FV at ObeyTabs@Whitespace at Tab}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -4470,26 +4703,43 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{FV at BreakLines}
+% \begin{macro}{FV at breaklines}
 % Turn line breaking on or off.  The |\FV at ListProcessLine| from \fancyvrb\ is |\let| to a (patched) version of the original or a version that supports line breaks.
 %    \begin{macrocode}
-\newboolean{FV at BreakLines}
+\newbool{FV at breaklines}
 \define at booleankey{FV}{breaklines}%
-  {\FV at BreakLinestrue
-    \let\FV at ListProcessLine\FV at ListProcessLine@Break}%
-  {\FV at BreakLinesfalse
-    \let\FV at ListProcessLine\FV at ListProcessLine@NoBreak}
+ {\booltrue{FV at breaklines}%
+  \let\FV at ListProcessLine\FV at ListProcessLine@Break}%
+ {\boolfalse{FV at breaklines}%
+  \let\FV at ListProcessLine\FV at ListProcessLine@NoBreak}
 \AtEndOfPackage{\fvset{breaklines=false}}
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\FV at BreakLinesLuaTeXHook}
+% Fix hyphen handling under LuaTeX.  |\automatichyphenmode=2| would work for environments, but doesn't seem to work inline.  Instead, the active hyphen is redefined to |\mbox{-}|.
 %
+% This is needed before |\@noligs| is ever used, so it is placed in |\FV at FormattingPrep@PreHook|.
+%    \begin{macrocode}
+\def\FV at BreakLinesLuaTeXHook{%
+   \expandafter\def\expandafter\@noligs\expandafter{\@noligs
+     \begingroup\lccode`\~=`\-\lowercase{\endgroup\def~}{\leavevmode\kern\z@\mbox{-}}}}
+\ifcsname directlua\endcsname
+  \ifx\directlua\relax
+  \else
+    \FV at AddToHook\FV at FormattingPrep@PreHook\FV at BreakLinesLuaTeXHook
+  \fi  
+\fi
+%    \end{macrocode}
+% \end{macro}
+%
+%
 % \begin{macro}{\FV at BreakLinesIndentationHook}
 % A hook for performing on-the-fly indentation calculations when |breaklines=true|.  This is used for all |*NChars| related indentation.  It is important to use |\FV at FormattingPrep@PostHook| because it is always invoked \emph{after} any font-related settings.
 %    \begin{macrocode}
 \def\FV at BreakLinesIndentationHook{}
 \g at addto@macro\FV at FormattingPrep@PostHook{%
-  \ifFV at BreakLines
+  \ifFV at breaklines
     \FV at BreakLinesIndentationHook
   \fi}
 %    \end{macrocode}
@@ -4516,12 +4766,12 @@
 % \end{macro}
 %
 %
-% \begin{macro}{FV at BreakAutoIndent}
+% \begin{macro}{FV at breakautoindent}
 % Auto indentation of continuation lines to indentation of original line.  Adds to |\FV at BreakIndent|.
 %    \begin{macrocode}
-\newboolean{FV at BreakAutoIndent}
+\newbool{FV at breakautoindent}
 \define at booleankey{FV}{breakautoindent}%
-  {\FV at BreakAutoIndenttrue}{\FV at BreakAutoIndentfalse}
+  {\booltrue{FV at breakautoindent}}{\boolfalse{FV at breakautoindent}}
 \fvset{breakautoindent=true}
 %    \end{macrocode}
 % \end{macro}
@@ -4675,25 +4925,26 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\FV at Break@Token}
-% Macro that controls token handling between |\FancyVerbBreakStart| and |\FancyVerbBreakStop|.  Initially |\let| to |\relax|; later |\let| to |\FV at Break@AnyToken| or |\FV at Break@BeforeAfterToken| as appropriate.  There is no need to |\let\FV at Break@Token\relax| when |breakanywhere|, |breakbefore|, and |breakafter| are not in use.  In that case, |\FancyVerbBreakStart| and |\FancyVerbBreakStop| are |\let| to |\relax|, and |\FV at Break@Token| is never invoked.
+% \begin{macro}{\FV at Break@DefaultToken}
+% Macro that controls default token handling between |\FancyVerbBreakStart| and |\FancyVerbBreakStop|.  Initially |\let| to |\FV at Break@NBToken|, which does not insert breaks.  Later |\let| to |\FV at Break@AnyToken| or |\FV at Break@BeforeAfterToken| if |breakanywhere| or |breakbefore|/|breakafter| are in use.
 %    \begin{macrocode}
-\let\FV at Break@Token\relax
+\let\FV at Break@DefaultToken\FV at Break@NBToken
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{FV at BreakAnywhere}
+% \begin{macro}{FV at breakanywhere}
 % Allow line breaking (almost) anywhere.  Set |\FV at Break| and |\FV at EndBreak| to be used, and |\let| |\FV at Break@Token| to the appropriate macro.
 %    \begin{macrocode}
-\newboolean{FV at BreakAnywhere}
+\newbool{FV at breakanywhere}
 \define at booleankey{FV}{breakanywhere}%
-  {\FV at BreakAnywheretrue
+  {\booltrue{FV at breakanywhere}%
     \let\FancyVerbBreakStart\FV at Break
     \let\FancyVerbBreakStop\FV at EndBreak
-    \let\FV at Break@Token\FV at Break@AnyToken}%
-  {\FV at BreakAnywherefalse
+    \let\FV at Break@DefaultToken\FV at Break@AnyToken}%
+  {\boolfalse{FV at breakanywhere}%
     \let\FancyVerbBreakStart\relax
-    \let\FancyVerbBreakStop\relax}
+    \let\FancyVerbBreakStop\relax
+    \let\FV at Break@DefaultToken\FV at Break@NBToken}
 \fvset{breakanywhere=false}
 %    \end{macrocode}
 % \end{macro}
@@ -4706,24 +4957,25 @@
   \ifstrempty{#1}%
    {\let\FV at BreakBefore\@empty
     \let\FancyVerbBreakStart\relax
-    \let\FancyVerbBreakStop\relax}%
+    \let\FancyVerbBreakStop\relax
+    \let\FV at Break@DefaultToken\FV at Break@NBToken}%
    {\def\FV at BreakBefore{#1}%
     \let\FancyVerbBreakStart\FV at Break
     \let\FancyVerbBreakStop\FV at EndBreak
-    \let\FV at Break@Token\FV at Break@BeforeAfterToken}%
+    \let\FV at Break@DefaultToken\FV at Break@BeforeAfterToken}%
 }
 \fvset{breakbefore={}}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{FV at BreakBeforeGroup}
-% Determine whether breaking before specified characters is always allowed before each individual character, or is only allowed before the first in a group of identical characters.
+% \begin{macro}{FV at breakbeforeinrun}
+% Determine whether breaking before specified characters is always allowed before each individual character, or is only allowed before the first in a run of identical characters.
 %    \begin{macrocode}
-\newboolean{FV at BreakBeforeGroup}
-\define at booleankey{FV}{breakbeforegroup}%
- {\FV at BreakBeforeGrouptrue}%
- {\FV at BreakBeforeGroupfalse}%
-\fvset{breakbeforegroup=true}
+\newbool{FV at breakbeforeinrun}
+\define at booleankey{FV}{breakbeforeinrun}%
+ {\booltrue{FV at breakbeforeinrun}}%
+ {\boolfalse{FV at breakbeforeinrun}}%
+\fvset{breakbeforeinrun=false}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -4770,24 +5022,25 @@
   \ifstrempty{#1}%
    {\let\FV at BreakAfter\@empty
     \let\FancyVerbBreakStart\relax
-    \let\FancyVerbBreakStop\relax}%
+    \let\FancyVerbBreakStop\relax
+    \let\FV at Break@DefaultToken\FV at Break@NBToken}%
    {\def\FV at BreakAfter{#1}%
     \let\FancyVerbBreakStart\FV at Break
     \let\FancyVerbBreakStop\FV at EndBreak
-    \let\FV at Break@Token\FV at Break@BeforeAfterToken}%
+    \let\FV at Break@DefaultToken\FV at Break@BeforeAfterToken}%
 }
 \fvset{breakafter={}}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{FV at BreakAfterGroup}
-% Determine whether breaking after specified characters is always allowed after each individual character, or is only allowed after groups of identical characters.
+% \begin{macro}{FV at breakafterinrun}
+% Determine whether breaking after specified characters is always allowed after each individual character, or is only allowed after the last in a run of identical characters.
 %    \begin{macrocode}
-\newboolean{FV at BreakAfterGroup}
-\define at booleankey{FV}{breakaftergroup}%
- {\FV at BreakAfterGrouptrue}%
- {\FV at BreakAfterGroupfalse}%
-\fvset{breakaftergroup=true}
+\newbool{FV at breakafterinrun}
+\define at booleankey{FV}{breakafterinrun}%
+ {\booltrue{FV at breakafterinrun}}%
+ {\boolfalse{FV at breakafterinrun}}%
+\fvset{breakafterinrun=false}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -4810,16 +5063,16 @@
     }%
     \def\FV at BreakAfter@Process at i##1{%
       \ifcsname FV at BreakBefore@Token\detokenize{##1}\endcsname
-        \ifthenelse{\boolean{FV at BreakBeforeGroup}}%
-         {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
+        \ifbool{FV at breakbeforeinrun}%
+         {\ifbool{FV at breakafterinrun}%
            {}%
            {\PackageError{fvextra}%
-            {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}%
-            {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}}%
-         {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
+            {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}%
+            {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}}}%
+         {\ifbool{FV at breakafterinrun}%
            {\PackageError{fvextra}%
-             {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}%
-             {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}%
+             {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}%
+             {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}}%
            {}}%
       \fi
       \g at addto@macro\FV at BreakAfter@Def{%
@@ -4944,6 +5197,20 @@
 % \end{macro}
 %
 %
+% \begin{macro}{breaknonspaceingroup}
+% \begin{macro}{FV at breaknonspaceingroup}
+% When inserting breaks, insert breaks within groups (typically |{...}| but depends on |commandchars|) instead of skipping over them.  This isn't the default because it is incompabile with many macros since it inserts breaks into all arguments.  For those cases, redefining macros to use |\FancyVerbBreakStart...\FancyVerbBreakStop| to insert breaks is better.
+%    \begin{macrocode}
+\newbool{FV at breaknonspaceingroup}
+\define at booleankey{FV}{breaknonspaceingroup}%
+ {\booltrue{FV at breaknonspaceingroup}}%
+ {\boolfalse{FV at breaknonspaceingroup}}
+\fvset{breaknonspaceingroup=false}
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
 % \subsubsection{Line breaking implementation}
 %
 % \paragraph{Helper macros}
@@ -4972,26 +5239,29 @@
 % \begin{macro}{\FV at GetLineIndent}
 % A macro that takes a line and determines the indentation, storing the indentation chars in |\FV at LineIndentChars|.
 %    \begin{macrocode}
-\def\FV at CleanRemainingChars#1\FV at Undefined{}
-\def\FV at GetLineIndent{\afterassignment\FV at CheckIndentChar\let\FV at NextChar=}
-\def\FV at CheckIndentChar{%
-  \ifx\FV at NextChar\FV at Undefined\relax
-    \let\FV at Next=\relax
-  \else
-    \ifx\FV at NextChar\FV at FVSpaceToken\relax
-      \g at addto@macro{\FV at LineIndentChars}{\FV at FVSpaceToken}%
-      \let\FV at Next=\FV at GetLineIndent
-    \else
-      \ifx\FV at NextChar\FV at FVTabToken\relax
-        \g at addto@macro{\FV at LineIndentChars}{\FV at FVTabToken}%
-        \let\FV at Next=\FV at GetLineIndent
+\def\FV at GetLineIndent{%
+  \@ifnextchar\FV at Sentinel
+   {\FV at GetLineIndent@End}%
+   {\ifx\@let at token\FV at FVSpaceToken
+      \let\FV at Next\FV at GetLineIndent@Whitespace
+    \else\ifx\@let at token\FV at FVTabToken
+      \let\FV at Next\FV at GetLineIndent@Whitespace
+    \else\ifcsname FV at PYG@Redefed\endcsname
+      \ifx\@let at token\FV at PYG@Redefed
+        \let\FV at Next\FV at GetLineIndent@Pygments
       \else
-        \let\FV at Next=\FV at CleanRemainingChars
+        \let\FV at Next\FV at GetLineIndent@End
       \fi
-    \fi
-  \fi
-  \FV at Next
-}
+    \else
+      \let\FV at Next\FV at GetLineIndent@End
+    \fi\fi\fi
+    \FV at Next}}
+\def\FV at GetLineIndent@End#1\FV at Sentinel{}
+\def\FV at GetLineIndent@Whitespace#1{%
+  \expandafter\def\expandafter\FV at LineIndentChars\expandafter{\FV at LineIndentChars#1}%
+  \FV at GetLineIndent}
+\def\FV at GetLineIndent@Pygments#1#2#3{%
+  \FV at GetLineIndent#3}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -5019,82 +5289,227 @@
 %
 % \paragraph{Line scanning and break insertion macros}\hfill\\
 %
-% \noindent The strategy here is to scan a line token-by-token, and insert breaks at appropriate points.  An alternative would be to make characters active, and have them expand to literal versions of themselves plus appropriate breaks.  Both approaches have advantages and drawbacks.  A catcode-based approach could work, but in general would require redefining some existing active characters to insert both appropriate breaks and their original definitions.  The current approach works regardless of catcodes.  It is also convenient for working with macros that expand to single characters, such as those created in highlighting code with Pygments (which is used by \pkg{minted} and \pkg{pythontex}).  In that case, working with active characters would not be enough, and scanning for macros (or redefining them) is necessary.  With the current approach, working with more complex macros is also straightforward.  Adding support for line breaks within a macro simply requires wrapping macro contents with |\FancyVerbBreakStart...\FancyVerbBreakStop|.  A catcode-based approach could require |\scantokens| or a similar retokenization in some cases, but would have the advantage that in other cases no macro redefinition would be needed.
+% \noindent The strategy here is to scan through text token by token, inserting potential breaks at appropriate points.  The final text with breaks inserted is stored in |\FV at BreakBuffer|, which is ultimately passed on to a wrapper macro like |\FancyVerbFormatText| or |\FancyVerbFormatInline|.
 %
-% \begin{macro}{\FV at Break}
-% The entry macro for breaking lines, either anywhere or before/after specified characters.  The current line (or argument) will be scanned token by token/group by group, and accumulated (with added potential breaks) in |\FV at TmpLine|.  After scanning is complete, |\FV at TmpLine| will be inserted.  It would be possible to insert each token/group into the document immediately after it is scanned, instead of accumulating them in a ``buffer.''  But that would interfere with macros.  Even in the current approach, macros that take optional arguments are problematic.\footnote{Through a suitable definition that tracks the current state and looks for square brackets, this might be circumvented.  Then again, in verbatim contexts, macro use should be minimal, so the restriction to macros without optional arguments should generally not be an issue.}  The last token is tracked with |\FV at LastToken|, to allow lookbehind when breaking by groups of identical characters.  |\FV at LastToken| is |\let| to |\FV at Undefined| any time the last token was something that shouldn't be compared against (for example, a non-empty group), and it is not reset whenever the last token may be ignored (for example, |{}|).  When setting |\FV at LastToken|, it is vital always to use |\let\FV at LastToken=...| so that |\let\FV at LastToken==| will work (so that the equals sign |=| won't break things).
+% If user macros insert breaks via |\FancyVerbBreakStart...\FancyVerbBreakStop|, this invokes an additional scanning/insertion pass within each macro after expansion.  The scanning/insertion only applies to the part of the expanded macros wrapped in |\FancyVerbBreakStart...\FancyVerbBreakStop|.  At the time this occurs, during macro processing, text will already be wrapped in a wrapper macro like |\FancyVerbFormatText| or |\FancyVerbFormatInline|.  That is, the built-in break insertion occurs before any typesetting, but user macro break insertion occurs during typesetting.
 %
-% The current definition of |\FV at Break@Token| is swapped for a UTF-8 compatible one under pdfTeX when necessary.  The standard macros are defined next, since they make the algorithms simpler to understand.  The more complex |UTF| variants are defined later.
+% Token comparison is currently based on |\ifx|.  This is sufficient for verbatim text but a comparison based on |\detokenize| might be better for cases when |commandchars| is in use.  For example, with |commandchars| characters other than the curly braces |{}| might be the group tokens.
+%
+% It would be possible to insert each token/group into the document immediately after it is scanned, instead of accumulating them in a ``buffer.''  But that would interfere with macros.  Even in the current approach, macros that take optional arguments are problematic, since with some settings breaks will interference with optional arguments.\footnote{Through a suitable definition that tracks the current state and looks for square brackets, this might be circumvented.  Then again, in verbatim contexts, macro use should be minimal, so the restriction to macros without optional arguments should generally not be an issue.}
+%
+% The last token is tracked with |\FV at LastToken|, to allow lookbehind when breaking by groups of identical characters.  |\FV at LastToken| is |\let| to |\FV at Undefined| any time the last token was something that shouldn't be compared against (for example, a non-empty group), and it is not reset whenever the last token may be ignored (for example, |{}|).  When setting |\FV at LastToken|, it is vital always to use |\let\FV at LastToken=...| so that |\let\FV at LastToken==| will work (so that the equals sign |=| won't break things).
+%
+% \begin{macro}{FV at BreakBufferDepth}
+% Track buffer depth while inserting breaks.  Some macros and command sequences require recursive processing.  For example, groups |{...}| (with |commandchars| and |breaknonspaceingroup|), math, and nested |\FancyVerbBreakStart...\FancyVerbBreakStop|.  Depth starts at zero.  The current buffer at depth $n$ is always |\FV at BreakBuffer|, with other buffers |\FV at BreakBuffer<n>| etc.\ named via |\csname| to allow for the integer.
 %    \begin{macrocode}
-\def\FV at Break{%
-  \def\FV at TmpLine{}%
+\newcounter{FV at BreakBufferDepth}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\FV at BreakBuffer@Append}
+% Append to |\FV at BreakBuffer|.
+%    \begin{macrocode}
+\def\FV at BreakBuffer@Append#1{%
+  \expandafter\def\expandafter\FV at BreakBuffer\expandafter{\FV at BreakBuffer#1}}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\FV at BreakBufferStart}
+% Create a new buffer, either at the beginning of scanning or during recursion.  The single mandatory argument is the macro for handling tokens, which is |\let| to |\FV at Break@Token|.  An intermediate |\FV at BreakBufferStart@i| is used to optimize |\ifx| comparisons for |\FV at BreakBufferStart| during scanning.
+%
+% For recursion, |\FV at BreakBuffer<n>| and |\FV at Break@Token<n>| store the state (buffer and token handling macro) immediately prior to recusion with depth |<n>|.
+%    \begin{macrocode}
+\def\FV at BreakBufferStart{%
+  \FV at BreakBufferStart@i}
+\def\FV at BreakBufferStart@i#1{%
+  \ifnum\value{FV at BreakBufferDepth}>0\relax
+    \expandafter\let\csname FV at BreakBuffer\arabic{FV at BreakBufferDepth}\endcsname
+      \FV at BreakBuffer
+    \expandafter\let\csname FV at Break@Token\arabic{FV at BreakBufferDepth}\endcsname
+      \FV at Break@Token
+  \fi
+  \def\FV at BreakBuffer{}%
+  \let\FV at Break@Token=#1%
+  \stepcounter{FV at BreakBufferDepth}%
   \let\FV at LastToken=\FV at Undefined
-  \ifFV at pdfTeXinputenc
-    \ifdefstring{\inputencodingname}{utf8}%
-     {\ifx\FV at Break@Token\FV at Break@AnyToken
-        \let\FV at Break@Token\FV at Break@AnyToken at UTF
-      \else
-         \ifx\FV at Break@Token\FV at Break@BeforeAfterToken
-           \let\FV at Break@Token\FV at Break@BeforeAfterToken at UTF
-         \fi
-      \fi}%
-     {}%
+  \FV at Break@Scan}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{FV at UserMacroBreaks}
+% Whether a user macro is inserting breaks, as opposed to \pkg{fvextra}'s standard scanning routine.  When breaks come from \pkg{fvextra}, |\FV at BreakBufferStop| does nothing with |\FV at BreakBuffer| at buffer depth 0, since |\FV at InsertBreaks| handles buffer insertion.  When breaks come from user macros, |\FV at BreakBufferStop| needs to insert |\FV at BreakBuffer| at buffer depth 0.
+%    \begin{macrocode}
+\newbool{FV at UserMacroBreaks}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\FV at BreakBufferStop}
+% Complete the current buffer.  The single mandatory argument is a wrapper macro for |\FV at BreakBuffer|'s contents (for example, insert recursively scanned group into braces |{...}|).  If the mandatory argument is empty, no wrapper is used.
+%
+% For \pkg{fvextra}'s standard scanning:  If this is the main buffer (depth 0), stop scanning---which ultimately allows |\FV at BreakBuffer| to be handled by |\FV at InsertBreaks|.  For user macros:  Insert |\FV at BreakBuffer| at buffer depth 0.  Otherwise for both cases:  Append the current buffer to the previous buffer, and continue scanning.
+%
+% An intermediate |\FV at BreakBufferStop@i| is used to optimize |\ifx| comparisons for |\FV at BreakBufferStop| during scanning. 
+%    \begin{macrocode}
+\def\FV at BreakBufferStop{%
+  \FV at BreakBufferStop@i}
+\def\FV at BreakBufferStop@i#1{%
+  \addtocounter{FV at BreakBufferDepth}{-1}%
+  \let\FV at LastToken=\FV at Undefined
+  \ifnum\value{FV at BreakBufferDepth}<0\relax
+    \PackageError{fvextra}%
+     {Line break insertion error (extra \string\FancyVerbBreakStop?)}%
+     {Line break insertion error (extra \string\FancyVerbBreakStop?)}%
+    \def\FV at BreakBuffer{}%
   \fi
-  \FV at Break@Scan
-}
+  \ifnum\value{FV at BreakBufferDepth}>0\relax
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+   {\expandafter\FV at BreakBufferStop@ii\expandafter{\FV at BreakBuffer}{#1}}%
+   {\ifbool{FV at UserMacroBreaks}%
+     {\expandafter\let\expandafter\FV at BreakBuffer\expandafter\FV at Undefined\FV at BreakBuffer}%
+     {}}}
+\def\FV at BreakBufferStop@ii#1#2{%
+  \ifstrempty{#2}%
+   {\FV at BreakBufferStop@iii{#1}}%
+   {\expandafter\FV at BreakBufferStop@iii\expandafter{#2{#1}}}}
+\def\FV at BreakBufferStop@iii#1{%
+  \expandafter\let\expandafter\FV at BreakBufferUpLevel
+    \csname FV at BreakBuffer\arabic{FV at BreakBufferDepth}\endcsname
+  \expandafter\def\expandafter\FV at BreakBuffer\expandafter{\FV at BreakBufferUpLevel#1}%
+  \expandafter\let\expandafter\FV at Break@Token
+    \csname FV at Break@Token\arabic{FV at BreakBufferDepth}\endcsname
+  \FV at Break@Scan}
 %    \end{macrocode}
 % \end{macro}
 %
+%
+% \begin{macro}{\FV at InsertBreaks}
+% This inserts breaks within text (|#2|) and stores the result in |\FV at BreakBuffer|.  Then it invokes a macro (|#1|) on the result.  That allows |\FancyVerbFormatInline| and |\FancyVerbFormatText| to operate on the final text (with breaks) directly, rather than being given text without breaks or text wrapped with macros that will (potentially recursively) insert breaks.  (Breaks inserted by user macros are not yet present, though, since they are only inserted---potentially recursively---during macro processing.)
+%
+% The initial |\ifx| skips break insertion when break insertion is turned off (|\FancyVerbBreakStart| is |\relax|).
+%
+% The current definition of |\FV at Break@Token| is swapped for a UTF-8 compatible one under pdfTeX when necessary.  In what follows, the default macros are defined after |\FV at Break|, since they make the algorithms simpler to understand.  The more complex |UTF| variants are defined afterward.
+%    \begin{macrocode}
+\def\FV at InsertBreaks#1#2{%
+  \ifx\FancyVerbBreakStart\relax
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+   {#1{#2}}%
+   {\ifFV at pdfTeXinputenc
+      \ifdefstring{\inputencodingname}{utf8}%
+       {\ifx\FV at Break@DefaultToken\FV at Break@AnyToken
+          \let\FV at Break@DefaultToken\FV at Break@AnyToken at UTF
+        \else
+           \ifx\FV at Break@DefaultToken\FV at Break@BeforeAfterToken
+             \let\FV at Break@DefaultToken\FV at Break@BeforeAfterToken at UTF
+           \fi
+        \fi}%
+       {}%
+    \fi
+    \setcounter{FV at BreakBufferDepth}{0}%
+    \boolfalse{FV at UserMacroBreaks}%
+    \FancyVerbBreakStart#2\FancyVerbBreakStop
+    \setcounter{FV at BreakBufferDepth}{0}%
+    \booltrue{FV at UserMacroBreaks}%
+    \expandafter\FV at InsertBreaks@i\expandafter{\FV at BreakBuffer}{#1}}}
+\def\FV at InsertBreaks@i#1#2{%
+  \let\FV at BreakBuffer\FV at Undefined
+  #2{#1}}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\FV at Break}
+% The entry macro for break insertion.  Whatever is delimited (after expansion) by |\FV at Break...\FV at EndBreak| will be scanned token by token/group by group, and accumulated (with any added breaks) in |\FV at BreakBuffer|.  After scanning is complete, |\FV at BreakBuffer| will be inserted.
+%    \begin{macrocode}
+\def\FV at Break{%
+  \FV at BreakBufferStart{\FV at Break@DefaultToken}}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\FV at EndBreak}
 %    \begin{macrocode}
-\def\FV at EndBreak{\FV at TmpLine}
+\def\FV at EndBreak{%
+  \FV at BreakBufferStop{}}
 %    \end{macrocode}
 % \end{macro}
 %
+%
 % \begin{macro}{\FV at Break@Scan}
 % Look ahead via |\@ifnextchar|.  Don't do anything if we're at the end of the region to be scanned.  Otherwise, invoke a macro to deal with what's next based on whether it is math, or a group, or something else.
 %
-% This and some following macros are defined inside of groups, to ensure proper catcodes.
+% This and some following macros are defined inside of groups to ensure proper catcodes.
+%
+% The check against |\FV at BreakBufferStart| should typically not be necessary; it is included for completeness and to allow for future extensions and customization.  |\FV at BreakBufferStart| is only inserted raw (rather than wrapped in |\FancyVerbBreakStart|) in token processing macros, where it initiates (or restarts) scanning and is not itself scanned.
+%
 %    \begin{macrocode}
 \begingroup
-\catcode`\$=3%
+\catcode`\$=3
 \gdef\FV at Break@Scan{%
-  \@ifnextchar\FV at EndBreak%
+  \@ifnextchar\FancyVerbBreakStart%
    {}%
-   {\ifx\@let at token$\relax
+   {\ifx\@let at token\FancyVerbBreakStop
+      \let\FV at Break@Next\relax
+    \else\ifx\@let at token\FV at BreakBufferStart
+      \let\FV at Break@Next\relax
+    \else\ifx\@let at token\FV at BreakBufferStop
+      \let\FV at Break@Next\relax
+    \else\ifx\@let at token$
       \let\FV at Break@Next\FV at Break@Math
+    \else\ifx\@let at token\bgroup
+      \let\FV at Break@Next\FV at Break@Group
     \else
-      \ifx\@let at token\bgroup\relax
-        \let\FV at Break@Next\FV at Break@Group
-      \else
-        \let\FV at Break@Next\FV at Break@Token
-      \fi
-    \fi
-    \FV at Break@Next}%
-}
+      \let\FV at Break@Next\FV at Break@Token
+    \fi\fi\fi\fi\fi
+    \FV at Break@Next}}
 \endgroup
 %    \end{macrocode}
 % \end{macro}
 %
+%
 % \begin{macro}{\FV at Break@Math}
-% Grab an entire math span, and insert it into |\FV at TmpLine|.  Due to grouping, this works even when math contains things like |\text{$x$}|.  After dealing with the math span, continue scanning.
+% Grab an entire math span, and insert it into |\FV at BreakBuffer|.  Due to grouping, this works even when math contains things like |\text{$x$}|.  After dealing with the math span, continue scanning.
 %    \begin{macrocode}
 \begingroup
 \catcode`\$=3%
 \gdef\FV at Break@Math$#1${%
-  \g at addto@macro{\FV at TmpLine}{$#1$}%
-  \let\FV at LastToken=\FV at Undefined
-  \FV at Break@Scan}
+  \FV at BreakBufferStart{\FV at Break@NBToken}#1\FV at BreakBufferStop{\FV at Break@MathTemplate}}
+\gdef\FV at Break@MathTemplate#1{$#1$}
 \endgroup
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\FV at Break@Group}
-% Grab the group, and insert it into |\FV at TmpLine| (as a group) before continuing scanning.
+% Grab the group, and insert it into |\FV at BreakBuffer| (as a group) before continuing scanning.
 %    \begin{macrocode}
 \def\FV at Break@Group#1{%
-  \g at addto@macro{\FV at TmpLine}{{#1}}%
-  \ifstrempty{#1}{}{\let\FV at LastToken=\FV at Undefined}%
+  \ifstrempty{#1}%
+   {\FV at BreakBuffer@Append{{}}%
+    \FV at Break@Scan}%
+   {\ifbool{FV at breaknonspaceingroup}%
+     {\FV at BreakBufferStart{\FV at Break@DefaultToken}%
+        #1\FV at BreakBufferStop{\FV at Break@GroupTemplate}}%
+     {\FV at BreakBufferStart{\FV at Break@NBToken}%
+        #1\FV at BreakBufferStop{\FV at Break@GroupTemplate}}}}
+\def\FV at Break@GroupTemplate#1{{#1}}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\FV at Break@NBToken}
+% Append token to buffer while adding no breaks (|NB|) and reset last token.
+%    \begin{macrocode}
+\def\FV at Break@NBToken#1{%
+  \FV at BreakBuffer@Append{#1}%
+  \let\FV at Break@LastToken=\FV at Undefined
   \FV at Break@Scan}
 %    \end{macrocode}
 % \end{macro}
@@ -5113,7 +5528,7 @@
 %\catcode`\+=12%
 %\gdef\FV at Break...
 %  \ifcat\noexpand#1a%
-%    \g at addto@macro{\FV at TmpLine}...
+%    \FV at BreakBuffer@Append...
 %  \else
 %...
 %\endgroup
@@ -5122,7 +5537,7 @@
 %
 %    \begin{macrocode}
 \def\FV at Break@AnyToken#1{%
-  \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakAnywhereBreak#1}%
+  \FV at BreakBuffer@Append{\FancyVerbBreakAnywhereBreak#1}%
   \FV at Break@Scan}
 %    \end{macrocode}
 % \end{macro}
@@ -5131,6 +5546,8 @@
 % Deal with breaking around only specified tokens.  This is a bit trickier.  We only break if a macro corresponding to the token exists.  We also need to check whether the specified token should be grouped, that is, whether breaks are allowed between identical characters.  All of this has to be written carefully so that nothing is accidentally inserted into the stream for future scanning.
 %
 % Dealing with tokens followed by empty groups (for example, |\x{}|) is particularly challenging when we want to avoid breaks between identical characters.  When a token is followed by a group, we need to save the current token for later reference (|\x| in the example), then capture and save the following group, and then---only if the group was empty---see if the following token is identical to the old saved token.
+%
+% The |\csname @let at token\endcsname| prevents issues if |\@let at token| is ever |\else| or |\fi|.
 %    \begin{macrocode}
 \def\FV at Break@BeforeAfterToken#1{%
   \ifcsname FV at BreakBefore@Token\detokenize{#1}\endcsname
@@ -5145,40 +5562,40 @@
   \FV at Break@Next{#1}%
 }
 \def\FV at Break@BeforeAfterTokenNoBreak#1{%
-  \g at addto@macro{\FV at TmpLine}{#1}%
+  \FV at BreakBuffer@Append{#1}%
   \let\FV at LastToken=#1%
   \FV at Break@Scan}
 \def\FV at Break@BeforeTokenBreak#1{%
-  \ifthenelse{\boolean{FV at BreakBeforeGroup}}%
+  \ifbool{FV at breakbeforeinrun}%
+   {\ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
+      \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak}%
+      \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan
+      \def\FV at RescanToken{#1}%
+    \else
+      \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak#1}%
+      \let\FV at Break@Next\FV at Break@Scan
+      \let\FV at LastToken=#1%
+    \fi}%
    {\ifx#1\FV at LastToken\relax
       \ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
         \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan
         \def\FV at RescanToken{#1}%
       \else
-        \g at addto@macro{\FV at TmpLine}{#1}%
+        \FV at BreakBuffer@Append{#1}%
         \let\FV at Break@Next\FV at Break@Scan
         \let\FV at LastToken=#1%
       \fi
     \else
       \ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
-        \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak}%
+        \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak}%
         \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan
         \def\FV at RescanToken{#1}%
       \else
-        \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak#1}%
+        \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak#1}%
         \let\FV at Break@Next\FV at Break@Scan
         \let\FV at LastToken=#1%
       \fi
     \fi}%
-   {\ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
-      \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak}%
-      \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan
-      \def\FV at RescanToken{#1}%
-    \else
-      \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak#1}%
-      \let\FV at Break@Next\FV at Break@Scan
-      \let\FV at LastToken=#1%
-    \fi}%
   \FV at Break@Next}
 \def\FV at Break@BeforeTokenBreak at AfterRescan{%
   \expandafter\FV at Break@AfterTokenBreak\FV at RescanToken}
@@ -5185,35 +5602,32 @@
 \def\FV at Break@AfterTokenBreak#1{%
   \let\FV at LastToken=#1%
   \@ifnextchar\FV at FVSpaceToken%
-   {\g at addto@macro{\FV at TmpLine}{#1}\FV at Break@Scan}%
-   {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
+   {\FV at BreakBuffer@Append{#1}\FV at Break@Scan}%
+   {\ifbool{FV at breakafterinrun}%
+     {\FV at BreakBuffer@Append{#1\FancyVerbBreakAfterBreak}%
+      \let\FV at Break@Next\FV at Break@Scan}%
      {\ifx\@let at token#1\relax
-        \g at addto@macro{\FV at TmpLine}{#1}%
+        \FV at BreakBuffer@Append{#1}%
         \let\FV at Break@Next\FV at Break@Scan
       \else
-        \ifx\@let at token\bgroup\relax
-          \g at addto@macro{\FV at TmpLine}{#1}%
+        \expandafter\ifx\csname @let at token\endcsname\bgroup\relax
+          \FV at BreakBuffer@Append{#1}%
           \let\FV at Break@Next\FV at Break@AfterTokenBreak at Group
         \else
-          \g at addto@macro{\FV at TmpLine}{#1\FancyVerbBreakAfterBreak}%
+          \FV at BreakBuffer@Append{#1\FancyVerbBreakAfterBreak}%
           \let\FV at Break@Next\FV at Break@Scan
         \fi
       \fi}%
-     {\g at addto@macro{\FV at TmpLine}{#1\FancyVerbBreakAfterBreak}%
-      \let\FV at Break@Next\FV at Break@Scan}%
     \FV at Break@Next}%
 }
 \def\FV at Break@AfterTokenBreak at Group#1{%
-  \g at addto@macro{\FV at TmpLine}{{#1}}%
   \ifstrempty{#1}%
-   {\let\FV at Break@Next\FV at Break@AfterTokenBreak at Group@i}%
-   {\let\FV at Break@Next\FV at Break@Scan\let\FV at LastToken=\FV at Undefined}%
-  \FV at Break@Next}
-\def\FV at Break@AfterTokenBreak at Group@i{%
-  \@ifnextchar\FV at LastToken%
-   {\FV at Break@Scan}%
-   {\g at addto@macro{\FV at TmpLine}{\FancyVerbBreakAfterBreak}%
-    \FV at Break@Scan}}
+   {\FV at BreakBuffer@Append{{}}%
+    \@ifnextchar\FV at LastToken%
+     {\FV at Break@Scan}%
+     {\FV at BreakBuffer@Append{\FancyVerbBreakAfterBreak}%
+      \FV at Break@Scan}}%
+   {\FV at Break@Group{#1}}}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -5289,16 +5703,16 @@
       \expandafter\FV at BreakAfter@Process at ii\expandafter{##1}}%
     \def\FV at BreakAfter@Process at ii##1{%
       \ifcsname FV at BreakBefore@Token\detokenize{##1}\endcsname
-        \ifthenelse{\boolean{FV at BreakBeforeGroup}}%
-         {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
+        \ifbool{FV at breakbeforeinrun}%
+         {\ifbool{FV at breakafterinrun}%
            {}%
            {\PackageError{fvextra}%
-            {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}%
-            {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}}%
-         {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
+            {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}%
+            {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}}}%
+         {\ifbool{FV at breakafterinrun}%
            {\PackageError{fvextra}%
-             {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}%
-             {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}%
+             {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}%
+             {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}}%
            {}}%
       \fi
       \g at addto@macro\FV at BreakAfter@Def{%
@@ -5318,7 +5732,7 @@
 %
 %
 % \begin{macro}{\FV at Break@AnyToken at UTF}
-% Instead of just adding each token to |\FV at TmpLine| with a preceding break, also check for multi-byte code points and capture the remaining bytes when they are encountered.
+% Instead of just adding each token to |\FV at BreakBuffer| with a preceding break, also check for multi-byte code points and capture the remaining bytes when they are encountered.
 %    \begin{macrocode}
 \def\FV at Break@AnyToken at UTF#1{%
   \ifcsname FV at U8:\detokenize{#1}\endcsname
@@ -5330,7 +5744,7 @@
   \FV at Break@Next{#1}%
 }
 \def\FV at Break@AnyToken at UTF@i#1{%
-  \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakAnywhereBreak#1}%
+  \FV at BreakBuffer@Append{\FancyVerbBreakAnywhereBreak#1}%
   \FV at Break@Scan}
 %    \end{macrocode}
 % \end{macro}
@@ -5362,41 +5776,41 @@
   \FV at Break@Next{#1}%
 }
 \def\FV at Break@BeforeAfterTokenNoBreak at UTF#1{%
-  \g at addto@macro{\FV at TmpLine}{#1}%
+  \FV at BreakBuffer@Append{#1}%
   \def\FV at LastToken{#1}%
   \FV at Break@Scan}
 \def\FV at Break@BeforeTokenBreak at UTF#1{%
   \def\FV at CurrentToken{#1}%
-  \ifthenelse{\boolean{FV at BreakBeforeGroup}}%
+  \ifbool{FV at breakbeforeinrun}%
+   {\ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
+      \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak}%
+      \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan@UTF
+      \def\FV at RescanToken{#1}%
+    \else
+      \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak#1}%
+      \let\FV at Break@Next\FV at Break@Scan
+      \def\FV at LastToken{#1}%
+    \fi}%
    {\ifx\FV at CurrentToken\FV at LastToken\relax
       \ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
         \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan@UTF
         \def\FV at RescanToken{#1}%
       \else
-        \g at addto@macro{\FV at TmpLine}{#1}%
+        \FV at BreakBuffer@Append{#1}%
         \let\FV at Break@Next\FV at Break@Scan
         \def\FV at LastToken{#1}%
       \fi
     \else
       \ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
-        \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak}%
+        \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak}%
         \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan@UTF
         \def\FV at RescanToken{#1}%
       \else
-        \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak#1}%
+        \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak#1}%
         \let\FV at Break@Next\FV at Break@Scan
         \def\FV at LastToken{#1}%
       \fi
     \fi}%
-   {\ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
-      \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak}%
-      \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan@UTF
-      \def\FV at RescanToken{#1}%
-    \else
-      \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak#1}%
-      \let\FV at Break@Next\FV at Break@Scan
-      \def\FV at LastToken{#1}%
-    \fi}%
   \FV at Break@Next}
 \def\FV at Break@BeforeTokenBreak at AfterRescan@UTF{%
   \expandafter\FV at Break@AfterTokenBreak at UTF\expandafter{\FV at RescanToken}}
@@ -5403,16 +5817,16 @@
 \def\FV at Break@AfterTokenBreak at UTF#1{%
   \def\FV at LastToken{#1}%
   \@ifnextchar\FV at FVSpaceToken%
-   {\g at addto@macro{\FV at TmpLine}{#1}\FV at Break@Scan}%
-   {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
-     {\g at addto@macro{\FV at TmpLine}{#1}%
+   {\FV at BreakBuffer@Append{#1}\FV at Break@Scan}%
+   {\ifbool{FV at breakafterinrun}%
+     {\FV at BreakBuffer@Append{#1\FancyVerbBreakAfterBreak}%
+      \let\FV at Break@Next\FV at Break@Scan}%
+     {\FV at BreakBuffer@Append{#1}%
       \ifx\@let at token\bgroup\relax
         \let\FV at Break@Next\FV at Break@AfterTokenBreak at Group@UTF
       \else
         \let\FV at Break@Next\FV at Break@AfterTokenBreak at UTF@i
       \fi}%
-     {\g at addto@macro{\FV at TmpLine}{#1\FancyVerbBreakAfterBreak}%
-      \let\FV at Break@Next\FV at Break@Scan}%
     \FV at Break@Next}%
 }
 \def\FV at Break@AfterTokenBreak at UTF@i#1{%
@@ -5423,30 +5837,27 @@
     \def\FV at NextToken{#1}%
     \ifx\FV at LastToken\FV at NextToken
     \else
-      \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakAfterBreak}%
+      \FV at BreakBuffer@Append{\FancyVerbBreakAfterBreak}%
     \fi
     \let\FV at Break@Next\FV at Break@Scan
   \fi
   \FV at Break@Next#1}
 \def\FV at Break@AfterTokenBreak at Group@UTF#1{%
-  \g at addto@macro{\FV at TmpLine}{{#1}}%
   \ifstrempty{#1}%
-   {\let\FV at Break@Next\FV at Break@AfterTokenBreak at Group@UTF at i}%
-   {\let\FV at Break@Next\FV at Break@Scan\let\FV at LastToken=\FV at Undefined}%
-  \FV at Break@Next}
-\def\FV at Break@AfterTokenBreak at Group@UTF at i{%
-  \@ifnextchar\bgroup%
-   {\FV at Break@Scan}%
-   {\FV at Break@AfterTokenBreak at Group@UTF at ii}}
-\def\FV at Break@AfterTokenBreak at Group@UTF at ii#1{%
+   {\FV at BreakBuffer@Append{{}}%
+    \@ifnextchar\bgroup
+     {\FV at Break@Group}%
+     {\FV at Break@AfterTokenBreak at Group@UTF at i}}%
+   {\FV at Break@Group{#1}}}
+\def\FV at Break@AfterTokenBreak at Group@UTF at i#1{%
   \ifcsname FV at U8:\detokenize{#1}\endcsname
     \expandafter\let\expandafter\FV at Break@Next\csname FV at U8:\detokenize{#1}\endcsname
-    \let\FV at UTF@octets at after\FV at Break@AfterTokenBreak at Group@UTF at ii
+    \let\FV at UTF@octets at after\FV at Break@AfterTokenBreak at Group@UTF at i
   \else
     \def\FV at NextToken{#1}%
     \ifx\FV at LastToken\FV at NextToken
     \else
-      \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakAfterBreak}%
+      \FV at BreakBuffer@Append{\FancyVerbBreakAfterBreak}%
     \fi
     \let\FV at Break@Next\FV at Break@Scan
   \fi
@@ -5508,9 +5919,9 @@
   \savebox{\FV at LineBox}{%
     \advance\FV at LineWidth by -\FV at BreakIndent
     \hbox to \FV at BreakIndent{\hfill}%
-    \ifthenelse{\boolean{FV at BreakAutoIndent}}%
+    \ifbool{FV at breakautoindent}%
      {\let\FV at LineIndentChars\@empty
-      \FV at GetLineIndent#1\FV at Undefined
+      \FV at GetLineIndent#1\FV at Sentinel
       \savebox{\FV at LineIndentBox}{\FV at LineIndentChars}%
       \hbox to \wd\FV at LineIndentBox{\hfill}%
       \advance\FV at LineWidth by -\wd\FV at LineIndentBox
@@ -5529,12 +5940,11 @@
       \noindent\hspace*{-\FV at BreakIndent}%
       \ifdefempty{\FancyVerbBreakSymbolLeft}{}{%
         \hspace*{-\FV at BreakSymbolIndentLeft}}%
-      \ifthenelse{\boolean{FV at BreakAutoIndent}}%
+      \ifbool{FV at breakautoindent}%
        {\hspace*{-\wd\FV at LineIndentBox}}%
        {}%
       \FV at BreakByTokenAnywhereHook
-      \strut\FancyVerbFormatText{%
-        \FancyVerbBreakStart #1\FancyVerbBreakStop}\nobreak\strut
+      \strut\FV at InsertBreaks{\FancyVerbFormatText}{#1}\nobreak\strut
       \end{internallinenumbers*}
     }%
     \ifdefempty{\FancyVerbBreakSymbolRight}{}%
@@ -5569,6 +5979,8 @@
     \setcounter{FV at TrueTabCounter}{0}%
   \fi
   \sbox{\FV at LineBox}{%
+    \let\FancyVerbBreakStart\relax
+    \let\FancyVerbBreakStop\relax
     \FancyVerbFormatLine{%
       %\FancyVerbHighlightLine  %<-- Default definition using \rlap breaks breaking
        {\FV at ObeyTabs{\FancyVerbFormatText{#1}}}}}%
@@ -5596,6 +6008,8 @@
       \let\FV at Tab\FV at TrueTab
     \fi
   \else
+    \let\FancyVerbBreakStart\relax
+    \let\FancyVerbBreakStop\relax
     \FV at LeftListNumber
     \FV at LeftListFrame
     \FancyVerbFormatLine{%
@@ -5790,6 +6204,8 @@
 % In the |breakbytoken| cases, an |\hbox| is used to prevent breaks within the macro (breaks could occur at spaces even without |\FancyVerbBreakStart|).  The |breakbytokenanywhere| case is similar but a little tricky.  |\FV at BreakByTokenAnywhereHook|, which is inside |\FV at SaveLineBox| where line breaking occurs, is used to define |\FV at BreakByTokenAnywhereBreak| so that it will ``do nothing'' the first time it is used and on subsequent invocations become |\FancyVerbBreakByTokenAnywhereBreak|.  Because the hook is within the |internallinenumbers*| environment, the redefinition doesn't escape, and the default global definition of |\FV at BreakByTokenAnywhereBreak| as |\relax| is not affected.  We don't want the actual break to appear before the first Pygments macro in case it might cause a spurious break after leading whitespace.  But we must have breaks \emph{before} Pygments macros because otherwise lookahead would be necessary.
 %
 % An intermediate variable |\FV at PYG| is defined to avoid problems in case |#1|$=$|#2|.  There is also a check for a non-existant |#2| (|\PYG|\meta{style\_name} may not be created until a later compile in the \pkg{pythontex} case); if |#2| does not exist, fall back to |#1|.  For the existance check, |\ifx...\relax| must be used instead of |\ifcsname|, because |#2| will be a macro, and will typically be created with |\csname...\endcsname| which will |\let| the macro to |\relax| if it doesn't already exist.
+%
+% |\FV at PYG@Redefed| is |\let| to the Pygments macro that appears literally (after redefinition), so that it can be detected elsewhere to allow for special processing, such as in |breakautoindent|.
 %    \begin{macrocode}
 \def\FV at VerbatimPygments#1#2{%
   \edef\FV at PYG@Literal{\expandafter\FV at DetokMacro@StripSpace\detokenize{#1}}%
@@ -5798,9 +6214,9 @@
   \def\FV at BreakAfterPrep@PygmentsHook{%
     \expandafter\FV at BreakAfterPrep@Pygments\expandafter{\FV at PYG@Literal}}%
   \ifx#2\relax
-    \let\FV at PYG#1%
+    \let\FV at PYG=#1\relax
   \else
-    \let\FV at PYG#2%
+    \let\FV at PYG=#2\relax
   \fi
   \ifbool{FV at breakbytoken}%
    {\ifbool{FV at breakbytokenanywhere}%
@@ -5814,6 +6230,7 @@
         \leavevmode\hbox{\FV at PYG{##1}{##2}}}}}%
    {\def#1##1##2{%
      \FV at PYG{##1}{\FancyVerbBreakStart##2\FancyVerbBreakStop}}}%
+  \let\FV at PYG@Redefed=#1\relax
 }
 \let\FV at BreakByTokenAnywhereBreak\relax
 \def\FV at DetokMacro@StripSpace#1 {#1}

Modified: trunk/Master/texmf-dist/source/latex/fvextra/fvextra.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/fvextra/fvextra.ins	2022-12-01 10:50:03 UTC (rev 65157)
+++ trunk/Master/texmf-dist/source/latex/fvextra/fvextra.ins	2022-12-01 20:34:06 UTC (rev 65158)
@@ -1,4 +1,4 @@
-%% Copyright (C) 2016-2017 by Geoffrey M. Poore <gpoore at gmail.com>
+%% Copyright (C) 2016-2022 by Geoffrey M. Poore <gpoore at gmail.com>
 %% --------------------------------------------------------------------------
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -18,6 +18,7 @@
 
 \input docstrip.tex
 \keepsilent
+\askforoverwritefalse
 
 \usedir{tex/latex/fvextra}
 
@@ -25,7 +26,7 @@
 
 This is a generated file.
 
-Copyright (C) 2016-2017 by Geoffrey M. Poore <gpoore at gmail.com>
+Copyright (C) 2016-2022 by Geoffrey M. Poore <gpoore at gmail.com>
 --------------------------------------------------------------------------
 This work may be distributed and/or modified under the
 conditions of the LaTeX Project Public License, either version 1.3

Modified: trunk/Master/texmf-dist/tex/latex/fvextra/fvextra.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/fvextra/fvextra.sty	2022-12-01 10:50:03 UTC (rev 65157)
+++ trunk/Master/texmf-dist/tex/latex/fvextra/fvextra.sty	2022-12-01 20:34:06 UTC (rev 65158)
@@ -8,7 +8,7 @@
 %% 
 %% This is a generated file.
 %% 
-%% Copyright (C) 2016-2017 by Geoffrey M. Poore <gpoore at gmail.com>
+%% Copyright (C) 2016-2022 by Geoffrey M. Poore <gpoore at gmail.com>
 %% --------------------------------------------------------------------------
 %% This work may be distributed and/or modified under the
 %% conditions of the LaTeX Project Public License, either version 1.3
@@ -20,8 +20,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{fvextra}
-    [2019/02/04 v1.4 fvextra - extensions and patches for fancyvrb]
-\RequirePackage{ifthen}
+    [2022/11/30 v1.5 fvextra - extensions and patches for fancyvrb]
 \RequirePackage{etoolbox}
 \RequirePackage{fancyvrb}
 \RequirePackage{upquote}
@@ -127,6 +126,18 @@
   \fi
   \FV at UTF@octets at after{#1#2#3#4}}
 \fi
+\long\def\FVExtra at ifnextcharAny#1#2#3{%
+  \let\reserved at d= #1%
+  \def\reserved at a{#2}%
+  \def\reserved at b{#3}%
+  \futurelet\@let at token\FVExtra at ifnchAny}
+\def\FVExtra at ifnchAny{%
+  \ifx\@let at token\reserved at d
+    \expandafter\reserved at a
+  \else
+    \expandafter\reserved at b
+  \fi}
+
 \long\def\FVExtra at ifnextcharVArg#1#2#3{%
   \begingroup
   \edef\FV at TmpSpaceCat{\the\catcode` }%
@@ -148,8 +159,26 @@
   \begingroup
   \catcode`\^^M=\active
   \@ifnextchar[%
-   {\endgroup\FV at ReadOArgContinue{#2}}%
-   {\endgroup\FV at ReadOArgContinue{#2}[#1]}}
+   {\endgroup\FVExtraReadOArgBeforeVEnv at i{#2}}%
+   {\endgroup\FVExtraReadOArgBeforeVEnv at i{#2}[#1]}}
+\def\FVExtraReadOArgBeforeVEnv at i#1[#2]{%
+  \begingroup
+  \catcode`\^^M=\active
+  \FVExtraReadOArgBeforeVEnv at ii{#1}{#2}}
+\begingroup
+\catcode`\^^M=\active%
+\gdef\FVExtraReadOArgBeforeVEnv at ii#1#2#3^^M{%
+  \endgroup%
+  \FVExtraReadOArgBeforeVEnv at iii{#1}{#2}{#3}}%
+\endgroup%
+\def\FVExtraReadOArgBeforeVEnv at iii#1#2#3{%
+  \if\relax\detokenize{#3}\relax
+  \else
+    \PackageError{fvextra}%
+     {Discarded invalid text while checking for optional argument of verbatim environment}%
+     {Discarded invalid text while checking for optional argument of verbatim environment}%
+  \fi
+  #1{#2}}
 \def\FVExtraReadVArg#1{%
   \begingroup
   \ifFV at pdfTeXinputenc
@@ -290,6 +319,15 @@
   \def\FV at UnexpandedReadStarOArgBEscVArg@i#1#2{%
     \FVExtraPDFStringEscapedVerbatimDetokenize{#2}}%
   \makeatother}
+\def\FVExtraUnexpandedReadStarOArgMArgBVArg#1#{%
+  \FV at UnexpandedReadStarOArgMArgBVArg@i{#1}}
+\def\FV at UnexpandedReadStarOArgMArgBVArg@i#1#2#3{%
+  \FVExtraAlwaysUnexpanded{\FVExtraUnexpandedReadStarOArgMArgBVArg#1{#2}{#3}}}
+\FVExtrapdfstringdefDisableCommands{%
+  \makeatletter
+  \def\FV at UnexpandedReadStarOArgMArgBVArg@i#1#2#3{%
+    \FVExtraPDFStringVerbatimDetokenize{#3}}%
+  \makeatother}
 \def\FVExtraPDFStringEscapeChar#1{%
   \ifcsname FV at PDFStringEscapeChar@#1\endcsname
     \csname FV at PDFStringEscapeChar@#1\endcsname
@@ -888,9 +926,11 @@
 \edef\FV at dollarchar{\string$}
 \edef\FV at ampchar{\string&}
 \edef\FV at underscorechar{\string_}
+\edef\FV at caretchar{\string^}
 \edef\FV at tildechar{\string~}
 \edef\FV at leftsquarebracket{\string[}
 \edef\FV at rightsquarebracket{\string]}
+\edef\FV at commachar{\string,}
 \newcommand{\FV at EscChars}{%
   \let\#\FV at hashchar
   \let\%\@percentchar
@@ -899,11 +939,13 @@
   \let\$\FV at dollarchar
   \let\&\FV at ampchar
   \let\_\FV at underscorechar
+  \let\^\FV at caretchar
   \let\\\@backslashchar
   \let~\FV at tildechar
   \let\~\FV at tildechar
   \let\[\FV at leftsquarebracket
   \let\]\FV at rightsquarebracket
+  \let\,\FV at commachar
 } %$ <- highlighting
 \def\FV at InlineKeyValues{}
 \def\fvinlineset#1{%
@@ -917,6 +959,7 @@
  {\booltrue{FV at extra}}%
  {\boolfalse{FV at extra}}
 \fvset{extra=true}
+\def\FancyVerbFormatInline#1{#1}
 \def\Verb{%
   \FVExtraRobustCommand\RobustVerb\FVExtraUnexpandedReadStarOArgBVArg}
 \protected\def\RobustVerb{\FV at Command{}{Verb}}
@@ -946,12 +989,12 @@
     \FVExtraDetokenizeVArg{%
       \FVExtraRetokenizeVArg{\FVC at Verb@Extra at ii}{\FV at CatCodes}}}}
 \def\FVC at Verb@Extra at ii#1{%
-  \ifFV at BreakLines
+  \ifFV at breaklines
     \expandafter\@firstoftwo
   \else
     \expandafter\@secondoftwo
   \fi
-  {\FancyVerbBreakStart#1\FancyVerbBreakStop}%
+  {\FV at InsertBreaks{\FancyVerbFormatInline}{#1}}%
   {\mbox{#1}}%
   \endgroup}
 \let\FVC at SaveVerb@FV\FVC at SaveVerb
@@ -1010,12 +1053,12 @@
   \FVExtraDetokenizeVArg{%
     \FVExtraRetokenizeVArg{\FV at UseVerb@Extra}{\FV at CatCodes}}{#1}}
 \def\FV at UseVerb@Extra#1{%
-  \ifFV at BreakLines
+  \ifFV at breaklines
     \expandafter\@firstoftwo
   \else
     \expandafter\@secondoftwo
   \fi
-  {\FancyVerbBreakStart#1\FancyVerbBreakStop}%
+  {\FV at InsertBreaks{\FancyVerbFormatInline}{#1}}%
   {\mbox{#1}}%
   \endgroup}
 \def\EscVerb{%
@@ -1035,14 +1078,111 @@
   \FVExtraDetokenizeREscVArg{%
     \FVExtraRetokenizeVArg{\FVC at EscVerb@ii}{\FV at CatCodes}}{#1}}
 \def\FVC at EscVerb@ii#1{%
-  \ifFV at BreakLines
+  \ifFV at breaklines
     \expandafter\@firstoftwo
   \else
     \expandafter\@secondoftwo
   \fi
-  {\FancyVerbBreakStart#1\FancyVerbBreakStop}%
+  {\FV at InsertBreaks{\FancyVerbFormatInline}{#1}}%
   {\mbox{#1}}%
   \endgroup}
+\def\VerbEnv{%
+  \ifcsname @currenvir\endcsname
+    \ifx\@currenvir\@empty
+      \PackageError{fvextra}{VerbEnv is an environment}{VerbEnv is an environment}%
+    \else
+      \ifx\@currenvir\relax
+        \PackageError{fvextra}{VerbEnv is an environment}{VerbEnv is an environment}%
+      \fi
+    \fi
+  \else
+    \PackageError{fvextra}{VerbEnv is an environment}{VerbEnv is an environment}%
+  \fi
+  \VerbatimEnvironment
+  \FVExtraReadOArgBeforeVEnv{\expandafter\VerbEnv at i\expandafter{\FV at EnvironName}}}
+\def\VerbEnv at i#1#2{%
+  \begingroup
+  \let\do\@makeother\FVExtraDoSpecials
+  \catcode`\ =\active
+  \catcode`\^^I=\active
+  \catcode`\^^M=\active
+  \VerbEnv at ii{#1}{#2}}
+\begingroup
+\catcode`\!=0
+\catcode`\<=1
+\catcode`\>=2
+!catcode`!\=12
+!catcode`!{=12
+!catcode`!}=12
+!catcode`!^^M=!active%
+!gdef!VerbEnv at ii#1#2#3^^M<%
+  !endgroup%
+  !def!VerbEnv at CheckLine##1\end{#1}##2!FV at Sentinel<%
+    !if!relax!detokenize<##2>!relax%
+    !else%
+      !PackageError<fvextra><Missing environment contents><Missing environment contents>%
+      !let!VerbEnv at iii!VerbEnv at iii@Error%
+    !fi>%
+  !VerbEnv at CheckLine#3\end{#1}!FV at Sentinel%
+  !VerbEnv at iii<#1><#2><#3>>%
+!endgroup%
+\def\VerbEnv at iii@Error#1#2#3{}
+\def\VerbEnv at iii#1#2#3{%
+  \begingroup
+  \let\do\@makeother\FVExtraDoSpecials
+  \catcode`\ =10\relax
+  \catcode`\^^M=\active
+  \VerbEnv at iv{#1}{#2}{#3}}
+\begingroup
+\catcode`\!=0
+\catcode`\<=1
+\catcode`\>=2
+!catcode`!\=12
+!catcode`!{=12
+!catcode`!}=12
+!catcode`!^^M=!active%
+!gdef!VerbEnv at iv#1#2#3#4^^M<%
+  !endgroup%
+  !def!VerbEnv at CheckEndDelim##1\end{#1}##2!FV at Sentinel<%
+    !if!relax!detokenize<##2>!relax%
+      !PackageError<fvextra><Missing end for environment !FV at EnvironName><Add environment end>%
+      !let!VerbEnv at v!VerbEnv at v@Error%
+    !else%
+      !VerbEnv at CheckEndLeading##1!FV at Sentinel%
+      !VerbEnv at CheckEndTrailing##2!FV at Sentinel%
+    !fi>%
+  !def!VerbEnv at CheckEndTrailing##1\end{#1}!FV at Sentinel<%
+    !if!relax!detokenize<##1>!relax%
+    !else%
+      !PackageError<fvextra>%
+       <Discarded text after end of environment !FV at EnvironName>%
+       <Discarded text after end of environment !FV at EnvironName>%
+      !let!VerbEnv at v!VerbEnv at v@Error%
+    !fi>%
+  !VerbEnv at CheckEndDelim#4\end{#1}!FV at Sentinel%
+  !VerbEnv at v<#2><#3>>%
+!endgroup
+\def\VerbEnv at CheckEndLeading{%
+  \FVExtra at ifnextcharAny\@sptoken%
+   {\VerbEnv at CheckEndLeading@Continue}%
+   {\ifx\@let at token\FV at Sentinel
+      \expandafter\VerbEnv at CheckEndLeading@End
+    \else
+      \expandafter\VerbEnv at CheckEndLeading@EndError
+    \fi}}
+\def\VerbEnv at CheckEndLeading@Continue#1{%
+  \VerbEnv at CheckEndLeading}
+\def\VerbEnv at CheckEndLeading@End#1\FV at Sentinel{}
+\def\VerbEnv at CheckEndLeading@EndError{%
+  \PackageError{fvextra}%
+   {Discarded text before end of environment \FV at EnvironName}%
+   {Discarded text before end of environment \FV at EnvironName}%
+  \let\VerbEnv at v\VerbEnv at v@Error}
+\def\VerbEnv at v@Error#1#2{}
+\def\VerbEnv at v#1#2{%
+  \Verb[#1]{#2}%
+  \expandafter\end\expandafter{\FV at EnvironName}}
+\def\endVerbEnv{\global\let\FV at EnvironName\relax}
 \def\FV at Command#1#2{%
   \FVExtra at ifstarVArg
    {\def\FV at KeyValues{#1,showspaces}\FV@@Command{#2}}%
@@ -1103,7 +1243,7 @@
   \FV at TrueTabSaveWidth
   \setbox\FV at TabBox=\hbox\bgroup
     \unhbox\FV at TabBox\hbox to\@tempdima{\hss\FV at TabChar}}
-\newboolean{FV at ObeyTabs@Whitespace at Tab}
+\newbool{FV at ObeyTabs@Whitespace at Tab}
 \def\FV at TrueTab@Group{%
   \booltrue{FV at ObeyTabs@Whitespace at Tab}%
   \gdef\FV at TmpWhitespace{\FV at FVTabToken}%
@@ -1587,16 +1727,25 @@
     #1=0pt\relax
   \fi
 }
-\newboolean{FV at BreakLines}
+\newbool{FV at breaklines}
 \define at booleankey{FV}{breaklines}%
-  {\FV at BreakLinestrue
-    \let\FV at ListProcessLine\FV at ListProcessLine@Break}%
-  {\FV at BreakLinesfalse
-    \let\FV at ListProcessLine\FV at ListProcessLine@NoBreak}
+ {\booltrue{FV at breaklines}%
+  \let\FV at ListProcessLine\FV at ListProcessLine@Break}%
+ {\boolfalse{FV at breaklines}%
+  \let\FV at ListProcessLine\FV at ListProcessLine@NoBreak}
 \AtEndOfPackage{\fvset{breaklines=false}}
+\def\FV at BreakLinesLuaTeXHook{%
+   \expandafter\def\expandafter\@noligs\expandafter{\@noligs
+     \begingroup\lccode`\~=`\-\lowercase{\endgroup\def~}{\leavevmode\kern\z@\mbox{-}}}}
+\ifcsname directlua\endcsname
+  \ifx\directlua\relax
+  \else
+    \FV at AddToHook\FV at FormattingPrep@PreHook\FV at BreakLinesLuaTeXHook
+  \fi
+\fi
 \def\FV at BreakLinesIndentationHook{}
 \g at addto@macro\FV at FormattingPrep@PostHook{%
-  \ifFV at BreakLines
+  \ifFV at breaklines
     \FV at BreakLinesIndentationHook
   \fi}
 \newdimen\FV at BreakIndent
@@ -1610,9 +1759,9 @@
     \FV at SetToWidthNChars{\FV at BreakIndent}{\FV at BreakIndentNChars}%
   \fi}
 \fvset{breakindentnchars=0}
-\newboolean{FV at BreakAutoIndent}
+\newbool{FV at breakautoindent}
 \define at booleankey{FV}{breakautoindent}%
-  {\FV at BreakAutoIndenttrue}{\FV at BreakAutoIndentfalse}
+  {\booltrue{FV at breakautoindent}}{\boolfalse{FV at breakautoindent}}
 \fvset{breakautoindent=true}
 \define at key{FV}{breaksymbolleft}{\def\FancyVerbBreakSymbolLeft{#1}}
 \define at key{FV}{breaksymbol}{\fvset{breaksymbolleft=#1}}
@@ -1676,33 +1825,35 @@
   \ifnum\value{linenumber}=\value{FancyVerbLineBreakLast}\relax\else{#1}\fi}
 \let\FancyVerbBreakStart\relax
 \let\FancyVerbBreakStop\relax
-\let\FV at Break@Token\relax
-\newboolean{FV at BreakAnywhere}
+\let\FV at Break@DefaultToken\FV at Break@NBToken
+\newbool{FV at breakanywhere}
 \define at booleankey{FV}{breakanywhere}%
-  {\FV at BreakAnywheretrue
+  {\booltrue{FV at breakanywhere}%
     \let\FancyVerbBreakStart\FV at Break
     \let\FancyVerbBreakStop\FV at EndBreak
-    \let\FV at Break@Token\FV at Break@AnyToken}%
-  {\FV at BreakAnywherefalse
+    \let\FV at Break@DefaultToken\FV at Break@AnyToken}%
+  {\boolfalse{FV at breakanywhere}%
     \let\FancyVerbBreakStart\relax
-    \let\FancyVerbBreakStop\relax}
+    \let\FancyVerbBreakStop\relax
+    \let\FV at Break@DefaultToken\FV at Break@NBToken}
 \fvset{breakanywhere=false}
 \define at key{FV}{breakbefore}{%
   \ifstrempty{#1}%
    {\let\FV at BreakBefore\@empty
     \let\FancyVerbBreakStart\relax
-    \let\FancyVerbBreakStop\relax}%
+    \let\FancyVerbBreakStop\relax
+    \let\FV at Break@DefaultToken\FV at Break@NBToken}%
    {\def\FV at BreakBefore{#1}%
     \let\FancyVerbBreakStart\FV at Break
     \let\FancyVerbBreakStop\FV at EndBreak
-    \let\FV at Break@Token\FV at Break@BeforeAfterToken}%
+    \let\FV at Break@DefaultToken\FV at Break@BeforeAfterToken}%
 }
 \fvset{breakbefore={}}
-\newboolean{FV at BreakBeforeGroup}
-\define at booleankey{FV}{breakbeforegroup}%
- {\FV at BreakBeforeGrouptrue}%
- {\FV at BreakBeforeGroupfalse}%
-\fvset{breakbeforegroup=true}
+\newbool{FV at breakbeforeinrun}
+\define at booleankey{FV}{breakbeforeinrun}%
+ {\booltrue{FV at breakbeforeinrun}}%
+ {\boolfalse{FV at breakbeforeinrun}}%
+\fvset{breakbeforeinrun=false}
 \def\FV at BreakBeforePrep{%
   \ifx\FV at BreakBefore\@empty\relax
   \else
@@ -1731,18 +1882,19 @@
   \ifstrempty{#1}%
    {\let\FV at BreakAfter\@empty
     \let\FancyVerbBreakStart\relax
-    \let\FancyVerbBreakStop\relax}%
+    \let\FancyVerbBreakStop\relax
+    \let\FV at Break@DefaultToken\FV at Break@NBToken}%
    {\def\FV at BreakAfter{#1}%
     \let\FancyVerbBreakStart\FV at Break
     \let\FancyVerbBreakStop\FV at EndBreak
-    \let\FV at Break@Token\FV at Break@BeforeAfterToken}%
+    \let\FV at Break@DefaultToken\FV at Break@BeforeAfterToken}%
 }
 \fvset{breakafter={}}
-\newboolean{FV at BreakAfterGroup}
-\define at booleankey{FV}{breakaftergroup}%
- {\FV at BreakAfterGrouptrue}%
- {\FV at BreakAfterGroupfalse}%
-\fvset{breakaftergroup=true}
+\newbool{FV at breakafterinrun}
+\define at booleankey{FV}{breakafterinrun}%
+ {\booltrue{FV at breakafterinrun}}%
+ {\boolfalse{FV at breakafterinrun}}%
+\fvset{breakafterinrun=false}
 \def\FV at BreakAfterPrep{%
   \ifx\FV at BreakAfter\@empty\relax
   \else
@@ -1757,16 +1909,16 @@
     }%
     \def\FV at BreakAfter@Process at i##1{%
       \ifcsname FV at BreakBefore@Token\detokenize{##1}\endcsname
-        \ifthenelse{\boolean{FV at BreakBeforeGroup}}%
-         {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
+        \ifbool{FV at breakbeforeinrun}%
+         {\ifbool{FV at breakafterinrun}%
            {}%
            {\PackageError{fvextra}%
-            {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}%
-            {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}}%
-         {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
+            {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}%
+            {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}}}%
+         {\ifbool{FV at breakafterinrun}%
            {\PackageError{fvextra}%
-             {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}%
-             {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}%
+             {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}%
+             {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}}%
            {}}%
       \fi
       \g at addto@macro\FV at BreakAfter@Def{%
@@ -1827,80 +1979,163 @@
 \newcommand{\FancyVerbBreakAfterBreak}{%
   \discretionary{\FancyVerbBreakAfterSymbolPre}%
    {\FancyVerbBreakAfterSymbolPost}{}}
+\newbool{FV at breaknonspaceingroup}
+\define at booleankey{FV}{breaknonspaceingroup}%
+ {\booltrue{FV at breaknonspaceingroup}}%
+ {\boolfalse{FV at breaknonspaceingroup}}
+\fvset{breaknonspaceingroup=false}
 \newsavebox{\FV at LineBox}
 \newsavebox{\FV at LineIndentBox}
 \let\FV at LineIndentChars\@empty
-\def\FV at CleanRemainingChars#1\FV at Undefined{}
-\def\FV at GetLineIndent{\afterassignment\FV at CheckIndentChar\let\FV at NextChar=}
-\def\FV at CheckIndentChar{%
-  \ifx\FV at NextChar\FV at Undefined\relax
-    \let\FV at Next=\relax
-  \else
-    \ifx\FV at NextChar\FV at FVSpaceToken\relax
-      \g at addto@macro{\FV at LineIndentChars}{\FV at FVSpaceToken}%
-      \let\FV at Next=\FV at GetLineIndent
-    \else
-      \ifx\FV at NextChar\FV at FVTabToken\relax
-        \g at addto@macro{\FV at LineIndentChars}{\FV at FVTabToken}%
-        \let\FV at Next=\FV at GetLineIndent
+\def\FV at GetLineIndent{%
+  \@ifnextchar\FV at Sentinel
+   {\FV at GetLineIndent@End}%
+   {\ifx\@let at token\FV at FVSpaceToken
+      \let\FV at Next\FV at GetLineIndent@Whitespace
+    \else\ifx\@let at token\FV at FVTabToken
+      \let\FV at Next\FV at GetLineIndent@Whitespace
+    \else\ifcsname FV at PYG@Redefed\endcsname
+      \ifx\@let at token\FV at PYG@Redefed
+        \let\FV at Next\FV at GetLineIndent@Pygments
       \else
-        \let\FV at Next=\FV at CleanRemainingChars
+        \let\FV at Next\FV at GetLineIndent@End
       \fi
-    \fi
-  \fi
-  \FV at Next
-}
+    \else
+      \let\FV at Next\FV at GetLineIndent@End
+    \fi\fi\fi
+    \FV at Next}}
+\def\FV at GetLineIndent@End#1\FV at Sentinel{}
+\def\FV at GetLineIndent@Whitespace#1{%
+  \expandafter\def\expandafter\FV at LineIndentChars\expandafter{\FV at LineIndentChars#1}%
+  \FV at GetLineIndent}
+\def\FV at GetLineIndent@Pygments#1#2#3{%
+  \FV at GetLineIndent#3}
 \def\FV at TrueTab@UseWidth{%
   \@tempdima=\csname FV at TrueTab:Width\arabic{FV at TrueTabCounter}\endcsname sp\relax
   \stepcounter{FV at TrueTabCounter}%
   \hbox to\@tempdima{\hss\FV at TabChar}}
-\def\FV at Break{%
-  \def\FV at TmpLine{}%
+\newcounter{FV at BreakBufferDepth}
+\def\FV at BreakBuffer@Append#1{%
+  \expandafter\def\expandafter\FV at BreakBuffer\expandafter{\FV at BreakBuffer#1}}
+\def\FV at BreakBufferStart{%
+  \FV at BreakBufferStart@i}
+\def\FV at BreakBufferStart@i#1{%
+  \ifnum\value{FV at BreakBufferDepth}>0\relax
+    \expandafter\let\csname FV at BreakBuffer\arabic{FV at BreakBufferDepth}\endcsname
+      \FV at BreakBuffer
+    \expandafter\let\csname FV at Break@Token\arabic{FV at BreakBufferDepth}\endcsname
+      \FV at Break@Token
+  \fi
+  \def\FV at BreakBuffer{}%
+  \let\FV at Break@Token=#1%
+  \stepcounter{FV at BreakBufferDepth}%
   \let\FV at LastToken=\FV at Undefined
-  \ifFV at pdfTeXinputenc
-    \ifdefstring{\inputencodingname}{utf8}%
-     {\ifx\FV at Break@Token\FV at Break@AnyToken
-        \let\FV at Break@Token\FV at Break@AnyToken at UTF
-      \else
-         \ifx\FV at Break@Token\FV at Break@BeforeAfterToken
-           \let\FV at Break@Token\FV at Break@BeforeAfterToken at UTF
-         \fi
-      \fi}%
-     {}%
+  \FV at Break@Scan}
+\newbool{FV at UserMacroBreaks}
+\def\FV at BreakBufferStop{%
+  \FV at BreakBufferStop@i}
+\def\FV at BreakBufferStop@i#1{%
+  \addtocounter{FV at BreakBufferDepth}{-1}%
+  \let\FV at LastToken=\FV at Undefined
+  \ifnum\value{FV at BreakBufferDepth}<0\relax
+    \PackageError{fvextra}%
+     {Line break insertion error (extra \string\FancyVerbBreakStop?)}%
+     {Line break insertion error (extra \string\FancyVerbBreakStop?)}%
+    \def\FV at BreakBuffer{}%
   \fi
-  \FV at Break@Scan
-}
-\def\FV at EndBreak{\FV at TmpLine}
+  \ifnum\value{FV at BreakBufferDepth}>0\relax
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+   {\expandafter\FV at BreakBufferStop@ii\expandafter{\FV at BreakBuffer}{#1}}%
+   {\ifbool{FV at UserMacroBreaks}%
+     {\expandafter\let\expandafter\FV at BreakBuffer\expandafter\FV at Undefined\FV at BreakBuffer}%
+     {}}}
+\def\FV at BreakBufferStop@ii#1#2{%
+  \ifstrempty{#2}%
+   {\FV at BreakBufferStop@iii{#1}}%
+   {\expandafter\FV at BreakBufferStop@iii\expandafter{#2{#1}}}}
+\def\FV at BreakBufferStop@iii#1{%
+  \expandafter\let\expandafter\FV at BreakBufferUpLevel
+    \csname FV at BreakBuffer\arabic{FV at BreakBufferDepth}\endcsname
+  \expandafter\def\expandafter\FV at BreakBuffer\expandafter{\FV at BreakBufferUpLevel#1}%
+  \expandafter\let\expandafter\FV at Break@Token
+    \csname FV at Break@Token\arabic{FV at BreakBufferDepth}\endcsname
+  \FV at Break@Scan}
+\def\FV at InsertBreaks#1#2{%
+  \ifx\FancyVerbBreakStart\relax
+    \expandafter\@firstoftwo
+  \else
+    \expandafter\@secondoftwo
+  \fi
+   {#1{#2}}%
+   {\ifFV at pdfTeXinputenc
+      \ifdefstring{\inputencodingname}{utf8}%
+       {\ifx\FV at Break@DefaultToken\FV at Break@AnyToken
+          \let\FV at Break@DefaultToken\FV at Break@AnyToken at UTF
+        \else
+           \ifx\FV at Break@DefaultToken\FV at Break@BeforeAfterToken
+             \let\FV at Break@DefaultToken\FV at Break@BeforeAfterToken at UTF
+           \fi
+        \fi}%
+       {}%
+    \fi
+    \setcounter{FV at BreakBufferDepth}{0}%
+    \boolfalse{FV at UserMacroBreaks}%
+    \FancyVerbBreakStart#2\FancyVerbBreakStop
+    \setcounter{FV at BreakBufferDepth}{0}%
+    \booltrue{FV at UserMacroBreaks}%
+    \expandafter\FV at InsertBreaks@i\expandafter{\FV at BreakBuffer}{#1}}}
+\def\FV at InsertBreaks@i#1#2{%
+  \let\FV at BreakBuffer\FV at Undefined
+  #2{#1}}
+\def\FV at Break{%
+  \FV at BreakBufferStart{\FV at Break@DefaultToken}}
+\def\FV at EndBreak{%
+  \FV at BreakBufferStop{}}
 \begingroup
-\catcode`\$=3%
+\catcode`\$=3
 \gdef\FV at Break@Scan{%
-  \@ifnextchar\FV at EndBreak%
+  \@ifnextchar\FancyVerbBreakStart%
    {}%
-   {\ifx\@let at token$\relax
+   {\ifx\@let at token\FancyVerbBreakStop
+      \let\FV at Break@Next\relax
+    \else\ifx\@let at token\FV at BreakBufferStart
+      \let\FV at Break@Next\relax
+    \else\ifx\@let at token\FV at BreakBufferStop
+      \let\FV at Break@Next\relax
+    \else\ifx\@let at token$
       \let\FV at Break@Next\FV at Break@Math
+    \else\ifx\@let at token\bgroup
+      \let\FV at Break@Next\FV at Break@Group
     \else
-      \ifx\@let at token\bgroup\relax
-        \let\FV at Break@Next\FV at Break@Group
-      \else
-        \let\FV at Break@Next\FV at Break@Token
-      \fi
-    \fi
-    \FV at Break@Next}%
-}
+      \let\FV at Break@Next\FV at Break@Token
+    \fi\fi\fi\fi\fi
+    \FV at Break@Next}}
 \endgroup
 \begingroup
 \catcode`\$=3%
 \gdef\FV at Break@Math$#1${%
-  \g at addto@macro{\FV at TmpLine}{$#1$}%
-  \let\FV at LastToken=\FV at Undefined
-  \FV at Break@Scan}
+  \FV at BreakBufferStart{\FV at Break@NBToken}#1\FV at BreakBufferStop{\FV at Break@MathTemplate}}
+\gdef\FV at Break@MathTemplate#1{$#1$}
 \endgroup
 \def\FV at Break@Group#1{%
-  \g at addto@macro{\FV at TmpLine}{{#1}}%
-  \ifstrempty{#1}{}{\let\FV at LastToken=\FV at Undefined}%
+  \ifstrempty{#1}%
+   {\FV at BreakBuffer@Append{{}}%
+    \FV at Break@Scan}%
+   {\ifbool{FV at breaknonspaceingroup}%
+     {\FV at BreakBufferStart{\FV at Break@DefaultToken}%
+        #1\FV at BreakBufferStop{\FV at Break@GroupTemplate}}%
+     {\FV at BreakBufferStart{\FV at Break@NBToken}%
+        #1\FV at BreakBufferStop{\FV at Break@GroupTemplate}}}}
+\def\FV at Break@GroupTemplate#1{{#1}}
+\def\FV at Break@NBToken#1{%
+  \FV at BreakBuffer@Append{#1}%
+  \let\FV at Break@LastToken=\FV at Undefined
   \FV at Break@Scan}
 \def\FV at Break@AnyToken#1{%
-  \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakAnywhereBreak#1}%
+  \FV at BreakBuffer@Append{\FancyVerbBreakAnywhereBreak#1}%
   \FV at Break@Scan}
 \def\FV at Break@BeforeAfterToken#1{%
   \ifcsname FV at BreakBefore@Token\detokenize{#1}\endcsname
@@ -1915,40 +2150,40 @@
   \FV at Break@Next{#1}%
 }
 \def\FV at Break@BeforeAfterTokenNoBreak#1{%
-  \g at addto@macro{\FV at TmpLine}{#1}%
+  \FV at BreakBuffer@Append{#1}%
   \let\FV at LastToken=#1%
   \FV at Break@Scan}
 \def\FV at Break@BeforeTokenBreak#1{%
-  \ifthenelse{\boolean{FV at BreakBeforeGroup}}%
+  \ifbool{FV at breakbeforeinrun}%
+   {\ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
+      \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak}%
+      \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan
+      \def\FV at RescanToken{#1}%
+    \else
+      \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak#1}%
+      \let\FV at Break@Next\FV at Break@Scan
+      \let\FV at LastToken=#1%
+    \fi}%
    {\ifx#1\FV at LastToken\relax
       \ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
         \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan
         \def\FV at RescanToken{#1}%
       \else
-        \g at addto@macro{\FV at TmpLine}{#1}%
+        \FV at BreakBuffer@Append{#1}%
         \let\FV at Break@Next\FV at Break@Scan
         \let\FV at LastToken=#1%
       \fi
     \else
       \ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
-        \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak}%
+        \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak}%
         \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan
         \def\FV at RescanToken{#1}%
       \else
-        \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak#1}%
+        \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak#1}%
         \let\FV at Break@Next\FV at Break@Scan
         \let\FV at LastToken=#1%
       \fi
     \fi}%
-   {\ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
-      \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak}%
-      \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan
-      \def\FV at RescanToken{#1}%
-    \else
-      \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak#1}%
-      \let\FV at Break@Next\FV at Break@Scan
-      \let\FV at LastToken=#1%
-    \fi}%
   \FV at Break@Next}
 \def\FV at Break@BeforeTokenBreak at AfterRescan{%
   \expandafter\FV at Break@AfterTokenBreak\FV at RescanToken}
@@ -1955,35 +2190,32 @@
 \def\FV at Break@AfterTokenBreak#1{%
   \let\FV at LastToken=#1%
   \@ifnextchar\FV at FVSpaceToken%
-   {\g at addto@macro{\FV at TmpLine}{#1}\FV at Break@Scan}%
-   {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
+   {\FV at BreakBuffer@Append{#1}\FV at Break@Scan}%
+   {\ifbool{FV at breakafterinrun}%
+     {\FV at BreakBuffer@Append{#1\FancyVerbBreakAfterBreak}%
+      \let\FV at Break@Next\FV at Break@Scan}%
      {\ifx\@let at token#1\relax
-        \g at addto@macro{\FV at TmpLine}{#1}%
+        \FV at BreakBuffer@Append{#1}%
         \let\FV at Break@Next\FV at Break@Scan
       \else
-        \ifx\@let at token\bgroup\relax
-          \g at addto@macro{\FV at TmpLine}{#1}%
+        \expandafter\ifx\csname @let at token\endcsname\bgroup\relax
+          \FV at BreakBuffer@Append{#1}%
           \let\FV at Break@Next\FV at Break@AfterTokenBreak at Group
         \else
-          \g at addto@macro{\FV at TmpLine}{#1\FancyVerbBreakAfterBreak}%
+          \FV at BreakBuffer@Append{#1\FancyVerbBreakAfterBreak}%
           \let\FV at Break@Next\FV at Break@Scan
         \fi
       \fi}%
-     {\g at addto@macro{\FV at TmpLine}{#1\FancyVerbBreakAfterBreak}%
-      \let\FV at Break@Next\FV at Break@Scan}%
     \FV at Break@Next}%
 }
 \def\FV at Break@AfterTokenBreak at Group#1{%
-  \g at addto@macro{\FV at TmpLine}{{#1}}%
   \ifstrempty{#1}%
-   {\let\FV at Break@Next\FV at Break@AfterTokenBreak at Group@i}%
-   {\let\FV at Break@Next\FV at Break@Scan\let\FV at LastToken=\FV at Undefined}%
-  \FV at Break@Next}
-\def\FV at Break@AfterTokenBreak at Group@i{%
-  \@ifnextchar\FV at LastToken%
-   {\FV at Break@Scan}%
-   {\g at addto@macro{\FV at TmpLine}{\FancyVerbBreakAfterBreak}%
-    \FV at Break@Scan}}
+   {\FV at BreakBuffer@Append{{}}%
+    \@ifnextchar\FV at LastToken%
+     {\FV at Break@Scan}%
+     {\FV at BreakBuffer@Append{\FancyVerbBreakAfterBreak}%
+      \FV at Break@Scan}}%
+   {\FV at Break@Group{#1}}}
 \ifFV at pdfTeXinputenc
 \def\FV at BreakBeforePrep@UTF{%
   \ifx\FV at BreakBefore\@empty\relax
@@ -2039,16 +2271,16 @@
       \expandafter\FV at BreakAfter@Process at ii\expandafter{##1}}%
     \def\FV at BreakAfter@Process at ii##1{%
       \ifcsname FV at BreakBefore@Token\detokenize{##1}\endcsname
-        \ifthenelse{\boolean{FV at BreakBeforeGroup}}%
-         {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
+        \ifbool{FV at breakbeforeinrun}%
+         {\ifbool{FV at breakafterinrun}%
            {}%
            {\PackageError{fvextra}%
-            {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}%
-            {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}}%
-         {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
+            {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}%
+            {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}}}%
+         {\ifbool{FV at breakafterinrun}%
            {\PackageError{fvextra}%
-             {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}%
-             {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}%
+             {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}%
+             {Conflicting breakbeforeinrun and breakafterinrun for "\detokenize{##1}"}}%
            {}}%
       \fi
       \g at addto@macro\FV at BreakAfter@Def{%
@@ -2072,7 +2304,7 @@
   \FV at Break@Next{#1}%
 }
 \def\FV at Break@AnyToken at UTF@i#1{%
-  \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakAnywhereBreak#1}%
+  \FV at BreakBuffer@Append{\FancyVerbBreakAnywhereBreak#1}%
   \FV at Break@Scan}
 \def\FV at Break@BeforeAfterToken at UTF#1{%
   \ifcsname FV at U8:\detokenize{#1}\endcsname
@@ -2096,41 +2328,41 @@
   \FV at Break@Next{#1}%
 }
 \def\FV at Break@BeforeAfterTokenNoBreak at UTF#1{%
-  \g at addto@macro{\FV at TmpLine}{#1}%
+  \FV at BreakBuffer@Append{#1}%
   \def\FV at LastToken{#1}%
   \FV at Break@Scan}
 \def\FV at Break@BeforeTokenBreak at UTF#1{%
   \def\FV at CurrentToken{#1}%
-  \ifthenelse{\boolean{FV at BreakBeforeGroup}}%
+  \ifbool{FV at breakbeforeinrun}%
+   {\ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
+      \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak}%
+      \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan@UTF
+      \def\FV at RescanToken{#1}%
+    \else
+      \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak#1}%
+      \let\FV at Break@Next\FV at Break@Scan
+      \def\FV at LastToken{#1}%
+    \fi}%
    {\ifx\FV at CurrentToken\FV at LastToken\relax
       \ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
         \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan@UTF
         \def\FV at RescanToken{#1}%
       \else
-        \g at addto@macro{\FV at TmpLine}{#1}%
+        \FV at BreakBuffer@Append{#1}%
         \let\FV at Break@Next\FV at Break@Scan
         \def\FV at LastToken{#1}%
       \fi
     \else
       \ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
-        \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak}%
+        \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak}%
         \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan@UTF
         \def\FV at RescanToken{#1}%
       \else
-        \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak#1}%
+        \FV at BreakBuffer@Append{\FancyVerbBreakBeforeBreak#1}%
         \let\FV at Break@Next\FV at Break@Scan
         \def\FV at LastToken{#1}%
       \fi
     \fi}%
-   {\ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
-      \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak}%
-      \let\FV at Break@Next\FV at Break@BeforeTokenBreak at AfterRescan@UTF
-      \def\FV at RescanToken{#1}%
-    \else
-      \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakBeforeBreak#1}%
-      \let\FV at Break@Next\FV at Break@Scan
-      \def\FV at LastToken{#1}%
-    \fi}%
   \FV at Break@Next}
 \def\FV at Break@BeforeTokenBreak at AfterRescan@UTF{%
   \expandafter\FV at Break@AfterTokenBreak at UTF\expandafter{\FV at RescanToken}}
@@ -2137,16 +2369,16 @@
 \def\FV at Break@AfterTokenBreak at UTF#1{%
   \def\FV at LastToken{#1}%
   \@ifnextchar\FV at FVSpaceToken%
-   {\g at addto@macro{\FV at TmpLine}{#1}\FV at Break@Scan}%
-   {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
-     {\g at addto@macro{\FV at TmpLine}{#1}%
+   {\FV at BreakBuffer@Append{#1}\FV at Break@Scan}%
+   {\ifbool{FV at breakafterinrun}%
+     {\FV at BreakBuffer@Append{#1\FancyVerbBreakAfterBreak}%
+      \let\FV at Break@Next\FV at Break@Scan}%
+     {\FV at BreakBuffer@Append{#1}%
       \ifx\@let at token\bgroup\relax
         \let\FV at Break@Next\FV at Break@AfterTokenBreak at Group@UTF
       \else
         \let\FV at Break@Next\FV at Break@AfterTokenBreak at UTF@i
       \fi}%
-     {\g at addto@macro{\FV at TmpLine}{#1\FancyVerbBreakAfterBreak}%
-      \let\FV at Break@Next\FV at Break@Scan}%
     \FV at Break@Next}%
 }
 \def\FV at Break@AfterTokenBreak at UTF@i#1{%
@@ -2157,30 +2389,27 @@
     \def\FV at NextToken{#1}%
     \ifx\FV at LastToken\FV at NextToken
     \else
-      \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakAfterBreak}%
+      \FV at BreakBuffer@Append{\FancyVerbBreakAfterBreak}%
     \fi
     \let\FV at Break@Next\FV at Break@Scan
   \fi
   \FV at Break@Next#1}
 \def\FV at Break@AfterTokenBreak at Group@UTF#1{%
-  \g at addto@macro{\FV at TmpLine}{{#1}}%
   \ifstrempty{#1}%
-   {\let\FV at Break@Next\FV at Break@AfterTokenBreak at Group@UTF at i}%
-   {\let\FV at Break@Next\FV at Break@Scan\let\FV at LastToken=\FV at Undefined}%
-  \FV at Break@Next}
-\def\FV at Break@AfterTokenBreak at Group@UTF at i{%
-  \@ifnextchar\bgroup%
-   {\FV at Break@Scan}%
-   {\FV at Break@AfterTokenBreak at Group@UTF at ii}}
-\def\FV at Break@AfterTokenBreak at Group@UTF at ii#1{%
+   {\FV at BreakBuffer@Append{{}}%
+    \@ifnextchar\bgroup
+     {\FV at Break@Group}%
+     {\FV at Break@AfterTokenBreak at Group@UTF at i}}%
+   {\FV at Break@Group{#1}}}
+\def\FV at Break@AfterTokenBreak at Group@UTF at i#1{%
   \ifcsname FV at U8:\detokenize{#1}\endcsname
     \expandafter\let\expandafter\FV at Break@Next\csname FV at U8:\detokenize{#1}\endcsname
-    \let\FV at UTF@octets at after\FV at Break@AfterTokenBreak at Group@UTF at ii
+    \let\FV at UTF@octets at after\FV at Break@AfterTokenBreak at Group@UTF at i
   \else
     \def\FV at NextToken{#1}%
     \ifx\FV at LastToken\FV at NextToken
     \else
-      \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakAfterBreak}%
+      \FV at BreakBuffer@Append{\FancyVerbBreakAfterBreak}%
     \fi
     \let\FV at Break@Next\FV at Break@Scan
   \fi
@@ -2204,9 +2433,9 @@
   \savebox{\FV at LineBox}{%
     \advance\FV at LineWidth by -\FV at BreakIndent
     \hbox to \FV at BreakIndent{\hfill}%
-    \ifthenelse{\boolean{FV at BreakAutoIndent}}%
+    \ifbool{FV at breakautoindent}%
      {\let\FV at LineIndentChars\@empty
-      \FV at GetLineIndent#1\FV at Undefined
+      \FV at GetLineIndent#1\FV at Sentinel
       \savebox{\FV at LineIndentBox}{\FV at LineIndentChars}%
       \hbox to \wd\FV at LineIndentBox{\hfill}%
       \advance\FV at LineWidth by -\wd\FV at LineIndentBox
@@ -2225,12 +2454,11 @@
       \noindent\hspace*{-\FV at BreakIndent}%
       \ifdefempty{\FancyVerbBreakSymbolLeft}{}{%
         \hspace*{-\FV at BreakSymbolIndentLeft}}%
-      \ifthenelse{\boolean{FV at BreakAutoIndent}}%
+      \ifbool{FV at breakautoindent}%
        {\hspace*{-\wd\FV at LineIndentBox}}%
        {}%
       \FV at BreakByTokenAnywhereHook
-      \strut\FancyVerbFormatText{%
-        \FancyVerbBreakStart #1\FancyVerbBreakStop}\nobreak\strut
+      \strut\FV at InsertBreaks{\FancyVerbFormatText}{#1}\nobreak\strut
       \end{internallinenumbers*}
     }%
     \ifdefempty{\FancyVerbBreakSymbolRight}{}%
@@ -2256,6 +2484,8 @@
     \setcounter{FV at TrueTabCounter}{0}%
   \fi
   \sbox{\FV at LineBox}{%
+    \let\FancyVerbBreakStart\relax
+    \let\FancyVerbBreakStop\relax
     \FancyVerbFormatLine{%
       %\FancyVerbHighlightLine  %<-- Default definition using \rlap breaks breaking
        {\FV at ObeyTabs{\FancyVerbFormatText{#1}}}}}%
@@ -2283,6 +2513,8 @@
       \let\FV at Tab\FV at TrueTab
     \fi
   \else
+    \let\FancyVerbBreakStart\relax
+    \let\FancyVerbBreakStop\relax
     \FV at LeftListNumber
     \FV at LeftListFrame
     \FancyVerbFormatLine{%
@@ -2423,9 +2655,9 @@
   \def\FV at BreakAfterPrep@PygmentsHook{%
     \expandafter\FV at BreakAfterPrep@Pygments\expandafter{\FV at PYG@Literal}}%
   \ifx#2\relax
-    \let\FV at PYG#1%
+    \let\FV at PYG=#1\relax
   \else
-    \let\FV at PYG#2%
+    \let\FV at PYG=#2\relax
   \fi
   \ifbool{FV at breakbytoken}%
    {\ifbool{FV at breakbytokenanywhere}%
@@ -2439,6 +2671,7 @@
         \leavevmode\hbox{\FV at PYG{##1}{##2}}}}}%
    {\def#1##1##2{%
      \FV at PYG{##1}{\FancyVerbBreakStart##2\FancyVerbBreakStop}}}%
+  \let\FV at PYG@Redefed=#1\relax
 }
 \let\FV at BreakByTokenAnywhereBreak\relax
 \def\FV at DetokMacro@StripSpace#1 {#1}

Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds	2022-12-01 10:50:03 UTC (rev 65157)
+++ trunk/Master/tlpkg/libexec/ctan2tds	2022-12-01 20:34:06 UTC (rev 65158)
@@ -3160,7 +3160,7 @@
  'makelabels'	=> 'tex --8bit',
  'mandi'	=> 'pdflatex-preserve-pdf',
  'marathi' 	=> 'tex -8bit',
- 'mathfont'	=> 'latex',
+ 'mathfont'	=> 'lualatex',
  'mcmthesis'	=> 'tex',    # requires interaction
  'mversion'     => 'latex',  # requires interaction
  'minitoc'      => 'latex',  # requires interaction and 1000q instead of 10q



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