pkg://txt2tags-1.5.tbz:109102/
share/
txt2tags/unhtml.vim
downloads
" unhtml.vim - by aurelio
" converts HTML tags into txt2tags marks
" part of the txt2tags <http://txt2tags.sf.net> software
"
" INSTRUCTIONS
" 1. open the HTML file on Vim and execute
" :so unhtml.vim
"
" 2. a new <yourfile>.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]\s*$/join
g/<\s*a\s[^>]*>[^<]*$/join
""" [ do it! ]
" link
%s,<\s*a\s\+href="\(.\{-}\)"\s*>\(.\{-}\)<\/a>,[\2 \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,</\=\s*h1\s*>,=,ge
%s,</\=\s*h2\s*>,==,ge
%s,</\=\s*h3\s*>,===,ge
%s,</\=\s*h4\s*>,====,ge
%s,</\=\s*h5\s*>,=====,ge
%s,</\=\s*h6\s*>,=====,ge
" beutifiers
%s,</\=\s*code\s*>,`,ge
%s,</\=\s*b\s*>,**,ge
%s,</\=\s*i\s*>,//,ge
%s,</\=\s*u\s*>,__,ge
" pre
%s,</\=\s*pre\s*>,
---
,ge
" bullet/numbered list
%s,<\s*li\s*>,- ,ge
%s,</\s*li\s*>,,ge
%s,<\s*[uo]l\s*>,,ge
%s,</\s*[uo]l\s*>,
,ge
" definition list
%s,<\s*dl\s*>,,ge
%s,</\s*dl\s*>,
,ge
%s,<\s*dt\s*>,= ,ge
%s,</\s*dt\s*>,:,ge
%s,</\=\s*dd\s*>,,ge
" BR is ignored
%s,<\s*br\s*>,
,ge
" trash
%s,</\s*font[^>]*\s*>,,ge
%s,</\s*p\s*>,,ge
%s,</\s*a\s*>,,ge
%s,</\=\s*blink\s*>,,ge
%s,<\s*a\s\+name=[^>]*>,,ge
%s,</\=\s*\(html\|body\|head\|title\)\(\s[^>]*\)\=\s*>,,ge
" mmmmm, dangerous!
%s,<[^>]*>,,ge
" clear empty lines
%s,^\s*$,,
" special
%s,&,\&,ge
%s,>,>,ge
%s,<,<,ge
" save new .t2t file and turn on syntax
saveas! %.t2t | set ft=txt2tags