This article mainly introduces how long code z-blogSyntaxHighlighter cannot wrap (jquery ), if you need a highlight plug-in using SyntaxHighlighter syntax, you may have encountered a problem where the Code does not display line breaks. This problem cannot be solved on the Internet, it has been bothering me for a long time. Today we have solved it. The solution is actually simple. Let's talk about it below...
Solution:
Open the shcoredefault.css file, find the definition of. syntaxhighlighter textarea, and add word-break: break-all! Important; it's OK, which means to force line feed display of the Code.
Since each person calls different css, you can modify the css as needed.
Test found that version 3.08 is invalid. You can refer to the following method.
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.
1. css modification:
In the folder: zb_system \ ADMIN \ ueditor \ third-party \ SyntaxHighlighter
Add css in the file shcoredefault.pack.css:
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.