forked from swagger-api/swagger-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
performance swagger-api#1956 added highlightSizeThreshold option disa…
…ble highlight when length more than highlightSizeThreshold
- Loading branch information
Showing
6 changed files
with
58 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
(function () { | ||
var configure, highlightBlock; | ||
|
||
configure = hljs.configure; | ||
// "extending" hljs.configure method | ||
hljs.configure = function _configure (options) { | ||
var size = options.highlightSizeThreshold; | ||
|
||
// added highlightSizeThreshold option to set maximum size | ||
// of processed string. Set to null if not a number | ||
hljs.highlightSizeThreshold = size === +size ? size : null; | ||
|
||
configure.call(this, options); | ||
}; | ||
|
||
highlightBlock = hljs.highlightBlock; | ||
|
||
// "extending" hljs.highlightBlock method | ||
hljs.highlightBlock = function _highlightBlock (el) { | ||
var innerHTML = el.innerHTML; | ||
var size = hljs.highlightSizeThreshold; | ||
|
||
// check if highlightSizeThreshold is not set or element innerHTML | ||
// is less than set option highlightSizeThreshold | ||
if (size == null || size > innerHTML.length) { | ||
// proceed with hljs.highlightBlock | ||
highlightBlock.call(hljs, el); | ||
} | ||
}; | ||
|
||
})(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters