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:
This will should source code in PHP, starting from line 4 and lines 5 and 9 are highlighted. Here it is:
Plugin supports several color schemes for syntax highlighting, and you can choose the theme for that in the plugin settings on BBCodes panel.
4 thoughts on “BBCodes: Source Code – SCODE”
Leave a Comment
You must be logged in to post a comment.
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.
I don’t understand the problem, you tried to paste code in comment and that is not allowed, please use the forum to ask the question again.
Hi!!
Is it possible to use R language? if not, could you please add it?
Thanks
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.