ansifilter: Ansi Escape Sequences 转 html / latex / tex / rtf
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
ansifilter: Ansi Escape Sequences 转 html / latex / tex / rtf
比 ctlseqs2html.pl (格式/效率方面)效果好的,当然还是不及 vim:tohtml。但是更灵范啊。只要是命令结果,管道过去就行的。
多种格式支持。支持qt界面(这和我无关了)。
带上 -e "utf-8" 吧,居然缺省不使用 utf-8。等下改改源码。只是发现有些情况,颜色被过滤了。
http://www.andre-simon.de/zip/ansifilter-1.2.tar.bz2
多种格式支持。支持qt界面(这和我无关了)。
带上 -e "utf-8" 吧,居然缺省不使用 utf-8。等下改改源码。只是发现有些情况,颜色被过滤了。
http://www.andre-simon.de/zip/ansifilter-1.2.tar.bz2
- 附件
-
- 效果图
- 2009-02-25-104017_496x92_scrot.png (9.77 KiB) 查看 18189 次
● 鸣学
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
Re: ansifilter: Ansi Escape Sequences 转 html / latex / tex / rtf
http://search.cpan.org/~nuffin/HTML-Fro ... romANSI.pm 安装不了
probetohtml 找不到,难道仅仅在源码包里面???
136 sh exifprobe-2.0.1 /home/tar/public_html/lina/sloccount/exifprobe-2.0.1/aux/probetohtml
diffhtml.bash 不行
http://www.kessels.com/downloads/ansi2h ... 1.5.tar.gz C的,编译不了。。。。
http://www.koders.com/python/fid5D57DD3 ... f%3Aparser 仅仅一个测试版本
ansi2html 找不到合适的啊。
probetohtml 找不到,难道仅仅在源码包里面???
136 sh exifprobe-2.0.1 /home/tar/public_html/lina/sloccount/exifprobe-2.0.1/aux/probetohtml
diffhtml.bash 不行
http://www.kessels.com/downloads/ansi2h ... 1.5.tar.gz C的,编译不了。。。。
http://www.koders.com/python/fid5D57DD3 ... f%3Aparser 仅仅一个测试版本
ansi2html 找不到合适的啊。
● 鸣学
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
Re: ansifilter: Ansi Escape Sequences 转 html / latex / tex / rtf
谁来修改这脚本,sed转的。主要是cat -v过滤了东西。导致问题。
屏幕拷贝内容
代码: 全选
#!/bin/bash
# Convert ANSI (terminal) colour codes to HTML
# Author:
# http://www.pixelbeat.org/docs/terminal_colours/
# Changes:
# V0.1, 24 Apr 2008, Initial release
# V0.2, 01 Jan 2009, Phil Harnish <philharnish@gmail.com>
# Support `git diff --color` output by
# matching ANSI codes that specify only
# bold or background colour.
# P@draigBrady.com
# Support `ls --color` output by stripping
# redundant leading 0s from ANSI codes.
# Support `grep --color` by stripping
# unhandled ANSI codes (specifically ^[[K).
echo -n "
<head>
<style type=\"text/css\">
/* linux console palette */
.f0 { color: #000000; }
.f1 { color: #AA0000; }
.f2 { color: #00AA00; }
.f3 { color: #AA5500; }
.f4 { color: #0000AA; }
.f5 { color: #AA00AA; }
.f6 { color: #00AAAA; }
.f7 { color: #AAAAAA; }
.bf0 { color: #555555; }
.bf1 { color: #FF5555; }
.bf2 { color: #55FF55; }
.bf3 { color: #FFFF55; }
.bf4 { color: #5555FF; }
.bf5 { color: #FF55FF; }
.bf6 { color: #55FFFF; }
.bf7 { color: #FFFFFF; }
.b0 { background-color: #000000; }
.b1 { background-color: #AA0000; }
.b2 { background-color: #00AA00; }
.b3 { background-color: #AA5500; }
.b4 { background-color: #0000AA; }
.b5 { background-color: #AA00AA; }
.b6 { background-color: #00AAAA; }
.b7 { background-color: #AAAAAA; }
</style>
</head>
<html>
<body>
<pre>
"
cat -v |
#first line strips non SGR codes
#second line normalizes SGR codes a little
sed '
s#\^\[\#[0-9]##g
s#\^M##g
s#\^\[\[[0-9;]*[A-KSTfnsu]##g;
s#\^\[\[0\([0-7]\)#^[[\1#g; s#\^\[\[1m\^\[\[\([34][0-7]m\)#^[[1;\1#g; s#\^\[\[m#^[[0m#g;
s#\^\[\[1m#<span style="font-weight:bold">#g;
s#\^\[\[0m#</span>#g;
s#\^\[\[\([0-7]\);9\([0-7]\)m#<span class=" f\1 b\2">#g;
s#\^\[\[0;4\([0-7]\);3\([0-7]\)m#<span class="bf\1 b\2">#g;
s#\^\[\[3\([0-7]\)m#<span class=" f\1">#g;
s#\^\[\[4\([0-7]\)m#<span class=" b\1">#g;
s#\^\[\[1;3\([0-7]\)m#<span class="bf\1">#g;'
#s#\^\[\[3\([0-7]\);4\([0-7]\)m#<span class=" f\1 b\2">#g;
echo "</pre>
</body>
</html>
"
代码: 全选
^[#5^[[0m^[[0;93m 4 ^[[0;96m#cat ~/xterm-screenshot.copy|ansifilter -H -e "
utf-8">~/xterm-screenshot.htm^[[0m
^[#5^[[0m^[[0;93m ^[[0;96ml^[[0m
^[#5^[[0m^[[0;93m 5 ^[[0m
^[#5^[[0m^[[0;93m 6 if^[[0m ^[[0;93m[^[[0m ^[[0;93m-x^[[0m ~/# # /# # /ctls
eqs2html.pl ^[[0;93m];^[[0m ^[[0;93mthen^[[0m
^[#5^[[0m^[[0;93m 7 ^[[0m ctlseqs2html.pl -width ^[[0;95m100^[[0m ~/
xterm-screenshot.copy ^[[0;93m>^[[0m ~/xterm-screens^[[0m
^[#5^[[0m^[[0;93m ^[[0mhot.html^[[0m
^[#5^[[0m"xterm2html.bash" 9L, 276C # # # ^[[0m
^[#5^[[0m^[[0;47;31m2009-02-25 10:47:49 # ^[[0;47;32m ~ ^[[0m ^[[0m
^[#5^[[0m# ^[[0m
● 鸣学
- sevk
- 帖子: 2060
- 注册时间: 2007-05-08 16:26
- 系统: arch
- 来自: 火星内核某分子内某原子核内
- 联系:
Re: ansifilter: Ansi Escape Sequences 转 html / latex / tex / rtf
笔记本 :
F208S : gentoo
A460P i3G D6 : UBUNTU + WIN7
UN43D1 : UBUNTU + WIN7
1000人超级QQ群 LINUX + WIN : 31465544 或 18210387
F208S : gentoo
A460P i3G D6 : UBUNTU + WIN7
UN43D1 : UBUNTU + WIN7
1000人超级QQ群 LINUX + WIN : 31465544 或 18210387
- HuntXu
- 帖子: 5776
- 注册时间: 2007-09-29 3:09
Re: ansifilter: Ansi Escape Sequences 转 html / latex / tex / rtf
HUNT Unfortunately No Talent...
- HuntXu
- 帖子: 5776
- 注册时间: 2007-09-29 3:09
Re: ansifilter: Ansi Escape Sequences 转 html / latex / tex / rtf
不知道你说的cat -v会过滤掉什么,不会拷贝屏幕,没其他的测试...
HUNT Unfortunately No Talent...
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
Re: ansifilter: Ansi Escape Sequences 转 html / latex / tex / rtf
代码: 全选
☎ dog xterm2html.bash
cat > ~/xterm-screenshot.copy
cat ~/xterm-screenshot.copy|ansi2html.bash > ~/xterm-screenshot.html
代码: 全选
☎ dog ansi2html.bash
echo -n "
<head>
<style type=\"text/css\">
/* linux console palette */
.f0 { color: #000000; }
.f1 { color: #AA0000; }
.f2 { color: #00AA00; }
.f3 { color: #E5E414; }
.f4 { color: #0000AA; }
.f5 { color: #FF00FF; }
.f6 { color: #01FEFD; }
.f7 { color: #AAAAAA; }
.bf0 { color: #555555; }
.bf1 { color: #FF5555; }
.bf2 { color: #55FF55; }
.bf3 { color: #FFFF55; }
.bf4 { color: #5555FF; }
.bf5 { color: #FF55FF; }
.bf6 { color: #55FFFF; }
.bf7 { color: #FFFFFF; }
.b0 { background-color: #000000; }
.b1 { background-color: #AA0000; }
.b2 { background-color: #00AA00; }
.b3 { background-color: #AA5500; }
.b4 { background-color: #0000AA; }
.b5 { background-color: #AA00AA; }
.b6 { background-color: #00AAAA; }
.b7 { background-color: #AAAAAA; }
.b { font-weight:bold; }
.n { font-weight:normal; color: #AAAAAA; background-color: #000000; }
.r { color: #000000; background-color: #AAAAAA; }
</style>
</head>
<html>
<body bgcolor=\"#000000\" text=\"#ffffff\">
<pre>
"
echo '<span>'
sed 's/\xef\xbf\xbf//g'|\
sed 's#\&#\&#g; s#>#\>#g; s#<#\<#g'|\
sed 's#\x1b\#[0-9]##g'|\
sed 's#\x1b\[\([0-9;]*\)m#↗\1↖#g'|\
sed 's#\(↗[^↖]*\<1\>[^↖]*\)↖#\1 b↖#g'|\
sed 's#\(↗[^↖]*\<7\>[^↖]*\)↖#\1 r↖#g'|\
sed 's#\(↗[^↖]*\<3\([0-7]\)\>[^↖]*\)↖#\1 f\2↖#g'|\
sed 's#\(↗[^↖]*\<4\([0-7]\)\>[^↖]*\)↖#\1 b\2↖#g'|\
sed "s#↗[0-9;\ ]*#</span><span class=\"#g"|\
sed "s#↖#\">#g"|\
sed "s#^#</span><span class=\"n\">#g"|\
cat
echo '</span>'
echo "</pre>
</body>
</html>
"
● 鸣学
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
- xiooli
- 帖子: 6956
- 注册时间: 2007-11-19 21:51
- 来自: 成都
- 联系:
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
Re: ansifilter: Ansi Escape Sequences 转 html / latex / tex / rtf
完善版本,容易看懂了吧。
喜欢看html的:http://eexpress.blog.ubuntu.org.cn/2009 ... l-version/
喜欢看html的:http://eexpress.blog.ubuntu.org.cn/2009 ... l-version/
代码: 全选
#!/bin/bash
# Convert ANSI (terminal) colour codes to HTML
# Last Modify: eexpress @ 2009-02-27
# Author:
# http://www.pixelbeat.org/docs/terminal_colours/
echo -n "
<head>
<style type=\"text/css\">
/* linux console palette */
.f0 { color: #000000; }
.f1 { color: #FF0000; }
.f2 { color: #00AA00; }
.f3 { color: #E5E414; }
.f4 { color: #5B5BFC; }
.f5 { color: #FF00FF; }
.f6 { color: #01FEFD; }
.f7 { color: #AAAAAA; }
.bf0 { color: #555555; }
.bf1 { color: #FF5555; }
.bf2 { color: #55FF55; }
.bf3 { color: #FFFF55; }
.bf4 { color: #5555FF; }
.bf5 { color: #FF55FF; }
.bf6 { color: #55FFFF; }
.bf7 { color: #FFFFFF; }
.b0 { background-color: #000000; }
.b1 { background-color: #AA0000; }
.b2 { background-color: #00AA00; }
.b3 { background-color: #CDCD00; }
.b4 { background-color: #0000AA; }
.b5 { background-color: #AA00AA; }
.b6 { background-color: #00AAAA; }
.b7 { background-color: #E5E5E5; }
.bold { font-weight:bold; }
.normal { font-weight:normal; color: #AAAAAA; background-color: #000000; }
.reverse { background-color: #2A2A2A; }
.underline { text-decoration: underline; }
.line-through { text-decoration: line-through; }
.blink { text-decoration: blink; }
</style>
<title>xterm ansi color screenshot -> html</title>
</head>
<html>
<body bgcolor=\"#000000\" text=\"#ffffff\">
<pre>
"
#<meta content="charset=UTF-8">
#<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
#<meta http-equiv="content-type" content="text/html; charset=UTF-8">
p='↗[^↖]*\<'
e='\>[^↖]*'
echo '<span>'
sed 's/\xef\xbf\xbf//g'|\
sed 's#\&#\&#g; s#>#\>#g; s#<#\<#g'|\
#sed 's#\"#\"#g; s#\ +#\ #g'|\
sed 's#\x1b\#[0-9]##g'|\
#sed 's#\x1b\[0m##g'|\
sed 's#\x1b\[\([0-9;]*\)m#↗\1↖#g'|\
sed "s#${p}1${e}#& bold#g"|\
sed "s#${p}4${e}#& underline#g"|\
sed "s#${p}5${e}#& blink#g"|\
sed "s#${p}7${e}#& reverse#g"|\
sed "s#${p}9${e}#& line-through#g"|\
sed "s#${p}3\([0-7]\)${e}#& f\1#g"|\
sed "s#${p}4\([0-7]\)${e}#& b\1#g"|\
#sed "s#↗0↖##g"|\
sed "s#↗[0-9;\ ]\+#</span><span class=\"#g"|\
sed "s#↖#\">#g"|\
#sed "s#^#</span><span class=\"normal\">#g"|\
tr -d "\r"|\
cat
echo '</span>'
echo "</pre>
</body>
</html>
"
● 鸣学
-
- 帖子: 1
- 注册时间: 2019-09-27 15:50
- 系统: programmer
Re: ansifilter: Ansi Escape Sequences 转 html / latex / tex / rtf
Thank you guys, this actually solved my problem!:谢谢大家,这实际上解决了我的问题!