I am running a bash script from a nodejs server and then sending the output of that over to a webpage where it is being displayed. I want to be able to style the output and not have it appear as just a bunch of text. Right now the script outputs this:
Disk quotas for user {USER} :
Filesystem blocks quota limit grace files quota limit grace
hpcstore03:/hpc_home/home
33528 5120M 5120M 2668 4295m 4295m
This is run asynchronously on the server and then a render function is called that displays a webpage and all the page has on it is the output of the script. So something like:
router.get("/", function(request, response){
exec('/usr/local/bin/foobar', function(error, stdout, stderr){
response.render('index', {
baseUri: baseUri,
output: stdout,
title: "foobar",
error: stderr,
});
});
});
And the webpage code is just:
<h1>{{title}}</h1>
<pre>{{output}}</pre>
So how do I get the output to be formatted, like if I wanted to bold parts of it, or put separate parts of the output into a table? Would I write some javascript to be ran locally that would search through the {{output}} string and load parts of it into elements on the page? I'm not quite sure if that would work anyways because I am new to the whole rendering using {{}} syntax.
答案 0 :(得分:0)
您需要从docker run -d -p 5000:5000 --restart=always --name registry registry:2
生成HTML。你可以用换行符拆分它,因此有四行。围绕这些包裹stdout
。但在此之前,请按照您拥有的空白分隔符拆分元素,将单个单词放入<p></p>
,并确保为某些关键字设置<span></span>
的样式,例如 FileSystem 并确保font-weight
具有正确的span
t,因此它们之间会有空格。当然,你可以做更多,这些只是一些基本的建议。