Re: beautify html
Cream is a free, easy-to-use configuration of the Vim text editor
Brought to you by:
digitect
From: BG - B. A. <BAr...@dy...> - 2005-08-19 18:53:40
|
On Thu, 2005-04-21 at 13:47 -0400, Steve Hall wrote: > AFAIK there is no good way to re-format existing HTML (code) from > one/no particular format to another. Vim has a way to reformat C as I > understand, but I've never found anything that I trust. > > A simpler approach would be to write a function with a series of > regular expressions to re-format a given document. For example: > > function! Cream_prettify_html() > > if &ft != "html" > call confirm("Document is not filetype \"HTML\".") > return > endif > > " tags that end a line > :s%/html>\n*/html>\r/gei > :s%/head>\n*/head>\r/gei > :s%/body>\n*/body>\r/gei > :s%/<\/p>\n*/<\/p>\r/gei > :s%/<\/li>\n*/<\/li>\r/gei > :s%/<\/ul>\n*/<\/ul>\r/gei > :s%/<\/ol>\n*/<\/ol>\r/gei > :s%/<\/dl>\n*/<\/dl>\r/gei > :s%/<\/blockquote>\n*/<\/blockquote>\r/gei > > if exists("g:I-hate-XML") > :s%/strong>/b>/gei > :s%/em>/i>/gei > endif > > " ...etc... > > endfunction > > Basic, but I kind of like it. We can tweak the settings until everyone > is happy or option those settings that make some uncomfortable. > > Opinions? I have users here who would use such a thing. As an alternative, what about an external beautifier? It would be nice if you could make a selection, pass it to "tidy", and have the tidied results replace the selection. Ben |