• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
simple formatting problem - <pre>

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


<p><p>snippet of text...</p>
<p>snippet of text...

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

Someone wrote in the Php docs page for nl2br:

&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.


Read through the user contributed notes. Big Grin

cheers mate, off for a nosy the now

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.