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:
- There will be a large number
Style
AttributeDiv
Tags, which are difficult to edit;
- If the row number is displayed, the row number is also copied;
- No scroll bar. You cannot scroll left or right;
- 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:
- As described in the fourth point above, spaces at the beginning of the line often disappear;
- 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.
ComparedDiv
And WordPress response code, HTML TagPre
The text in is usually reserved with spaces and line breaks. ThereforePre
Code 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.