Plugins for syntax highlighting in WordPress – it’s special plugins that allow you to customize the code that you add to your article or web site so that it does not look like a bunch of unintelligible text complicated to analysis and research. For this site I used SyntaxHighlighter Evolved plugin. It’s not very complex to install it, you just need to go to add plugins page and find the title above.

and the resulting code will look like this:

#button { 
    font-weight: bold; 
    border: 2px solid #fff; 
}

Parameter «language» determines the language and syntax highlighting rules. The following values:

  • actionscript3
  • bash
  • coldfusion
  • cpp
  • csharp
  • css
  • delphi
  • erlang
  • fsharp
  • diff
  • groovy
  • html
  • javascript
  • java
  • javafx
  • matlab
  • objc
  • perl
  • php
  • text
  • powershell
  • python
  • r
  • ruby
  • scala
  • sql
  • vb
  • xml

The plugin contains many additional settings. They are listed below:

  • lang or language — The language syntax to highlight with. You can alternately just use that as the tag. Click here for a list of valid tags (under “aliases”).
  • autolinks — Toggle automatic URL linking.
  • classname — Add an additional CSS class to the code box.
  • collapse — Toggle collapsing the code box by default, requiring a click to expand it. Good for large code posts.
  • firstline — An interger specifying what number the first line should be (for the line numbering).
  • gutter — Toggle the left-side line numbering.
  • highlight — A comma-separated list of line numbers to highlight. You can also specify a range. Example: 2,5-10,12
  • htmlscript — Toggle highlighting any extra HTML/XML. Good for when you’re mixing HTML/XML with another language, such as having PHP inside an HTML web page. The above preview has it enabled for example. This only works with certain languages.
  • light — Toggle light mode which disables the gutter and toolbar all at once.
  • padlinenumbers — Controls line number padding. Valid values are false (no padding), true (automatic padding), or an integer (forced padding).
  • title (v3 only) — Sets some text to show up before the code. Very useful when combined with the collapse parameter.
  • toolbar — Toggle the toolbar (buttons in v2, the about question mark in v3)
  • wraplines (v2 only) — Toggle line wrapping.

An example of the use of tags with the following parameters:

Result:


p.serif {
    font-family: "Times New Roman", Times, serif;
}

p.sansserif {
    font-family: Arial, Helvetica, sans-serif;
}

Even add video with detailed explanations and operation settings.

Link to the official site of the plugin: http://alexgorbatchev.com/SyntaxHighlighter/

If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

Leave a Reply

Your email address will not be published. Required fields are marked *