format-html-in-php icon indicating copy to clipboard operation
format-html-in-php copied to clipboard

sth. error when html text contains charactor '>'

Open tarol opened this issue 7 years ago • 3 comments

for example: test.php:

<!doctype html>
<html>

<body>
  <div>
    <button id="test">test<</button>
  </div>
</body>

</html>

the formatting output is

<!doctype html>
<html>

<body>
  <div>
    <button id="test">test<</button> </div> </body> </html>

tarol avatar Feb 27 '19 12:02 tarol

Sorry I won't be able to support HTML that isn't valid, this is a format extension not an HTML linter. If you correct the HTML to have valid open closing tags it works perfectly. IE removing the double <<

<!doctype html>
<html>

<body>
  <div>
    <button id="test">test</button>
  </div>
</body>

</html>

RiFi2k avatar Mar 22 '19 00:03 RiFi2k

Actually I changed my mind I'll run this up the ladder and see what the devs over at JS Beautify think about this, if they opt to fix it, we will get the fix downstream here and if they close it then I'll have to do the same.

<!doctype html>
<html>

<body>
  <div>
    <button id="test">number 4 < 5, wow</button>
  </div>
</body>

</html>
<!doctype html>
<html>

	<body>
		<div>
			<button id="test">number 4 < 5 wow</button> </div> </body> </html>

Seems like encoding the > does the trick

<!doctype html>
<html>

<body>
  <div>
    <button id="test">number 4 %3C 5, wow</button>
  </div>
</body>

</html>

Works great, possibly the HTML parser that JSB uses will be able to take care of figuring out that it should be encoded and handling it before formating.

RiFi2k avatar Mar 22 '19 01:03 RiFi2k

Opened upstream, https://github.com/beautify-web/js-beautify/issues/1646 We will see what they say.

RiFi2k avatar Mar 22 '19 01:03 RiFi2k