Skip to content

Commit dc5c24f

Browse files
authored
Merge pull request #1614 from deeenes/master
`limit_outputs`: do not truncate HTML outputs
2 parents c76f991 + 6ed23cc commit dc5c24f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/jupyter_contrib_nbextensions/nbextensions/limit_output/limit-output.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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

src/jupyter_contrib_nbextensions/nbextensions/limit_output/main.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)