Zsolt Haraszti | 9ceb1b8 | 2016-10-01 15:15:18 -0700 | [diff] [blame] | 1 | 'use strict'; |
| 2 | |
| 3 | (function () { |
| 4 | var configure, highlightBlock; |
| 5 | |
| 6 | configure = hljs.configure; |
| 7 | // "extending" hljs.configure method |
| 8 | hljs.configure = function _configure (options) { |
| 9 | var size = options.highlightSizeThreshold; |
| 10 | |
| 11 | // added highlightSizeThreshold option to set maximum size |
| 12 | // of processed string. Set to null if not a number |
| 13 | hljs.highlightSizeThreshold = size === +size ? size : null; |
| 14 | |
| 15 | configure.call(this, options); |
| 16 | }; |
| 17 | |
| 18 | highlightBlock = hljs.highlightBlock; |
| 19 | |
| 20 | // "extending" hljs.highlightBlock method |
| 21 | hljs.highlightBlock = function _highlightBlock (el) { |
| 22 | var innerHTML = el.innerHTML; |
| 23 | var size = hljs.highlightSizeThreshold; |
| 24 | |
| 25 | // check if highlightSizeThreshold is not set or element innerHTML |
| 26 | // is less than set option highlightSizeThreshold |
| 27 | if (size == null || size > innerHTML.length) { |
| 28 | // proceed with hljs.highlightBlock |
| 29 | highlightBlock.call(hljs, el); |
| 30 | } |
| 31 | }; |
| 32 | |
| 33 | })(); |
| 34 | |