@@ -267,13 +267,15 @@ def html(self):
267
267
class ThebeSourceNode (docutils .nodes .container ):
268
268
"""Container that holds the cell source when thebelab is enabled"""
269
269
270
- def __init__ (self , rawsource = '' , * children , hide_code , ** attributes ):
271
- super ().__init__ ('' , hide_code = hide_code )
270
+ def __init__ (self , rawsource = '' , * children , hide_code , code_below , ** attributes ):
271
+ super ().__init__ ('' , hide_code = hide_code , code_below = code_below )
272
272
273
273
def html (self ):
274
274
code_class = 'thebelab-code'
275
275
if self ['hide_code' ]:
276
276
code_class += ' thebelab-hidden'
277
+ if self ['code_below' ]:
278
+ code_class += ' thebelab-below'
277
279
code = self .astext ()
278
280
return '<pre class="{}" data-executable="true" data-language="python">{}</pre>' \
279
281
.format (code_class , code )
@@ -540,16 +542,19 @@ def attach_outputs(output_nodes, node, thebe_config):
540
542
if thebe_config and not node .attributes ['no_thebelab' ]:
541
543
source = node .children [0 ]
542
544
543
- thebe_source = ThebeSourceNode (hide_code = node .attributes ['hide_code' ])
545
+ thebe_source = ThebeSourceNode (hide_code = node .attributes ['hide_code' ],
546
+ code_below = node .attributes ['code_below' ])
544
547
thebe_source .children = [source ]
545
548
546
549
node .children = [thebe_source ]
547
550
548
551
if not node .attributes ['hide_output' ]:
549
- # We ignore the code_below attribute since this is not supported with thebelab
550
552
thebe_output = ThebeOutputNode ()
551
553
thebe_output .children = output_nodes
552
- node .children .append (thebe_output )
554
+ if node .attributes ['code_below' ]:
555
+ node .children = [thebe_output ] + node .children
556
+ else :
557
+ node .children = node .children + [thebe_output ]
553
558
else :
554
559
if node .attributes ['hide_code' ]:
555
560
node .children = []
0 commit comments