Vim HTML to Markdown
01 Aug 2012If you need to remove HTML from documents (or convert basic HTML to Markdown) with Vim below are the main search and replace commands. I’ve been using these to convert stuff from simple html to markdown.
Pandoc is a great tool that can convert html to markdown - but I only want to convert sections in documents - so i’ve been using these Vim command to do the job - simple and works well
:%s/ / /g
:%s/ / /g
:%s/<div>//g
:%s/<\/div>//g
:%s/^M//g
:%s/<p \/>/\r/g
:%s/<p >//g
:%s/<p>//g
:%s/<\/p >/\r/g
:%s/<\/p>/\r/g
:%s/</</g
:%s/>/>/g
:%s/&/\&/g
Let me know if you have more Vim commands to strip HTML or convert to Markdown
Note: For more info re the ^M
search and replace command refer http://blog.justin.kelly.org.au/vim-remove-m/