About chajian8.com: syntaxhighlighter code highlighting

Source: Internet
Author: User
Tags wordpress blog

Digress: the WordPress plug-in progress of various microblogs has been highlighted last time, and the oauth and basic HTTP verification sections of nine microblogs have been completed.

Write this articleArticleThis article describes how to intelligently judge and load syntaxhighlighter.CodeHighlighted script. I have a habit of writing too many things that others can't write. When searching for the WordPress plug-in library, I found the plug-in auto syntaxhighlighter, which fully implements the expected content-automatically loads the corresponding script based on the code shown in this article, or even stronger. In this case, I will tell you the reason for choosing syntaxhighlighter.

Previously, I used the code plug-in (chajian8.com) to highlight the code. I first pasted the code to the Code plug-in (chajian8.com). The website highlighted the code and gave the HTML code, and then pasted it to the editor. What I don't like very much is:

    1. There will be a large numberStyleAttributeDivTags, which are difficult to edit;
    2. If the row number is displayed, the row number is also copied;
    3. No scroll bar. You cannot scroll left or right;
    4. If you use the WordPress built-in Editor, leading to the disappearance of spaces at the beginning of the line-unless you do not enter the "Visualization" editing mode.

In my opinion, the Code chajian8.com is more suitable for the use of many managed blogs.

WordPress has some code highlighting plug-ins, suchSyntaxhighlighter evolvedThey are enabled by using the code[Language]And[/Language]This also has a problem:

    1. As described in the fourth point above, spaces at the beginning of the line often disappear;
    2. UseWordPress response code(That is, the label enclosed by brackets) there is a porting problem: transferring an article from a Wordpress blog to another blog will leave[Language]The tag is directly displayed. Even if you still use WordPress, stopping this plug-in will cause the tag to be displayed.

ComparedDivAnd WordPress response code, HTML TagPreThe text in is usually reserved with spaces and line breaks. ThereforePreCode highlighting is the best choice.

Two plug-ins have been filtered. One isAuto syntaxhighlighterAnd the other isWP-syntax.

    • Auto syntaxhighlighter uses JavaScript to highlight code, which consumes less server resources (only used to determine whether Javascript is loaded), but does not highlight RSS output;
    • WP-syntax highlights code on the server, which occupies a large amount of resources. However, it can be highlighted in RSS and is not affected by browser-disabled JavaScript (of course, this rarely happens ).

I prefer to reduce server resource usage, so I chose auto syntaxhighlighter. It also has a killer. You can add a button to insert code to the tinymce Editor, which not only does not need to remember to enable the highlighted tag format, but also automatically materialized symbols such as <>, Which is considerate and convenient.

 

 

 

 

 

 

 

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.