-
Notifications
You must be signed in to change notification settings - Fork 3
/
tohtml.sh
55 lines (46 loc) · 1.24 KB
/
tohtml.sh
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh
#
# Configure colorscheme and where to source plantuml-syntax/syntax/plantuml.vim
# from
#
# colors="\$VIMRUNTIME/colors/default.vim"
# colors="${HOME}/.vim/bundle/gruvbox/colors/gruvbox.vim"
tools="tohtml.vim"
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: vimtohtml.sh <inputFile> <out>"
echo " produces out.pre.html and out.css"
exit 1
fi
toHtml="$VIM_TO_HTML"
if ! [ -e "$toHtml" ]; then
for ver in 91 90 82 81; do
toHtml="$HOME/install/share/vim/vim$ver/syntax/2html.vim"
if ! [ -e "$toHtml" ]; then
toHtml="/usr/share/vim/vim$ver/syntax/2html.vim"
fi
if [ -e "$toHtml" ]; then
break
fi
done
fi
if ! [ -e "$toHtml" ]; then
echo "Cannot find 2html.vim script, set VIM_TO_HTML variable"
exit 1
fi
tmpFile=$(mktemp /tmp/tohtml-sh.XXXX)
PACKPATH="`pwd`/vim"
vim --noplugin -u NONE \
-c ":syntax on" \
-c ":set nocp" \
-c ":source ${tools}" \
-c ":set bg=light" \
-c ":colorscheme default" \
-c ":call IndentPlantUML('$1')" \
-c ":let g:loaded_2html_plugin = 0" \
-c ":source $toHtml" \
-c ":w! ${tmpFile}" \
-c "qa!"
sed -rn '/^<pre/, /^<\/pre/ p' "${tmpFile}" > "${2}.pre.html"
sed -rn '/^\.[A-Z]+[a-zA-Z0-9]+ +\{/ p' "${tmpFile}" > "${2}.syntax.css"
echo tmp
cat "${tmpFile}"