-2

I have some HTML code in a file created by an online JS editor

<h1>Title</h1><p>Some text</p><p>Some text</p>

that is not easily readable offline. I'd like to split it like this with php, that is more readable

<h1>Title</h1>
<p>Some text</p>
<p>Some text</p>

I can make a string replace adding the newline after each closure, but if I save several times it adds newlines every time I save.

Do you have any suggestion?

Thank you.

P.S. the online JS editor is Summernote, maybe there is a config to work around this?

2 Answers2

1

what you looking to is "unminify html",there is some online tools can do the work like:

Mohamed Sa'ed
  • 771
  • 4
  • 12
0

Following the suggestions of Mohamed, I found Tidy.

Tidy comes with both a shell command (http://tidy.sourceforge.net/) and a PHP library (http://php.net/manual/en/book.tidy.php), both of them work very well and provide sereal tools to maintain HTML code.