-
Notifications
You must be signed in to change notification settings - Fork 9
/
html2wiki
executable file
·30 lines (27 loc) · 1.03 KB
/
html2wiki
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
# Usage:
# 1st step: vim sample.sh => :TOhtml => save as sample.sh.html
# 2nd step: html2wiki sample.sh.html
#
# Description about the following 5 sed command lines.
# 1st: replace <body bgcolor="#1c1c1c" text="#d0d0d0"> with <div style="font-family: Consolas, Monaco, Courier New; background: #1c1c1c; color:#d0d0d0">
# 2nd: remove <font face="">
# 3nd: replace </body> with </div>
# 4rd: because [[:xxx:]] is a wiki-style command, replace it!
# 5th: for fancy layout
# 6th: remove useless html lines, eg: <DOCTYPE..>, <html>, <head>, <title>, <meta> ...
#
#
ARGUMENT="$1"
if [ -z "$ARGUMENT" ] ; then
echo "Usage: $0 filename"
exit 1
fi
sed -e 's/<body bgcolor="\(.*\)" text="\(.*\)" \(.*\)>/<div style="font-size:13px; font-family: Consolas, Monaco, Courier New; background:\1; color:\2;">/;
s/<font face="\(.*\)">//;
s/<\/font>$/<\/div>/;
s/<\/html>$//;
s/<\/body>$//;
s/\[\[/<nowiki>\[\[<\/nowiki>/g;
s/ <\/span><br>/\ <\/span><br>/g;
1,40d; $d' $1