Syntaxhighlighter 3.0.83 Use notes _javascript tips

Source: Internet
Author: User

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.

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.