File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -2170,11 +2170,21 @@ def depart_codearea_latex(self, node):
2170
2170
if lines [0 ].startswith (r'\fvset{' ): # Sphinx >= 1.6.6 and < 1.8.3
2171
2171
out .append (lines [0 ])
2172
2172
del lines [0 ]
2173
- assert 'Verbatim' in lines [0 ]
2174
- out .append (lines [0 ])
2173
+ # Sphinx 4.1.0 added "sphinxuseclass" environments around "sphinxVerbatim"
2174
+ for begin_verbatim , line in enumerate (lines ):
2175
+ if line .startswith (r'\begin{sphinxVerbatim}' ):
2176
+ break
2177
+ else :
2178
+ assert False
2179
+ for end_verbatim , line in enumerate (reversed (lines )):
2180
+ if line == r'\end{sphinxVerbatim}' :
2181
+ break
2182
+ else :
2183
+ assert False
2184
+ out .extend (lines [:begin_verbatim + 1 ])
2175
2185
code_lines = (
2176
2186
['' ] * node .get ('empty-lines-before' , 0 ) +
2177
- lines [1 :- 1 ] +
2187
+ lines [begin_verbatim + 1 :- end_verbatim - 1 ] +
2178
2188
['' ] * node .get ('empty-lines-after' , 0 )
2179
2189
)
2180
2190
prompt = node ['prompt' ]
@@ -2185,8 +2195,7 @@ def depart_codearea_latex(self, node):
2185
2195
assert code_lines
2186
2196
code_lines [0 ] = prefix + code_lines [0 ]
2187
2197
out .extend (code_lines )
2188
- assert 'Verbatim' in lines [- 1 ]
2189
- out .append (lines [- 1 ])
2198
+ out .extend (lines [- end_verbatim - 1 :])
2190
2199
out .append ('}' ) # End of scope for colors
2191
2200
out .append ('' )
2192
2201
self .body .append ('\n ' .join (out ))
You can’t perform that action at this time.
0 commit comments