#!/bin/sh
# (c) komar
#
# Please run script from vim by adding to ~/www/.vimrc
# ---
# autocmd BufWritePost */index.c :!./c2html index.c
# ---
# colorcheme of vim will apply.

[ $# != 1 ] && exit 1
# COLOR_SCHEME=elflord
# COLOR_SCHEME=desert
# COLOR_SCHEME=ron
# COLOR_SCHEME=delek

#       +"colorscheme $COLOR_SCHEME" \

vim -n +"syn on"\
       +"let g:html_hover_unfold = 1"\
       +"run! syntax/2html.vim"\
       +"wqa!"\
         $1

#vim -R +'syn on | run! syntax/2html.vim"<cr>| wqa!<cr>' $1

sed -i -e '
    /HAVE_WEB_MENU/,/#endif/{
        s@logs\.h@<a href="logs/linux_raw/?C=M;O=D">&</a>@
        t

        s@\(stats\|gallery\|workplaces\|fun-and-profit\|shots\|quote\|calc\|src\)\.h@<a href="\1">&</a>@
        t

        s@;\([a-z]\{1,\}\.h\)@;<a href="\1tml">\1</a>@
    }
    s@font-@&size: 1.2em; &@

    /<style type="text\/css">/a \
        a:link, a:active { color\: #0033ff\; } \
        a:visited { color: #0066ff\; }

    #s@\(href\)\(='\''javascript:toggleFold\)@\1="#" target="_blank" onClick\2@g
    s@hover@onclick@g

    s@\(<span id='\''fold3'\'' class='\''\)open-fold\('\''>\)@\1closed-fold\2@
' $1.html
