Skip to content

Commit 4e193de

Browse files
committed
Prettify html and js
1 parent c9dd33a commit 4e193de

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

demo_frame.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ module.exports = function(node){
4444
var js = getJS.call(this, sourceEl);
4545

4646
var dataForHtml = node.querySelector("[data-for=html] > pre");
47-
dataForHtml.innerHTML = html;
47+
dataForHtml.innerHTML = prettyify(html);
4848

4949
var dataForJS = node.querySelector("[data-for=js] > pre");
50-
dataForJS.innerHTML = js;
50+
dataForJS.innerHTML = prettyify(js.replace(/\t/g," "));
5151
show(node.querySelector("[data-tab=js]"));
5252

5353
tabs();
@@ -126,4 +126,10 @@ module.exports = function(node){
126126

127127
}
128128

129+
function prettyify(txt){
130+
txt = txt.replace(/</g, '&lt;');
131+
return typeof prettyPrintOne !== "undefined" ?
132+
prettyPrintOne(txt) : txt;
133+
}
134+
129135
};

0 commit comments

Comments
 (0)