Mobile app version of vmapp.org
Login or Join
Jessie594

: How can I automatically clean, beautify, and autoindent dynamic HTML code? Using content management systems to build dynamic sites invariably results in ugly HTML. Indent levels are often wrong,

@Jessie594

Posted in: #Code #CodeQuality #Html

Using content management systems to build dynamic sites invariably results in ugly HTML. Indent levels are often wrong, white space litters the page, and a host of other tiny annoyances plague anyone attempting to read the source code for debugging or educational purposes.

Is there a way to automatically strip white space, autoindent, and otherwise beautify the output of a PHP or other dynamic script that spits out HTML?

I'm interested in any automated server-side solution that will improve the legibility of dynamically generated HTML, as well as solutions that strip all white space for compression purposes. If it matters, I normally run Apache or nginx.

It's safe to assume that I'm caching the output, so I won't be running whatever HTML beautification witchcraft you suggest on every page view (and taking the associated performance hit each time). As such, I'm more interested in ease of setup and reliable results than I am in performance.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Jessie594

1 Comments

Sorted by latest first Latest Oldest Best

 

@Steve110

Check out HTML Tidy. There are a lot of different bindings for different languages, so you should be able to find one that works for you.

Edit: If you're looking for something actively maintained, check out HTMLawed.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme