texlive[73854] Master/texmf-dist: fvextra (10feb25)

commits+karl at tug.org commits+karl at tug.org
Mon Feb 10 21:19:35 CET 2025


Revision: 73854
          https://tug.org/svn/texlive?view=revision&revision=73854
Author:   karl
Date:     2025-02-10 21:19:34 +0100 (Mon, 10 Feb 2025)
Log Message:
-----------
fvextra (10feb25)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/fvextra/CHANGELOG.md
    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/CHANGELOG.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/fvextra/CHANGELOG.md	2025-02-10 20:19:24 UTC (rev 73853)
+++ trunk/Master/texmf-dist/doc/latex/fvextra/CHANGELOG.md	2025-02-10 20:19:34 UTC (rev 73854)
@@ -1,6 +1,42 @@
 # Changelog
 
 
+## v1.11.0 (2025/02/09)
+
+*  Added command `\InsertBuffer`.  This inserts an existing buffer created
+   with `VerbatimBuffer` so that it is interpreted as LaTeX.
+
+*  Added `\ClearBuffer` as an alias for `\VerbatimClearBuffer`.
+
+*  When `afterbuffer` is used with `VerbatimBuffer` or derived environments to
+   typeset the buffer, the typeset buffer may now contain `VerbatimBuffer` or
+   environments based on it.  Previously, nested buffering overwrote temp
+   macros and produced incorrect results.  Typically, nested buffering should
+   be avoided for a given buffer; a different buffer should be used at each
+   level of nesting.  The current buffer depth is now available in
+   `\FancyVerbBufferDepth`.
+
+*  Added option `backgroundcolorboxoverlap` and alias `bgcolorboxoverlap`.
+   When there is a background color for a block of text, this oversizes the
+   `\colorbox` behind each line by `backgroundcolorboxoverlap`, and then
+   slightly overlaps these boxes by the same amount.  Some PDF viewers and
+   browsers produce rendering artifacts with a background color.  These appear
+   in between lines of text as extremely thin horizontal rules that are the
+   color of the page behind the background.  `backgroundcolorboxoverlap`
+   eliminates rendering artifacts in most software that produces them, and
+   otherwise significantly reduces artifacts (gpoore/minted#429).
+
+*  Line breaking now works with very long lines (#28).  Previously, very long
+   lines could result in a "Dimension too large" error if they were longer
+   than `\maxdimen`, or no error and also no line breaking if they were so
+   long that the length overflowed and became negative.
+
+*  Renamed `\FV at bufferlengthname` to `\FancyVerbBufferLengthName`.  Added
+   documentation for `\FancyVerbBufferLengthName` and
+   `\FancyVerbBufferLineName`.
+
+
+
 ## v1.10.0 (2024/11/17)
 
 *  Replaced `FancyVerbBufferIndex` counter with `\FancyVerbBufferIndex` macro

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	2025-02-10 20:19:24 UTC (rev 73853)
+++ trunk/Master/texmf-dist/source/latex/fvextra/fvextra.dtx	2025-02-10 20:19:34 UTC (rev 73854)
@@ -26,7 +26,7 @@
 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
 %<package>\ProvidesPackage{fvextra}
 %<*package>
-    [2024/11/17 v1.10.0 fvextra - extensions and patches for fancyvrb]
+    [2025/02/09 v1.11.0 fvextra - extensions and patches for fancyvrb]
 %</package>
 %
 %<*driver>
@@ -371,11 +371,21 @@
 %
 % Background colors are implemented with |\colorbox|, which prevents line breaking for |\Verb|, |\UseVerb|, and |\EscVerb|.  Background colors are only compatible with \fvextra's reimplemented |\Verb| and |\UseVerb| (|extra=true|).
 %
+% When there is a background color in environments such as |Verbatim| that typeset blocks of text, some PDF readers and browsers can introduce rendering artifacts.  These appear in between lines of text as extremely thin horizontal rules that are the color of the page behind the background.  They tend to be more noticeable for dark background colors on a light page.  \fvextra\ attempts to prevent rendering artifacts by slightly oversizing the |\colorbox| behind each line and then slightly overlapping these boxes.  This overlap can be fine-tuned if necessary with |backgroundcolorboxoverlap|.  If rendering artifacts are an issue with your software in spite of a small overlap, consider \href{https://ctan.org/pkg/tcolorbox}{\pkg{tcolorbox}} or a similar package, or a custom background color implementation.
+%
 % See |backgroundcolorvphantom| to customize the height of the background for each line of text, especially for |\Verb|, |\EscVerb|, and |BVerbatim|.
 %
 % When |backgroundcolor| is used with |Verbatim| with a |frame|, it may be necessary to adjust |framesep| and |fillcolor| depending on the desired result.  |backgroundcolorpadding| provides a shortcut for this.
 %
 %
+% \item[backgroundcolorboxoverlap (length) (0.25pt)]
+% The amount by which |\colorbox|es that are used to provide |backgroundcolor| are oversized and then overlapped, to prevent rendering artifacts.
+%
+% When there is a background color in environments such as |Verbatim| that typeset blocks of text, some PDF readers and browsers can introduce rendering artifacts.  These appear in between lines of text as extremely thin horizontal rules that are the color of the page behind the background.  They tend to be more noticeable for dark background colors on a light page.  \fvextra\ attempts to prevent rendering artifacts by slightly oversizing the |\colorbox| behind each line by |backgroundcolorboxoverlap|, and then slightly overlapping these boxes by the same amount.
+%
+% Chrome and Adobe Acrobat Reader generally work correctly even with no overlap (|backgroundcolorboxoverlap=0pt|).  Many PDF previews in \TeX\ editing software and PDF readers need an overlap in the |0.1pt| to |0.15pt| range.  Whether Firefox needs overlap, and if so the amount needed, seems to depend on resolution and possibly operating system.  Safari and macOS Preview may show artifacts, particularly when zoomed out, even with overlaps of |0.25pt| or greater.
+%
+%
 % \item[backgroundcolorpadding (length) (none)]
 % Padding when |backgroundcolor| is set.  For |\Verb|, |\UseVerb|, |\EscVerb|, and |BVerbatim|, this sets |\fboxsep| for the |\colorbox| that is used to create the background color.  For |Verbatim|, \fancyvrb's frame options are used instead, particularly |framesep| and |fillcolor|.
 %
@@ -403,6 +413,9 @@
 % \item[bgcolor (string) (none)]
 % Alias for |backgroundcolor|.
 %
+% \item[bgcolorboxoverlap (length) (0.25pt)]
+% Alias for |backgroundcolorboxoverlap|.
+%
 % \item[bgcolorpadding (length) (none)]
 % Alias for |backgroundcolorpadding|.
 %
@@ -874,8 +887,12 @@
 %
 % \begin{optionlist}
 % \item[afterbuffer (macro) (\meta{none})]
-% Macro or macros invoked at the end of the environment, after all lines of the environment have been buffered.  This is outside the |\begingroup...\endgroup| that wraps verbatim processing, so \fancyvrb\ settings are no longer active.  However, the buffer line macros and the buffer length macro are still accessible.
+% Macro or macros invoked at the end of the environment, after all lines of the environment have been buffered.  This is outside the |\begingroup...\endgroup| that wraps verbatim processing, so \fancyvrb\ settings are no longer active.  However, the buffer line macros and the buffer length macro are still accessible even when |globalbuffer=false|.
 %
+% When |afterbuffer| is used to typeset the buffer, the typeset buffer may contain |VerbatimBuffer| or environments based on it.  Typically, nested buffering should be avoided for a given buffer; a different buffer should be used at each level of nesting.  Otherwise, for nested |VerbatimBuffer| environments, the buffer will contain the contents of the outermost |VerbatimBuffer| environment concatenated with the contents of nested environments.  
+%
+% The current buffer depth is available in |\FancyVerbBufferDepth|.  This has a value of |0| outside of any |VerbatimBuffer| environments, a value of |1| within the outermost |VerbatimBuffer| environment, and so forth.  This can be used to automatically generate a unique |buffername| at a given nesting depth.
+%
 % \item[bufferer (macro) (\Verb{\FancyVerbDefaultBufferer})]
 % This is the macro that adds lines to the buffer.  The default is designed to create a truly verbatim buffer via |\detokenize|.  This can be customized if you wish to use \fancyvrb\ options related to catcodes to create a buffer that is only partially verbatim (that contains macros).
 % \begin{Verbatim}[gobble=2, fontsize=\small]
@@ -892,6 +909,8 @@
 % \item[bufferlengthname (string) (FancyVerbBufferLength)]
 % Name of the macro storing the length of the buffer.  This is the number of lines stored.
 %
+% Macros that operate within a |VerbatimBuffer| environment can access the current value of |bufferlengthname| via |\FancyVerbBufferLengthName|.
+%
 % \item[bufferlinename (string) (FancyVerbBufferLine)]
 % The base name of the buffer line macros.  The default is |FancyVerbBufferLine|, which will result in buffer macros |\FancyVerbBufferLine<n>| with integer |n| greater than or equal to one and less than or equal to the number of lines (one-based indexing).  Since buffer macro names contain a number, they must be accessed differently than typical macros:
 % \begin{Verbatim}[gobble=2]
@@ -898,8 +917,10 @@
 % \csname FancyVerbBufferLine<n>\endcsname
 % \@nameuse{FancyVerbBufferLine<n>}
 % \end{Verbatim}
-% Typically the buffer macros will be looped over with a counter that is incremented, in which case |<n>| should be the counter value |\arabic{<counter>}|.
+% If the buffer macros are looped over with a counter that is incremented, then |<n>| should be the counter value |\arabic{<counter>}|.
 %
+% Macros that operate within a |VerbatimBuffer| environment can access the current value of |bufferlinename| via |\FancyVerbBufferLineName|.
+%
 % \item[buffername (string) (\meta{none})]
 % Shortcut for setting |bufferlengthname| and |bufferlinename| simultaneously, using the same root name.  This sets |bufferlengthname| to |<buffername>length| and |bufferlinename| to |<buffername>line|.
 %
@@ -936,8 +957,32 @@
 % Clear an existing buffer created with \cmd{VerbatimBuffer}.  |\global\let| all buffer line macros to an undefined macro and set the buffer length macro to zero.
 %
 %
+% \subsection{\cmd{\InsertBuffer}}
+% \DescribeMacro{\InsertBuffer\oarg{options}}
+% This inserts an existing buffer created with |VerbatimBuffer| so that it is interpreted as \LaTeX.  The result is essentially the same as if the buffered text had been included literally at the insertion point.
 %
+% Internally, this processes the buffer with |\scantokens|.  For typesetting verbatim text, |\VerbatimInsertBuffer| with the |insertenvname| option should typically be used instead of creating a buffer that begins/ends with a verbatim environment, and then using |\InsertBuffer| to typeset that buffer.  The implementation of |\VerbatimInsertBuffer| is significantly more efficient for purely verbatim content.
 %
+%\begin{tcblisting}{oversize=5em}
+%\begin{VerbatimBuffer}[buffername=ins, globalbuffer]
+%Text.  Math $f(x)$.  Verb \Verb|~#\{}|.
+%\begin{Verbatim}
+%Verbatim.  ~#\{}.
+%\end{Verbatim}
+%More text.
+%\end{VerbatimBuffer}
+%
+%\textbf{BEFORE}\InsertBuffer[buffername=ins]\textbf{AFTER}
+%\end{tcblisting}
+%
+%
+% \subsection{\cmd{\ClearBuffer}}
+% \DescribeMacro{\ClearBuffer\oarg{options}}
+% Alias for \cmd{\VerbatimClearBuffer}.
+%
+%
+%
+%
 % \section{Line breaking}
 % \label{sec:breaklines}
 %
@@ -4061,7 +4106,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{bufferlengthname, \FV at bufferlengthname}
+% \begin{macro}{bufferlengthname, \FancyVerbBufferLengthName}
 % Name of macro storing the length of the buffer.
 %    \begin{macrocode}
 \define at key{FV}{bufferlengthname}{%
@@ -4069,7 +4114,7 @@
   \else
     \expandafter\xdef\csname#1\endcsname{0}%
   \fi
-  \def\FV at bufferlengthname{#1}%
+  \def\FancyVerbBufferLengthName{#1}%
   \expandafter\def\expandafter\FV at bufferlengthmacro\expandafter{%
     \csname#1\endcsname}}
 \fvset{bufferlengthname=FancyVerbBufferLength}
@@ -4111,11 +4156,7 @@
 % A special buffer counter is used to track line numbers while avoiding incrementing the regular counter that is used for typeset code.  Some macros do nothing with the default |bufferer|, but are needed to enable \fancyvrb\ options when a custom |bufferer| is used in conjunction with optional environment arguments.  These include |\FancyVerbDefineActive| and |\FancyVerbFormatCom|.  Since counters are global, the exact location of the |\setcounter| commands at the end of the environment relative to |\begingroup...\endgroup| is not important.
 %    \begin{macrocode}
 \newcounter{FancyVerbBufferLine}
-\newbool{FV at globalbuffer@tmp}
-\let\FV at oldbufferlength\relax
-\let\FV at bufferlengthmacro@tmp\relax
-\let\FancyVerbBufferLineName at tmp\relax
-\let\FV at afterbuffer@tmp\relax
+\def\FancyVerbBufferDepth{0}
 \def\VerbatimBuffer{%
   \FV at Environment
    {codes=,commandchars=none,commentchar=none,defineactive,%
@@ -4123,6 +4164,7 @@
    {VerbatimBuffer}}
 \def\FVB at VerbatimBuffer{%
   \@bsphack
+  \xdef\FancyVerbBufferDepth{\the\numexpr\FancyVerbBufferDepth+1\relax}%
   \begingroup
   \FV at UseKeyValues
   \setcounter{FancyVerbBufferLine}{\FV at bufferlengthmacro}%
@@ -4129,12 +4171,22 @@
   \let\c at FancyVerbLine\c at FancyVerbBufferLine
   \xdef\FancyVerbBufferIndex{\FV at bufferlengthmacro}%
   \ifbool{FV at globalbuffer}%
-   {\global\booltrue{FV at globalbuffer@tmp}}%
-   {\global\boolfalse{FV at globalbuffer@tmp}%
-    \expandafter\global\expandafter\let\expandafter\FV at oldbufferlength\FV at bufferlengthmacro
-    \global\let\FV at bufferlengthmacro@tmp\FV at bufferlengthmacro
-    \global\let\FancyVerbBufferLineName at tmp\FancyVerbBufferLineName}%
-  \global\let\FV at afterbuffer@tmp\FV at afterbuffer
+   {}%
+   {\expandafter\xdef\csname FV at setbufferlocalscopevars\FancyVerbBufferDepth\endcsname{%
+      \unexpanded{\def\FV at oldbufferlength}%
+       {\FV at bufferlengthmacro}%
+      \unexpanded{\def\FV at bufferlengthmacro}%
+       {\unexpanded\expandafter{\FV at bufferlengthmacro}}%
+      \unexpanded{\def\FancyVerbBufferLineName}%
+       {\unexpanded\expandafter{\FancyVerbBufferLineName}}}}%
+  \ifx\FV at afterbuffer\@empty
+  \else
+    \ifx\FV at afterbuffer\relax
+    \else
+      \expandafter\global\expandafter
+        \let\csname FV at afterbuffer\FancyVerbBufferDepth\endcsname\FV at afterbuffer
+    \fi
+  \fi
   \FV at DefineWhiteSpace
   \def\FV at ProcessLine{%
     \xdef\FancyVerbBufferIndex{\the\numexpr\FancyVerbBufferIndex+1\relax}%
@@ -4149,22 +4201,27 @@
   \gdef\FancyVerbBufferIndex{0}%
   \endgroup
   \@esphack
-  \begingroup
-  \FV at afterbuffer@tmp
-  \global\let\FV at afterbuffer@tmp\relax
-  \endgroup
-  \ifbool{FV at globalbuffer@tmp}%
-   {}%
-   {\loop\unless\ifnum\FV at bufferlengthmacro@tmp=\FV at oldbufferlength\relax
-      \expandafter\global\expandafter\let\csname
-        \FancyVerbBufferLineName at tmp\FV at bufferlengthmacro@tmp
-        \endcsname\FV at Undefined
-      \expandafter\xdef\FV at bufferlengthmacro@tmp{%
-        \the\numexpr\FV at bufferlengthmacro@tmp-1\relax}%
+  \ifcsname FV at afterbuffer\FancyVerbBufferDepth\endcsname
+    \begingroup
+    \csname FV at afterbuffer\FancyVerbBufferDepth\endcsname
+    \endgroup
+    \expandafter\global\expandafter
+      \let\csname FV at afterbuffer\FancyVerbBufferDepth\endcsname\FV at Undefined
+  \fi
+  \ifcsname FV at setbufferlocalscopevars\FancyVerbBufferDepth\endcsname
+    \begingroup
+    \csname FV at setbufferlocalscopevars\FancyVerbBufferDepth\endcsname
+    \loop\unless\ifnum\FV at bufferlengthmacro=\FV at oldbufferlength\relax
+      \expandafter\global\expandafter
+        \let\csname\FancyVerbBufferLineName\FV at bufferlengthmacro\endcsname\FV at Undefined
+      \expandafter\xdef\FV at bufferlengthmacro{%
+        \the\numexpr\FV at bufferlengthmacro-1\relax}%
     \repeat
-    \global\let\FV at bufferlengthmacro@tmp\relax
-    \global\let\FancyVerbBufferLineName at tmp\relax}%
-  \global\let\FV at oldbufferlength\relax}
+    \endgroup
+    \expandafter\global\expandafter
+      \let\csname FV at setbufferlocalscopevars\FancyVerbBufferDepth\endcsname\FV at Undefined
+  \fi
+  \xdef\FancyVerbBufferDepth{\the\numexpr\FancyVerbBufferDepth-1\relax}}
 \def\endVerbatimBuffer{\FVE at VerbatimBuffer}
 %    \end{macrocode}
 % \end{macro}
@@ -4192,7 +4249,8 @@
   \xdef\FV at EnvironName{\FV at VerbatimInsertEnvName}%
   \ifnum\FV at bufferlengthmacro=\z@\relax
     \PackageError{fvextra}%
-     {Buffer length macro \expandafter\string\FV at bufferlengthmacro\space is invalid or zero}%
+     {Buffer length macro \expandafter\string\FV at bufferlengthmacro\space 
+      is invalid or zero}%
      {}%
     \let\FV at GetLine\relax
   \fi
@@ -4268,8 +4326,57 @@
 % \end{macro}
 %
 %
+% \subsubsection{\cmd{\InsertBuffer}}
+% \begin{macro}{\InsertBuffer}
+% This inserts an existing buffer created with |VerbatimBuffer| so that it is interpreted as \LaTeX.  The result is essentially the same as if the buffered text had been included literally at the insertion point.
+%    \begin{macrocode}
+\newcommand{\InsertBuffer}[1][]{%
+  \begingroup
+  \def\FV at KeyValues{#1}%
+  \FV at UseKeyValues
+  \global\let\FV at tmpbufferlengthmacro\FV at bufferlengthmacro
+  \global\let\FV at tmpbufferlinename\FancyVerbBufferLineName
+  \endgroup
+  \ifnum\FV at tmpbufferlengthmacro<1
+    \expandafter\@gobble
+  \else
+    \expandafter\@firstofone
+  \fi
+  \InsertBuffer at i}
+\def\InsertBuffer at i{%
+  \InsertBuffer at expandbuffer
+  \expandafter\InsertBuffer at cleanup\expandafter\scantokens\expandafter{%
+    \FV at expandedbuffer\unskip\noexpand}\relax}
+\def\InsertBuffer at expandbuffer{%
+  \edef\FV at expandedbuffer{\InsertBuffer at expandbufferlines{1}}}
+\def\InsertBuffer at expandbufferlines#1{%
+  \unexpanded\expandafter\expandafter\expandafter{%
+    \csname\FV at tmpbufferlinename#1\endcsname^^J}%
+  \ifnum\FV at tmpbufferlengthmacro=#1
+    \expandafter\@gobble
+  \else
+    \expandafter\@firstofone
+  \fi
+  {\expandafter\InsertBuffer at expandbufferlines\expandafter{\the\numexpr#1+1\relax}}}
+\def\InsertBuffer at cleanup{%
+  \global\let\FV at tmpbufferlengthmacro\FV at Undefined
+  \global\let\FV at tmpbufferlinename\FV at Undefined
+  \global\let\FV at expandedbuffer\FV at Undefined}
+%    \end{macrocode}
+% \end{macro}
 %
 %
+% \subsubsection{\cmd{\ClearBuffer}}
+% \begin{macro}{\ClearBuffer}
+% Clear an existing buffer.  Alias for |\VerbatimClearBuffer|.
+%    \begin{macrocode}
+\let\ClearBuffer\VerbatimClearBuffer
+%    \end{macrocode} 
+% \end{macro}
+%
+%
+%
+%
 % \subsection{Patches}
 % \label{sec:impl:patches}
 %
@@ -4925,7 +5032,7 @@
             \FV at ObeyTabs{\FancyVerbFormatText{#1}}}}}\hss
       \FV at RightListFrame
       \FV at RightListNumber}%
-    \hss}}
+    \hss}\FV at bgcoloroverlap}
 %    \end{macrocode}
 % \end{macro}
 %
@@ -5170,6 +5277,8 @@
 % \label{sec:impl:extensions:bgcolor}
 %
 % Define an option |backgroundcolor| that provides a basic implementation of a background color behind commands and environments.  \pkg{tcolorbox} or a similar package should be used for more sophisticated background colors.
+%
+% The patch to |\FV at List| prevents narrow horizontal gaps in the background color between lines of text under some circumstances.
 % \begin{macro}{backgroundcolor,bgcolor,\FancyVerbBackgroundColor}
 %    \begin{macrocode}
 \define at key{FV}{backgroundcolor}{%
@@ -5182,10 +5291,53 @@
 \fvset{backgroundcolor=none}
 \define at key{FV}{bgcolor}{%
   \fvset{backgroundcolor=#1}}
+\patchcmd{\FV at List}%
+ {\FV at BeginListFrame}%
+ {\ifx\FancyVerbBackgroundColor\relax
+  \else
+    \lineskip\z@
+  \fi
+  \FV at BeginListFrame}%
+ {}%
+ {\PackageError{fvextra}%
+   {Failed to patch \string\FV at List\ for backgroundcolor}%
+   {Failed to patch \string\FV at List\ for backgroundcolor}}
 %    \end{macrocode}
 % \end{macro}
 %
 %
+% \begin{macro}{backgroundcolorboxoverlap, bgcolorboxoverlap, \FV at backgroundcolorboxoverlap, \FV at bgcolorstrut, \FV at bgcoloroverlap}
+%    \begin{macrocode}
+\define at key{FV}{backgroundcolorboxoverlap}{%
+  \ifdim#1=0pt\relax
+    \let\FV at backgroundcolorboxoverlap\relax
+  \else
+    \def\FV at backgroundcolorboxoverlap{#1}%
+  \fi}
+\fvset{backgroundcolorboxoverlap=0.25pt}
+\define at key{FV}{bgcolorboxoverlap}{%
+  \fvset{backgroundcolorboxoverlap=#1}}
+\newsavebox{\FV at bgcolorstructbox}
+\def\FV at bgcolorstrut{%
+  \ifx\FancyVerbBackgroundColor\relax
+    \FancyVerbBackgroundColorVPhantom\strut
+  \else\ifx\FV at backgroundcolorboxoverlap\relax
+    \FancyVerbBackgroundColorVPhantom\strut
+  \else
+    \savebox{\FV at bgcolorstructbox}{\hbox{\FancyVerbBackgroundColorVPhantom\strut}}%
+    \vrule height \ht\FV at bgcolorstructbox 
+           depth \dimexpr\dp\FV at bgcolorstructbox+\FV at backgroundcolorboxoverlap\relax
+           width 0pt\relax
+  \fi\fi}
+\def\FV at bgcoloroverlap{%
+  \ifx\FV at backgroundcolorboxoverlap\relax
+  \else
+    \vspace{-\FV at backgroundcolorboxoverlap}%
+  \fi}
+%    \end{macrocode}
+% \end{macro}
+%
+%
 % \begin{macro}{backgroundcolorvphantom,bgcolorvphantom,\FancyVerbBackgroundColorVPhantom}
 %    \begin{macrocode}
 \define at key{FV}{backgroundcolorvphantom}{%
@@ -5262,7 +5414,7 @@
 %
 %
 % \begin{macro}{\FV at BGColor@List}
-% Background color for environments based on |Verbatim|.  Puts each line in a colorbox.  The |\FancyVerbBackgroundColorVPhantom| will not have any effect in this case, unless it is larger than |\strut|.
+% Background color for environments based on |Verbatim|.  Puts each line in a colorbox.
 %    \begin{macrocode}
 \def\FV at BGColor@List#1{%
   \ifx\FancyVerbBackgroundColor\relax
@@ -5275,7 +5427,7 @@
     \setlength{\fboxsep}{0pt}%
     \colorbox{\FancyVerbBackgroundColor}{%
       \setlength{\fboxsep}{\FV at TmpLength}%
-      \rlap{\FancyVerbBackgroundColorVPhantom\strut#1}%
+      \rlap{\FV at bgcolorstrut#1}%
       \hspace{\linewidth}%
       \ifx\FV at RightListFrame\relax\else
         \hspace{-\FV at FrameSep}%
@@ -7010,6 +7162,7 @@
 %
 % If a line is too wide, then it is passed to |\FV at SaveLineBox|.  If there is no right-hand break symbol, then the saved result in |\FV at LineBox| may be used immediately.  If there is a right-hand break symbol, then the line must be processed a second time, so that the right-hand break symbol may be removed from the final segment of the broken line (since it does not continue).  During the first use of |\FV at SaveLineBox|, the counter |FancyVerbLineBreakLast| is set to the internal line number of the last segment of the broken line.  During the second use of |\FV at SaveLineBox|, we disable this (|\let\FV at SetLineBreakLast\relax|) so that the value of |FancyVerbLineBreakLast| remains fixed and thus may be used to determine when a right-hand break symbol should be inserted.
 %    \begin{macrocode}
+\expandafter\let\expandafter\FV at iffp\csname fp_compare:nNnTF\endcsname
 \def\FV at ListProcessLine@Break#1{%
   \hbox to \hsize{%
   \kern\leftmargin
@@ -7036,7 +7189,11 @@
   \ifx\FV at Tab\FV at TrueTab
     \let\FV at TrueTabSaveWidth\relax
   \fi
-  \ifdim\wd\FV at LineBox>\FV at LineWidth
+  \ifnum
+    \FV at iffp{\the\wd\FV at LineBox}>{\FV at LineWidth}{1}{0}% width greater than line
+    \FV at iffp{\the\wd\FV at LineBox}<{0}{1}{0}% width overflows
+    >0
+  \relax
     \setcounter{FancyVerbLineBreakLast}{0}%
     \ifx\FV at Tab\FV at TrueTab
       \let\FV at Tab\FV at TrueTab@UseWidth
@@ -7070,7 +7227,7 @@
     \FV at RightListFrame
     \FV at RightListNumber
   \fi}%
-  \hss}\baselineskip\z@\lineskip\z@}
+  \hss}\FV at bgcoloroverlap\baselineskip\z@\lineskip\z@}
 %    \end{macrocode}
 % \end{macro}
 %

Modified: trunk/Master/texmf-dist/tex/latex/fvextra/fvextra.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/fvextra/fvextra.sty	2025-02-10 20:19:24 UTC (rev 73853)
+++ trunk/Master/texmf-dist/tex/latex/fvextra/fvextra.sty	2025-02-10 20:19:34 UTC (rev 73854)
@@ -20,7 +20,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{fvextra}
-    [2024/11/17 v1.10.0 fvextra - extensions and patches for fancyvrb]
+    [2025/02/09 v1.11.0 fvextra - extensions and patches for fancyvrb]
 \RequirePackage{etoolbox}
 \RequirePackage{fancyvrb}
 \RequirePackage{upquote}
@@ -1284,7 +1284,7 @@
   \else
     \expandafter\xdef\csname#1\endcsname{0}%
   \fi
-  \def\FV at bufferlengthname{#1}%
+  \def\FancyVerbBufferLengthName{#1}%
   \expandafter\def\expandafter\FV at bufferlengthmacro\expandafter{%
     \csname#1\endcsname}}
 \fvset{bufferlengthname=FancyVerbBufferLength}
@@ -1299,11 +1299,7 @@
  {\boolfalse{FV at globalbuffer}}
 \fvset{globalbuffer=false}
 \newcounter{FancyVerbBufferLine}
-\newbool{FV at globalbuffer@tmp}
-\let\FV at oldbufferlength\relax
-\let\FV at bufferlengthmacro@tmp\relax
-\let\FancyVerbBufferLineName at tmp\relax
-\let\FV at afterbuffer@tmp\relax
+\def\FancyVerbBufferDepth{0}
 \def\VerbatimBuffer{%
   \FV at Environment
    {codes=,commandchars=none,commentchar=none,defineactive,%
@@ -1311,6 +1307,7 @@
    {VerbatimBuffer}}
 \def\FVB at VerbatimBuffer{%
   \@bsphack
+  \xdef\FancyVerbBufferDepth{\the\numexpr\FancyVerbBufferDepth+1\relax}%
   \begingroup
   \FV at UseKeyValues
   \setcounter{FancyVerbBufferLine}{\FV at bufferlengthmacro}%
@@ -1317,12 +1314,22 @@
   \let\c at FancyVerbLine\c at FancyVerbBufferLine
   \xdef\FancyVerbBufferIndex{\FV at bufferlengthmacro}%
   \ifbool{FV at globalbuffer}%
-   {\global\booltrue{FV at globalbuffer@tmp}}%
-   {\global\boolfalse{FV at globalbuffer@tmp}%
-    \expandafter\global\expandafter\let\expandafter\FV at oldbufferlength\FV at bufferlengthmacro
-    \global\let\FV at bufferlengthmacro@tmp\FV at bufferlengthmacro
-    \global\let\FancyVerbBufferLineName at tmp\FancyVerbBufferLineName}%
-  \global\let\FV at afterbuffer@tmp\FV at afterbuffer
+   {}%
+   {\expandafter\xdef\csname FV at setbufferlocalscopevars\FancyVerbBufferDepth\endcsname{%
+      \unexpanded{\def\FV at oldbufferlength}%
+       {\FV at bufferlengthmacro}%
+      \unexpanded{\def\FV at bufferlengthmacro}%
+       {\unexpanded\expandafter{\FV at bufferlengthmacro}}%
+      \unexpanded{\def\FancyVerbBufferLineName}%
+       {\unexpanded\expandafter{\FancyVerbBufferLineName}}}}%
+  \ifx\FV at afterbuffer\@empty
+  \else
+    \ifx\FV at afterbuffer\relax
+    \else
+      \expandafter\global\expandafter
+        \let\csname FV at afterbuffer\FancyVerbBufferDepth\endcsname\FV at afterbuffer
+    \fi
+  \fi
   \FV at DefineWhiteSpace
   \def\FV at ProcessLine{%
     \xdef\FancyVerbBufferIndex{\the\numexpr\FancyVerbBufferIndex+1\relax}%
@@ -1337,22 +1344,27 @@
   \gdef\FancyVerbBufferIndex{0}%
   \endgroup
   \@esphack
-  \begingroup
-  \FV at afterbuffer@tmp
-  \global\let\FV at afterbuffer@tmp\relax
-  \endgroup
-  \ifbool{FV at globalbuffer@tmp}%
-   {}%
-   {\loop\unless\ifnum\FV at bufferlengthmacro@tmp=\FV at oldbufferlength\relax
-      \expandafter\global\expandafter\let\csname
-        \FancyVerbBufferLineName at tmp\FV at bufferlengthmacro@tmp
-        \endcsname\FV at Undefined
-      \expandafter\xdef\FV at bufferlengthmacro@tmp{%
-        \the\numexpr\FV at bufferlengthmacro@tmp-1\relax}%
+  \ifcsname FV at afterbuffer\FancyVerbBufferDepth\endcsname
+    \begingroup
+    \csname FV at afterbuffer\FancyVerbBufferDepth\endcsname
+    \endgroup
+    \expandafter\global\expandafter
+      \let\csname FV at afterbuffer\FancyVerbBufferDepth\endcsname\FV at Undefined
+  \fi
+  \ifcsname FV at setbufferlocalscopevars\FancyVerbBufferDepth\endcsname
+    \begingroup
+    \csname FV at setbufferlocalscopevars\FancyVerbBufferDepth\endcsname
+    \loop\unless\ifnum\FV at bufferlengthmacro=\FV at oldbufferlength\relax
+      \expandafter\global\expandafter
+        \let\csname\FancyVerbBufferLineName\FV at bufferlengthmacro\endcsname\FV at Undefined
+      \expandafter\xdef\FV at bufferlengthmacro{%
+        \the\numexpr\FV at bufferlengthmacro-1\relax}%
     \repeat
-    \global\let\FV at bufferlengthmacro@tmp\relax
-    \global\let\FancyVerbBufferLineName at tmp\relax}%
-  \global\let\FV at oldbufferlength\relax}
+    \endgroup
+    \expandafter\global\expandafter
+      \let\csname FV at setbufferlocalscopevars\FancyVerbBufferDepth\endcsname\FV at Undefined
+  \fi
+  \xdef\FancyVerbBufferDepth{\the\numexpr\FancyVerbBufferDepth-1\relax}}
 \def\endVerbatimBuffer{\FVE at VerbatimBuffer}
 \define at key{FV}{insertenvname}{%
   \def\FV at VerbatimInsertEnvName{#1}}
@@ -1365,7 +1377,8 @@
   \xdef\FV at EnvironName{\FV at VerbatimInsertEnvName}%
   \ifnum\FV at bufferlengthmacro=\z@\relax
     \PackageError{fvextra}%
-     {Buffer length macro \expandafter\string\FV at bufferlengthmacro\space is invalid or zero}%
+     {Buffer length macro \expandafter\string\FV at bufferlengthmacro\space
+      is invalid or zero}%
      {}%
     \let\FV at GetLine\relax
   \fi
@@ -1429,6 +1442,39 @@
   \repeat
   \gdef\FancyVerbBufferIndex{0}%
   \endgroup}
+\newcommand{\InsertBuffer}[1][]{%
+  \begingroup
+  \def\FV at KeyValues{#1}%
+  \FV at UseKeyValues
+  \global\let\FV at tmpbufferlengthmacro\FV at bufferlengthmacro
+  \global\let\FV at tmpbufferlinename\FancyVerbBufferLineName
+  \endgroup
+  \ifnum\FV at tmpbufferlengthmacro<1
+    \expandafter\@gobble
+  \else
+    \expandafter\@firstofone
+  \fi
+  \InsertBuffer at i}
+\def\InsertBuffer at i{%
+  \InsertBuffer at expandbuffer
+  \expandafter\InsertBuffer at cleanup\expandafter\scantokens\expandafter{%
+    \FV at expandedbuffer\unskip\noexpand}\relax}
+\def\InsertBuffer at expandbuffer{%
+  \edef\FV at expandedbuffer{\InsertBuffer at expandbufferlines{1}}}
+\def\InsertBuffer at expandbufferlines#1{%
+  \unexpanded\expandafter\expandafter\expandafter{%
+    \csname\FV at tmpbufferlinename#1\endcsname^^J}%
+  \ifnum\FV at tmpbufferlengthmacro=#1
+    \expandafter\@gobble
+  \else
+    \expandafter\@firstofone
+  \fi
+  {\expandafter\InsertBuffer at expandbufferlines\expandafter{\the\numexpr#1+1\relax}}}
+\def\InsertBuffer at cleanup{%
+  \global\let\FV at tmpbufferlengthmacro\FV at Undefined
+  \global\let\FV at tmpbufferlinename\FV at Undefined
+  \global\let\FV at expandedbuffer\FV at Undefined}
+\let\ClearBuffer\VerbatimClearBuffer
 \def\FV at Command#1#2{%
   \FVExtra at ifstarVArg
    {\def\FV at KeyValues{#1,showspaces,showtabs}\FV@@Command{#2}}%
@@ -1729,7 +1775,7 @@
             \FV at ObeyTabs{\FancyVerbFormatText{#1}}}}}\hss
       \FV at RightListFrame
       \FV at RightListNumber}%
-    \hss}}
+    \hss}\FV at bgcoloroverlap}
 \def\FV at BProcessLine#1{%
   \hbox{\FancyVerbFormatLine{%
     \ifx\FancyVerbBackgroundColor\relax
@@ -1911,6 +1957,43 @@
 \fvset{backgroundcolor=none}
 \define at key{FV}{bgcolor}{%
   \fvset{backgroundcolor=#1}}
+\patchcmd{\FV at List}%
+ {\FV at BeginListFrame}%
+ {\ifx\FancyVerbBackgroundColor\relax
+  \else
+    \lineskip\z@
+  \fi
+  \FV at BeginListFrame}%
+ {}%
+ {\PackageError{fvextra}%
+   {Failed to patch \string\FV at List\ for backgroundcolor}%
+   {Failed to patch \string\FV at List\ for backgroundcolor}}
+\define at key{FV}{backgroundcolorboxoverlap}{%
+  \ifdim#1=0pt\relax
+    \let\FV at backgroundcolorboxoverlap\relax
+  \else
+    \def\FV at backgroundcolorboxoverlap{#1}%
+  \fi}
+\fvset{backgroundcolorboxoverlap=0.25pt}
+\define at key{FV}{bgcolorboxoverlap}{%
+  \fvset{backgroundcolorboxoverlap=#1}}
+\newsavebox{\FV at bgcolorstructbox}
+\def\FV at bgcolorstrut{%
+  \ifx\FancyVerbBackgroundColor\relax
+    \FancyVerbBackgroundColorVPhantom\strut
+  \else\ifx\FV at backgroundcolorboxoverlap\relax
+    \FancyVerbBackgroundColorVPhantom\strut
+  \else
+    \savebox{\FV at bgcolorstructbox}{\hbox{\FancyVerbBackgroundColorVPhantom\strut}}%
+    \vrule height \ht\FV at bgcolorstructbox
+           depth \dimexpr\dp\FV at bgcolorstructbox+\FV at backgroundcolorboxoverlap\relax
+           width 0pt\relax
+  \fi\fi}
+\def\FV at bgcoloroverlap{%
+  \ifx\FV at backgroundcolorboxoverlap\relax
+  \else
+    \vspace{-\FV at backgroundcolorboxoverlap}%
+  \fi}
 \define at key{FV}{backgroundcolorvphantom}{%
   \def\FancyVerbBackgroundColorVPhantom{#1}%
   \ifx\FancyVerbBackgroundColorVPhantom\FV at None
@@ -1985,7 +2068,7 @@
     \setlength{\fboxsep}{0pt}%
     \colorbox{\FancyVerbBackgroundColor}{%
       \setlength{\fboxsep}{\FV at TmpLength}%
-      \rlap{\FancyVerbBackgroundColorVPhantom\strut#1}%
+      \rlap{\FV at bgcolorstrut#1}%
       \hspace{\linewidth}%
       \ifx\FV at RightListFrame\relax\else
         \hspace{-\FV at FrameSep}%
@@ -3064,6 +3147,7 @@
   }%
 }
 \let\FV at BreakByTokenAnywhereHook\relax
+\expandafter\let\expandafter\FV at iffp\csname fp_compare:nNnTF\endcsname
 \def\FV at ListProcessLine@Break#1{%
   \hbox to \hsize{%
   \kern\leftmargin
@@ -3090,7 +3174,11 @@
   \ifx\FV at Tab\FV at TrueTab
     \let\FV at TrueTabSaveWidth\relax
   \fi
-  \ifdim\wd\FV at LineBox>\FV at LineWidth
+  \ifnum
+    \FV at iffp{\the\wd\FV at LineBox}>{\FV at LineWidth}{1}{0}% width greater than line
+    \FV at iffp{\the\wd\FV at LineBox}<{0}{1}{0}% width overflows
+    >0
+  \relax
     \setcounter{FancyVerbLineBreakLast}{0}%
     \ifx\FV at Tab\FV at TrueTab
       \let\FV at Tab\FV at TrueTab@UseWidth
@@ -3124,7 +3212,7 @@
     \FV at RightListFrame
     \FV at RightListNumber
   \fi}%
-  \hss}\baselineskip\z@\lineskip\z@}
+  \hss}\FV at bgcoloroverlap\baselineskip\z@\lineskip\z@}
 \def\FV at BreakBeforePrep@Pygments#1{%
   \ifcsname FV at BreakBefore@Token\@backslashchar\endcsname
     \@namedef{FV at BreakBefore@Token#1Zbs }{}%



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