If if you do :help 2HTML, you will get the to documentation about the conversion of an higlighted buffer to the equivalent HTML.
in reply to Using vim for highlighting in Perl
2HTML *2html.vim* *convert-to-HTML*
This is not a syntax file itself, but a script that converts the current
window into HTML. Vim opens a new window in which it builds the HTML file.
You are not supposed to set the 'filetype' or 'syntax' option to "2html"!
Source the script to convert the current file: >
Warning: This is slow!
After you save the resulting file, you can view it with any HTML viewer, such
as Netscape. The colors should be exactly the same as you see them in Vim.
Read the doc. There is more to it.
I did not tried it though.