29 lines
1.2 KiB
Diff
29 lines
1.2 KiB
Diff
|
---
|
||
|
Doc/tools/extensions/pyspecific.py | 11 +++++++----
|
||
|
1 file changed, 7 insertions(+), 4 deletions(-)
|
||
|
|
||
|
--- a/Doc/tools/extensions/pyspecific.py
|
||
|
+++ b/Doc/tools/extensions/pyspecific.py
|
||
|
@@ -31,14 +31,17 @@ Body.enum.converters['loweralpha'] = \
|
||
|
# doctest docs themselves
|
||
|
orig_visit_literal_block = HTMLTranslator.visit_literal_block
|
||
|
def new_visit_literal_block(self, node):
|
||
|
+ old_trim_doctest_flags = None
|
||
|
meta = self.builder.env.metadata[self.builder.current_docname]
|
||
|
- old_trim_doctest_flags = self.highlighter.trim_doctest_flags
|
||
|
- if 'keepdoctest' in meta:
|
||
|
- self.highlighter.trim_doctest_flags = False
|
||
|
+ if hasattr(self.highlighter, 'trim_doctest_flags'):
|
||
|
+ old_trim_doctest_flags = self.highlighter.trim_doctest_flags
|
||
|
+ if 'keepdoctest' in meta:
|
||
|
+ self.highlighter.trim_doctest_flags = False
|
||
|
try:
|
||
|
orig_visit_literal_block(self, node)
|
||
|
finally:
|
||
|
- self.highlighter.trim_doctest_flags = old_trim_doctest_flags
|
||
|
+ if old_trim_doctest_flags is not None:
|
||
|
+ self.highlighter.trim_doctest_flags = old_trim_doctest_flags
|
||
|
|
||
|
HTMLTranslator.visit_literal_block = new_visit_literal_block
|
||
|
|