Note that there are some explanatory texts on larger screens.

plurals
  1. POPhp tidy and text areas
    text
    copied!<p>I am using <a href="http://au.php.net/manual/en/book.tidy.php">tidy</a> to clean up and format the output of HTML generated by the <a href="http://www.twig-project.org">twig template engine</a>.</p> <p>I am using the following configuration for tidy:</p> <pre><code>$config = array('indent' =&gt; TRUE, 'output-html' =&gt; TRUE, 'wrap' =&gt; 0); </code></pre> <p>Everything works nice and well, except when we get to textareas.</p> <p>Here's the uncleaned fragment:</p> <pre><code>&lt;textarea id="words" rows="10" cols="50" &gt;sdfds&lt;/textarea&gt; </code></pre> <p>While the formatting is very messy, the correct value is outputted in the text area: 'sdfds' without any whitespace before or after.</p> <p>This is the cleaned format after using tidy:</p> <pre><code> &lt;textarea id="words" name="words" rows="10" cols="50" title="prompt"&gt; sdfds &lt;/textarea&gt; </code></pre> <p>As can be seen, the markup is much neater now, but tidy has introduced a linebreak after 'sdfds', which means that the cursor is now pointing at the line after 'sdfds' when viewed in the browser.</p> <p>This is rather annoying, and I am not sure how to go about dealing with this. I would still want to have the textarea tag cleaned up, but I would prefer it to be formatted like so:</p> <pre><code>&lt;textarea id="words" name="words" rows="10" cols="50" title="prompt"&gt;sdfds&lt;/textarea&gt; </code></pre> <p>Has anyone dealt with this issue before? If so, How can I get tidy to not introduce those whitespaces for the textarea tag?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload