\NewTaggingSocket{lstlisting/number}{2}
\NewTaggingSocketPlug{lstlisting/number}{default}
 {
   \tag_mc_end_push:
   \tagstructbegin{tag=Lbl}
    \tagmcbegin{}
     #2
    \tagmcend
   \tagstructend
   \tag_mc_begin_pop:n{}
 }
\AssignTaggingSocketPlug{lstlisting/number}{default}
\ExplSyntaxOff
\lst@Key{numbers}{none}{%
    \let\lst@PlaceNumber\@empty
    \lstKV@SwitchCases{#1}%
    {none:\\%
     left:\def\lst@PlaceNumber{\llap{\normalfont
                \UseTaggingSocket{lstlisting/number}
                  {}
                  {\lst@numberstyle{\thelstnumber}}\kern\lst@numbersep}}\\%
     right:\def\lst@PlaceNumber{\rlap{\normalfont
                \kern\linewidth \kern\lst@numbersep
                \UseTaggingSocket{lstlisting/number}
                  {}
                  {\lst@numberstyle{\thelstnumber}}}}%
    }{\PackageError{Listings}{value `#1' for keyword `numbers' not supported}\@ehc}}
\DeclareInstance{blockenv}{lstlisting}{std}
   {
    name           = lstlisting,
    tag-name       = verbatim,
    tag-attr-class = ,
    tagging-recipe = standard,
    inner-level-counter  = ,
    transparent-level = true,
    block-instance = lstlisting ,
    inner-instance = ,
    final-code     = \AssignStructureRole {para/textblock}%
                         {\UseStructureName{block/verbatim/codeline}}\ignorespaces,
    tagging-suppress-paras = true
   }

\DeclareInstance{block}{lstlisting-1}{std}  {
  ,left-margin      = 0pt
  ,para-vspace      = 0pt
  ,begin-vspace=0pt
  ,end-vspace= 0pt
}
\DeclareInstanceCopy{block}{lstlisting-2}{lstlisting-1}
\DeclareInstanceCopy{block}{lstlisting-3}{lstlisting-1}
\DeclareInstanceCopy{block}{lstlisting-4}{lstlisting-1}
\DeclareInstanceCopy{block}{lstlisting-5}{lstlisting-1}
\DeclareInstanceCopy{block}{lstlisting-6}{lstlisting-1}
\def\lst@EveryDisplay{%
    \MathCollectFalse
     \ifx\lst@float\relax
      \SimpleBlockEnv{lstlisting}{}%
     \else
      \SimpleBlockEnv{lstlisting}{tagging-recipe = standalone}
     \fi}
 \lst@AddToHook{PreInit}
  {%
   \ifhmode
    \UseTaggingSocket{inline/begin}{tag=\UseStructureName{text/verb}}%
    \fi
  }
 \lst@AddToHook{DeInit}
   {\ifhmode
    \UseTaggingSocket{inline/end}%
    \else
    \edef\@current@float@struct{\UseName{tag_get:n}{struct_num}}\BlockEnvEnd
    \fi}%
\tagpdfsetup{float/new=lstlisting}
\def\lst@makecaption{%
  \AssignStructureRole {para/textblock}{Span}\def\@captype{lstlisting}\@makecaption}
\def\lst@maketitle{\def\@captype{lstlisting}%
 \AssignStructureRole {para/textblock}{Span}
 \AssignTaggingSocketPlug{caption/label/begin}{noop}%
 \AssignTaggingSocketPlug{caption/label/end}{noop}%
 \AssignSocketPlug{caption/label}{noop}%
 \@makecaption\lst@title@dropdelim}
\newcommand\lst@invisiblespace{\pdffakespace\ }
\lst@AddToHook{Init}{\lst@ifshowspaces\else \let\lst@outputspace\lst@invisiblespace\fi}
