Skip to content

Commit

Permalink
do not pipe non-json data through json.dumps
Browse files Browse the repository at this point in the history
  • Loading branch information
sgsaenger committed Nov 6, 2018
1 parent eb3b0a7 commit 061543f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions nbconvert/preprocessors/extractoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class ExtractOutputPreprocessor(Preprocessor):
).tag(config=True)

extract_output_types = Set(
{'image/png', 'image/jpeg', 'image/svg+xml', 'application/pdf'}
{'image/png', 'image/jpeg', 'image/svg+xml',
'application/pdf', 'application/json'}
).tag(config=True)

def preprocess_cell(self, cell, resources, cell_index):
Expand Down Expand Up @@ -80,10 +81,7 @@ def preprocess_cell(self, cell, resources, cell_index):
if mime_type in out.data:
data = out.data[mime_type]

if (
not isinstance(data, text_type)
or mime_type == 'application/json'
):
if mime_type == 'application/json':
# Data is either JSON-like and was parsed into a Python
# object according to the spec, or data is for sure
# JSON. In the latter case we want to go extra sure that
Expand Down

0 comments on commit 061543f

Please sign in to comment.