1, download
Syntaxhighlighter 3.0.83:http://alexgorbatchev.com/syntaxhighlighter
2, configuration
(1) Default label for syntaxhighlighter resolution, default to pre
Copy Code code as follows:
Syntaxhighlighter.config.tagname= "DIV";
(2) To remove HTML line-wrapping tags
If your software adds a < br/> tag at the end of each line, this option allows you to ignore these tags.
The implementation code in Shcore.js is:
Copy Code code as follows:
if (Sh.config.stripBrs = = True)
str = str.replace (BR, ');
Syntaxhighlighter.config.stripbrs=true;
(3) Do not display the tool bar
Copy Code code as follows:
syntaxhighlighter.defaults[' toolbar '] = false;
3, the use of the Code
3.1 Brush is required and the rest is optional:
Copy Code code as follows:
<div class= "brush:java;class-name:mycode;highlight:[1,3];" >some Java code</div>
Brush value: Java/xml/sql/c/js/css etc, see: http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/
3.2 Coloring Calls:
Copy Code code as follows:
Syntaxhighlighter.highlight ();
Or
Copy Code code as follows:
Syntaxhighlighter.all ();
The difference between all () and highlight () is that all () is registered in the OnLoad () event.
4, use in the blog park
Blog Park default Support Syntaxhighlighter. The code modifies the default value (because jquery does not support setting the!important style so you need to set Csstext):
Copy Code code as follows:
var sh = $ (". Syntaxhighlighter");
var code = sh.find ("code");
var line = Sh.find (". Line");
var caption = Sh.find ("table caption");
Sh.css ("Csstext", "Width:auto!important");
Code.add (line)
. Add (Caption)
. CSS ("Csstext", "font-size:20px!important;white-space:nowrap!important;line-height:1.5em!important;");
The above is the entire content of this article, small partners on the use of Syntaxhighlighter has a new understanding of it, I hope you can like this article.