@@ -269,6 +269,9 @@ def __init__(
269
269
code = "\n " .join (code_lines )
270
270
lite_options ["code" ] = code
271
271
272
+ if "execute" in lite_options and lite_options ["execute" ] == "0" :
273
+ lite_options ["execute" ] = "0"
274
+
272
275
app_path = self .lite_app
273
276
if notebook is not None :
274
277
lite_options ["path" ] = notebook
@@ -401,6 +404,7 @@ class RepliteDirective(SphinxDirective):
401
404
"width" : directives .unchanged ,
402
405
"height" : directives .unchanged ,
403
406
"kernel" : directives .unchanged ,
407
+ "execute" : directives .unchanged ,
404
408
"toolbar" : directives .unchanged ,
405
409
"theme" : directives .unchanged ,
406
410
"prompt" : directives .unchanged ,
@@ -421,6 +425,17 @@ def run(self):
421
425
422
426
new_tab = self .options .pop ("new_tab" , False )
423
427
428
+ # We first check the global config, and then the per-directive
429
+ # option. It defaults to true for backwards compatibility.
430
+ execute = self .options .pop ("execute" , None )
431
+ if execute is None :
432
+ execute = str (self .env .config .replite_auto_execute ).lower ()
433
+ else :
434
+ execute = execute .lower ()
435
+
436
+ if execute == "false" :
437
+ self .options ["execute" ] = "0"
438
+
424
439
content = self .content
425
440
426
441
button_text = None
@@ -1155,6 +1170,7 @@ def setup(app):
1155
1170
man = (skip , None ),
1156
1171
)
1157
1172
app .add_directive ("replite" , RepliteDirective )
1173
+ app .add_config_value ("replite_auto_execute" , True , rebuild = "html" )
1158
1174
1159
1175
# Initialize Voici directive and tabbed interface
1160
1176
app .add_node (
0 commit comments