Skip to content

Commit 8303634

Browse files
authored
Merge pull request #86 from DMOJ/optional-hljs
Make hljs optional in the preview
2 parents e674bd8 + 2db263e commit 8303634

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

martor/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
'mention': 'false', # to enable/disable mention
99
'jquery': 'true', # to include/revoke jquery (require for admin default django)
1010
'living': 'false', # to enable/disable live updates in preview
11-
'spellcheck': 'true', # to enable/disable spellcheck in form textareas
11+
'spellcheck': 'true', # to enable/disable spellcheck in form textareas
12+
'hljs': 'true', # to enable/disable hljs highlighting in preview
1213
}
1314
)
1415

martor/static/martor/js/martor.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,16 @@
151151
contentType: false,
152152
success: function(response) {
153153
if(response){
154+
if (editorConfig.hljs == 'true') {
155+
$('pre').each(function (i, block) {
156+
hljs.highlightBlock(block);
157+
});
158+
}
154159
currentTab.html(response).removeClass('martor-preview-stale');
155-
$('pre').each(function(i, block){
156-
hljs.highlightBlock(block);
157-
});
158160
$(document).trigger('martor:preview', [currentTab]);
159-
}else {currentTab.html('<p>Nothing to preview</p>');}
161+
}else {
162+
currentTab.html('<p>Nothing to preview</p>');
163+
}
160164
},
161165
error: function(response) {
162166
console.log("error", response);

0 commit comments

Comments
 (0)