@@ -379,8 +379,8 @@ def apply(self):
379
379
if output ['output_type' ] == 'stream'
380
380
and output ['name' ] == 'stderr' ]
381
381
if stderr and not node .attributes ['stderr' ]:
382
- raise ExtensionError ('Cell printed to stderr:\n {}'
383
- .format (stderr [0 ]['text' ]))
382
+ logger . warning ('Cell printed to stderr:\n {}'
383
+ .format (stderr [0 ]['text' ]))
384
384
385
385
try :
386
386
lexer = notebook .metadata .language_info .pygments_lexer
@@ -407,6 +407,7 @@ def apply(self):
407
407
output_nodes = cell_output_to_nodes (
408
408
cell ,
409
409
self .config .jupyter_execute_data_priority ,
410
+ bool (node .attributes ["stderr" ]),
410
411
sphinx_abs_dir (self .env ),
411
412
thebe_config
412
413
)
@@ -463,14 +464,16 @@ def count(x):
463
464
return (list (x ) for _ , x in groupby (it , count ))
464
465
465
466
466
- def cell_output_to_nodes (cell , data_priority , dir , thebe_config ):
467
+ def cell_output_to_nodes (cell , data_priority , write_stderr , dir , thebe_config ):
467
468
"""Convert a jupyter cell with outputs and filenames to doctree nodes.
468
469
469
470
Parameters
470
471
----------
471
472
cell : jupyter cell
472
473
data_priority : list of mime types
473
474
Which media types to prioritize.
475
+ write_stderr : bool
476
+ If True include stderr in cell output
474
477
dir : string
475
478
Sphinx "absolute path" to the output folder, so it is a relative path
476
479
to the source folder prefixed with ``/``.
@@ -483,6 +486,8 @@ def cell_output_to_nodes(cell, data_priority, dir, thebe_config):
483
486
if (
484
487
output_type == 'stream'
485
488
):
489
+ if not write_stderr and output ["name" ] == "stderr" :
490
+ continue
486
491
to_add .append (docutils .nodes .literal_block (
487
492
text = output ['text' ],
488
493
rawsource = output ['text' ],
0 commit comments