Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/426.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将生成的子进程输出显示为彩色html?_Javascript_Html_Node.js_Electron - Fatal编程技术网

Javascript 如何将生成的子进程输出显示为彩色html?

Javascript 如何将生成的子进程输出显示为彩色html?,javascript,html,node.js,electron,Javascript,Html,Node.js,Electron,我正在开发一个electron node js应用程序。(我是新手) 我有一些代码可以启动一个进程,然后在html窗口中显示输出 但是如果可能的话,我想更进一步,并以彩色显示输出。(在我当前的html自定义web组件中) 我该怎么做?或者更具体地说,如何获取颜色信息,以便将其转换为html 以下是运行该流程的部分代码: let child function start(startInfo) { output.lines = [`${startInfo.processName} ${st

我正在开发一个electron node js应用程序。(我是新手)

我有一些代码可以启动一个进程,然后在html窗口中显示输出

但是如果可能的话,我想更进一步,并以彩色显示输出。(在我当前的html自定义web组件中)

我该怎么做?或者更具体地说,如何获取颜色信息,以便将其转换为html

以下是运行该流程的部分代码:

let child

function start(startInfo) {
    output.lines = [`${startInfo.processName} ${startInfo.args.join(' ')}`]

    child = child_process.spawn(startInfo.processName, startInfo.args)

    child.on('error', addOutput)
    child.on('message', addOutput)
    child.on('close', (code, signal) => {
        addOutput('Pipeline closed')
        child = null
    })

    child.stdout.setEncoding('utf8')
    child.stdout.on('data', addOutput)

    child.stderr.setEncoding('utf8')
    child.stderr.on('data', addOutput)
    child.on('exit', (code, signal) => {
        addOutput(`Exited with ${code}`)
        child = null
    })
}

function addOutput(newLine) {
    output.lines = output.lines.concat(['\n', newLine])
}
这就是我看到的输出(HTML):

如何更接近原始控制台输出:


?不完全是这样,我正试图做相反的
过程输出->html页面(带有颜色信息)
粉笔
帮助
记录(颜色)->过程输出
?不完全是这样,我正试图做相反的
过程输出->html页面(带有颜色信息)
粉笔
帮助
记录(颜色)->过程输出