summaryrefslogtreecommitdiff
path: root/javascript/videojs/docs/legacy-docs/api/js/highlight-syntax.js
diff options
context:
space:
mode:
Diffstat (limited to 'javascript/videojs/docs/legacy-docs/api/js/highlight-syntax.js')
-rw-r--r--javascript/videojs/docs/legacy-docs/api/js/highlight-syntax.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/javascript/videojs/docs/legacy-docs/api/js/highlight-syntax.js b/javascript/videojs/docs/legacy-docs/api/js/highlight-syntax.js
new file mode 100644
index 0000000..2fc9370
--- /dev/null
+++ b/javascript/videojs/docs/legacy-docs/api/js/highlight-syntax.js
@@ -0,0 +1,31 @@
+BCLSHighlighter = (function(hljs) {
+ var codeBlocks = document.querySelectorAll('pre>code'),
+ i,
+ iMax,
+ txt,
+ reLT = new RegExp('<', 'g'),
+ reGT = new RegExp('>;', 'g');
+
+ /**
+ * tests for all the ways a variable might be undefined or not have a value
+ * @param {*} x the variable to test
+ * @return {Boolean} true if variable is defined and has a value
+ */
+ function isDefined(x) {
+ if (x === '' || x === null || x === undefined || x === NaN) {
+ return false;
+ }
+ return true;
+ };
+
+ if (isDefined(codeBlocks)) {
+ iMax = codeBlocks.length;
+ for (i = 0; i < iMax; i++) {
+ txt = codeBlocks[i].innerHTML.toString();
+ txt = txt.replace(reLT, '&lt;');
+ txt = txt.replace(reGT, '&gt;');
+ codeBlocks[i].innerHTML = txt;
+ hljs.highlightBlock(codeBlocks[i]);
+ }
+ }
+})(hljs); \ No newline at end of file