Jump to content

Syntax highlighter


eevan79

Recommended Posts

I dont know how to solve this. I installed syntax highlight script for my forum script. And its working, but when I write some code I get following:

    function highlight_search($search_words,$string,$bgcolors='yellow')
<br>    {
<br>        if (is_array($bgcolors)) {
<br>            $no_colors=count($bgcolors);
<br>        } else {
<br>            $temp=$bgcolors;
<br>            unset($bgcolors);
<br>            $bgcolors[0]=$temp;
<br>            $no_colors=1;
<br>        }
<br>        $word_no=0;

This is example code and you can see <br> at every line.

Here is used bbcode:

function BBCode ($text) {
$search = array(
'/\[php\](.*?)\[\/php\]/is'};

and replace:

$replace = array(
'<pre class="brush: php;">$1</pre>');

 

How to remove this <br> at every line?

 

Here is screenshot:

00020xo.jpg

Link to comment
Share on other sites

cant edit post :(

 

$text = preg_replace
('/<pre class="brush: php;">(.+?)<\/pre>/is', 
preg_replace('<\/br>', '$1', 
'<pre class="brush: php;">$1</pre>'), $text);

 

script above not working...something is wrong.

Link to comment
Share on other sites

Again cant edit post :( . Sry.

I found why I get this <br> . Before text is inserted into database I use some BBCode parser and this code:

$text = str_replace("\n", "<br>", $text);

Without this code I dont have new lines, but also it disaplay <br>'s in

[php ] tags.
I think I need to remove all <br>'s here (when parsing bbcodes):
<pre class="brush: php;">$1</pre>

[/code]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.