texlive[41697] Master/texmf-dist: fvextra (14jul16)

commits+karl at tug.org commits+karl at tug.org
Thu Jul 14 23:40:44 CEST 2016


Revision: 41697
          http://tug.org/svn/texlive?view=revision&revision=41697
Author:   karl
Date:     2016-07-14 23:40:44 +0200 (Thu, 14 Jul 2016)
Log Message:
-----------
fvextra (14jul16)

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

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	2016-07-14 21:40:33 UTC (rev 41696)
+++ trunk/Master/texmf-dist/source/latex/fvextra/fvextra.dtx	2016-07-14 21:40:44 UTC (rev 41697)
@@ -26,7 +26,7 @@
 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
 %<package>\ProvidesPackage{fvextra}
 %<*package>
-    [2016/06/28 v1.0 fvextra - extensions and patches for fancyvrb]
+    [2016/07/14 v1.1 fvextra - extensions and patches for fancyvrb]
 %</package>
 %
 %<*driver>
@@ -60,6 +60,36 @@
 }
 \usepackage{cleveref}
 
+% Create a short verbatim pipe that handles quotation marks properly
+\begingroup
+\catcode`\|=\active
+\gdef\pipe at active@verbatim{%
+  \begingroup
+  \let\do\@makeother\dospecials
+  \catcode`\|=\active
+  \catcode`\`=\active
+  \catcode`\'=\active
+  \catcode`\<=\active
+  \catcode`\>=\active
+  \catcode`\-=\active
+  \catcode`\,=\active
+  \catcode`\ =\active
+  \pipe at active@verbatim at i}
+\gdef\pipe at active@verbatim at i#1|{%
+  \endgroup
+  \begingroup
+  \def\FV at SV@pipe at active@verbatim{%
+    \FV at Gobble
+    \expandafter\FV at ProcessLine\expandafter{#1}}%
+  %\let\FV at BeginVBox\relax
+  %\let\FV at EndVBox\relax
+  %\def\FV at BProcessLine##1{\FancyVerbFormatLine{##1}}%
+  \BUseVerbatim{pipe at active@verbatim}%
+  \endgroup}
+\AtBeginDocument{\let|\pipe at active@verbatim}
+\endgroup
+
+
 \newcommand{\todo}[1]{}
 %\newcommand{\todo}[1]{\textcolor{red}{TO~DO: \scantokens{#1}}}
 
@@ -186,7 +216,7 @@
 %</driver>
 % \fi
 %
-% \CheckSum{1562}
+% \CheckSum{2566}
 %
 % \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
@@ -205,6 +235,16 @@
 %   Right brace   \}     Tilde         \~}
 %
 %
+% \begin{changelog}{v1.1}{2016/07/14}
+% \item The options \texttt{rulecolor} and \texttt{fillcolor} now accept color names directly; using \texttt{\string\color\{<color\_name>\}} is no longer necessary, though it still works.
+% \item Added \texttt{tabcolor} and \texttt{spacecolor} options for use with \texttt{showtabs} and \texttt{showspaces}.
+% \item Added \texttt{highlightlines} option that takes a line number or range of line numbers and highlights the corresponding lines.  Added \texttt{highlightcolor} option that controls hightlighting color.
+% \item \texttt{obeytabs} no longer causes lines to vanish when tabs are inside macro arguments.  Tabs and spaces inside a macro argument but otherwise at the beginning of a line are expanded correctly.  Tabs inside a macro argument that are preceded by non-whitespace characters (not spaces or tabs) are expanded based on the starting position of the run of whitespace in which they occur.
+% \item The line breaking options \texttt{breakanywhere}, \texttt{breakbefore}, and \texttt{breakafter} now work with multi-byte UTF-8 code points under pdfTeX with \texttt{inputenc}.  They were already fully functional under XeTeX and LuaTeX.
+% \item Added \texttt{curlyquotes} option, which essentially disables the \texttt{uquote} package.
+% \end{changelog}
+%
+%
 % \begin{changelog}{v1.0}{2016/06/28}
 % \item Initial release.
 % \end{changelog}
@@ -246,7 +286,7 @@
 %
 % \fvextra\ is an add-on package that gives \fancyvrb\ several additional features, including automatic line breaking.  Because \fvextra\ patches and overwrites some of the \fancyvrb\ internals, it may not be suitable for documents that rely on the details of the original \fancyvrb\ implementation.  \fvextra\ tries to maintain the default \fancyvrb\ behavior in most cases.  All patches (\cref{sec:patch}) and modifications to \fancyvrb\ defaults (\cref{sec:modifications}) are documented.
 %
-% Some features of \fvextra\ were originally created as part of the \pkg{pythontex} and \pkg{minted} packages.  \fancyvrb-related patches and extensions that currently exist in those packages will gradually be migrated into \fvextra, and both packages will eventually require \fvextra.
+% Some features of \fvextra\ were originally created as part of the \pkg{pythontex} and \pkg{minted} packages.  \fancyvrb-related patches and extensions that currently exist in those packages will gradually be migrated into \fvextra, and both packages will require \fvextra\ in the future.
 %
 %
 % 
@@ -255,15 +295,13 @@
 %
 % \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 single quotation marks (\texttt{\textquotesingle}).  \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{ifthen} and \pkg{etoolbox} packages are 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.
 %
-% \fvextra\ must be loaded before \pkg{pythontex} and \pkg{minted}, so that it will not clash with the \fancyvrb\ patches that currently exist in those packages.  Those patches will eventually be migrated to \fvextra.
 %
 %
 %
-%
 % \section{General options}
 % \label{sec:general-options}
 %
@@ -271,6 +309,59 @@
 %
 % \begin{optionlist}
 %
+% \item[curlyquotes (boolean) (false)]
+% Unlike \fancyvrb, \pkg{fvextra} requires the \pkg{upquote} package, so the backtick (\texttt{\textasciigrave}) and typewriter single quotation mark (\texttt{\textquotesingle}) always appear literally by default, instead of becoming the left and right curly single quotation marks (\texttt{`'}).  This option allows these characters to be replaced by the curly quotation marks when that is desirable.
+%
+% \begin{example}
+%   \begin{Verbatim}
+%   `quoted text'
+%   \end{Verbatim}
+% \end{example}
+%
+% \begin{example}
+%   \begin{Verbatim}[curlyquotes]
+%   `quoted text'
+%   \end{Verbatim}
+% \end{example}
+%
+%
+% \item[highlightcolor (string) (LightCyan)]
+% Set the color used for |highlightlines|, using a predefined color name from \pkg{color} or \pkg{xcolor}, or a color defined via |\definecolor|.
+%
+%
+% \item[highlightlines (string) (\meta{none})]
+% This highlights a single line or a range of lines based on line numbers.  The line numbers refer to the line numbers that \fancyvrb\ would show if |numbers=left|, etc.  They do not refer to original or actual line numbers before adjustment by |firstnumber|.
+%
+% The highlighting color can be customized with |highlightcolor|.
+%
+% \begingroup 
+% \fvset{xleftmargin=2em}
+% \begin{longexample}
+%   \begin{Verbatim}[numbers=left, highlightlines={1, 3-4}]
+%   First line
+%   Second line
+%   Third line
+%   Fourth line
+%   Fifth line
+%   \end{Verbatim}
+% \end{longexample}
+% \endgroup
+%
+% The actual highlighting is performed by a set of commands.  These may be customized for additional fine-tuning of highlighting.  See the default definition of |\FancyVerbHighlightLineFirst| as a starting point.
+%
+% \vspace{0.1in}
+% $\bullet$ |\FancyVerbHighlightLineFirst|:  First line in a range. \\
+% \indent $\bullet$ |\FancyVerbHighlightLineMiddle|:  Inner lines in a range. \\
+% \indent $\bullet$ |\FancyVerbHighlightLineLast|:  Last line in a range. \\
+% \indent $\bullet$ |\FancyVerbHighlightLineSingle|:  Single highlighted lines. \\
+% \indent $\bullet$ |\FancyVerbHighlightLineNormal|:  Normal lines without highlighting. \\
+%
+% \vspace{-0.1in}
+% \noindent If these are customized in such a way that indentation or inter-line spacing is changed, then |\FancyVerbHighlightLineNormal| may be modified as well to make all lines uniform.  When working with the |First|, |Last|, and |Single| commands, keep in mind that \fvextra\ merges all numbers ranges, so that |{1, 2-3, 3-5}| is treated the same as |{1-5}|.
+%
+% Highlighting is applied after |\FancyVerbFormatText|, so any text formatting defined via that command will work with highlighting.  Highlighting is applied before |\FancyVerbFormatLine|, so if |\FancyVerbFormatLine| puts a line in a box, the box will be behind whatever is created by highlighting.  This prevents highlighting from vanishing due to user-defined customization.
+%
+%
 % \item[linenos (boolean) (false)]
 % \fancyvrb\ allows line numbers via the options |numbers=|\meta{position}.  This is essentially an alias for |numbers=left|.  It primarily exists for better compatibility with the \pkg{minted} package.
 %
@@ -300,7 +391,7 @@
 % \endgroup
 %
 %
-% \item[numbers (none\|left\|right\|both) (none)]
+% \item[numbers (none \| left \| right \| both) (none)]
 % \fvextra\ adds the |both| option for line numbering.
 %
 % \begingroup
@@ -317,9 +408,20 @@
 %
 %
 % \item[space (macro) (\string\textvisiblespace, \textvisiblespace)]
-% Redefine the visible space character.  Note that this is only used if |showspaces=true|.
+% Redefine the visible space character.  Note that this is only used if |showspaces=true|.  The color of the character may be set with |spacecolor|.
 %
 %
+% \item[spacecolor (string) (none)]
+% Set the color of visible spaces.  By default (|none|), they take the color of their surroundings.
+%
+% \begin{longexample}
+%   \color{gray}
+%   \begin{Verbatim}[showspaces, spacecolor=red]
+%   One  two  three
+%   \end{Verbatim}
+% \end{longexample}
+%
+%
 % \item[stepnumberfromfirst (boolean) (false)]
 % By default, when line numbering is used with |stepnumber| $\ne 1$, only line numbers that are a multiple of |stepnumber| are included.  This offsets the line numbering from the first line, so that the first line, and all lines separated from it by a multiple of |stepnumber|, are numbered.
 %
@@ -357,21 +459,23 @@
 %
 %
 % \item[tab (macro) ({\rmfamily\fancyvrb's} \string\FancyVerbTab, \FancyVerbTab)]
-% Redefine the visible tab character.  Note that this is only used if |showtabs=true|.
+% Redefine the visible tab character.  Note that this is only used if |showtabs=true|.  The color of the character may be set with |tabcolor|.
 %
+% When redefining the tab, you should include the font family, font shape, and text color in the definition.  Otherwise these may be inherited from the surrounding text.  This is particularly important when using the tab with syntax highlighting, such as with the \pkg{minted} or \pkg{pythontex} packages.
+%
 % \fvextra\ patches \fancyvrb\ tab expansion so that variable-width symbols such as |\rightarrowfill| may be used as tabs.  For example,
 %
 % \begingroup
-% \fvset{frame=single, rulecolor=\color{DarkGreen}, gobble=4}
+% \fvset{frame=single, rulecolor=DarkGreen, gobble=4}
 % \begin{VerbatimVerbatim}[breaklines, obeytabs, showtabs]
 %   \begin{Verbatim}[obeytabs, showtabs, breaklines, 
-%                    tab=\textcolor{orange}{\rightarrowfill}]
+%                    tab=\rightarrowfill, tabcolor=orange]
 %   	First	Second	Third	And more text that goes on for a while until wrapping is needed
 %   	First	Second	Third	Forth
 %   \end{Verbatim}
 % \end{VerbatimVerbatim}
-%   \begin{Verbatim}[obeytabs, showtabs, breaklines,
-%                    tab=\textcolor{orange}{\rightarrowfill}]
+%   \begin{Verbatim}[obeytabs, showtabs, breaklines, 
+%                    tab=\rightarrowfill, tabcolor=orange]
 %   	First	Second	Third	And more text that goes on for a while until wrapping is needed
 %   	First	Second	Third	Forth
 %   \end{Verbatim}
@@ -378,6 +482,10 @@
 % \endgroup
 %
 %
+% \item[tabcolor (string) (none)]
+% Set the color of visible tabs.  By default (|none|), they take the color of their surroundings.
+%
+%
 % \end{optionlist}
 %
 %
@@ -400,8 +508,7 @@
 % \begin{longexample}
 %   \renewcommand{\FancyVerbFormatLine}[1]{%
 %     \fcolorbox{DarkBlue}{LightGray}{#1}}
-%   \renewcommand{\FancyVerbFormatText}[1]{%
-%     \textcolor{DarkViolet}{#1}}
+%   \renewcommand{\FancyVerbFormatText}[1]{\textcolor{Green}{#1}}
 %
 %   \begin{Verbatim}[breaklines]
 %   Some text that proceeds for a while and finally wraps onto another line
@@ -425,7 +532,7 @@
 % \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.  |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 |#|, |{|, |}|, |%|, |[|, |]|; 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.
 %
@@ -475,7 +582,7 @@
 %
 %
 % \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.  |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 |#|, |{|, |}|, |%|, |[|, |]|; 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.
 %
@@ -736,14 +843,52 @@
 % \subsection{Visible spaces}
 % \label{sec:patch:visible-space}
 %
-% The command |\FancyVerbSpace| defines the visible space when |showspaces=true|.  The default \fancyvrb\ definition allows a font command to escape, so that all following text is forced to be teletype font.  The command is redefined to use |\textvisiblespace|.
+% The command |\FancyVerbSpace| defines the visible space when |showspaces=true|.  The default \fancyvrb\ definition allows a font command to escape under some circumstances, so that all following text is forced to be teletype font.  The command is redefined to use |\textvisiblespace|.
 %
 %
-% \subsection{Visible tabs}
+% \subsection{\texttt{obeytabs} with visible tabs and with tabs inside macro arguments}
 %
-% The default treatment of visible tabs when |showtabs=true| does not allow variable-width tab symbols such as |\rightarrowfill| to function correctly.  This is fixed through a redefinition of |\FV at TrueTab|.
+% The original \fancyvrb\ treatment of visible tabs when |showtabs=true| and |obeytabs=true| did not allow variable-width tab symbols such as |\rightarrowfill| to function correctly.  This is fixed through a redefinition of |\FV at TrueTab|.
 %
+% Various macros associated with |obeytabs=true| are also redefined so that tabs may be expanded regardless of whether they are within a group (within |{...}| with the normal \LaTeX\ meaning due to |commandchars|, etc.).  In the \fancyvrb\ implementation, using |obeytabs=true| when a tab is inside a group typically causes the entire line to vanish.  \fvextra\ patches this so that the tab is expanded and will be visible if |showtabs=true|.  Note, though, that the tab expansion in these cases is only guaranteed to be correct for leading whitespace that is inside a group.  The start of each run of whitespace that is inside a group is treated as a tab stop, whether or not it actually is, due to limitations of the tab expansion algorithm.  A more detailed discussion is provided in the implementation.
 %
+% The example below shows correct tab expansion of leading whitespace within a macro argument.  With \fancyvrb, the line of text would simply vanish in this case.
+% 
+% \begingroup
+% \fvset{frame=single, rulecolor=DarkGreen, gobble=4}
+% \begin{VerbatimVerbatim}[showtabs]
+%   \begin{Verbatim}[obeytabs, showtabs, showspaces, tabsize=4,
+%      commandchars=\\\{\}, tab=\textcolor{orange}{\rightarrowfill}]
+%   \textcolor{blue}{ 		Text after 1 space + 2 tabs}
+%   \end{Verbatim}
+% \end{VerbatimVerbatim}
+%
+%   \begin{Verbatim}[obeytabs, showtabs, showspaces, tabsize=4,
+%      commandchars=\\\{\}, tab=\textcolor{orange}{\rightarrowfill}]
+%   \textcolor{blue}{ 		Text after 1 space + 2 tabs}
+%   \end{Verbatim}
+% \endgroup
+%
+% The next example shows that tab expansion inside macros in the midst of text typically does not match up with the correct tab stops, since in such circumstances the beginning of the run of whitespace must be treated as a tab stop.
+%
+% \begingroup
+% \fvset{frame=single, rulecolor=DarkGreen, gobble=4, obeytabs}
+% \begin{VerbatimVerbatim}[showtabs]
+%   \begin{Verbatim}[obeytabs, showtabs, commandchars=\\\{\},
+%                    tab=\textcolor{orange}{\rightarrowfill}]
+%   \textcolor{blue}{		2 leading tabs}
+%   \textcolor{blue}{Text		then 2 tabs}
+%   \end{Verbatim}
+% \end{VerbatimVerbatim}
+%
+%   \begin{Verbatim}[obeytabs, showtabs, commandchars=\\\{\},
+%                    tab=\textcolor{orange}{\rightarrowfill}]
+%   \textcolor{blue}{		2 leading tabs}
+%   \textcolor{blue}{Text		then 2 tabs}
+%   \end{Verbatim}
+% \endgroup
+%
+%
 % \subsection{Math mode}
 % \label{sec:patch:math}
 %
@@ -794,13 +939,25 @@
 %
 %
 %
+% \subsection{\texttt{rulecolor} and \texttt{fillcolor}}
 %
+% The |rulecolor| and |fillcolor| options are redefined so that they accept color names directly, rather than requiring |\color{|\meta{color\_name}|}|.  The definitions still allow the old usage.
 %
+%
+%
+%
+%
 % \section{Additional modifications to \fancyvrb}
 % \label{sec:modifications}
 %
 % \fvextra\ modifies some \fancyvrb\ behavior with the intention of improving logical consistency or providing better defaults.
 %
+%
+% \subsection{Backtick and single quotation mark}
+%
+% With \fancyvrb, the backtick \texttt{\textasciigrave} and typewriter single quotation mark \texttt{\textquotesingle} are typeset as the left and right curly single quotation marks \texttt{`'}.  \pkg{fvextra} loads the \pkg{upquote} package so that these characters will appear literally by default.  The original \fancyvrb\ behavior can be restored with the \fvextra\ option |curlyquotes| (\cref{sec:general-options}). 
+%
+%
 % \subsection{Line numbering}
 % \label{sec:modifications:line-numbering}
 %
@@ -834,7 +991,7 @@
 %
 % \DescribeMacro{\FancyVerbTab}
 % 
-% This defines the visible tab character (\FancyVerbTab) that is used when |showtabs=true|.  The default definition in \fancyvrb\ is 
+% This defines the visible tab character (\FancyVerbTab) that is used when |showtabs=true|.  The default definition is
 %\begin{verbatim}
 %\def\FancyVerbTab{%
 %  \valign{%
@@ -881,19 +1038,31 @@
 \@ifpackageloaded{csquotes}%
  {\PackageWarning{fvextra}{csquotes should be loaded after fvextra, %
   to avoid a warning from the lineno package}}{}
-\@ifpackageloaded{minted}%
- {\PackageError{fvextra}%
-   {fvextra must be loaded before minted}%
-   {fvextra must be loaded before minted}}
-\@ifpackageloaded{pythontex}%
- {\PackageError{fvextra}%
-   {fvextra must be loaded before pythontex}%
-   {fvextra must be loaded before pythontex}}
 %    \end{macrocode}
 %
 %
 %
 %
+% \subsection{Utility macros}
+%
+% \begin{macro}{\FV at Space@ifx}
+% Macro for testing if a |\let| token is |\FV at Space| with |\ifx|.  The space will be active and defined as |\FV at Space|.
+%    \begin{macrocode}
+\def\FV at Space@ifx{\FV at Space}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\FV at Tab@ifx}
+% Macro for testing if a |\let| token is |\FV at Tab| with |\ifx|.  The tab will be active and defined as |\FV at Tab|.
+%    \begin{macrocode}
+\def\FV at Tab@ifx{\FV at Tab}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+%
+%
 % \subsection{Hooks}
 %
 %
@@ -943,11 +1112,11 @@
 % \subsubsection{Visible spaces}
 %
 % \begin{macro}{\FancyVerbSpace}
-% The default definition of visible spaces (|showspaces=true|) allows font commands to escape:
+% The default definition of visible spaces (|showspaces=true|) could allow font commands to escape under some circumstances, depending on how it is used:
 %\begin{verbatim}
 %{\catcode`\ =12 \gdef\FancyVerbSpace{\tt }}
 %\end{verbatim}
-% The command is redefined in more standard \LaTeX\ form.
+% The command is redefined in more robust and standard \LaTeX\ form.
 %    \begin{macrocode}
 \def\FancyVerbSpace{\textvisiblespace}
 %    \end{macrocode}
@@ -954,12 +1123,78 @@
 % \end{macro}
 %
 %
-% \subsubsection{Visible tabs}
+% \subsubsection{\texttt{obeytabs} with visible tabs and with tabs inside macro arguments}
+% \label{sec:patch:obeytabs}
 %
+% |\FV at TrueTab| governs tab appearance when |obeytabs=true| and |showtabs=true|. It is redefined so that symbols with flexible width, such as |\rightarrowfill|, will work as expected.  In the original \fancyvrb\ definition, |\kern\@tempdima\hbox to\z@{...}|.  The |\kern| is removed and instead the |\hbox| is given the width |\@tempdima|.
+%
+% |\FV at TrueTab| and related macros are also modified so that they function for tabs inside macro arguments when |obeytabs=true| (inside curly braces |{}| with their normal meaning, when using |commandchars|, etc.).  The \fancyvrb\ implementation of tab expansion assumes that tabs are never inside a group; when a group that contains a tab is present, the entire line typically vanishes.  The new implementation keeps the \fancyvrb\ behavior exactly for tabs outside groups; they are perfectly expanded to tab stops.  Tabs inside groups cannot be perfectly expanded to tab stops, at least not using the \fancyvrb\ approach.  Instead, when \fvextra\ encounters a run of whitespace characters (tabs and possibly spaces), it makes the assumption that the nearest tab stop was at the beginning of the run.  This gives the correct behavior if the whitespace characters are leading indentation that happens to be within a macro.  Otherwise, it will typically not give correct tab expansion---but at least the entire line will not be discarded, and the run of whitespace will be represented, even if imperfectly.
+%
+% A general solution to tab expansion may be possible, but will almost certainly require multiple compiles, perhaps even one compile (or more) per tab.  The \pkg{zref} package provides a |\zsaveposx| macro that stores the current $x$ position on the page for subsequent compiles.  This macro, or a similar macro from another package, could be used to establish a reference point at the beginning of each line.  Then each run of whitespace that contains a tab could have a reference point established at its start, and tabs could be expanded based on the distance between the start of the run and the start of the line.  Such an approach would allow the first run of whitespace to measure its distance from the start of the line on the 2nd compile (once both reference points were established), so it would be able expand the first run of whitespace correctly on the 3rd compile.  That would allow a second run of whitespace to definitely establish its starting point on the 3rd compile, which would allow it to expand correctly on the 4th compile.  And so on.  Thus, while it should be possible to perform completely correct tab expansion with such an approach, it will in general require at least 4 compiles to do better than the current approach.  Furthermore, the sketch of the algorithm provided so far does not include any complications introduced by line breaking.  In the current approach, it is necessary to determine how each tab would be expanded in the absence of line breaking, save all tab widths, and then expand using saved widths during the actual typesetting with line breaking.
+%
+%
+% \begin{macro}{FV at TrueTabGroupLevel}
+% Counter for keeping track of the group level (|\currentgrouplevel|) at the very beginning of a line, inside |\FancyVerbFormatLine| but outside |\FancyVerbFormatText|, which is where the tab expansion macro is invoked.  This allows us to determine whether we are in a group, and expand tabs accordingly.
+%    \begin{macrocode}
+\newcounter{FV at TrueTabGroupLevel}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\FV@@ObeyTabs}
+% The \fancyvrb\ macro responsible for tab expansion is modified so that it can handle tabs inside groups, even if imperfectly.  We need to use a special version of the space, |\FV at Space@ObeyTabs|, that within a group will capture all following spaces or tabs and then insert them with tab expansion based on the beginning of the run of whitespace.  We need to record the current group level, but then increment it by $1$ because all comparisons will be performed within the |\hbox{...}|.
+%    \begin{macrocode}
+\def\FV@@ObeyTabs#1{%
+  \let\FV at Space@Orig\FV at Space
+  \let\FV at Space\FV at Space@ObeyTabs
+  \setcounter{FV at TrueTabGroupLevel}{\the\currentgrouplevel}%
+  \addtocounter{FV at TrueTabGroupLevel}{1}%
+  \setbox\FV at TabBox=\hbox{#1}\box\FV at TabBox
+  \let\FV at Space\FV at Space@Orig}
+%    \end{macrocode}
+% \end{macro}
+%
+%
 % \begin{macro}{\FV at TrueTab}
-% Redefine |\FV at TrueTab| so that symbols with flexible width, such as |\rightarrowfill|, will work as expected.  In the original \fancyvrb\ definition, |\kern\@tempdima\hbox to\z@{...}|.  The |\kern| is removed and instead the |\hbox| is given the width |\@tempdima|.
+% Version that follows \fancyvrb\ if not in a group and takes another approach otherwise.
 %    \begin{macrocode}
 \def\FV at TrueTab{%
+  \ifnum\value{FV at TrueTabGroupLevel}=\the\currentgrouplevel\relax
+    \expandafter\FV at TrueTab@NoGroup
+  \else
+    \expandafter\FV at TrueTab@Group
+  \fi}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FV at TrueTabSaveWidth}
+% When linebreaking is in use, the \fancyvrb\ tab expansion algorithm cannot be used directly, since it involves |\hbox|, which doesn't allow for line breaks.  In those cases, tab widths will be calculated for the case without breaks and saved, and then saved widths will be used in the actual typesetting.  This macro is |\let| to width-saving code in those cases.
+%    \begin{macrocode}
+\let\FV at TrueTabSaveWidth\relax
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{FV at TrueTabCounter}
+% Counter for tracking saved tabs.
+%    \begin{macrocode}
+\newcounter{FV at TrueTabCounter}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FV at TrueTabSaveWidth@Save}
+% Save the current tab width, then increment the tab counter.  |\@tempdima| will hold the current tab width.
+%    \begin{macrocode}
+\def\FV at TrueTabSaveWidth@Save{%
+  \expandafter\xdef\csname FV at TrueTab:Width\arabic{FV at TrueTabCounter}\endcsname{%
+    \number\@tempdima}%
+  \stepcounter{FV at TrueTabCounter}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FV at TrueTab@NoGroup}
+% This follows the \fancyvrb\ approach exactly, except for the |\hbox to\@tempdima| adjustment and the addition of |\FV at TrueTabSaveWidth|.
+%    \begin{macrocode}
+\def\FV at TrueTab@NoGroup{%
   \egroup
   \@tempdima=\FV at ObeyTabSize sp\relax
   \@tempcnta=\wd\FV at TabBox
@@ -967,12 +1202,117 @@
   \divide\@tempcnta\@tempdima
   \multiply\@tempdima\@tempcnta
   \advance\@tempdima-\wd\FV at TabBox
+  \FV at TrueTabSaveWidth
   \setbox\FV at TabBox=\hbox\bgroup
     \unhbox\FV at TabBox\hbox to\@tempdima{\hss\FV at TabChar}}
 %    \end{macrocode}
 % \end{macro}
 %
+% \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}
+%    \end{macrocode}
+% \end{macro}
 %
+% \begin{macro}{\FV at TrueTab@Group}
+% If in a group, a tab should start collecting whitespace characters for later tab expansion, beginning with itself.  The collected whitespace will use |\FV at Tab@ifx| and |\FV at Space@ifx| so that any |\ifx| comparisons performed later will behave as expected.  This shouldn't be strictly necessary, because |\FancyVerbBreakStart| operates with saved tab widths rather than using the tab expansion code directly.  But it is safer in case any other unanticipated scanning is going on.
+%    \begin{macrocode}
+\def\FV at TrueTab@Group{%
+  \booltrue{FV at ObeyTabs@Whitespace at Tab}%
+  \gdef\FV at TmpWhitespace{\FV at Tab@ifx}%
+  \FV at ObeyTabs@ScanWhitespace}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\FV at Space@ObeyTabs}
+% Space treatment, like tab treatment, now depends on whether we are in a group, because in a group we want to collect all runs of whitespace and then expand any tabs.
+%    \begin{macrocode}
+\def\FV at Space@ObeyTabs{%
+  \ifnum\value{FV at TrueTabGroupLevel}=\the\currentgrouplevel\relax
+    \expandafter\FV at Space@ObeyTabs at NoGroup
+  \else
+    \expandafter\FV at Space@ObeyTabs at Group
+  \fi}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FV at Space@ObeyTabs at NoGroup}
+% Fall back to normal space.
+%    \begin{macrocode}
+\def\FV at Space@ObeyTabs at NoGroup{\FV at Space@Orig}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FV at Space@ObeyTabs at Group}
+% Make a note that no tabs have yet been encountered, store the current space, then scan for following whitespace.
+%    \begin{macrocode}
+\def\FV at Space@ObeyTabs at Group{%
+  \boolfalse{FV at ObeyTabs@Whitespace at Tab}%
+  \gdef\FV at TmpWhitespace{\FV at Space@ifx}%
+  \FV at ObeyTabs@ScanWhitespace}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\FV at ObeyTabs@ScanWhitespace}
+% Collect whitespace until the end of the run, then process it.  Proper lookahead comparison requires |\FV at Space@ifx| and |\FV at Tab@ifx|.
+%    \begin{macrocode}
+\def\FV at ObeyTabs@ScanWhitespace{%
+  \@ifnextchar\FV at Space@ifx%
+   {\FV at TrueTab@CaptureWhitespace at Space}%
+   {\ifx\@let at token\FV at Tab@ifx
+      \expandafter\FV at TrueTab@CaptureWhitespace at Tab
+    \else
+      \expandafter\FV at ObeyTabs@ResolveWhitespace
+    \fi}}
+\def\FV at TrueTab@CaptureWhitespace at Space#1{%
+  \g at addto@macro\FV at TmpWhitespace{\FV at Space@ifx}%
+  \FV at ObeyTabs@ScanWhitespace}
+\def\FV at TrueTab@CaptureWhitespace at Tab#1{%
+  \booltrue{FV at ObeyTabs@Whitespace at Tab}%
+  \g at addto@macro\FV at TmpWhitespace{\FV at Tab@ifx}%
+  \FV at ObeyTabs@ScanWhitespace}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\FV at TrueTab@Group at Expand}
+% Yet another tab definition, this one for use in the actual expansion of tabs in whitespace.  This uses the \fancyvrb\ algorithm, but only over a restricted region known to contain no groups.
+%    \begin{macrocode}
+\newbox\FV at TabBox@Group
+\def\FV at TrueTab@Group at Expand{%
+  \egroup
+  \@tempdima=\FV at ObeyTabSize sp\relax
+  \@tempcnta=\wd\FV at TabBox@Group
+  \advance\@tempcnta\FV@@ObeyTabSize\relax
+  \divide\@tempcnta\@tempdima
+  \multiply\@tempdima\@tempcnta
+  \advance\@tempdima-\wd\FV at TabBox@Group
+  \FV at TrueTabSaveWidth
+  \setbox\FV at TabBox@Group=\hbox\bgroup
+    \unhbox\FV at TabBox@Group\hbox to\@tempdima{\hss\FV at TabChar}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FV at ObeyTabs@ResolveWhitespace}
+% Need to make sure the right definitions of the space and tab are in play here.  Only do tab expansion, with the associated |\hbox|, if a tab is indeed present.
+%    \begin{macrocode}
+\def\FV at ObeyTabs@ResolveWhitespace{%
+  \let\FV at Space\FV at Space@Orig
+  \let\FV at Tab\FV at TrueTab@Group at Expand
+  \expandafter\FV at ObeyTabs@ResolveWhitespace at i\expandafter{\FV at TmpWhitespace}%
+  \let\FV at Space\FV at Space@ObeyTabs
+  \let\FV at Tab\FV at TrueTab}
+\def\FV at ObeyTabs@ResolveWhitespace at i#1{%
+  \ifbool{FV at ObeyTabs@Whitespace at Tab}%
+   {\setbox\FV at TabBox@Group=\hbox{#1}\box\FV at TabBox@Group}%
+   {#1}}
+%    \end{macrocode}
+% \end{macro}
+%
+%
 % \subsubsection{Spacing in math mode}
 %
 % \begin{macro}{\FancyVerbMathSpace}
@@ -1071,6 +1411,53 @@
 %
 %
 %
+% \subsubsection{\texttt{rulecolor} and \texttt{fillcolor}}
+%
+% The |rulecolor| and |fillcolor| options are redefined so that they accept color names directly, rather than requiring |\color{|\meta{color\_name}|}|.  The definitions still allow the old usage.
+% 
+% \begin{macro}{rulecolor}
+%    \begin{macrocode}
+\define at key{FV}{rulecolor}{%
+  \ifstrempty{#1}%
+   {\let\FancyVerbRuleColor\relax}%
+   {\ifstrequal{#1}{none}%
+     {\let\FancyVerbRuleColor\relax}%
+     {\def\@tempa{#1}%
+      \FV at KVProcess@RuleColor#1\FV at Undefined}}}
+\def\FV at KVProcess@RuleColor#1#2\FV at Undefined{%
+  \ifx#1\color
+  \else
+    \expandafter\def\expandafter\@tempa\expandafter{%
+      \expandafter\color\expandafter{\@tempa}}%
+  \fi
+  \let\FancyVerbRuleColor\@tempa}
+\fvset{rulecolor=none}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{fillcolor}
+%    \begin{macrocode}
+\define at key{FV}{fillcolor}{%
+  \ifstrempty{#1}%
+   {\let\FancyVerbFillColor\relax}%
+   {\ifstrequal{#1}{none}%
+     {\let\FancyVerbFillColor\relax}%
+     {\def\@tempa{#1}%
+      \FV at KVProcess@FillColor#1\FV at Undefined}}}
+\def\FV at KVProcess@FillColor#1#2\FV at Undefined{%
+  \ifx#1\color
+  \else
+    \expandafter\def\expandafter\@tempa\expandafter{%
+      \expandafter\color\expandafter{\@tempa}}%
+  \fi
+  \let\FancyVerbFillColor\@tempa}
+\fvset{fillcolor=none}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+%
+%
 % \subsection{Extensions}
 %
 %
@@ -1094,6 +1481,23 @@
 % \end{macro}
 %
 %
+% \begin{macro}{tabcolor}
+% Set tab color, or allow it to adjust to surroundings (the default \fancyvrb\ behavior).  This involves re-creating the |showtabs| option to add |\FV at TabColor|.
+%    \begin{macrocode}
+\define at key{FV}{tabcolor}%
+ {\ifstrempty{#1}%
+   {\let\FV at TabColor\relax}%
+   {\ifstrequal{#1}{none}%
+     {\let\FV at TabColor\relax}%
+     {\def\FV at TabColor{\textcolor{#1}}}}}
+\define at booleankey{FV}{showtabs}%
+ {\def\FV at TabChar{\FV at TabColor{\FancyVerbTab}}}%
+ {\let\FV at TabChar\relax}
+\fvset{tabcolor=none, showtabs=false}
+%    \end{macrocode}
+% \end{macro}
+%
+%
 % \begin{macro}{space}
 % Redefine |\FancyVerbSpace|.
 %    \begin{macrocode}
@@ -1102,6 +1506,23 @@
 % \end{macro}
 %
 %
+% \begin{macro}{spacecolor}
+% Set space color, or allow it to adjust to surroundings (the default \fancyvrb\ behavior).  This involves re-creating the |showspaces| option to add |\FV at SpaceColor|.
+%    \begin{macrocode}
+\define at key{FV}{spacecolor}%
+ {\ifstrempty{#1}%
+   {\let\FV at SpaceColor\relax}%
+   {\ifstrequal{#1}{none}%
+     {\let\FV at SpaceColor\relax}%
+     {\def\FV at SpaceColor{\textcolor{#1}}}}}
+\define at booleankey{FV}{showspaces}%
+ {\def\FV at Space{\FV at SpaceColor{\FancyVerbSpace}}}%
+ {\def\FV at Space{\ }}
+\fvset{spacecolor=none, showspaces=false}
+%    \end{macrocode}
+% \end{macro}
+%
+%
 % \begin{macro}{mathescape}
 % Give |$|, |^|, and |_| their normal catcodes to allow normal typeset math.
 %    \begin{macrocode}
@@ -1108,19 +1529,41 @@
 \define at booleankey{FV}{mathescape}%
  {\let\FancyVerbMathEscape\FV at MathEscape}%
  {\let\FancyVerbMathEscape\relax}
+\def\FV at MathEscape{\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}
 \FV at AddToHook\FV at CatCodesHook\FancyVerbMathEscape
-\def\FV at MathEscape{\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}
 \fvset{mathescape=false}
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \subsubsection{\texttt{\textbackslash FancyVerbFormatLine} and \texttt{\textbackslash FancyVerbFormatText}}
+% \begin{macro}{curlyquotes}
+% Let \texttt{\textasciigrave} and \texttt{\textquotesingle} produce curly quotation marks \texttt{`} and \texttt{'} rather than the backtick and typewriter single quotation mark produced by default via \pkg{upquote}.
+%    \begin{macrocode}
+\newbool{FV at CurlyQuotes}
+\define at booleankey{FV}{curlyquotes}%
+ {\booltrue{FV at CurlyQuotes}}%
+ {\boolfalse{FV at CurlyQuotes}}
+\def\FancyVerbCurlyQuotes{%
+  \ifbool{FV at CurlyQuotes}%
+   {\expandafter\def\expandafter\@noligs\expandafter{\@noligs
+      \begingroup\lccode`\~=`\`\lowercase{\endgroup\def~}{`}%
+      \begingroup\lccode`\~=`\'\lowercase{\endgroup\def~}{'}}}%
+   {}}
+\g at addto@macro\FV at FormattingPrepHook{\FancyVerbCurlyQuotes}
+\fvset{curlyquotes=false}
+%    \end{macrocode}
+% \end{macro}
 % 
+%
+%
+% \subsubsection{Formatting with \texttt{\textbackslash FancyVerbFormatLine}, \texttt{\textbackslash FancyVerbFormatText}, and \texttt{\textbackslash FancyVerbHighlightLine}}
+% 
 % \fancyvrb\ defines |\FancyVerbFormatLine|, which defines the formatting for each line. The introduction of line breaks introduces an issue for |\FancyVerbFormatLine|.  Does it format the entire line, including any whitespace in the margins or behind line break symbols (that is, is it outside the |\parbox| in which the entire line is wrapped when breaking is active)?  Or does it only format the text part of the line, only affecting the actual characters (inside the |\parbox|)?  Since both might be desirable, |\FancyVerbFormatLine| is assigned to the entire line, and a new macro |\FancyVerbFormatText| is assigned to the text, within the |\parbox|.
 %
 % An additional complication is that the \fancyvrb\ documentation says that the default value is |\def\FancyVerbFormatLine#1{#1}|.  But the actual default is |\def\FancyVerbFormatLine#1{\FV at ObeyTabs{#1}}|.  That is, |\FV at ObeyTabs| needs to operate directly on the line to handle tabs.  As a result, \emph{all} \fancyvrb\ commands that involve |\FancyVerbFormatLine| are patched, so that |\def\FancyVerbFormatLine#1{#1}|.
 %
+% An additional macro |\FancyVerbHighlightLine| is added between |\FancyVerbFormatLine| and |\FancyVerbFormatText|.  This is used to highlight selected lines (\cref{sec:impl:extensions:highlighting}).  It is inside |\FancyVerbHighlightLine| so that if |\FancyVerbHighlightLine| is used to provide a background color, |\FancyVerbHighlightLine| can override it.
+%
 % \begin{macro}{\FancyVerbFormatLine}
 % Format the entire line, following the definition given in the \fancyvrb\ documentation.  Because this is formatting the entire line, using boxes works with line breaking.
 %    \begin{macrocode}
@@ -1146,7 +1589,9 @@
     \hbox to \linewidth{%
       \FV at LeftListNumber
       \FV at LeftListFrame
-      \FancyVerbFormatLine{\FV at ObeyTabs{\FancyVerbFormatText{#1}}}\hss
+      \FancyVerbFormatLine{%
+        \FancyVerbHighlightLine{%
+          \FV at ObeyTabs{\FancyVerbFormatText{#1}}}}\hss
       \FV at RightListFrame
       \FV at RightListNumber}%
     \hss}}
@@ -1157,7 +1602,10 @@
 % \begin{macro}{\FV at BProcessLine}
 % Redefined |\FV at BProcessLine| in which |\FancyVerbFormatText| is added and tab handling is explicit.
 %    \begin{macrocode}
-\def\FV at BProcessLine#1{\hbox{\FancyVerbFormatLine{\FV at ObeyTabs{\FancyVerbFormatText{#1}}}}}
+\def\FV at BProcessLine#1{%
+  \hbox{\FancyVerbFormatLine{%
+    \FancyVerbHighlightLine{%
+      \FV at ObeyTabs{\FancyVerbFormatText{#1}}}}}}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1383,7 +1831,172 @@
 %
 %
 %
+% \subsubsection{Line highlighting or emphasis}
+% \label{sec:impl:extensions:highlighting}
 %
+% This adds an option |highlightlines| that allows specific lines, or lines within a range, to be highlighted or otherwise emphasized.
+%
+% \begin{macro}{highlightlines}\begin{macro}{\FV at HighlightLinesList}
+%    \begin{macrocode}
+\define at key{FV}{highlightlines}{\def\FV at HighlightLinesList{#1}}%
+\fvset{highlightlines=}
+%    \end{macrocode}
+% \end{macro}\end{macro}
+%
+% \begin{macro}{highlightcolor}\begin{macro}{\FV at HighlightColor}
+% Define color for highlighting.  The default is LightCyan.  A good alternative for a brighter color would be LemonChiffon.
+%    \begin{macrocode}
+\define at key{FV}{highlightcolor}{\def\FancyVerbHighlightColor{#1}}%
+\let\FancyVerbHighlightColor\@empty
+\ifcsname definecolor\endcsname
+\ifx\definecolor\relax
+\else
+  \definecolor{FancyVerbHighlightColor}{HTML}{E0FFFF}
+  \fvset{highlightcolor=FancyVerbHighlightColor}
+\fi\fi
+\AtBeginDocument{%
+  \ifx\FancyVerbHighlightColor\@empty
+    \ifcsname definecolor\endcsname
+    \ifx\definecolor\relax
+    \else
+    \definecolor{FancyVerbHighlightColor}{rgb}{0,1,1}
+    \fvset{highlightcolor=FancyVerbHighlightColor}
+    \fi\fi
+  \fi}
+%    \end{macrocode}
+% \end{macro}\end{macro}
+%
+%
+% \begin{macro}{\FancyVerbHighlightLine}
+% This is the entry macro into line highlighting.  By default it should do nothing.  It is always invoked between |\FancyVerbFormatLine| and |\FancyVerbFormatText|, so that it can provide a background color (won't interfere with line breaking) and can override any formatting provided by |\FancyVerbFormatLine|.  It is |\let| to |\FV at HighlightLine| when highlighting is active.
+%    \begin{macrocode}
+\def\FancyVerbHighlightLine#1{#1}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\FV at HighlightLine}
+% This determines whether highlighting should be performed, and if so, which macro should be invoked.
+%    \begin{macrocode}
+\def\FV at HighlightLine#1{%
+  \@tempcnta=\c at FancyVerbLine
+  \@tempcntb=\c at FancyVerbLine
+  \ifcsname FV at HighlightLine:\number\@tempcnta\endcsname
+    \advance\@tempcntb\m at ne
+    \ifcsname FV at HighlightLine:\number\@tempcntb\endcsname
+      \advance\@tempcntb\tw@
+      \ifcsname FV at HighlightLine:\number\@tempcntb\endcsname
+        \let\FV at HighlightLine@Next\FancyVerbHighlightLineMiddle
+      \else
+        \let\FV at HighlightLine@Next\FancyVerbHighlightLineLast
+      \fi
+    \else
+      \advance\@tempcntb\tw@
+      \ifcsname FV at HighlightLine:\number\@tempcntb\endcsname
+        \let\FV at HighlightLine@Next\FancyVerbHighlightLineFirst
+      \else
+        \let\FV at HighlightLine@Next\FancyVerbHighlightLineSingle
+      \fi
+    \fi
+  \else
+    \let\FV at HighlightLine@Next\FancyVerbHighlightLineNormal
+  \fi
+  \FV at HighlightLine@Next{#1}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FancyVerbHighlightLineNormal}
+% A normal line that is not highlighted or otherwise emphasized.  This could be redefined to de-emphasize the line.
+%    \begin{macrocode}
+\def\FancyVerbHighlightLineNormal#1{#1}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FV at TmpLength}
+%    \begin{macrocode}
+\newlength{\FV at TmpLength}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FancyVerbHighlightLineFirst}
+% The first line in a multi-line range.
+%
+% |\fboxsep| is set to zero so as to avoid indenting the line or changing inter-line spacing.  It is restored to its original value inside to prevent any undesired effects.  The |\strut| is needed to get the highlighting to be the appropriate height.  The |\rlap| and |\hspace| make the |\colorbox| expand to the full |\linewidth|.  Note that if |\fboxsep| $\ne0$, then we would want to use |\dimexpr\linewidth-2\fboxsep| or add |\hspace{-2\fboxsep}| at the end.
+%
+% If this macro is customized so that the text cannot take up the full |\linewidth|, then adjustments may need to be made here or in the line breaking code to make sure that line breaking takes place at the appropriate location.
+%    \begin{macrocode}
+\def\FancyVerbHighlightLineFirst#1{%
+  \setlength{\FV at TmpLength}{\fboxsep}%
+  \setlength{\fboxsep}{0pt}%
+  \colorbox{\FancyVerbHighlightColor}{%
+    \setlength{\fboxsep}{\FV at TmpLength}%
+    \rlap{\strut#1}%
+    \hspace{\linewidth}}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FancyVerbHighlightLineMiddle}
+% A middle line in a multi-line range.
+%    \begin{macrocode}
+\let\FancyVerbHighlightLineMiddle\FancyVerbHighlightLineFirst
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FancyVerbHighlightLineLast}
+% The last line in a multi-line range.
+%    \begin{macrocode}
+\let\FancyVerbHighlightLineLast\FancyVerbHighlightLineFirst
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\FancyVerbHighlightLineSingle}
+% A single line not in a multi-line range.
+%    \begin{macrocode}
+\let\FancyVerbHighlightLineSingle\FancyVerbHighlightLineFirst
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\FV at HighlightLinesPrep}
+% Process the list of lines to highlight (if any).  A macro is created for each line to be highlighted.  During highlighting, a line is highlighted if the corresponding macro exists.  All of the macro creating is ultimately within the current environment group so it stays local.  |\FancyVerbHighlightLine| is |\let| to a version that will invoke the necessary logic.
+%    \begin{macrocode}
+\def\FV at HighlightLinesPrep{%
+  \ifx\FV at HighlightLinesList\@empty
+  \else
+    \let\FancyVerbHighlightLine\FV at HighlightLine
+    \expandafter\FV at HighlightLinesPrep@i
+  \fi}
+\def\FV at HighlightLinesPrep@i{%
+  \renewcommand{\do}[1]{%
+    \ifstrempty{##1}{}{\FV at HighlightLinesParse##1-\FV at Undefined}}%
+  \expandafter\docsvlist\expandafter{\FV at HighlightLinesList}}
+\def\FV at HighlightLinesParse#1-#2\FV at Undefined{%
+  \ifstrempty{#2}%
+   {\FV at HighlightLinesParse@Single{#1}}%
+   {\FV at HighlightLinesParse@Range{#1}#2\relax}}
+\def\FV at HighlightLinesParse@Single#1{%
+  \expandafter\let\csname FV at HighlightLine:\detokenize{#1}\endcsname\relax}
+\newcounter{FV at HighlightLinesStart}
+\newcounter{FV at HighlightLinesStop}
+\def\FV at HighlightLinesParse@Range#1#2-{%
+  \setcounter{FV at HighlightLinesStart}{#1}%
+  \setcounter{FV at HighlightLinesStop}{#2}%
+  \stepcounter{FV at HighlightLinesStop}%
+  \FV at HighlightLinesParse@Range at Loop}
+\def\FV at HighlightLinesParse@Range at Loop{%
+  \ifnum\value{FV at HighlightLinesStart}<\value{FV at HighlightLinesStop}\relax
+    \expandafter\let\csname FV at HighlightLine:\arabic{FV at HighlightLinesStart}\endcsname\relax
+    \stepcounter{FV at HighlightLinesStart}%
+    \expandafter\FV at HighlightLinesParse@Range at Loop
+  \fi}
+\g at addto@macro\FV at FormattingPrepHook{\FV at HighlightLinesPrep}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+%
+%
 % \subsection{Line breaking}
 %
 % The following code adds automatic line breaking functionality to \pkg{fancyvrb}'s |Verbatim| environment.  Automatic breaks may be inserted after spaces, or before or after specified characters.  Breaking before or after specified characters involves scanning each line token by token to insert |\discretionary| at all potential break locations.
@@ -1584,6 +2197,8 @@
 % We need a way to break before characters if and only if they have been specified as breaking characters.  It would be possible to do that via a nested conditional, but that would be messy.  It is much simpler to create an empty macro whose name contains the character, and test for the existence of this macro.  This needs to be done inside a |\begingroup...\endgroup| so that the macros do not have to be cleaned up manually.  A good place to do this is in |\FV at FormattingPrep|, which is inside a group and before processing starts.  The macro is added to |\FV at FormattingPrepHook|, which contains \fvextra\ exntensions to |\FV at FormattingPrep|, after |\FV at BreakAfterPrep| is defined below.
 %
 % The procedure here is a bit roundabout.  We need to use |\FV at EscChars| to handle character escapes, but the character redefinitions need to be kept local, requiring that we work within a |\begingroup...\endgroup|.  So we loop through the breaking tokens and assemble a macro that will itself define character macros.  Only this defining macro is declared global, and it contains \emph{expanded} characters so that there is no longer any dependence on |\FV at EscChars|.
+%
+% A pdfTeX-compatible version for working with UTF-8 is defined later, and |\FV at BreakBeforePrep| is |\let| to it under pdfTeX as necessary.
 %    \begin{macrocode}
 \def\FV at BreakBeforePrep{%
   \ifx\FV at BreakBefore\@empty\relax
@@ -1640,6 +2255,8 @@
 %
 % \begin{macro}{\FV at BreakAfterPrep}
 % This is the |breakafter| equivalent of |\FV at BreakBeforePrep|.  It is also used within |\FV at FormattingPrep|.  The order of |\FV at BreakBeforePrep| and |\FV at BreakAfterPrep| is important; |\FV at BreakAfterPrep| must always be second, because it checks for conflicts with |breakbefore|.
+%
+% A pdfTeX-compatible version for working with UTF-8 is defined later, and |\FV at BreakAfterPrep| is |\let| to it under pdfTeX as necessary.
 %    \begin{macrocode}
 \def\FV at BreakAfterPrep{%
   \ifx\FV at BreakAfter\@empty\relax
@@ -1666,7 +2283,6 @@
              {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}%
              {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}%
            {}}%
-      \else
       \fi
       \g at addto@macro\FV at BreakAfter@Def{%
         \@namedef{FV at BreakAfter@Token\detokenize{##1}}{}}%
@@ -1680,9 +2296,22 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% Now that |\FV at BreakBeforePrep| and |\FV at BreakAfterPrep| are defined, add them to |\FV at FormattingPrepHook|, which is the \fvextra\ extension to |\FV at FormattingPrep|.  The ordering here is important, since |\FV at BreakAfterPrep| contains compatibility checks with |\FV at BreakBeforePrep|, and thus must be used after it.
+% Now that |\FV at BreakBeforePrep| and |\FV at BreakAfterPrep| are defined, add them to |\FV at FormattingPrepHook|, which is the \fvextra\ extension to |\FV at FormattingPrep|.  The ordering here is important, since |\FV at BreakAfterPrep| contains compatibility checks with |\FV at BreakBeforePrep|, and thus must be used after it.  Also, we have to check for the pdfTeX engine with \pkg{inputenc} using UTF-8, and use the |UTF| macros instead when that is the case.
 %    \begin{macrocode}
-\g at addto@macro\FV at FormattingPrepHook{\FV at BreakBeforePrep\FV at BreakAfterPrep}
+\g at addto@macro\FV at FormattingPrepHook{%
+  \ifcsname pdfmatch\endcsname
+  \ifx\pdfmatch\relax
+  \else
+    \ifcsname inputencodingname\endcsname
+    \ifx\inputencodingname\relax
+    \else
+      \ifdefstring{\inputencodingname}{utf8}%
+       {\let\FV at BreakBeforePrep\FV at BreakBeforePrep@UTF
+        \let\FV at BreakAfterPrep\FV at BreakAfterPrep@UTF}%
+       {}%
+    \fi\fi
+  \fi\fi
+  \FV at BreakBeforePrep\FV at BreakAfterPrep}
 %    \end{macrocode}
 %
 %
@@ -1815,12 +2444,12 @@
   \ifx\FV at NextChar\FV at Undefined\relax
     \let\FV at Next=\relax
   \else
-    \expandafter\ifx\FV at NextChar\FV at Space\relax
-      \g at addto@macro{\FV at LineIndentChars}{\FV at Space}%
+    \ifx\FV at NextChar\FV at Space@ifx\relax
+      \g at addto@macro{\FV at LineIndentChars}{\FV at Space@ifx}%
       \let\FV at Next=\FV at GetLineIndent
     \else
-      \expandafter\ifx\FV at NextChar\FV at Tab\relax
-        \g at addto@macro{\FV at LineIndentChars}{\FV at Tab}%
+      \ifx\FV at NextChar\FV at Tab@ifx\relax
+        \g at addto@macro{\FV at LineIndentChars}{\FV at Tab@ifx}%
         \let\FV at Next=\FV at GetLineIndent
       \else
         \let\FV at Next=\FV at CleanRemainingChars
@@ -1835,46 +2464,18 @@
 %
 % \paragraph{Tab expansion}\hfill\\
 %
-% \noindent The \fancyvrb\ option |obeytabs| uses a clever algorithm involving boxing and unboxing to expand tabs based on tab stops rather than a fixed number of equivalent space characters.  (See the definitions of |\FV@@ObeyTabs| and |\FV at TrueTab|.)  Unfortunately, since this involves |\hbox|, it interferes with the line breaking algorithm, and an alternative is required.
+% \noindent The \fancyvrb\ option |obeytabs| uses a clever algorithm involving boxing and unboxing to expand tabs based on tab stops rather than a fixed number of equivalent space characters.  (See the definitions of |\FV@@ObeyTabs| and |\FV at TrueTab| in \cref{sec:patch:obeytabs}.)  Unfortunately, since this involves |\hbox|, it interferes with the line breaking algorithm, and an alternative is required.
 %
-% There are probably many ways tab expansion could be performed while still allowing line breaks.  The current approach has been chosen because it is relatively straightforward and yields identical results to the case without line breaks.  Line breaking involves saving a line in a box, and determining whether the box is too wide.  During this process, if |obeytabs=true|, |\FV at TrueTab| is |\let| to a version that saves the width of every tab in a macro.  When a line is broken, all tabs within it will then use another variant of |\FV at TrueTab| that sequentially retrieves the saved widths.  This maintains the exact behavior of the case without line breaks.
+% There are probably many ways tab expansion could be performed while still allowing line breaks.  The current approach has been chosen because it is relatively straightforward and yields identical results to the case without line breaks.  Line breaking involves saving a line in a box, and determining whether the box is too wide.  During this process, if |obeytabs=true|, |\FV at TrueTabSaveWidth|, which is inside |\FV at TrueTab|, is |\let| to a version that saves the width of every tab in a macro.  When a line is broken, all tabs within it will then use a variant of |\FV at TrueTab| that sequentially retrieves the saved widths.  This maintains the exact behavior of the case without line breaks.
 %
-% Note that the variants of |\FV at TrueTab| are based on the \fvextra\ patched version of |\FV at TrueTab|, not on the original |\FV at TrueTab| defined in \fancyvrb.
+% Note that the special version of |\FV at TrueTab| is based on the \fvextra\ patched version of |\FV at TrueTab|, not on the original |\FV at TrueTab| defined in \fancyvrb.
 %
 %
-% \begin{macro}{FV at TrueTabCounter}
-% Counter for tabs, for creating uniquely named macros containing tab widths.
-%    \begin{macrocode}
-\newcounter{FV at TrueTabCounter}
-%    \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\FV at TrueTab@SaveWidths}
-% Version of |\FV at TrueTab| that also saves the width of each tab in sequentially numbered macros.
-%    \begin{macrocode}
-\def\FV at TrueTab@SaveWidths{%
-  \egroup
-  \@tempdima=\FV at ObeyTabSize sp\relax
-  \@tempcnta=\wd\FV at TabBox
-  \advance\@tempcnta\FV@@ObeyTabSize\relax
-  \divide\@tempcnta\@tempdima
-  \multiply\@tempdima\@tempcnta
-  \advance\@tempdima-\wd\FV at TabBox
-  \expandafter\xdef\csname FV at TrueTab@Width\arabic{FV at TrueTabCounter}\endcsname{%
-    \number\@tempdima}%
-  \stepcounter{FV at TrueTabCounter}%
-  \setbox\FV at TabBox=\hbox\bgroup
-    \unhbox\FV at TabBox\hbox to\@tempdima{\hss\FV at TabChar}}
-%    \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\FV at TrueTab@UseWidths}
+% \begin{macro}{\FV at TrueTab@UseWidth}
 % Version of |\FV at TrueTab| that uses pre-computed tab widths.
 %    \begin{macrocode}
-\def\FV at TrueTab@UseWidths{%
-  \@tempdima=\csname FV at TrueTab@Width\arabic{FV at TrueTabCounter}\endcsname sp\relax
+\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}}
 %    \end{macrocode}
@@ -1888,10 +2489,29 @@
 %
 % \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).
+%
+% 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.  When swapping for the |UTF| macros, it is important to make sure that pdfTeX is indeed in use, that \pkg{inputenc} is indeed in use, and that the current encoding is UTF-8.  The checks take into account the possibility of an errant |\ifx| test creating a previously non-existent macro and then |\let|ting it to |\relax|.
 %    \begin{macrocode}
 \def\FV at Break{%
   \def\FV at TmpLine{}%
   \let\FV at LastToken=\FV at Undefined
+  \ifcsname pdfmatch\endcsname
+  \ifx\pdfmatch\relax
+  \else
+    \ifcsname inputencodingname\endcsname
+    \ifx\inputencodingname\relax
+    \else
+      \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}%
+       {}%
+    \fi\fi
+  \fi\fi
   \FV at Break@Scan
 }
 %    \end{macrocode}
@@ -2036,7 +2656,7 @@
   \expandafter\FV at Break@AfterTokenBreak\FV at RescanToken}
 \def\FV at Break@AfterTokenBreak#1{%
   \let\FV at LastToken=#1%
-  \@ifnextchar\FV at Space%
+  \@ifnextchar\FV at Space@ifx%
    {\g at addto@macro{\FV at TmpLine}{#1}\FV at Break@Scan}%
    {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
      {\ifx\@let at token#1\relax
@@ -2070,6 +2690,320 @@
 % \end{macro}
 %
 %
+% \paragraph{Line scanning and break insertion macros for pdfTeX with UTF-8}\hfill\\
+% The macros above work with the XeTeX and LuaTeX engines and are also fine for pdfTeX with 8-bit character encodings.  Unfortunately, pdfTeX works with multi-byte UTF-8 code points at the byte level, making things significantly trickier.  The code below re-implements the macros in a manner compatible with the \pkg{inputenc} package with option |utf8|.  Note that there is no attempt for compatibility with |utf8x|; |utf8| has been significantly improved in recent years and should be sufficient in the vast majority of cases.  And implementing variants for |utf8| was already sufficiently painful.
+%
+% All of the |UTF| macros are only needed with pdfTeX, so they are created conditionally, inspired by the approach of the \pkg{iftex} package.  The pdfTeX test deals with the possibility that a previous test using |\ifx| rather than the cleaner |\ifcsname| has already been performed.
+%    \begin{macrocode}
+\ifcsname pdfmatch\endcsname
+\ifx\pdfmatch\relax
+\else
+%    \end{macrocode}
+%
+%
+% \begin{macro}{\FV at UTF@two at octets}%
+% \begin{macro}{\FV at UTF@three at octets}%
+% \begin{macro}{\FV at UTF@four at octets}
+% These are variants of the |utf8.def| macros that capture all bytes of a multi-byte code point and then pass them on as a single argument for further processing.  The current |\FV at Break| (or other invoking macro) will have |\let| |\FV at Break@NextNext| to an appropriate macro that performs further processing.  All code points are checked for validity here so as to raise errors as early as possible.  Otherwise an invalid terminal byte sequence might gobble |\FV at EndBreak|, |\FV at Undefined|, or another delimiting macro, potentially making debugging much more difficult.  It would be possible to use |\UTFviii at defined{|\meta{bytes}|}| to trigger an error directly, but the current approach is to attempt to typeset invalid code points, which should trigger errors without relying on the details of the |utf8.def| implementation.
+%    \begin{macrocode}
+\def\FV at UTF@two at octets#1#2{%
+  \ifcsname u8:\detokenize{#1#2}\endcsname
+  \else
+    #1#2%
+  \fi
+  \FV at Break@NextNext{#1#2}}
+\def\FV at UTF@three at octets#1#2#3{%
+  \ifcsname u8:\detokenize{#1#2#3}\endcsname
+  \else
+    #1#2#3%
+  \fi
+  \FV at Break@NextNext{#1#2#3}}
+\def\FV at UTF@four at octets#1#2#3#4{%
+  \ifcsname u8:\detokenize{#1#2#3#4}\endcsname
+  \else
+    #1#2#3#4%
+  \fi
+  \FV at Break@NextNext{#1#2#3#4}}
+%    \end{macrocode}
+% \end{macro}\end{macro}\end{macro}
+%
+% \begin{macro}{\FV at U8:<byte>}
+% Define macros for each active byte.  These are used for determining whether the current token is the first byte in a multi-byte sequence, and if so, invoking the necessary macro to capture the remaining bytes.  The code is adapted from the beginning of |utf8.def|.  Completely capitalized macro names are used to avoid having to worry about |\uppercase|.
+%    \begin{macrocode}
+\begingroup
+\catcode`\~=13
+\catcode`\"=12
+\def\FV at UTFviii@loop{%
+  \uccode`\~\count@
+  \uppercase\expandafter{\FV at UTFviii@Tmp}%
+  \advance\count@\@ne
+  \ifnum\count@<\@tempcnta
+  \expandafter\FV at UTFviii@loop
+  \fi}
+%    \end{macrocode}
+% Setting up 2-byte UTF-8:
+%    \begin{macrocode}
+\count@"C2
+\@tempcnta"E0
+\def\FV at UTFviii@Tmp{\expandafter\gdef\csname FV at U8:\string~\endcsname{%
+  \FV at UTF@two at octets}}
+\FV at UTFviii@loop
+%    \end{macrocode}
+% Setting up 3-byte UTF-8:
+%    \begin{macrocode}
+\count@"E0
+\@tempcnta"F0
+\def\FV at UTFviii@Tmp{\expandafter\gdef\csname FV at U8:\string~\endcsname{%
+  \FV at UTF@three at octets}}
+\FV at UTFviii@loop
+%    \end{macrocode}
+% Setting up 4-byte UTF-8:
+%    \begin{macrocode}
+\count@"F0
+\@tempcnta"F4
+\def\FV at UTFviii@Tmp{\expandafter\gdef\csname FV at U8:\string~\endcsname{%
+  \FV at UTF@four at octets}}
+\FV at UTFviii@loop
+\endgroup
+%    \end{macrocode}
+% \end{macro}
+%
+%
+%
+% \begin{macro}{\FV at BreakBeforePrep@UTF}
+% We need |UTF| variants of the |breakbefore| and |breakafter| prep macros.  These are only ever used with \pkg{inputenc} with UTF-8.  There is no need for encoding checks here; checks are performed in |\FV at FormattingPrepHook| (checks are inserted into it after the non-|UTF| macro definitions).
+%    \begin{macrocode}
+\def\FV at BreakBeforePrep@UTF{%
+  \ifx\FV at BreakBefore\@empty\relax
+  \else
+    \gdef\FV at BreakBefore@Def{}%
+    \begingroup
+    \def\FV at BreakBefore@Process##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 Break@NextNext\FV at BreakBefore@Process at ii
+      \else
+        \ifx##1\FV at Undefined
+          \let\FV at Break@Next\@gobble
+        \else
+          \let\FV at Break@Next\FV at BreakBefore@Process at i
+        \fi
+      \fi
+      \FV at Break@Next##1%
+    }%
+    \def\FV at BreakBefore@Process at i##1{%
+      \expandafter\FV at BreakBefore@Process at ii\expandafter{##1}}%
+    \def\FV at BreakBefore@Process at ii##1{%
+      \g at addto@macro\FV at BreakBefore@Def{%
+        \@namedef{FV at BreakBefore@Token\detokenize{##1}}{}}%
+      \FV at BreakBefore@Process
+    }%
+    \FV at EscChars
+    \expandafter\FV at BreakBefore@Process\FV at BreakBefore\FV at Undefined
+    \endgroup
+    \FV at BreakBefore@Def
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\FV at BreakAfterPrep@UTF}
+%    \begin{macrocode}
+\def\FV at BreakAfterPrep@UTF{%
+  \ifx\FV at BreakAfter\@empty\relax
+  \else
+    \gdef\FV at BreakAfter@Def{}%
+    \begingroup
+    \def\FV at BreakAfter@Process##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 Break@NextNext\FV at BreakAfter@Process at ii
+      \else
+        \ifx##1\FV at Undefined
+          \let\FV at Break@Next\@gobble
+        \else
+          \let\FV at Break@Next\FV at BreakAfter@Process at i
+        \fi
+      \fi
+      \FV at Break@Next##1%
+    }%
+    \def\FV at BreakAfter@Process at i##1{%
+      \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}}%
+           {}%
+           {\PackageError{fvextra}%
+            {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}%
+            {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}}%
+         {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
+           {\PackageError{fvextra}%
+             {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}%
+             {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}%
+           {}}%
+      \fi
+      \g at addto@macro\FV at BreakAfter@Def{%
+        \@namedef{FV at BreakAfter@Token\detokenize{##1}}{}}%
+      \FV at BreakAfter@Process
+    }%
+    \FV at EscChars
+    \expandafter\FV at BreakAfter@Process\FV at BreakAfter\FV at Undefined
+    \endgroup
+    \FV at BreakAfter@Def
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+%
+% \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.
+%    \begin{macrocode}
+\def\FV at Break@AnyToken at UTF#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 Break@NextNext\FV at Break@AnyToken at UTF@i
+  \else
+    \let\FV at Break@Next\FV at Break@AnyToken at UTF@i
+  \fi
+  \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 Break@Scan}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+%
+% \begin{macro}{\FV at Break@BeforeAfterToken at UTF}
+% Due to the way that the flow works, |#1| will sometimes be a single byte and sometimes be a multi-byte UTF-8 code point.  As a result, it is vital use use |\detokenize| in the UTF-8 leading byte checks; |\string| would only deal with the first byte.  It is also important to keep track of the distinction between |\FV at Break@Next#1| and |\FV at Break@Next{#1}|.  In some cases, a multi-byte sequence is being passed on as a single argument, so it must be enclosed in curly braces; in other cases, it is being re-inserted into the scanning stream and curly braces must be avoided lest they be interpreted as part of the original text.
+%    \begin{macrocode}
+\def\FV at Break@BeforeAfterToken at UTF#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 Break@NextNext\FV at Break@BeforeAfterToken at UTF@i
+  \else
+    \let\FV at Break@Next\FV at Break@BeforeAfterToken at UTF@i
+  \fi
+  \FV at Break@Next{#1}%
+}
+\def\FV at Break@BeforeAfterToken at UTF@i#1{%
+  \ifcsname FV at BreakBefore@Token\detokenize{#1}\endcsname
+    \let\FV at Break@Next\FV at Break@BeforeTokenBreak at UTF
+  \else
+    \ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
+      \let\FV at Break@Next\FV at Break@AfterTokenBreak at UTF
+    \else
+      \let\FV at Break@Next\FV at Break@BeforeAfterTokenNoBreak at UTF
+    \fi
+  \fi
+  \FV at Break@Next{#1}%
+}
+\def\FV at Break@BeforeAfterTokenNoBreak at UTF#1{%
+  \g at addto@macro{\FV at TmpLine}{#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}}%
+   {\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}%
+        \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}%
+        \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
+    \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}}
+\def\FV at Break@AfterTokenBreak at UTF#1{%
+  \def\FV at LastToken{#1}%
+  \@ifnextchar\FV at Space@ifx%
+   {\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}%
+      \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{%
+  \ifcsname FV at U8:\detokenize{#1}\endcsname
+    \expandafter\let\expandafter\FV at Break@Next\csname FV at U8:\detokenize{#1}\endcsname
+    \let\FV at Break@NextNext\FV at Break@AfterTokenBreak at UTF@i
+  \else
+    \def\FV at NextToken{#1}%
+    \ifx\FV at LastToken\FV at NextToken
+    \else
+      \g at addto@macro{\FV at TmpLine}{\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{%
+  \ifcsname FV at U8:\detokenize{#1}\endcsname
+    \expandafter\let\expandafter\FV at Break@Next\csname FV at U8:\detokenize{#1}\endcsname
+    \let\FV at Break@NextNext\FV at Break@AfterTokenBreak at Group@UTF at ii
+  \else
+    \def\FV at NextToken{#1}%
+    \ifx\FV at LastToken\FV at NextToken
+    \else
+      \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakAfterBreak}%
+    \fi
+    \let\FV at Break@Next\FV at Break@Scan
+  \fi
+  \FV at Break@Next#1}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% End the conditional creation of the pdfTeX |UTF| macros:
+%    \begin{macrocode}
+\fi\fi
+%    \end{macrocode}
+%
+%
+%
 % \paragraph{Line processing before scanning}
 %
 % \begin{macro}{\FV at makeLineNumber}
@@ -2151,17 +3085,20 @@
     \advance\linewidth by -\FV at FrameRule
   \fi
   \ifx\FV at Tab\FV at TrueTab
-    \let\FV at Tab\FV at TrueTab@SaveWidths
+    \let\FV at TrueTabSaveWidth\FV at TrueTabSaveWidth@Save
     \setcounter{FV at TrueTabCounter}{0}%
   \fi
-  \sbox{\FV at LineBox}{\FancyVerbFormatLine{\FV at ObeyTabs{\FancyVerbFormatText{#1}}}}%
-  \ifx\FV at Tab\FV at TrueTab@SaveWidths
-     \let\FV at Tab\FV at TrueTab
+  \sbox{\FV at LineBox}{%
+    \FancyVerbFormatLine{%
+      %\FancyVerbHighlightLine  %<-- Default definition using \rlap breaks breaking
+       {\FV at ObeyTabs{\FancyVerbFormatText{#1}}}}}%
+  \ifx\FV at Tab\FV at TrueTab
+    \let\FV at TrueTabSaveWidth\relax
   \fi
   \ifdim\wd\FV at LineBox>\linewidth
     \setcounter{FancyVerbLineBreakLast}{0}%
     \ifx\FV at Tab\FV at TrueTab
-      \let\FV at Tab\FV at TrueTab@UseWidths
+      \let\FV at Tab\FV at TrueTab@UseWidth
       \setcounter{FV at TrueTabCounter}{0}%
     \fi
     \FV at SaveLineBox{#1}%
@@ -2171,10 +3108,11 @@
       \FV at SaveLineBox{#1}}%
     \FV at LeftListNumber
     \FV at LeftListFrame
-    \FancyVerbFormatLine{\usebox{\FV at LineBox}}%
+    \FancyVerbFormatLine{%
+      \FancyVerbHighlightLine{\usebox{\FV at LineBox}}}%
     \FV at RightListFrame
     \FV at RightListNumber
-    \ifx\FV at Tab\FV at TrueTab@UseWidths
+    \ifx\FV at Tab\FV at TrueTab@UseWidth
       \let\FV at Tab\FV at TrueTab
     \fi
   \else
@@ -2181,7 +3119,9 @@
     \FV at LeftListNumber
     \FV at LeftListFrame
     \FancyVerbFormatLine{%
-      \parbox[t]{\linewidth}{\noindent\strut\FV at ObeyTabs{\FancyVerbFormatText{#1}}\strut}}%
+      \FancyVerbHighlightLine{%
+        \parbox[t]{\linewidth}{%
+          \noindent\strut\FV at ObeyTabs{\FancyVerbFormatText{#1}}\strut}}}%
     \FV at RightListFrame
     \FV at RightListNumber
   \fi}%

Modified: trunk/Master/texmf-dist/tex/latex/fvextra/fvextra.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/fvextra/fvextra.sty	2016-07-14 21:40:33 UTC (rev 41696)
+++ trunk/Master/texmf-dist/tex/latex/fvextra/fvextra.sty	2016-07-14 21:40:44 UTC (rev 41697)
@@ -20,7 +20,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{fvextra}
-    [2016/06/28 v1.0 fvextra - extensions and patches for fancyvrb]
+    [2016/07/14 v1.1 fvextra - extensions and patches for fancyvrb]
 \RequirePackage{ifthen}
 \RequirePackage{etoolbox}
 \RequirePackage{fancyvrb}
@@ -35,14 +35,8 @@
 \@ifpackageloaded{csquotes}%
  {\PackageWarning{fvextra}{csquotes should be loaded after fvextra, %
   to avoid a warning from the lineno package}}{}
-\@ifpackageloaded{minted}%
- {\PackageError{fvextra}%
-   {fvextra must be loaded before minted}%
-   {fvextra must be loaded before minted}}
-\@ifpackageloaded{pythontex}%
- {\PackageError{fvextra}%
-   {fvextra must be loaded before pythontex}%
-   {fvextra must be loaded before pythontex}}
+\def\FV at Space@ifx{\FV at Space}
+\def\FV at Tab@ifx{\FV at Tab}
 \let\FV at FormattingPrepHook\@empty
 \expandafter\def\expandafter\FV at FormattingPrep\expandafter{%
   \expandafter\FV at FormattingPrepHook\FV at FormattingPrep}
@@ -68,7 +62,27 @@
   \let\]\FV at rightsquarebracket
 } %$ <- highlighting
 \def\FancyVerbSpace{\textvisiblespace}
+\newcounter{FV at TrueTabGroupLevel}
+\def\FV@@ObeyTabs#1{%
+  \let\FV at Space@Orig\FV at Space
+  \let\FV at Space\FV at Space@ObeyTabs
+  \setcounter{FV at TrueTabGroupLevel}{\the\currentgrouplevel}%
+  \addtocounter{FV at TrueTabGroupLevel}{1}%
+  \setbox\FV at TabBox=\hbox{#1}\box\FV at TabBox
+  \let\FV at Space\FV at Space@Orig}
 \def\FV at TrueTab{%
+  \ifnum\value{FV at TrueTabGroupLevel}=\the\currentgrouplevel\relax
+    \expandafter\FV at TrueTab@NoGroup
+  \else
+    \expandafter\FV at TrueTab@Group
+  \fi}
+\let\FV at TrueTabSaveWidth\relax
+\newcounter{FV at TrueTabCounter}
+\def\FV at TrueTabSaveWidth@Save{%
+  \expandafter\xdef\csname FV at TrueTab:Width\arabic{FV at TrueTabCounter}\endcsname{%
+    \number\@tempdima}%
+  \stepcounter{FV at TrueTabCounter}}
+\def\FV at TrueTab@NoGroup{%
   \egroup
   \@tempdima=\FV at ObeyTabSize sp\relax
   \@tempcnta=\wd\FV at TabBox
@@ -76,8 +90,62 @@
   \divide\@tempcnta\@tempdima
   \multiply\@tempdima\@tempcnta
   \advance\@tempdima-\wd\FV at TabBox
+  \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}
+\def\FV at TrueTab@Group{%
+  \booltrue{FV at ObeyTabs@Whitespace at Tab}%
+  \gdef\FV at TmpWhitespace{\FV at Tab@ifx}%
+  \FV at ObeyTabs@ScanWhitespace}
+\def\FV at Space@ObeyTabs{%
+  \ifnum\value{FV at TrueTabGroupLevel}=\the\currentgrouplevel\relax
+    \expandafter\FV at Space@ObeyTabs at NoGroup
+  \else
+    \expandafter\FV at Space@ObeyTabs at Group
+  \fi}
+\def\FV at Space@ObeyTabs at NoGroup{\FV at Space@Orig}
+\def\FV at Space@ObeyTabs at Group{%
+  \boolfalse{FV at ObeyTabs@Whitespace at Tab}%
+  \gdef\FV at TmpWhitespace{\FV at Space@ifx}%
+  \FV at ObeyTabs@ScanWhitespace}
+\def\FV at ObeyTabs@ScanWhitespace{%
+  \@ifnextchar\FV at Space@ifx%
+   {\FV at TrueTab@CaptureWhitespace at Space}%
+   {\ifx\@let at token\FV at Tab@ifx
+      \expandafter\FV at TrueTab@CaptureWhitespace at Tab
+    \else
+      \expandafter\FV at ObeyTabs@ResolveWhitespace
+    \fi}}
+\def\FV at TrueTab@CaptureWhitespace at Space#1{%
+  \g at addto@macro\FV at TmpWhitespace{\FV at Space@ifx}%
+  \FV at ObeyTabs@ScanWhitespace}
+\def\FV at TrueTab@CaptureWhitespace at Tab#1{%
+  \booltrue{FV at ObeyTabs@Whitespace at Tab}%
+  \g at addto@macro\FV at TmpWhitespace{\FV at Tab@ifx}%
+  \FV at ObeyTabs@ScanWhitespace}
+\newbox\FV at TabBox@Group
+\def\FV at TrueTab@Group at Expand{%
+  \egroup
+  \@tempdima=\FV at ObeyTabSize sp\relax
+  \@tempcnta=\wd\FV at TabBox@Group
+  \advance\@tempcnta\FV@@ObeyTabSize\relax
+  \divide\@tempcnta\@tempdima
+  \multiply\@tempdima\@tempcnta
+  \advance\@tempdima-\wd\FV at TabBox@Group
+  \FV at TrueTabSaveWidth
+  \setbox\FV at TabBox@Group=\hbox\bgroup
+    \unhbox\FV at TabBox@Group\hbox to\@tempdima{\hss\FV at TabChar}}
+\def\FV at ObeyTabs@ResolveWhitespace{%
+  \let\FV at Space\FV at Space@Orig
+  \let\FV at Tab\FV at TrueTab@Group at Expand
+  \expandafter\FV at ObeyTabs@ResolveWhitespace at i\expandafter{\FV at TmpWhitespace}%
+  \let\FV at Space\FV at Space@ObeyTabs
+  \let\FV at Tab\FV at TrueTab}
+\def\FV at ObeyTabs@ResolveWhitespace at i#1{%
+  \ifbool{FV at ObeyTabs@Whitespace at Tab}%
+   {\setbox\FV at TabBox@Group=\hbox{#1}\box\FV at TabBox@Group}%
+   {#1}}
 \def\FancyVerbMathSpace{ }
 \def\FV at SetupMathSpace{%
   \everymath\expandafter{\the\everymath\let\FV at Space\FancyVerbMathSpace}}
@@ -122,16 +190,78 @@
   \kern\FV at FrameSep\relax
   \penalty\@M
   \endgroup}
+\define at key{FV}{rulecolor}{%
+  \ifstrempty{#1}%
+   {\let\FancyVerbRuleColor\relax}%
+   {\ifstrequal{#1}{none}%
+     {\let\FancyVerbRuleColor\relax}%
+     {\def\@tempa{#1}%
+      \FV at KVProcess@RuleColor#1\FV at Undefined}}}
+\def\FV at KVProcess@RuleColor#1#2\FV at Undefined{%
+  \ifx#1\color
+  \else
+    \expandafter\def\expandafter\@tempa\expandafter{%
+      \expandafter\color\expandafter{\@tempa}}%
+  \fi
+  \let\FancyVerbRuleColor\@tempa}
+\fvset{rulecolor=none}
+\define at key{FV}{fillcolor}{%
+  \ifstrempty{#1}%
+   {\let\FancyVerbFillColor\relax}%
+   {\ifstrequal{#1}{none}%
+     {\let\FancyVerbFillColor\relax}%
+     {\def\@tempa{#1}%
+      \FV at KVProcess@FillColor#1\FV at Undefined}}}
+\def\FV at KVProcess@FillColor#1#2\FV at Undefined{%
+  \ifx#1\color
+  \else
+    \expandafter\def\expandafter\@tempa\expandafter{%
+      \expandafter\color\expandafter{\@tempa}}%
+  \fi
+  \let\FancyVerbFillColor\@tempa}
+\fvset{fillcolor=none}
 \define at booleankey{FV}{linenos}%
   {\@nameuse{FV at Numbers@left}}{\@nameuse{FV at Numbers@none}}
 \define at key{FV}{tab}{\def\FancyVerbTab{#1}}
+\define at key{FV}{tabcolor}%
+ {\ifstrempty{#1}%
+   {\let\FV at TabColor\relax}%
+   {\ifstrequal{#1}{none}%
+     {\let\FV at TabColor\relax}%
+     {\def\FV at TabColor{\textcolor{#1}}}}}
+\define at booleankey{FV}{showtabs}%
+ {\def\FV at TabChar{\FV at TabColor{\FancyVerbTab}}}%
+ {\let\FV at TabChar\relax}
+\fvset{tabcolor=none, showtabs=false}
 \define at key{FV}{space}{\def\FancyVerbSpace{#1}}
+\define at key{FV}{spacecolor}%
+ {\ifstrempty{#1}%
+   {\let\FV at SpaceColor\relax}%
+   {\ifstrequal{#1}{none}%
+     {\let\FV at SpaceColor\relax}%
+     {\def\FV at SpaceColor{\textcolor{#1}}}}}
+\define at booleankey{FV}{showspaces}%
+ {\def\FV at Space{\FV at SpaceColor{\FancyVerbSpace}}}%
+ {\def\FV at Space{\ }}
+\fvset{spacecolor=none, showspaces=false}
 \define at booleankey{FV}{mathescape}%
  {\let\FancyVerbMathEscape\FV at MathEscape}%
  {\let\FancyVerbMathEscape\relax}
+\def\FV at MathEscape{\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}
 \FV at AddToHook\FV at CatCodesHook\FancyVerbMathEscape
-\def\FV at MathEscape{\catcode`\$=3\catcode`\^=7\catcode`\_=8\relax}
 \fvset{mathescape=false}
+\newbool{FV at CurlyQuotes}
+\define at booleankey{FV}{curlyquotes}%
+ {\booltrue{FV at CurlyQuotes}}%
+ {\boolfalse{FV at CurlyQuotes}}
+\def\FancyVerbCurlyQuotes{%
+  \ifbool{FV at CurlyQuotes}%
+   {\expandafter\def\expandafter\@noligs\expandafter{\@noligs
+      \begingroup\lccode`\~=`\`\lowercase{\endgroup\def~}{`}%
+      \begingroup\lccode`\~=`\'\lowercase{\endgroup\def~}{'}}}%
+   {}}
+\g at addto@macro\FV at FormattingPrepHook{\FancyVerbCurlyQuotes}
+\fvset{curlyquotes=false}
 \def\FancyVerbFormatLine#1{#1}
 \def\FancyVerbFormatText#1{#1}
 \def\FV at ListProcessLine@NoBreak#1{%
@@ -140,11 +270,16 @@
     \hbox to \linewidth{%
       \FV at LeftListNumber
       \FV at LeftListFrame
-      \FancyVerbFormatLine{\FV at ObeyTabs{\FancyVerbFormatText{#1}}}\hss
+      \FancyVerbFormatLine{%
+        \FancyVerbHighlightLine{%
+          \FV at ObeyTabs{\FancyVerbFormatText{#1}}}}\hss
       \FV at RightListFrame
       \FV at RightListNumber}%
     \hss}}
-\def\FV at BProcessLine#1{\hbox{\FancyVerbFormatLine{\FV at ObeyTabs{\FancyVerbFormatText{#1}}}}}
+\def\FV at BProcessLine#1{%
+  \hbox{\FancyVerbFormatLine{%
+    \FancyVerbHighlightLine{%
+      \FV at ObeyTabs{\FancyVerbFormatText{#1}}}}}}
 \newbool{FV at NumberFirstLine}
 \define at booleankey{FV}{numberfirstline}%
  {\booltrue{FV at NumberFirstLine}}%
@@ -308,6 +443,93 @@
         \fi}{}%
     \fi}%
 }
+\define at key{FV}{highlightlines}{\def\FV at HighlightLinesList{#1}}%
+\fvset{highlightlines=}
+\define at key{FV}{highlightcolor}{\def\FancyVerbHighlightColor{#1}}%
+\let\FancyVerbHighlightColor\@empty
+\ifcsname definecolor\endcsname
+\ifx\definecolor\relax
+\else
+  \definecolor{FancyVerbHighlightColor}{HTML}{E0FFFF}
+  \fvset{highlightcolor=FancyVerbHighlightColor}
+\fi\fi
+\AtBeginDocument{%
+  \ifx\FancyVerbHighlightColor\@empty
+    \ifcsname definecolor\endcsname
+    \ifx\definecolor\relax
+    \else
+    \definecolor{FancyVerbHighlightColor}{rgb}{0,1,1}
+    \fvset{highlightcolor=FancyVerbHighlightColor}
+    \fi\fi
+  \fi}
+\def\FancyVerbHighlightLine#1{#1}
+\def\FV at HighlightLine#1{%
+  \@tempcnta=\c at FancyVerbLine
+  \@tempcntb=\c at FancyVerbLine
+  \ifcsname FV at HighlightLine:\number\@tempcnta\endcsname
+    \advance\@tempcntb\m at ne
+    \ifcsname FV at HighlightLine:\number\@tempcntb\endcsname
+      \advance\@tempcntb\tw@
+      \ifcsname FV at HighlightLine:\number\@tempcntb\endcsname
+        \let\FV at HighlightLine@Next\FancyVerbHighlightLineMiddle
+      \else
+        \let\FV at HighlightLine@Next\FancyVerbHighlightLineLast
+      \fi
+    \else
+      \advance\@tempcntb\tw@
+      \ifcsname FV at HighlightLine:\number\@tempcntb\endcsname
+        \let\FV at HighlightLine@Next\FancyVerbHighlightLineFirst
+      \else
+        \let\FV at HighlightLine@Next\FancyVerbHighlightLineSingle
+      \fi
+    \fi
+  \else
+    \let\FV at HighlightLine@Next\FancyVerbHighlightLineNormal
+  \fi
+  \FV at HighlightLine@Next{#1}%
+}
+\def\FancyVerbHighlightLineNormal#1{#1}
+\newlength{\FV at TmpLength}
+\def\FancyVerbHighlightLineFirst#1{%
+  \setlength{\FV at TmpLength}{\fboxsep}%
+  \setlength{\fboxsep}{0pt}%
+  \colorbox{\FancyVerbHighlightColor}{%
+    \setlength{\fboxsep}{\FV at TmpLength}%
+    \rlap{\strut#1}%
+    \hspace{\linewidth}}}
+\let\FancyVerbHighlightLineMiddle\FancyVerbHighlightLineFirst
+\let\FancyVerbHighlightLineLast\FancyVerbHighlightLineFirst
+\let\FancyVerbHighlightLineSingle\FancyVerbHighlightLineFirst
+\def\FV at HighlightLinesPrep{%
+  \ifx\FV at HighlightLinesList\@empty
+  \else
+    \let\FancyVerbHighlightLine\FV at HighlightLine
+    \expandafter\FV at HighlightLinesPrep@i
+  \fi}
+\def\FV at HighlightLinesPrep@i{%
+  \renewcommand{\do}[1]{%
+    \ifstrempty{##1}{}{\FV at HighlightLinesParse##1-\FV at Undefined}}%
+  \expandafter\docsvlist\expandafter{\FV at HighlightLinesList}}
+\def\FV at HighlightLinesParse#1-#2\FV at Undefined{%
+  \ifstrempty{#2}%
+   {\FV at HighlightLinesParse@Single{#1}}%
+   {\FV at HighlightLinesParse@Range{#1}#2\relax}}
+\def\FV at HighlightLinesParse@Single#1{%
+  \expandafter\let\csname FV at HighlightLine:\detokenize{#1}\endcsname\relax}
+\newcounter{FV at HighlightLinesStart}
+\newcounter{FV at HighlightLinesStop}
+\def\FV at HighlightLinesParse@Range#1#2-{%
+  \setcounter{FV at HighlightLinesStart}{#1}%
+  \setcounter{FV at HighlightLinesStop}{#2}%
+  \stepcounter{FV at HighlightLinesStop}%
+  \FV at HighlightLinesParse@Range at Loop}
+\def\FV at HighlightLinesParse@Range at Loop{%
+  \ifnum\value{FV at HighlightLinesStart}<\value{FV at HighlightLinesStop}\relax
+    \expandafter\let\csname FV at HighlightLine:\arabic{FV at HighlightLinesStart}\endcsname\relax
+    \stepcounter{FV at HighlightLinesStart}%
+    \expandafter\FV at HighlightLinesParse@Range at Loop
+  \fi}
+\g at addto@macro\FV at FormattingPrepHook{\FV at HighlightLinesPrep}
 \newboolean{FV at BreakLines}
 \define at booleankey{FV}{breaklines}%
   {\FV at BreakLinestrue
@@ -440,7 +662,6 @@
              {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}%
              {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}%
            {}}%
-      \else
       \fi
       \g at addto@macro\FV at BreakAfter@Def{%
         \@namedef{FV at BreakAfter@Token\detokenize{##1}}{}}%
@@ -451,7 +672,20 @@
     \FV at BreakAfter@Def
   \fi
 }
-\g at addto@macro\FV at FormattingPrepHook{\FV at BreakBeforePrep\FV at BreakAfterPrep}
+\g at addto@macro\FV at FormattingPrepHook{%
+  \ifcsname pdfmatch\endcsname
+  \ifx\pdfmatch\relax
+  \else
+    \ifcsname inputencodingname\endcsname
+    \ifx\inputencodingname\relax
+    \else
+      \ifdefstring{\inputencodingname}{utf8}%
+       {\let\FV at BreakBeforePrep\FV at BreakBeforePrep@UTF
+        \let\FV at BreakAfterPrep\FV at BreakAfterPrep@UTF}%
+       {}%
+    \fi\fi
+  \fi\fi
+  \FV at BreakBeforePrep\FV at BreakAfterPrep}
 \define at key{FV}{breakanywheresymbolpre}{%
   \ifstrempty{#1}%
     {\def\FancyVerbBreakAnywhereSymbolPre{}}%
@@ -500,12 +734,12 @@
   \ifx\FV at NextChar\FV at Undefined\relax
     \let\FV at Next=\relax
   \else
-    \expandafter\ifx\FV at NextChar\FV at Space\relax
-      \g at addto@macro{\FV at LineIndentChars}{\FV at Space}%
+    \ifx\FV at NextChar\FV at Space@ifx\relax
+      \g at addto@macro{\FV at LineIndentChars}{\FV at Space@ifx}%
       \let\FV at Next=\FV at GetLineIndent
     \else
-      \expandafter\ifx\FV at NextChar\FV at Tab\relax
-        \g at addto@macro{\FV at LineIndentChars}{\FV at Tab}%
+      \ifx\FV at NextChar\FV at Tab@ifx\relax
+        \g at addto@macro{\FV at LineIndentChars}{\FV at Tab@ifx}%
         \let\FV at Next=\FV at GetLineIndent
       \else
         \let\FV at Next=\FV at CleanRemainingChars
@@ -514,27 +748,30 @@
   \fi
   \FV at Next
 }
-\newcounter{FV at TrueTabCounter}
-\def\FV at TrueTab@SaveWidths{%
-  \egroup
-  \@tempdima=\FV at ObeyTabSize sp\relax
-  \@tempcnta=\wd\FV at TabBox
-  \advance\@tempcnta\FV@@ObeyTabSize\relax
-  \divide\@tempcnta\@tempdima
-  \multiply\@tempdima\@tempcnta
-  \advance\@tempdima-\wd\FV at TabBox
-  \expandafter\xdef\csname FV at TrueTab@Width\arabic{FV at TrueTabCounter}\endcsname{%
-    \number\@tempdima}%
+\def\FV at TrueTab@UseWidth{%
+  \@tempdima=\csname FV at TrueTab:Width\arabic{FV at TrueTabCounter}\endcsname sp\relax
   \stepcounter{FV at TrueTabCounter}%
-  \setbox\FV at TabBox=\hbox\bgroup
-    \unhbox\FV at TabBox\hbox to\@tempdima{\hss\FV at TabChar}}
-\def\FV at TrueTab@UseWidths{%
-  \@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{}%
   \let\FV at LastToken=\FV at Undefined
+  \ifcsname pdfmatch\endcsname
+  \ifx\pdfmatch\relax
+  \else
+    \ifcsname inputencodingname\endcsname
+    \ifx\inputencodingname\relax
+    \else
+      \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}%
+       {}%
+    \fi\fi
+  \fi\fi
   \FV at Break@Scan
 }
 \def\FV at EndBreak{\FV at TmpLine}
@@ -621,7 +858,7 @@
   \expandafter\FV at Break@AfterTokenBreak\FV at RescanToken}
 \def\FV at Break@AfterTokenBreak#1{%
   \let\FV at LastToken=#1%
-  \@ifnextchar\FV at Space%
+  \@ifnextchar\FV at Space@ifx%
    {\g at addto@macro{\FV at TmpLine}{#1}\FV at Break@Scan}%
    {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
      {\ifx\@let at token#1\relax
@@ -651,6 +888,252 @@
    {\FV at Break@Scan}%
    {\g at addto@macro{\FV at TmpLine}{\FancyVerbBreakAfterBreak}%
     \FV at Break@Scan}}
+\ifcsname pdfmatch\endcsname
+\ifx\pdfmatch\relax
+\else
+\def\FV at UTF@two at octets#1#2{%
+  \ifcsname u8:\detokenize{#1#2}\endcsname
+  \else
+    #1#2%
+  \fi
+  \FV at Break@NextNext{#1#2}}
+\def\FV at UTF@three at octets#1#2#3{%
+  \ifcsname u8:\detokenize{#1#2#3}\endcsname
+  \else
+    #1#2#3%
+  \fi
+  \FV at Break@NextNext{#1#2#3}}
+\def\FV at UTF@four at octets#1#2#3#4{%
+  \ifcsname u8:\detokenize{#1#2#3#4}\endcsname
+  \else
+    #1#2#3#4%
+  \fi
+  \FV at Break@NextNext{#1#2#3#4}}
+\begingroup
+\catcode`\~=13
+\catcode`\"=12
+\def\FV at UTFviii@loop{%
+  \uccode`\~\count@
+  \uppercase\expandafter{\FV at UTFviii@Tmp}%
+  \advance\count@\@ne
+  \ifnum\count@<\@tempcnta
+  \expandafter\FV at UTFviii@loop
+  \fi}
+\count@"C2
+\@tempcnta"E0
+\def\FV at UTFviii@Tmp{\expandafter\gdef\csname FV at U8:\string~\endcsname{%
+  \FV at UTF@two at octets}}
+\FV at UTFviii@loop
+\count@"E0
+\@tempcnta"F0
+\def\FV at UTFviii@Tmp{\expandafter\gdef\csname FV at U8:\string~\endcsname{%
+  \FV at UTF@three at octets}}
+\FV at UTFviii@loop
+\count@"F0
+\@tempcnta"F4
+\def\FV at UTFviii@Tmp{\expandafter\gdef\csname FV at U8:\string~\endcsname{%
+  \FV at UTF@four at octets}}
+\FV at UTFviii@loop
+\endgroup
+\def\FV at BreakBeforePrep@UTF{%
+  \ifx\FV at BreakBefore\@empty\relax
+  \else
+    \gdef\FV at BreakBefore@Def{}%
+    \begingroup
+    \def\FV at BreakBefore@Process##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 Break@NextNext\FV at BreakBefore@Process at ii
+      \else
+        \ifx##1\FV at Undefined
+          \let\FV at Break@Next\@gobble
+        \else
+          \let\FV at Break@Next\FV at BreakBefore@Process at i
+        \fi
+      \fi
+      \FV at Break@Next##1%
+    }%
+    \def\FV at BreakBefore@Process at i##1{%
+      \expandafter\FV at BreakBefore@Process at ii\expandafter{##1}}%
+    \def\FV at BreakBefore@Process at ii##1{%
+      \g at addto@macro\FV at BreakBefore@Def{%
+        \@namedef{FV at BreakBefore@Token\detokenize{##1}}{}}%
+      \FV at BreakBefore@Process
+    }%
+    \FV at EscChars
+    \expandafter\FV at BreakBefore@Process\FV at BreakBefore\FV at Undefined
+    \endgroup
+    \FV at BreakBefore@Def
+  \fi
+}
+\def\FV at BreakAfterPrep@UTF{%
+  \ifx\FV at BreakAfter\@empty\relax
+  \else
+    \gdef\FV at BreakAfter@Def{}%
+    \begingroup
+    \def\FV at BreakAfter@Process##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 Break@NextNext\FV at BreakAfter@Process at ii
+      \else
+        \ifx##1\FV at Undefined
+          \let\FV at Break@Next\@gobble
+        \else
+          \let\FV at Break@Next\FV at BreakAfter@Process at i
+        \fi
+      \fi
+      \FV at Break@Next##1%
+    }%
+    \def\FV at BreakAfter@Process at i##1{%
+      \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}}%
+           {}%
+           {\PackageError{fvextra}%
+            {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}%
+            {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}}%
+         {\ifthenelse{\boolean{FV at BreakAfterGroup}}%
+           {\PackageError{fvextra}%
+             {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}%
+             {Conflicting breakbeforegroup and breakaftergroup for "\detokenize{##1}"}}%
+           {}}%
+      \fi
+      \g at addto@macro\FV at BreakAfter@Def{%
+        \@namedef{FV at BreakAfter@Token\detokenize{##1}}{}}%
+      \FV at BreakAfter@Process
+    }%
+    \FV at EscChars
+    \expandafter\FV at BreakAfter@Process\FV at BreakAfter\FV at Undefined
+    \endgroup
+    \FV at BreakAfter@Def
+  \fi
+}
+\def\FV at Break@AnyToken at UTF#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 Break@NextNext\FV at Break@AnyToken at UTF@i
+  \else
+    \let\FV at Break@Next\FV at Break@AnyToken at UTF@i
+  \fi
+  \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 Break@Scan}
+\def\FV at Break@BeforeAfterToken at UTF#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 Break@NextNext\FV at Break@BeforeAfterToken at UTF@i
+  \else
+    \let\FV at Break@Next\FV at Break@BeforeAfterToken at UTF@i
+  \fi
+  \FV at Break@Next{#1}%
+}
+\def\FV at Break@BeforeAfterToken at UTF@i#1{%
+  \ifcsname FV at BreakBefore@Token\detokenize{#1}\endcsname
+    \let\FV at Break@Next\FV at Break@BeforeTokenBreak at UTF
+  \else
+    \ifcsname FV at BreakAfter@Token\detokenize{#1}\endcsname
+      \let\FV at Break@Next\FV at Break@AfterTokenBreak at UTF
+    \else
+      \let\FV at Break@Next\FV at Break@BeforeAfterTokenNoBreak at UTF
+    \fi
+  \fi
+  \FV at Break@Next{#1}%
+}
+\def\FV at Break@BeforeAfterTokenNoBreak at UTF#1{%
+  \g at addto@macro{\FV at TmpLine}{#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}}%
+   {\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}%
+        \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}%
+        \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
+    \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}}
+\def\FV at Break@AfterTokenBreak at UTF#1{%
+  \def\FV at LastToken{#1}%
+  \@ifnextchar\FV at Space@ifx%
+   {\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}%
+      \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{%
+  \ifcsname FV at U8:\detokenize{#1}\endcsname
+    \expandafter\let\expandafter\FV at Break@Next\csname FV at U8:\detokenize{#1}\endcsname
+    \let\FV at Break@NextNext\FV at Break@AfterTokenBreak at UTF@i
+  \else
+    \def\FV at NextToken{#1}%
+    \ifx\FV at LastToken\FV at NextToken
+    \else
+      \g at addto@macro{\FV at TmpLine}{\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{%
+  \ifcsname FV at U8:\detokenize{#1}\endcsname
+    \expandafter\let\expandafter\FV at Break@Next\csname FV at U8:\detokenize{#1}\endcsname
+    \let\FV at Break@NextNext\FV at Break@AfterTokenBreak at Group@UTF at ii
+  \else
+    \def\FV at NextToken{#1}%
+    \ifx\FV at LastToken\FV at NextToken
+    \else
+      \g at addto@macro{\FV at TmpLine}{\FancyVerbBreakAfterBreak}%
+    \fi
+    \let\FV at Break@Next\FV at Break@Scan
+  \fi
+  \FV at Break@Next#1}
+\fi\fi
 \def\FV at makeLineNumber{%
   \hss
   \FancyVerbBreakSymbolLeftLogic{\FancyVerbBreakSymbolLeft}%
@@ -710,17 +1193,20 @@
     \advance\linewidth by -\FV at FrameRule
   \fi
   \ifx\FV at Tab\FV at TrueTab
-    \let\FV at Tab\FV at TrueTab@SaveWidths
+    \let\FV at TrueTabSaveWidth\FV at TrueTabSaveWidth@Save
     \setcounter{FV at TrueTabCounter}{0}%
   \fi
-  \sbox{\FV at LineBox}{\FancyVerbFormatLine{\FV at ObeyTabs{\FancyVerbFormatText{#1}}}}%
-  \ifx\FV at Tab\FV at TrueTab@SaveWidths
-     \let\FV at Tab\FV at TrueTab
+  \sbox{\FV at LineBox}{%
+    \FancyVerbFormatLine{%
+      %\FancyVerbHighlightLine  %<-- Default definition using \rlap breaks breaking
+       {\FV at ObeyTabs{\FancyVerbFormatText{#1}}}}}%
+  \ifx\FV at Tab\FV at TrueTab
+    \let\FV at TrueTabSaveWidth\relax
   \fi
   \ifdim\wd\FV at LineBox>\linewidth
     \setcounter{FancyVerbLineBreakLast}{0}%
     \ifx\FV at Tab\FV at TrueTab
-      \let\FV at Tab\FV at TrueTab@UseWidths
+      \let\FV at Tab\FV at TrueTab@UseWidth
       \setcounter{FV at TrueTabCounter}{0}%
     \fi
     \FV at SaveLineBox{#1}%
@@ -730,10 +1216,11 @@
       \FV at SaveLineBox{#1}}%
     \FV at LeftListNumber
     \FV at LeftListFrame
-    \FancyVerbFormatLine{\usebox{\FV at LineBox}}%
+    \FancyVerbFormatLine{%
+      \FancyVerbHighlightLine{\usebox{\FV at LineBox}}}%
     \FV at RightListFrame
     \FV at RightListNumber
-    \ifx\FV at Tab\FV at TrueTab@UseWidths
+    \ifx\FV at Tab\FV at TrueTab@UseWidth
       \let\FV at Tab\FV at TrueTab
     \fi
   \else
@@ -740,7 +1227,9 @@
     \FV at LeftListNumber
     \FV at LeftListFrame
     \FancyVerbFormatLine{%
-      \parbox[t]{\linewidth}{\noindent\strut\FV at ObeyTabs{\FancyVerbFormatText{#1}}\strut}}%
+      \FancyVerbHighlightLine{%
+        \parbox[t]{\linewidth}{%
+          \noindent\strut\FV at ObeyTabs{\FancyVerbFormatText{#1}}\strut}}}%
     \FV at RightListFrame
     \FV at RightListNumber
   \fi}%



More information about the tex-live-commits mailing list