开发者

Syntaxhighlighter inserting extra blank line after each line

开发者 https://www.devze.com 2023-03-27 00:39 出处:网络
I use syntaxhighlighter on my bl开发者_C百科og to format C++ code. Since last few days I am gettingextra blank line after each line after each line of code. Please see this link for more info.

I use syntaxhighlighter on my bl开发者_C百科og to format C++ code. Since last few days I am getting extra blank line after each line after each line of code. Please see this link for more info.

Following is the code I wrote there. I am not seeing any line break in that.

//Define MAX 1 less so that adding 1 doesn't make it 0
#define MAX 0xFFFFFFFE;

unsigned int jump(int *array, int n)
{
    unsigned int *result = new unsigned int[n];
    int i, j;

    //Boundry conditions
    if (n == 0 || array[0] == 0)
        return MAX;

     result[0] = 0;  //no need to jump at first element
     for (i = 1; i < n; i++)
     {
           result[i] = MAX; //Initialization of result[i]
           for (j = 0; j < i; j++)
           {
                 //check if jump is possible from j to is
                 if (array[j] >= (i-j))
                 {
                       //check if better solution available
                       if ((result[j] + 1) < result[i])
                             result[i] = result[j] + 1;  //updating result[i]
                 }
           }
     }

     //return result[n-1]
     unsigned int answer = result[n-1];
     delete[] result;

     return answer;
}

Surprisingly this is happening only for new posts, all old posts are shown currently w/o extra blank lines.


Your source code (before JavaScript) basically looks like this:

<pre>
First line
<br />Another line
<br />Last line
</pre>

If you are using a <pre> tag, you don't need to insert <br /> tags to force line feeds but, if you do, they should replace the original line feed.

Update: I'll make a blind guess with the little information we have. Your code is saved into a local file using Windows line feeds (CR+LF). The server runs Linux and applies a function that replaces Linux line feeds (LF). with <br /> tags so you end up with CR<br />. This is inserted into a <pre> tag so the browser converts this to two consecutive line feeds.

My hypothesis seems likely because, if you save the HTML source code into a file and open it with a text editor that can display line feeds, it'll show the file is using Linux style (LF) everywhere expect in the code snippet, where it's using CR (old MacOS 9 style).

Syntaxhighlighter inserting extra blank line after each line

Workaround: save the file as Unix before copying or copy with another editor or copy to another browser.

0

精彩评论

暂无评论...
验证码 换一张
取 消