javascript - What is the better way to show a log in HTML showing the indentation? -
i have application gulp task, in task have retire, security package, when run task gulp, log this:
demo-mobile 1.1.5 ↳ debowerify 1.3.1 ↳ bower 1.3.12 ↳ semver 2.3.2
i want save log in html format not possible, when run gulp, saves in html div.
child.stdout.setencoding('utf8'); child.stdout.on('data', function (data) { console.log(data); loginfo+= data; });
the html template doesn't have indentation console.
demo-mobile-1.1.5-↳-debowerify-1.3.1-↳-bower-1.3.12-
somebody have , idea how fix behavior.
best regards.
well, there might better way, how about:
var input = "demo-mobile-1.1.5-↳-debowerify-1.3.1-↳-bower-1.3.12-"; var spaces = " "; while (input.indexof("-↳-") >0) { input = input.replace("-↳-", "<br>"+spaces+"↳"); spaces += " "; } // below show output. var outputdiv = document.getelementbyid("output"); outputdiv.innerhtml = input;
<div id="output" style="white-space: pre"> </div>
Comments
Post a Comment