Tidy_repair_string removes line break (\ n or \ r)

$HTMLcodeOutput = tidy_repair_string($HTMLcode, array('show-body-only' => true, 'indent' => true));

will remove $ htmlcode 'end of line. Example:

that in the main box



##What does it do ?

it does everything



##Output:

Will output

that in the main box ##What does it do ? it does everything
##Output: I will giv ea a grat output

This would not be a problem if this line were not reflected in the <pre> after that. Thus, the character \ n or \ r is important. I looked at the documentation but did not find anything obvious.

Is there any way to keep these string return characters?

(Adding tags before using a neat line fix is ​​a bad idea, as this will cause the <pre> tags to be repeated as visible in the browser as strings (decoded), and not as tags.)

+4
source share
1 answer

, html , "pre", , tidy htmlspecialchars .

"pre" ? :

$config = array('show-body-only' => true, 'indent' => true);
$HTMLcodeOutput = tidy_repair_string('<pre>'.$HTMLcode.'</pre>', $config);
$HTMLcodeOutput = substr($HTMLcodeOutput, 5, -6);
+3

All Articles