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

#1
[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?

#2
[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

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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