Is there a way to prevent FCKeditor from tidying the edited source? I'm using a templating system and after using FCKeditor on the templates, the HTML parts look great but because it erases new lines things get complicated. Look here:
Source:
-------
{* Smarty *}
{add_button title="South Africa" link="southafrica.php"}
{add_button title="Toronto" link="toronto.php"}
After edit:
-----------
{* Smarty *} {add_button title="South Africa" link="southafrica.php"} {add_button title="Toronto" link="toronto.php"}
i.e. all the newlines are removed. Obviously when working with big files this makes things very hard to understand. What can I do?
My first guess would be to add support for all the tags but that's quite a mission, isn't it? or is it easy?
Mon, 12/05/2005 - 10:26
#1
RE: Retaining new lines of source
RE: Retaining new lines of source
Before given to editor:
$contents = preg_replace("/^({.*})\n$/smU", "<pre class=\"tpl\">\\1</pre>\n", $contents);
Before save:
$contents = preg_replace("/^<pre class=\"tpl\">({.*})<\/pre>/mU", "\\1\n", $contents);
This is nice because it also lets me put the tags in a different color. Only real problem I can see is that FCKeditor seems to be converting newlines to <br /> even when they are within <pre> tags. Anyone have ideas to get around that?