前端组件 ansiparser
- 授权协议: MIT
- 开发语言: HTML/CSS
- 操作系统: 跨平台
- 软件首页: https://github.com/duguying/ansiparser
- 软件文档: https://github.com/duguying/ansiparser
- 官方下载: https://github.com/duguying/ansiparser
软件介绍
ansiparser是一个前端组件,用于将linux终端输出的彩色日志展示到web页面。它通过解析linux终端的ansi转义字符实现彩色渲染,其渲染效果如下图。
安装
npm install xlog-ansiparser --save
使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="./node_modules/jquery/dist/jquery.js"></script>
<script src="./dist/xlog-1.0.0.js"></script>
<link rel="stylesheet" target="_blank" rel="nofollow" href="./xlog.css">
<style>
body{
margin: 0;
}
</style>
</head>
<body>
<pre id="xlog" class="dark">
</pre>
</body>
<script>
var container = document.getElementById("xlog")
var lexer = new XLog(container)
$(document).ready(function (e) {
$.ajax({
method: "GET",
url: "https://api.travis-ci.org/v3/job/31095019/log.txt",
success: function (data) {
let segs = data.split("\n");
segs.forEach((v, i) => {
setTimeout(() => {
let substr = v;
if (segs.length !== i + 1) {
substr = substr + "\n"
}
lexer.write(substr)
}, 0)
})
}
})
});
</script>
</html>
源码仓库
https://github.com/duguying/ansiparser
Effective JavaScript
David Herman / Addison-Wesley Professional / 2012-12-6 / USD 39.99
"It's uncommon to have a programming language wonk who can speak in such comfortable and friendly language as David does. His walk through the syntax and semantics of JavaScript is both charming and h......一起来看看 《Effective JavaScript》 这本书的介绍吧!
