##// END OF EJS Templates
fix(jupyter): added handling of v3 format issues. Fixes RCCE-30
ilin.s -
r5265:3705b0c6 default
parent child Browse files
Show More
@@ -539,18 +539,27 b' class MarkupRenderer(object):'
539 return body, resources
539 return body, resources
540
540
541 captured_errors = {}
541 captured_errors = {}
542 error_body = """
543 <div style="text-align: center;">
544 <h3>Invalid Notebook!</h3>
545 <p>{}</p>
546 </div>
547 """
542 # TODO: In the event of a newer jupyter notebook version, consider increasing the as_version parameter
548 # TODO: In the event of a newer jupyter notebook version, consider increasing the as_version parameter
543 notebook = nbformat.reads(source, as_version=4, capture_validation_error=captured_errors)
549 notebook = nbformat.reads(source, as_version=4, capture_validation_error=captured_errors)
544 if captured_errors:
550 if captured_errors:
545 error_messages = '<br>'.join(str(error) for error in captured_errors.values())
551 error_messages = '<br>'.join(str(error) for error in captured_errors.values())
546 body = f"""
552 body = error_body.format(error_messages)
547 <div style="text-align: center;">
548 <h3>Invalid Notebook!</h3>
549 <p>{error_messages}</p>
550 </div>
551 """
552 else:
553 else:
553 body, _ = as_html(notebook)
554 try:
555 body, _ = as_html(notebook)
556 except AttributeError:
557 try:
558 nbformat.validate(nbformat.reader.reads(source))
559 except nbformat.ValidationError as exc:
560 body = error_body.format(str(exc))
561 else:
562 raise
554 return body
563 return body
555
564
556
565
General Comments 0
You need to be logged in to leave comments. Login now