Z-blog syntaxhighlighter Long Code cannot wrap solution (jquery) _jquery

Source: Internet
Author: User

Because my blog is mainly code sharing, a lot of code, are very long. Most of the time I have to hand him the line.

But today I can't stand it. Find a way to solve the problem online.

1, CSS Modification:

In folder: \zb_system\admin\ueditor\third-party\syntaxhighlighter

Add CSS to file shCoreDefault.pack.css:

Copy Code code as follows:

Body. Syntaxhighlighter. line{white-space:pre-wrap!important; Syntaxhighlighter{width:100%!important;margin:. 3em 0 3em 0!important;position:relative!important;overflow:auto!important;background-color: #f5f5f5!important; border:1px solid #ccc!important;word-break:break-all;

2, jquery code:

$ (function () {//Line wrap back var shlinewrap = function () {$ ('. Syntaxhighlighter '). each (function () { 
        Fetch var $sh = $ (this), $gutter = $sh. Find (' Td.gutter '), $code = $sh. Find (' Td.code ') 
      ; Cycle through lines $gutter. Children ('. Line '). each (function (i) {//Fetch var $gutterLine = $ 
        (this), $codeLine = $code. Find ('. Line:nth-child (' + (i + 1) + ') '); 
        alert ($gutterLine); Fetch height var height = $codeLine. Height () | | 
        0; 
        if (!height) {height = ' auto '; 
          else {height = height = ' px '; 
        alert (height); //Copy height over $gutterLine. attr (' <span style= ' Width:auto; Height:auto; Float:none "Id=0_nwp><a style=" Text-decoration:none "id=0_nwl href=" http://cpro.baidu.com/cpro/ui/uijs.php? Rs=1&u=http%3a%2f%2fwww%2esuchso%2ecom%2fprojecteactuAl%2fz%2dblog%2djquery%2dsyntaxhighlighter%2dlongcode%2ehtml&p=baidu&c=news&n=10&t=tpclicked3_ hc&q=95053049_cpr&k=style&k0=%ce%c4%bc%fe%bc%d0&kdi0=32&k1=style&kdi1=1&k2=%b2%a9% Bf%cd&kdi2=1&sid=77860fedb9413425&ch=0&tu=u1702844&jk=e7459084404b7b2f&cf=29&fv=15 &stid=9&urlid=0&luki=2&seller_id=1&di=128 "Target=_blank mpid=" 0 "><SPAN style=" WIDTH: Auto Float:none; Height:auto; COLOR: #0000ff; Font-size:16px ">style</SPAN></A></SPAN>", ' Height: ' + height + '!important ');  Fix by Edi, for JQuery 1.7+ under Firefox 15.0 console.debug ($gutterLine. Height (), height, $gutterLine. Text (), 
      $codeLine); 
    }); 
  }); 
  }; Line wrap then syntax highlighter has done it ' s stuff var shlinewrapwhenready = function () {if ($ ('. Synt 
    Axhighlighter '). Length = = 0) {settimeout (Shlinewrapwhenready, 10); 
    else {shlinewrap ();} 
  }; Fire Shlinewrapwhenready ();

The above code belongs to the long code. Let's see if we've all changed the line??

Now, the height of the line number can be consistent with the height of the code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.