]>
git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/pretty-json/node_modules/jsonminify/report/assets/scripts/vendor/codemirror/util/colorize.js
62286d21e406fe90dfb7c28ac731245ca7ea5b29
1 CodeMirror
.colorize
= (function() {
3 var isBlock
= /^(p|li|div|h\\d|pre|blockquote|td)$/;
5 function textContent(node
, out
) {
6 if (node
.nodeType
== 3) return out
.push(node
.nodeValue
);
7 for (var ch
= node
.firstChild
; ch
; ch
= ch
.nextSibling
) {
9 if (isBlock
.test(node
.nodeType
)) out
.push("\n");
13 return function(collection
, defaultMode
) {
14 if (!collection
) collection
= document
.body
.getElementsByTagName("pre");
16 for (var i
= 0; i
< collection
.length
; ++i
) {
17 var node
= collection
[i
];
18 var mode
= node
.getAttribute("data-lang") || defaultMode
;
22 textContent(node
, text
);
24 CodeMirror
.runMode(text
.join(""), mode
, node
);
26 node
.className
+= " cm-s-default";