html2wiki

保留颜色语法高亮是最重要的。要不vim的html输出就没意义了。

先建立一个html2wiki.sed

s/<a href=”/[[/g
s/" mce_href="/[[/g
s/">http/|http/g
s/</a>/]]/g

s/<font |</font>/@@/g
s/color=”/color(/g
s/”>/):/g

/<pre>|</pre>/ d
/<body|</body>/ d
/<html>|</html>/ d
/<head>|</head>/ d
/<meta/ d

s/<title>/!!/g
s/</title>//g

s///// //g
s/<b>|</b>|<B>|</B>/”/g
#&><”
s/t/>/g
#s/^ */>/g
s/ {8}/>/g


然后,建立一个bash文件html2wiki.sh:

$ cat ./html2wiki.sh
#!/bin/bash

vim -c ":syntax on|:colorscheme morning|:TOhtml" -c ":w|:qa" $1

file $1.html|grep HTML
[ $? != 0 ] && exit;
sed -f ./html2wiki.sed $1.html > $1.wiki


直接这样运行。
$ html2wiki.sh 4428.c

得到的wiki文件,可以直接粘贴到tiddlywiki的编辑里面即可。

Monthly Archives

Pages

Powered by Movable Type 7.7.2

About this Entry

This page contains a single entry by Cnangel published on July 2, 2009 1:01 AM.

Pidgin and Yahoo (2) was the previous entry in this blog.

[Fw]When Linux Runs Out of Memory is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.