simple formatting problem - <pre> |
[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> Code: <p>snippet of text... Is there a function or some sort of workaround for this?
[eluser]stuffradio[/eluser]
Someone wrote in the Php docs page for nl2br: Code: <? $string = preg_replace('/<pre>(.*?)<\/pre>/ise',"'<pre>' . preg_replace('/(<br \/?>)/is','','\\1') . '</pre>'",$string); ?> That function would allow you to use your '<pre>' formatting I believe. http://us2.php.net/nl2br Read through the user contributed notes. ![]()
|
Welcome Guest, Not a member yet? Register Sign In |