Make PDF highlighting work as expected also in absence of `:linenos:`

Method at 347f15ca2 was overly complicated, due to not enough
understanding of LaTeX package fancyvrb's innards.
This commit is contained in:
jfbu 2017-12-13 11:12:18 +01:00
parent 7f3a7c3b81
commit 8de0abd1b6

View File

@ -853,8 +853,7 @@
\newcommand*{\sphinxVerbatimEnvironment}{\gdef\FV@EnvironName{sphinxVerbatim}}
% serves to implement line highlighting and line wrapping
\newcommand\sphinxFancyVerbFormatLine[1]{%
\expandafter\sphinx@verbatim@checkifhl
\expandafter{\the\numexpr\value{FancyVerbLine}-\spx@verbatim@linedelta}%
\expandafter\sphinx@verbatim@checkifhl\expandafter{\the\FV@CodeLineNo}%
\ifin@
\sphinxVerbatimHighlightLine{#1}%
\else
@ -876,8 +875,6 @@
\strut #1\strut}%
}%
\newcommand\sphinxVerbatimFormatLineNoWrap[1]{\hb@xt@\linewidth{\strut #1\hss}}%
\def\sphinx@FancyVerbCodesHook
{\FV@SetLineNo\edef\spx@verbatim@linedelta{\the\value{FancyVerbLine}}}%
\g@addto@macro\FV@SetupFont{%
\sbox\sphinxcontinuationbox {\spx@opt@verbatimcontinued}%
\sbox\sphinxvisiblespacebox {\spx@opt@verbatimvisiblespace}%
@ -933,15 +930,11 @@
% Allow breaks at special characters using \PYG... macros.
\sphinxbreaksatspecials
% Breaks at punctuation characters . , ; ? ! and / (needs catcode activation)
\expandafter\def\expandafter\sphinx@FancyVerbCodesHook\expandafter
{\sphinx@FancyVerbCodesHook\sphinxbreaksviaactive}%
\fvset{codes*=\sphinxbreaksviaactive}%
\else % end of conditional code for wrapping long code lines
\let\sphinxVerbatimFormatLine\sphinxVerbatimFormatLineNoWrap
\fi
\let\FancyVerbFormatLine\sphinxFancyVerbFormatLine
% hook into \FancyVerbCodes to recover at first code line the numbering offset
\expandafter\def\expandafter\FancyVerbCodes\expandafter
{\FancyVerbCodes\sphinx@FancyVerbCodesHook}%
% go around fancyvrb's check of \@currenvir
\let\VerbatimEnvironment\sphinxVerbatimEnvironment
% go around fancyvrb's check of current list depth