Jump to content

how to fix the code display problem


m118

Recommended Posts

hello

 

I need to fix code display problem. The code below cause the disorder problem. When I delete the part of it , the code display in the right way. I do not really understand it .

 

The template try to use  bx_textarea to display code,so I find the function in it. Finally , I found this function cause the disorder code problem.

<?php echo bx_highlight(bx_textarea($view_query_result['jdescription']), $kwd_search);?>

 

 

    if ($char == "<") {
            $skip=1;
        }    
        elseif ($char == ">") {
            $skip=0;
        }    
        elseif ($char == " ") {
            $wrap=0;
         }   
         if ($skip==0) {
            $wrap=$wrap+1;
        }


 

function bx_wordwrap($a_str, $a_break_length=75) {
    $length = strlen($a_str);
    for ($i=0; $i<=$length; $i=$i+1) {
        $char = substr($a_str, $i, 1);
        if ($char == "<") {
            $skip=1;
        }    
        elseif ($char == ">") {
            $skip=0;
        }    
        elseif ($char == " ") {
            $wrap=0;
         }   
         if ($skip==0) {
            $wrap=$wrap+1;
        }
        $res_str = $res_str . $char;
        if ($wrap>$a_break_length) {
            $res_str = $res_str." ";
            $wrap=0;
        }
    }
    return $res_str;
}
function bx_textarea($text) {
  return nl2br(preg_replace('/\t/','        ',bx_wordwrap($text, 75)));
}//end function bx_textarea($text)

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.