" unhtml.vim - by Aurelio Jargas " - Converts HTML tags into txt2tags marks " - Part of the txt2tags software " " INSTRUCTIONS " 1. Open the HTML file on Vim and execute " :so /path/to/unhtml.vim " " 2. A new .html.t2t will be saved. " " 3. Check the new .t2t file and correct by hand what has left. " """ [ preparing ] " ignore case set ic " join multiline tags g/<\s*\([ap]\|img\)\s*$/join g/<\s*a\s[^>]*>[^<]*$/join """ [ do it! ] " link %s,<\s*a\s[^>]*href="\(.\{-}\)"[^>]*>\(.\{-}\)<\/a>,[\2 \1],ge %s,<\s*a\s[^>]*href=\([^ >]\+\)[^>]*>\(.\{-}\)<\/a>,[\2 \1],ge " images %s,<\s*img\s[^>]*src="\(.\{-}\)"[^>]*>,[\1],ge %s,<\s*img\s[^>]*src=\([^ >]\+\)[^>]*>,[\1],ge " anchor %s,^<\s*a\s\+name=.\{-}>\(.*\)<\/a>,== \1 ==,ge " comments %s,\s*,\% \1,ge //s,^,\% ,e " paragraph %s,<\s*p\(\s[^>]*\)\=\s*>, ,ge " bar %s,<\s*hr[^>]*>,-------------------------------------------------,ge " title %s,,=,ge %s,,==,ge %s,,===,ge %s,,====,ge %s,,=====,ge %s,,=====,ge " beautifiers %s,,``,ge %s,,**,ge %s,,//,ge %s,,__,ge " pre %s,, ``` ,ge " bullet/numbered list %s,<\s*li\s*>,- ,ge %s,,,ge %s,<\s*[uo]l\s*>,,ge %s,, ,ge " definition list %s,<\s*dl\s*>,,ge %s,, ,ge %s,<\s*dt\s*>,: ,ge %s,, ,ge %s,,,ge " BR is ignored %s,<\s*br\s*/*>, ,ge " trash %s,]*\s*>,,ge %s,,,ge %s,,,ge %s,,,ge %s,<\s*a\s\+name=[^>]*>,,ge %s,]*\)\=\s*>,,ge " mmmmm, dangerous! it removes all remaining HTML tags "%s,<[^>]*>,,ge " clear just-blanks lines %s,^\s*$,, " special entities %s,",",ge %s,&,\&,ge %s,>,>,ge %s,<,<,ge %s, , ,ge " save new .t2t file and turn on syntax saveas! %.t2t | set ft=txt2tags