CodeIgniter Forums
simple formatting problem - <pre> - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: simple formatting problem - <pre> (/showthread.php?tid=10558)



simple formatting problem - <pre> - El Forum - 08-04-2008

[eluser]karloff[/eluser]
Ok, so i have built a simple blog, however i have used the old nl2br_except_pre($body)for formatting my body text.

However when i include the <pre> tag it obviously breaks it by not formatting text below the <pre> tag to a paragraph.

can anyone advise how best to format my text? I was think about simple coding the markup into the db field but this will break as on may pages (ie: home page) i have a snippet of a latest post which uses the word_limiter and therefore would include multiple <p> tags or not close

eg:

Code:
<p><p>snippet of text...</p>
or
Code:
<p>snippet of text...

Is there a function or some sort of workaround for this?


simple formatting problem - <pre> - El Forum - 08-04-2008

[eluser]stuffradio[/eluser]
Someone wrote in the Php docs page for nl2br:

Code:
&lt;? $string =  preg_replace('/<pre>(.*?)<\/pre>/ise',"'<pre>' . preg_replace('/(<br \/?&gt;)/is','','\\1') . '</pre>'",$string); ?&gt;

That function would allow you to use your '<pre>' formatting I believe.

http://us2.php.net/nl2br

Read through the user contributed notes. Big Grin


simple formatting problem - <pre> - El Forum - 08-05-2008

[eluser]karloff[/eluser]
cheers mate, off for a nosy the now