BBCodes: Source Code – SCODE

Posting source code (and syntax highlighting) in the forum is a very common requirement, and due to various limitations, not an easy thing to do, especially when you take into account user roles restrictions for using many HTML tags.

GD bbPress Toolbox Pro 4.0 adds a new BBCode for posting source code called SCODE. This BBCode has several attributes:

  • lang: language of the source code to use for syntax highlighting. Default: text.
  • line: number to use as a start for line numbering: Default: 1.
  • gutter: should highlight show gutter with a line number. Default: true.
  • class: additional CSS class names to add to the source code block. Default: ”.
  • highlight: number of lines to highlight in the source code. Default: ”. This should be a string with a number of lines comma separated.

You can post any sort of source code, but for syntax highlighting language (lang attribute) you can use one of these values (with their corresponding language):

  • applescript: AppleScript
  • actionscript3, as3: ActionScript3
  • bash, shell, sh: Bash
  • coldfusion, cf: ColdFusion
  • cpp, c, cc, c++, h, hpp, h++: Cpp
  • c#, c-sharp, csharp: CSharp
  • css: CSS
  • delphi, pascal, pas: Delphi or Pascal
  • diff, patch: Diff
  • erl, erlang: Erlang
  • groovy: Groovy
  • haxe, hx: Haxe
  • java: Java
  • jfx, javafx: JavaFX
  • js, jscript, javascript, json: JavaScript
  • perl, pl: Perl
  • php: PHP
  • text, plain: Plain Text
  • powershell, ps, posh: PowerShell
  • py, python: Python
  • ruby, rails, ror, rb: Ruby
  • sass scss: SASS or SCSS
  • scala: Scala
  • sql: SQL
  • swift: Apple Swift
  • tap: Tap
  • typescript, ts: Typescript
  • vb, vbnet: VisalBasic
  • xml, xhtml, xslt, html, plist: XML, HTML

Here is the example:

Source Code Example
Source Code Example

This will should source code in PHP, starting from line 4 and lines 5 and 9 are highlighted. Here it is:

Displayed Source Code
Displayed Source Code

Plugin supports several color schemes for syntax highlighting, and you can choose the theme for that in the plugin settings on BBCodes panel.

Rate this article

You are not allowed to rate this post.

4 thoughts on “BBCodes: Source Code – SCODE”

  1. I have tried many different settings for the lang=”” field to display simply BBCode/HTML — but it always interprets the code anyway?

    This code I would like to display as code, not as a picture, basically:

    Any ideas? Thanks!
    We are on the latest WP, BBpress, and GD Toolbox Pro versions.

    • If it is not listed, it is not supported. Supported languages depend on the highlighting script, and I include everything that is supported. If that changes in the future, I will surely add support for more languages.

Leave a Comment