diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index df4d5315a4..e7a1442f67 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -108,6 +108,7 @@ \define@key{sphinx}{shadowrule}{\sphinxshadowrule\dimexpr #1\relax} % verbatim \DeclareBoolOption[true]{verbatimwithframe} +\DeclareBoolOption[false]{verbatimopenframe} \DeclareBoolOption[true]{verbatimwrapslines} \DeclareBoolOption[false]{verbatimforcewraps} \DeclareStringOption[3]{verbatimmaxoverfull} diff --git a/sphinx/texinputs/sphinxlatexliterals.sty b/sphinx/texinputs/sphinxlatexliterals.sty index fc75565b9a..c4e54d02a4 100644 --- a/sphinx/texinputs/sphinxlatexliterals.sty +++ b/sphinx/texinputs/sphinxlatexliterals.sty @@ -144,51 +144,18 @@ % problematic features regarding color in a context like here where #3 % may contain an unbalanced "color push". % - \def\spx@boxes@fcolorbox@init{% from sphinxpackageboxes.sty -% TODO: provide interface for activating various border widths! - \spx@boxes@border@top \sphinxverbatimborder - \spx@boxes@border@right \sphinxverbatimborder - \spx@boxes@border@bottom\sphinxverbatimborder - \spx@boxes@border@left \sphinxverbatimborder - \spx@boxes@border \sphinxverbatimborder - % -% TODO: provide interface for activating various padding widths! - \spx@boxes@padding@top \sphinxverbatimsep % - \spx@boxes@padding@right \sphinxverbatimsep %2\sphinxverbatimsep for testing - \spx@boxes@padding@bottom\sphinxverbatimsep %4 - \spx@boxes@padding@left \sphinxverbatimsep %8 - % -% TODO: provide interface for activating various corner radii! - \spx@boxes@radius@topleft \sphinxverbatimradius % twice that - \spx@boxes@radius@topright \sphinxverbatimradius % 4\sphinxverbatimradius for testing - \spx@boxes@radius@bottomright \sphinxverbatimradius % 8 - \spx@boxes@radius@bottomleft \sphinxverbatimradius % 16 - % -% TODO: think about perhaps activating shadows (or rather not...) - \spx@boxes@noshadowtrue % no shadow - % - \spx@boxes@nobackgroundcolorfalse % use background color - \sphinxcolorlet{spx@boxes@backgroundcolor}{VerbatimColor}% legacy name - % - \spx@boxes@nobordercolorfalse % use border color - \sphinxcolorlet{spx@boxes@bordercolor}{VerbatimBorderColor}% - }% \setbox\z@\hbox{#3}% \edef\spx@verb@fcolorbox@width@sp {\number\dimexpr\wd\z@+2\sphinxverbatimsep+2\sphinxverbatimborder sp}% - \vbox{#1% continuation hint attached above frame - % uses \spx@verb@fcolorbox@width@sp + \vbox{#1% continuation hint attached above frame, uses \spx@verb@fcolorbox@width@sp \ifdim\sphinxverbatimradius>\z@ \expandafter\spx@boxes@fcolorbox@rounded \else \expandafter\spx@boxes@fcolorbox \fi {\box\z@}% the macro constructs an \hbox with bbox containing the border -% TODO: remove this \nointerlineskip at 6.0.0 - \nointerlineskip % to maintain legacy spacing (I think since Sphinx 1.7) - % as formerly there was an \hrule last in vertical list - #2% continuation hint attached below frame, - % uses \spx@verb@fcolorbox@width@sp + \nointerlineskip + #2% continuation hint attached below frame, uses \spx@verb@fcolorbox@width@sp }% end of \vbox }% \def\spx@verb@fcolorbox@put@c#1{% hide width from framed.sty measuring @@ -218,12 +185,72 @@ % \def\sphinxVerbatim@FrameCommand {\spx@verb@FrameCommand\sphinxVerbatim@Before\sphinxVerbatim@After}% -\def\sphinxVerbatim@FirstFrameCommand - {\spx@verb@FrameCommand\sphinxVerbatim@Before\sphinxVerbatim@Continues}% -\def\sphinxVerbatim@MidFrameCommand - {\spx@verb@FrameCommand\sphinxVerbatim@Continued\sphinxVerbatim@Continues}% -\def\sphinxVerbatim@LastFrameCommand - {\spx@verb@FrameCommand\sphinxVerbatim@Continued\sphinxVerbatim@After}% +\def\sphinxVerbatim@FirstFrameCommand{% + \ifspx@opt@verbatimopenframe + \let\spx@boxes@fcolorbox@init\spx@verb@boxes@fcolorbox@init@openbottom + \fi + \spx@verb@FrameCommand\sphinxVerbatim@Before\sphinxVerbatim@Continues +}% +\def\sphinxVerbatim@MidFrameCommand{% + \ifspx@opt@verbatimopenframe + \let\spx@boxes@fcolorbox@init\spx@verb@boxes@fcolorbox@init@openboth + \sphinxverbatimradius=\z@ + \fi + \spx@verb@FrameCommand\sphinxVerbatim@Continued\sphinxVerbatim@Continues +}% +\def\sphinxVerbatim@LastFrameCommand{% + \ifspx@opt@verbatimopenframe + \let\spx@boxes@fcolorbox@init\spx@verb@boxes@fcolorbox@init@opentop + \fi + \spx@verb@FrameCommand\sphinxVerbatim@Continued\sphinxVerbatim@After +}% +% +\def\spx@verb@boxes@fcolorbox@init{% for using \spx@boxes@fcolorbox +% TODO: provide interface for activating various border widths! + \spx@boxes@border@top \sphinxverbatimborder + \spx@boxes@border@right \sphinxverbatimborder + \spx@boxes@border@bottom\sphinxverbatimborder + \spx@boxes@border@left \sphinxverbatimborder + \spx@boxes@border \sphinxverbatimborder + % +% TODO: provide interface for activating various padding widths! + \spx@boxes@padding@top \sphinxverbatimsep % + \spx@boxes@padding@right \sphinxverbatimsep %2\sphinxverbatimsep for testing + \spx@boxes@padding@bottom\sphinxverbatimsep %4 + \spx@boxes@padding@left \sphinxverbatimsep %8 + % +% TODO: provide interface for activating various corner radii! + \spx@boxes@radius@topleft \sphinxverbatimradius % twice that + \spx@boxes@radius@topright \sphinxverbatimradius % 4\sphinxverbatimradius for testing + \spx@boxes@radius@bottomright \sphinxverbatimradius % 8 + \spx@boxes@radius@bottomleft \sphinxverbatimradius % 16 + % +% TODO: think about perhaps activating shadows (or rather not...) + \spx@boxes@noshadowtrue % no shadow + % + \spx@boxes@nobackgroundcolorfalse % use background color + \sphinxcolorlet{spx@boxes@backgroundcolor}{VerbatimColor}% legacy name + % + \spx@boxes@nobordercolorfalse % use border color + \sphinxcolorlet{spx@boxes@bordercolor}{VerbatimBorderColor}% +}% +\def\spx@verb@boxes@fcolorbox@init@openbottom{% + \spx@verb@boxes@fcolorbox@init + \spx@boxes@border@bottom \z@ + \spx@boxes@radius@bottomright\z@ + \spx@boxes@radius@bottomleft \z@ +}% +\def\spx@verb@boxes@fcolorbox@init@opentop{% + \spx@verb@boxes@fcolorbox@init + \spx@boxes@border@top \z@ + \spx@boxes@radius@topright\z@ + \spx@boxes@radius@topleft \z@ +}% +\def\spx@verb@boxes@fcolorbox@init@openboth{% + \spx@verb@boxes@fcolorbox@init + \spx@boxes@border@top \z@ + \spx@boxes@border@bottom \z@ +}% % For linebreaks inside Verbatim environment from package fancyvrb. \newbox\sphinxcontinuationbox @@ -691,6 +718,7 @@ \global\let\sphinxLiteralBlockLabel\empty \global\let\sphinxVerbatimTitle\empty \let\FrameCommand \sphinxVerbatim@FrameCommand + % they will check status of verbatimopenframe option \let\FirstFrameCommand\sphinxVerbatim@FirstFrameCommand \let\MidFrameCommand \sphinxVerbatim@MidFrameCommand \let\LastFrameCommand \sphinxVerbatim@LastFrameCommand @@ -698,6 +726,7 @@ \let\sphinxVerbatim@Continued\@empty \let\sphinxVerbatim@Continues\@empty \fi + \def\spx@boxes@fcolorbox@init{\spx@verb@boxes@fcolorbox@init}% \ifspx@opt@verbatimwrapslines % deep hack into fancyvrb's internal processing of input lines \let\FV@@PreProcessLine\spx@verb@@PreProcessLine diff --git a/sphinx/texinputs/sphinxpackageboxes.sty b/sphinx/texinputs/sphinxpackageboxes.sty index 998d0e7471..a4c5362595 100644 --- a/sphinx/texinputs/sphinxpackageboxes.sty +++ b/sphinx/texinputs/sphinxpackageboxes.sty @@ -302,6 +302,32 @@ {\spx@boxes@radius@bottomleft}% {\spx@boxes@radius@bottomleft}{180}{270}% }% end of definition of \spx@boxes@roundedpath +\def\spx@boxes@roundedpath@opentop{% + \spx@moveto(\z@,\ht\spx@tempboxa+\dp\spx@tempboxa-\spx@boxes@border)% + \spx@lineto(\z@,\spx@boxes@radius@bottomleft)% + \spx@circlearc[2]{\spx@boxes@radius@bottomleft}% + {\spx@boxes@radius@bottomleft}% + {\spx@boxes@radius@bottomleft}{180}{270}% + \spx@lineto(\wd\spx@tempboxa-\spx@boxes@border-\spx@boxes@radius@bottomright,\z@)% + \spx@circlearc[2]{\wd\spx@tempboxa-\spx@boxes@border-\spx@boxes@radius@bottomright}% + {\spx@boxes@radius@bottomright}% + {\spx@boxes@radius@bottomright}{-90}{0}% + \spx@lineto(\wd\spx@tempboxa-\spx@boxes@border,% + \ht\spx@tempboxa+\dp\spx@tempboxa-\spx@boxes@border)% +}% end of definition of \spx@boxes@roundedpath@opentop +\def\spx@boxes@roundedpath@openbottom{% + \spx@moveto(\wd\spx@tempboxa-\spx@boxes@border,\z@)% + \spx@lineto(\wd\spx@tempboxa-\spx@boxes@border,% + \ht\spx@tempboxa+\dp\spx@tempboxa-\spx@boxes@border-\spx@boxes@radius@topright)% + \spx@circlearc[2]{\wd\spx@tempboxa-\spx@boxes@border-\spx@boxes@radius@topright} + {\ht\spx@tempboxa+\dp\spx@tempboxa-\spx@boxes@border-\spx@boxes@radius@topright}% + {\spx@boxes@radius@topright}{0}{90}% + \spx@lineto(\spx@boxes@radius@topleft,\ht\spx@tempboxa+\dp\spx@tempboxa-\spx@boxes@border)% + \spx@circlearc[2]{\spx@boxes@radius@topleft}% + {\ht\spx@tempboxa+\dp\spx@tempboxa-\spx@boxes@border-\spx@boxes@radius@topleft}% + {\spx@boxes@radius@topleft}{90}{180}% + \spx@lineto(\z@,\z@)% +}% end of definition of \spx@boxes@roundedpath@openbottom \long\def\spx@boxes@fcolorbox@rounded #1{% \hbox{\vbox{% @@ -323,11 +349,18 @@ \color{spx@boxes@backgroundcolor}% \spx@boxes@roundedpath\fillpath \color{spx@boxes@bordercolor}% -\ifdim\spx@boxes@border>\z@ % even with \spx@boxes@border set to 0pt, the - % stroke will produce a visible contour, so we - % must explicitly exclude doing it. +\ifdim\spx@boxes@border>\z@ +% even with \spx@boxes@border set to 0pt as done if verbatimwithframe=false +% stroke will produce a visible contour, so we exclude doing it in that case \linethickness{\spx@boxes@border}% - \spx@boxes@roundedpath\strokepath + \ifdim\spx@boxes@border@top=\z@ + \spx@boxes@roundedpath@opentop + \else + \ifdim\spx@boxes@border@bottom=\z@ + \spx@boxes@roundedpath@openbottom + \else\spx@boxes@roundedpath + \fi\fi + \strokepath \fi \end{picture}}% % now the contents