File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
src/jupyter_contrib_nbextensions/nbextensions/limit_output Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ Parameters:
2424 description : Enable limiting display_data messages
2525 input_type : checkbox
2626 default : false
27+ - name : limit_html_output
28+ description : Enable limiting HTML outputs
29+ input_type : checkbox
30+ default : false
2731- name : limit_output_message
2832 description : Message to append when output is limited
2933 input_type : text
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ define([
1818 limit_stream : true ,
1919 limit_execute_result : true ,
2020 limit_display_data : false ,
21+ limit_html_output : false ,
2122 // message to print when output is limited
2223 limit_output_message : '<b>limit_output extension: Maximum message size of {limit_output_length} exceeded with {output_length} characters</b>'
2324 } ;
@@ -49,6 +50,14 @@ define([
4950 return old_handle_output . apply ( this , arguments ) ;
5051 }
5152 else {
53+ // HTML contents can not be simply truncated
54+ // that would result unclosed tags, corrupted HTML
55+ if (
56+ ! params . limit_html_output &&
57+ msg . content . data [ 'text/html' ] !== undefined
58+ ) {
59+ return old_handle_output . apply ( this , arguments ) ;
60+ }
5261 // get MAX_CHARACTERS from cell metadata if present, otherwise param
5362 //msg.header.msg_type
5463 var MAX_CHARACTERS = params . limit_output ;
You can’t perform that action at this time.
0 commit comments