简体   繁体   English

如何将控制台应用程序(如MSBuild或PowerShell)的彩色输出转换为保留颜色的HTML格式?

[英]How to convert colored output of a console application (like MSBuild or PowerShell) into HTML format preserving colors?

When I run certain console applications (particularly, MSBuild or PowerShell) they produce an output containing text of different colors (for warnings, errors etc). 当我运行某些控制台应用程序(特别是MSBuild或PowerShell)时,它们会生成包含不同颜色文本的输出(用于警告,错误等)。 Sometimes I need to save it for a future analysis, or to send it in an e-mail. 有时我需要将其保存以供将来分析,或通过电子邮件发送。 I only can copy plain text from the console, or redirect the program output to a file, but this way all colors are lost. 我只能从控制台复制纯文本,或者将程序输出重定向到文件,但这样所有颜色都会丢失。 Is there a way to capture an output of a console application in a color-preserving format like HTML or RTF? 有没有办法以HTML或RTF等颜色保留格式捕获控制台应用程序的输出?

Powershell团队在博客中发布了脚本 ,该脚本将控制台屏幕缓冲区捕获到当前光标位置并以HTML格式返回。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM