Skip to content Skip to sidebar Skip to footer

Php Tidy Alternative To Only Tab-indent Output

Is there any PHP Tidy alternative to only tab-indent HTML output? I need the latter for development/debug purposes only to go through the generated output code. Though, as much as

Solution 1:

I always use jsbeautifier. Though it doesn't follow my standards with javascript, the html indentation is awesome.

EDIT: Before you downvote, notice that jsbeautifier is open source, and has ports in several languages, all serverside: https://github.com/einars/js-beautify

Solution 2:

Two years later and there is still no library to achieve HTML output indentation without using implementations that rely on DOM API (ie. Tidy and alike).

I've developed library that tokenises HTML input using regular expression. None of the HTML is changed beyond adding the required spacing for indentation.

https://github.com/gajus/dindent

Solution 3:

You can try the htmLawed library. It's a Tidy alternative for PHP. If you just need an indenting function, you can use the code for the hl_tidy function of the library.

// indent usingone tab per indent, withall HTML being within an imaginary div
$out= hl_tidy($in, 't', 'div')

Solution 4:

I use LogicHammers HTMLFormatter which you need to pay for but is worth every penny. Use it to format the html before you look at it and it makes it much easier.

Solution 5:

Though this is not the exact answer , see if this helps you. I use netbeans and to make code indented I simply right click and Format the code. If you are using any other IDE search for similar functionality or may be you can import with help of 3rd party plugins.

Post a Comment for "Php Tidy Alternative To Only Tab-indent Output"