The long code of z-blogSyntaxHighlighter cannot be wrapped in line. (jquery) _ jquery

Source: Internet
Author: User
Because my blog is mainly about code sharing, a lot of code is very long. Most of the time, I manually wrap a line. But today we can't stand it. Find a solution from the Internet. Because my blog is mainly about code sharing, many of the codes are very long. Most of the time, I manually wrap a line.

But today we can't stand it. Find a solution from the Internet.

1. css modification:

In the folder: zb_system \ ADMIN \ ueditor \ third-party \ SyntaxHighlighter

Add css in the file shcoredefault.pack.css:

The Code is 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('style', 'height: ' + height + ' !important'); // fix by Edi, for JQuery 1.7+ under Firefox 15.0         console.debug($gutterLine.height(), height, $gutterLine.text(), $codeLine);       });     });   };   // Line wrap back when syntax highlighter has done it's stuff   var shLineWrapWhenReady = function () {     if ($('.syntaxhighlighter').length === 0) {       setTimeout(shLineWrapWhenReady, 10);     }     else {       shLineWrap();     }   };   // Fire   shLineWrapWhenReady();});

The above code is long code. Let's see if all of them have line breaks ??

Now, the height of the row number can be the same as that of the Code.

Related Article

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.