Adding A New Brush (Language)

While SyntaxHighlighter Evolved comes bundled with brushes (the “plugins” that add support for specific languages) for most of the popular programming languages, there still may be a language that isn’t supported but that you need.

You’ll want to start by checking out this awesome blog post. It has a list of a ton of third part brushes and links to download them. If your language isn’t supported, then check out the official documentation for how to write your own brush (it’s really simple).

Once you have your brush that you want to add to my plugin, you’ll need to throw together a tiny little plugin of your own that will tell my plugin about the new brush so that it can be used.

We start by registering the Javascript file with WordPress (note we’re registering it, not enqueueing it as my plugin will do that itself if it’s needed):

wp_register_script( 'syntaxhighlighter-brush-language', plugins_url( 'shBrushLanguage.js', __FILE__ ), array('syntaxhighlighter-core'), '1.2.3' );

wp_register_script() takes the same parameters as wp_enqueue_script().

Some notes on the parameters:

  1. This needs to be in this syntax: syntaxhighlighter-brush-some-unique-language-stub
  2. This is the URL to the brush file. It’s filename and location don’t matter (I would advise not storing it in my plugin’s folder as it will be deleted when upgrading my plugin). I’d recommend using the cool plugins_url() function (unofficial documentation).
  3. The brush requires the core SyntaxHighlighter file, so list it as a dependency.
  4. An arbitrary version number that you should change if you modify the file (to break browser caches).

Okay, so now that the brush file is registered with WordPress, we need to tell SyntaxHighlighter about the new brush and what language aliases it can be used for. To do this, we use the “syntaxhighlighter_brushes” filter, like so:

add_filter( 'syntaxhighlighter_brushes', 'a_unique_function_name_of_your_choosing' );

function a_unique_function_name_of_your_choosing( $brushes ) {
	$brushes['alias1'] = 'language';
	$brushes['alias2'] = 'language';

	return $brushes;
}
  • “alias1″ and “alias2″ are some example aliases. These will be available directly as shortcodes or as valid parameters for the “language” attribute of my plugin’s shortcode.
  • “language” is the stub that you used above when registering the brush with WordPress.

Activate the plugin and you’ll be good to go!

Overall Example

Assuming you have a brush file called “shBrushFoobar.js” for the language “foobar” and that brush file is in the same folder as the plugin, here’s what the plugin could look like:

<?php
/*
Plugin Name: SyntaxHighlighter Evolved: Foobar Brush
Description: Adds support for the Foobar language to the SyntaxHighlighter Evolved plugin.
Author: Your Name Here
Version: 1.0.0
Author URI: http://yourblog.com/
*/

// SyntaxHighlighter Evolved doesn't do anything until early in the "init" hook, so best to wait until after that
add_action( 'init', 'syntaxhighlighter_foobar_regscript' );

// Tell SyntaxHighlighter Evolved about this new language/brush
add_filter( 'syntaxhighlighter_brushes', 'syntaxhighlighter_foobar_addlang' );

// Register the brush file with WordPress
function syntaxhighlighter_foobar_regscript() {
	wp_register_script( 'syntaxhighlighter-brush-foobar', plugins_url( 'shBrushFoobar.js', __FILE__ ), array('syntaxhighlighter-core'), '1.2.3' );
}

// Filter SyntaxHighlighter Evolved's language array
function syntaxhighlighter_foobar_addlang( $brushes ) {
	$brushes['foobar'] = 'foobar';
	$brushes['fb'] = 'foobar';

	return $brushes;
}

?>

You can then use it like this:

[foobar]your code here[/foobar]

Or like this:

1

64 thoughts on “Adding A New Brush (Language)

  1. I ended up editing the syntaxhighlighter.php file, and I have my custom brush running. But will this change be blown away on the next upgrade? Where should I be adding my custom languages so that they aren’t over written by upgrade?

    -Thanks

  2. Yes, that will be deleted when you upgrade.

    The code needs to go into a plugin (see the “Overall Example” above) or into your theme’s functions.php file (the first is better). My plugin’s entire folder will be deleted upon upgrade, so don’t put the plugin file in that folder either.

  3. Very cool. I stopped reading the tutorial when I was blocked on the first step. :D I guess it’s a writing style thing. The “Overall Example” was pretty good. You might want to add that people should make a Folder in their Plug-in directory and give them an example install name “syntaxhighlighter-fooBrush.php”.

    It’s running nicely now.

    • That brush hasn’t been properly updated for the new version of SyntaxHighlighter (2.x).

      Check out this diff as an example of how the Obj-C brush was updated:

      --- C:/Users/Alex/Desktop/old.js	Fri Dec 18 21:58:14 2009
      +++ C:/Users/Alex/Desktop/new.js	Fri Dec 18 21:58:24 2009
      @@ -14,7 +14,7 @@
        * 
        */
       
      -dp.sh.Brushes.ObjC = function() {
      +SyntaxHighlighter.brushes.ObjC = function() {
       	
       	var datatypes =	'char bool BOOL double float int long short id void';
       	
      @@ -31,13 +31,13 @@
       	keywords += 'using uuid virtual volatile whcar_t while';
       	
       	this.regexList = [
      -		{ regex: dp.sh.RegexLib.SingleLineCComments,	css: 'comment' },		// one line comments
      -		{ regex: dp.sh.RegexLib.MultiLineCComments,		css: 'comment' },		// multiline comments
      -		{ regex: dp.sh.RegexLib.DoubleQuotedString,		css: 'string' },		// double quoted strings
      -		{ regex: dp.sh.RegexLib.SingleQuotedString,		css: 'string' },		// single quoted strings
      +		{ regex: SyntaxHighlighter.regexLib.singleLineCComments,	css: 'comment' },		// one line comments
      +		{ regex: SyntaxHighlighter.regexLib.multiLineCComments,		css: 'comment' },		// multiline comments
      +		{ regex: SyntaxHighlighter.regexLib.doubleQuotedString,		css: 'string' },		// double quoted strings
      +		{ regex: SyntaxHighlighter.regexLib.singleQuotedString,		css: 'string' },		// single quoted strings
       		{ regex: new RegExp('^ *#.*', 'gm'),						css: 'preprocessor' },	// preprocessor
      -		{ regex: new RegExp(this.GetKeywords(datatypes), 'gm'),		css: 'datatypes' },		// datatypes
      -		{ regex: new RegExp(this.GetKeywords(keywords), 'gm'),		css: 'keyword' },		// keyword
      +		{ regex: new RegExp(this.getKeywords(datatypes), 'gm'),		css: 'datatypes' },		// datatypes
      +		{ regex: new RegExp(this.getKeywords(keywords), 'gm'),		css: 'keyword' },		// keyword
       		{ regex: new RegExp('\\bNS\\w+\\b', 'g'),					css: 'keyword' },		// keyword
       		{ regex: new RegExp('@\\w+\\b', 'g'),						css: 'keyword' },		// keyword
       		{ regex: new RegExp('@"(?:\\.|(\\\\\\")|[^\\""\\n])*"', 'g'),	css: 'string' }	// objc string		
      @@ -45,5 +45,5 @@
       	
       }
       
      -dp.sh.Brushes.ObjC.prototype = new dp.sh.Highlighter();
      -dp.sh.Brushes.ObjC.Aliases = ['objc', 'obj-c'];
      \ No newline at end of file
      +SyntaxHighlighter.brushes.ObjC.prototype = new SyntaxHighlighter.Highlighter();
      +SyntaxHighlighter.brushes.ObjC.aliases = ['objc', 'obj-c'];

      Basically you gotta get rid of all of the dp.sh. stuff.

  4. Pingback: ???????? » My SyntaxHighlighter 2.0 Haskell Brush

  5. Pingback: Wordpress SyntaxHighlighter Plugin Additional Languages « folios

  6. I added file shBrushMathematica.js and syntaxhighlighter-MathematicaBrush.php

    in

    /wp-content/plugins/myplugin/

    shBrushMathematica.js reads

    SyntaxHighlighter.brushes.Mathematica = function()
    {
    	var funcs		= 'Plot Map NumericQ NumberQ';
    	var keywords	= 'foo';
    	var operators	= '+ - /';
    
    	this.regexList = [
    		{ regex: /--(.*)$/gm,												css: 'comments' },
    		{ regex: SyntaxHighlighter.regexLib.multiLineDoubleQuotedString,	css: 'string' }//,
    		//{ regex: new RegExp(this.getKeywords(funcs), 'gmi'),				css: 'blue' },
    		//{ regex: new RegExp(this.getKeywords(operators), 'gmi'),			css: 'green' },
    		//{ regex: new RegExp(this.getKeywords(keywords), 'gmi'),				css: 'keyword' }
    		];
    };
    SyntaxHighlighter.brushes.Mathematica.prototype	= new SyntaxHighlighter.Highlighter();
    SyntaxHighlighter.brushes.Mathematica.aliases	= ['mathematica', 'mma'];
    

    syntaxhighlighter-MathematicaBrush.php reads

    <?php
    /*
    Plugin Name: SyntaxHighlighter Evolved: mathematica Brush
    Description: Adds support for the mathematica language to the SyntaxHighlighter Evolved plugin.
    Author: Your Name Here
    Version: 1.0.0
    Author URI: http://yourblog.com/
    */
    
    // SyntaxHighlighter Evolved doesn't do anything until early in the "init" hook, so best to wait until after that
    add_action( 'init', 'syntaxhighlighter_mathematica_regscript' );
    
    // Tell SyntaxHighlighter Evolved about this new language/brush
    add_filter( 'syntaxhighlighter_brushes', 'syntaxhighlighter_mathematica_addlang' );
    
    // Register the brush file with WordPress
    function syntaxhighlighter_mathematica_regscript() {
    	wp_register_script( 'syntaxhighlighter-brush-mathematica', plugins_url( 'shBrushMathematica.js', __FILE__ ), array('syntaxhighlighter-core'), '1.2.3' );
    }
    
    // Filter SyntaxHighlighter Evolved's language array
    function syntaxhighlighter_foobar_addlang( $brushes ) {
    	$brushes['Mathematica'] = 'mathematica';
    	$brushes['mma'] = 'mathematica';
    
    	return $brushes;
    }
    
    ?>
    

    But it is still not showing correctly:

    http://i49.tinypic.com/125gkdv.png

    • mma: You forgot to rename the function that adds the aliases. It’s still “syntaxhighlighter_foobar_addlang” while you registered “syntaxhighlighter_mathematica_addlang” as the callback.

  7. Pingback: Donovan's Blog » FileMaker Syntax Highlighting

  8. Pingback: Custom Brush for SyntaxHighlighter Evolved | Skelton Networks: Programming

  9. Hi

    I wrote a plugin for AppleScript but I have one problem – the custom stylesheet isn’t being loaded. I’m trying like this:
    wp_register_style( ‘syntaxhighlighter-theme-applescript’, plugins_url( ‘shThemeAppleScript.css’, __FILE__ ), array(‘syntaxhighlighter-core’), ’1.0′ );
    Which does not work.
    When I enqueue the file though:
    wp_enqueue_style( ‘syntaxhighlighter-theme-applescript’, plugins_url( ‘shThemeAppleScript.css’, __FILE__ ), array(‘syntaxhighlighter-core’), ’1.0′ );
    Then it works like a charm.

    I’m pretty new to WordPress – can someone tell me off hand why the registered stylesheet isn’t being loaded?

    • I assume you mean you wrote a highlighter (brush) that parses the AppleScript language and need a stylesheet to go along with it? If so, you don’t want “syntaxhighlighter-theme-foobar”. That’s for global color themes (to better match the design of your blog).

      Have your plugin register it’s brush (see top of page) and then also do wp_enqueue_style() (enqueue registers it and also enqueues it). wp_register_style() is for when you want to tell WordPress about a stylesheet but not necessarily output it.

      Further reading:

      http://codex.wordpress.org/Function_Reference/wp_register_style
      http://codex.wordpress.org/Function_Reference/wp_enqueue_style

      • Thanks for your reply Viper.
        I did use wp_enqueue_style as stated in my post. But then the stylesheet is loaded on every page of my blog, instead of the few that actually have AppleScript in them. I figured there must be a way to only load the stylesheet when it’s needed, in the same way the javascript is only loaded when it’s needed.

        • No, that’s not easily possible.

          My plugin does it by waiting until the footer to output the Javascript as by then all posts have been outputted and it knows what scripts are needed. It also uses Javascript to inject a stylesheet into the head (the only valid place for CSS) which is pretty hackish. There’s no easy way for your plugin to do the same thing without writing a bunch of code.

          • Yeah I saw that JavaScript bit the other day. I was wondering why it was done like that.
            Well then, wp_enqueue_style() will have to do, thanks for your help and the plugin.

            Cheers

  10. Pingback: www.hans-eric.com » D Brush For SyntaxHighlighter

  11. Pingback: lingtech : Syntax highlighting in WordPress

  12. Pingback: WordPress plugin extension: SyntaxHighlighter Evolved – D Brush « sociomantic labs

  13. Thanks for the plugin. A bit roundabout, but got there in the end.

    Worth nothing that if you put the code in a file called syntaxhighlighter-foobar.php in a folder called syntaxhighlighter-foobar (i.e, plugins/syntaxhighlighter-foobar/syntaxhighlighter-foobar.php ) and you do what you suggest in the example

    wp_register_script( 'syntaxhighlighter-brush-foobar', plugins_url( 'shBrushFoobar.js', __FILE__ ), array('syntaxhighlighter-core'), '1.2.3' );

    then you need to create a folder ANOTHER folder called syntaxhighlighter-foobar put your javascript brush in there (i.e., plugins/syntaxhighlighter-foobar/syntaxhighlighter-foobar/shBrushFoobar.js). It’s all a bit confusing.

    I think it’s easier leaving the brush in plugins/syntaxhighlighter-foobar/shBrushFoobar.js and changing the syntaxhighlighter_foobar_regscript function to

    wp_register_script( 'syntaxhighlighter-brush-foobar', plugins_url( syntaxhighlighter-foobar/shBrushFoobar.js' ), array('syntaxhighlighter-core'), '1.2.3' );
    • That’s gotta be a WordPress bug of some type. plugins_url( 'shBrushFoobar.js', __FILE__ ) should work out to be /plugins/syntaxhighlighter-foobar/shBrushFoobar.js. I do this in tons of my plugins and have never had any issues doing so.

  14. Pingback: Progress / OpenEdge / ABL Syntax Highlighting for HTML & Wordpress | Abe's Blog

  15. Pingback: ????????????????SyntaxHighlighter? | SanRin?

  16. Dear Alex,

    Thanks for the nice job you have done. I used your code for an assembly language brush plugin. It works perfectly and you can see it in action here : http://www.chlankboot.com/blog/asm-brush

    Now, I’m submitting it to wordpress.org to allow the asm community using it, but frankly I wish if you could add that brush (available on that same mentioned page) to the next version of the SyntaxHighlighter Evolved plugin as I have no time to maintain mine.

    Greetz

  17. Pingback: | Sys Admin Extraordinaire | » Blog Archive » Test SyntaxHighlighter

  18. Pingback: ?SyntaxHighlighter????? | QuarterGeek

  19. I am trying to install applesript and I need help reconciling these instructions to those on this site. Will someone help me with the script?!?!?
    Where should I install the three items provided?

    http://davidchambersdesign.com/applescript-syntax-highlighting/

    1. Download SyntaxHighlighter, and follow the setup instructions.
    2.Download AppleScript brush (?7.8?kB), and upload it to your SyntaxHighlighter scripts directory.
    3.Download AppleScript theme (?4.4?kB), and upload it to your SyntaxHighlighter styles directory.
    4.Download background image (154?bytes), and upload it to your SyntaxHighlighter styles directory.
    5.Include the brush like so:

    Thanks for the time.

  20. Soo … I added this to file name syntaxhighlighter-brush-applescript.php

    <?php
    /*
    Plugin Name: SyntaxHighlighter Evolved: AppleScript Brush
    Description: Adds support for the AppleScript language to the SyntaxHighlighter Evolved plugin.
    Author: john
    Version: 1.0.0
    */
    
    // SyntaxHighlighter Evolved doesn't do anything until early in the "init" hook, so best to wait until after that
    add_action( 'init', 'syntaxhighlighter_applescript_regscript' );
    
    // Tell SyntaxHighlighter Evolved about this new language/brush
    add_filter( 'syntaxhighlighter_brushes', 'syntaxhighlighter_applescript_addlang' );
    
    // Register the brush file with WordPress
    function syntaxhighlighter_applescript_regscript() {
    	wp_register_script( 'syntaxhighlighter-brush-applescript', plugins_url( 'shBrushAppleScript.js', __FILE__ ), array('syntaxhighlighter-core'), '1.2.3' );
    }
    
    // Filter SyntaxHighlighter Evolved's language array
    function syntaxhighlighter_foobar_addlang( $brushes ) {
    	$brushes['applescript'] = 'applescript';
    	$brushes['as'] = 'applescript';
    
    	return $brushes;
    }
    
    ?>

    I then uploaded shBrushAppleScript.js and syntaxhighlighter-brush-applescript.php to plugins/mine/. Code from shBrushAppleScript.js is

    /*
     * AppleScript brush for SyntaxHighlighter
     *
     * SyntaxHighlighter by Alex Gorbatchev
     * http://alexgorbatchev.com/
     *
     * AppleScript brush by David Chambers
     * http://davidchambersdesign.com/
     * { last updated: 10 August 2009 }
     */
    
    SyntaxHighlighter.brushes.AppleScript = function ()
    {
    	var keywords, ordinals, specials;
    	keywords = 'after before beginning continue copy each end every from return get global in local named of set some that the then times to where whose with without';
    	ordinals = 'first second third fourth fifth sixth seventh eighth ninth tenth last front back middle';
    	specials = 'activate add alias AppleScript ask attachment boolean class constant delete duplicate empty exists false id integer list make message modal modified new no paragraph pi properties quit real record remove rest result reveal reverse run running save string true word yes';
    
    	this.regexList = [
    
    		{ regex: /(--|#).*$/gm,
    		    css: 'comments' },
    
    		{ regex: /\(\*(?:[\s\S]*?\(\*[\s\S]*?\*\))*[\s\S]*?\*\)/gm, // support nested comments
    		    css: 'comments' },
    
    		{ regex: /"[\s\S]*?"/gm,
    		    css: 'string' },
    
    		{ regex: /(?:,|:|¬|'s\b|\(|\)|\{|\}|«|\b\w*»)/g,
    		    css: 'standard' },
    
    		{ regex: /(-)?(\d)+(\.(\d)?)?(E\+(\d)+)?/g, // numbers
    		    css: 'standard' },
    
    		{ regex: /(?:&(amp;|gt;|lt;)?|=|?|>|<|?|>=|?|<=|\*|\+|-|\/|÷|\^)/g,
    		    css: 'operator' },
    
    		{ regex: /\b(?:and|as|div|mod|not|or|return(?!\s&)(ing)?|equals|(is(n't| not)? )?equal( to)?|does(n't| not) equal|(is(n't| not)? )?(greater|less) than( or equal( to)?)?|(comes|does(n't| not) come) (after|before)|is(n't| not)?( in)? (back|front) of|is(n't| not)? behind|is(n't| not)?( (in|contained by))?|does(n't| not) contain|contain(s)?|(start|begin|end)(s)? with|((but|end) )?(consider|ignor)ing|prop(erty)?|(a )?ref(erence)?( to)?|repeat (until|while|with)|((end|exit) )?repeat|((else|end) )?if|else|(end )?(script|tell|try)|(on )?error|(put )?into|(of )?(it|me)|its|my|with (timeout( of)?|transaction)|end (timeout|transaction))\b/g,
    		    css: 'keyword' },
    
    		{ regex: /\b\d+(st|nd|rd|th)\b/g, // ordinals
    		    css: 'keyword' },
    
    		{ regex: /\b(?:about|above|against|around|at|below|beneath|beside|between|by|(apart|aside) from|(instead|out) of|into|on(to)?|over|since|thr(ough|u)|under)\b/g,
    		    css: 'special' },
    
    		{ regex: /\b(?:adding folder items to|after receiving|choose( ((remote )?application|color|folder|from list|URL))?|clipboard info|set the clipboard to|(the )?clipboard|entire contents|display(ing| (alert|dialog|mode))?|document( (edited|file|nib name))?|file( (name|type))?|(info )?for|giving up after|(name )?extension|quoted form|return(ed)?|second(?! item)(s)?|list (disks|folder)|text item(s| delimiters)?|(Unicode )?text|(disk )?item(s)?|((current|list) )?view|((container|key) )?window|with (data|icon( (caution|note|stop))?|parameter(s)?|prompt|properties|seed|title)|case|diacriticals|hyphens|numeric strings|punctuation|white space|folder creation|application(s( folder)?| (processes|scripts position|support))?|((desktop )?(pictures )?|(documents|downloads|favorites|home|keychain|library|movies|music|public|scripts|sites|system|users|utilities|workflows) )folder|desktop|Folder Action scripts|font(s| panel)?|help|internet plugins|modem scripts|(system )?preferences|printer descriptions|scripting (additions|components)|shared (documents|libraries)|startup (disk|items)|temporary items|trash|on server|in AppleTalk zone|((as|long|short) )?user name|user (ID|locale)|(with )?password|in (bundle( with identifier)?|directory)|(close|open for) access|read|write( permission)?|(g|s)et eof|using( delimiters)?|starting at|default (answer|button|color|country code|entr(y|ies)|identifiers|items|name|location|script editor)|hidden( answer)?|open(ed| (location|untitled))?|error (handling|reporting)|(do( shell)?|load|run|store) script|administrator privileges|altering line endings|get volume settings|(alert|boot|input|mount|output|set) volume|output muted|(fax|random )?number|round(ing)?|up|down|toward zero|to nearest|as taught in school|system (attribute|info)|((AppleScript( Studio)?|system) )?version|(home )?directory|(IPv4|primary Ethernet) address|CPU (type|speed)|physical memory|time (stamp|to GMT)|replacing|ASCII (character|number)|localized string|from table|offset|summarize|beep|delay|say|(empty|multiple) selections allowed|(of|preferred) type|invisibles|showing( package contents)?|editable URL|(File|FTP|News|Media|Web) [Ss]ervers|Telnet hosts|Directory services|Remote applications|waiting until completion|saving( (in|to))?|path (for|to( (((current|frontmost) )?application|resource))?)|POSIX (file|path)|(background|RGB) color|(OK|cancel) button name|cancel button|button(s)?|cubic ((centi)?met(re|er)s|yards|feet|inches)|square ((kilo)?met(re|er)s|miles|yards|feet)|(centi|kilo)?met(re|er)s|miles|yards|feet|inches|lit(re|er)s|gallons|quarts|(kilo)?grams|ounces|pounds|degrees (Celsius|Fahrenheit|Kelvin)|print( (dialog|settings))?|clos(e(able)?|ing)|(de)?miniaturized|miniaturizable|zoom(ed|able)|attribute run|action (method|property|title)|phone|email|((start|end)ing|home) page|((birth|creation|current|custom|modification) )?date|((((phonetic )?(first|last|middle))|computer|host|maiden|related) |nick)?name|aim|icq|jabber|msn|yahoo|address(es)?|save addressbook|should enable action|city|country( code)?|formatte(r|d address)|(palette )?label|state|street|zip|AIM [Hh]andle(s)?|my card|select(ion| all)?|unsaved|(alpha )?value|entr(y|ies)|group|(ICQ|Jabber|MSN) handle|person|people|company|department|icon image|job title|note|organization|suffix|vcard|url|copies|collating|pages (across|down)|request print time|target( printer)?|((GUI Scripting|Script menu) )?enabled|show Computer scripts|(de)?activated|awake from nib|became (key|main)|call method|of (class|object)|center|clicked toolbar item|closed|for document|exposed|(can )?hide|idle|keyboard (down|up)|event( (number|type))?|launch(ed)?|load (image|movie|nib|sound)|owner|log|mouse (down|dragged|entered|exited|moved|up)|move|column|localization|resource|script|register|drag (info|types)|resigned (active|key|main)|resiz(e(d)?|able)|right mouse (down|dragged|up)|scroll wheel|(at )?index|should (close|open( untitled)?|quit( after last window closed)?|zoom)|((proposed|screen) )?bounds|show(n)?|behind|in front of|size (mode|to fit)|update(d| toolbar item)?|was (hidden|miniaturized)|will (become active|close|finish launching|hide|miniaturize|move|open|quit|(resign )?active|((maximum|minimum|proposed) )?size|show|zoom)|bundle|data source|movie|pasteboard|sound|tool(bar| tip)|(color|open|save) panel|coordinate system|frontmost|main( (bundle|menu|window))?|((services|(excluded from )?windows) )?menu|((executable|frameworks|resource|scripts|shared (frameworks|support)) )?path|(selected item )?identifier|data|content(s| view)?|character(s)?|click count|(command|control|option|shift) key down|context|delta (x|y|z)|key( code)?|location|pressure|unmodified characters|types|(first )?responder|playing|(allowed|selectable) identifiers|allows customization|(auto saves )?configuration|visible|image( name)?|menu form representation|tag|user(-| )defaults|associated file name|(auto|needs) display|current field editor|floating|has (resize indicator|shadow)|hides when deactivated|level|minimized (image|title)|opaque|position|release when closed|sheet|title(d)?)\b/g,
    		    css: 'special' },
    
    		{ regex: new RegExp(this.getKeywords(specials), 'gm'), css: 'special' },
    		{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' },
    		{ regex: new RegExp(this.getKeywords(ordinals), 'gm'), css: 'keyword' },
    
    		{ regex: /\b\w+\b/g,
    		    css: 'userdef' }
    	];
    };
    
    SyntaxHighlighter.brushes.AppleScript.prototype = new SyntaxHighlighter.Highlighter();
    SyntaxHighlighter.brushes.AppleScript.aliases = ['applescript'];

    I then get the following error across the top of the screen :
    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘syntaxhighlighter_applescript_addlang’ was given in /homepages/xx/xxxxxxxxxx/htdocs/xxxxxxx/wp-includes/plugin.php on line 166

    Any thoughts?

  21. Pingback: Creating brushes for Syntax Highlighter | Alauda Project

  22. I appreciate the effort to make this plug-in expandable, but these instructions are really really hard to follow for regular WP admins.

  23. Pingback: SyntaxHighlighter Evolved PHP5 « « Sandro Bilbeisi

  24. Pingback: Golang Brush for SyntaxHighlighter Evolved | El Pingüinario de Luis Iván

  25. Pingback: Salesforce Apex & VisualForce Syntax Highlighter for Wordpress

  26. Pingback: Arduino Code Syntax Highlighting Plugin for your WordPress Blog

  27. The instructions are a bit easier to follow if you look at the general logic of WordPress plugins, the way you register scripts and themes. I agree, it’s probably a bit difficult if you jump straight into it without prior JS, CSS and PHP programming experience. But if you have at least some knowledge of these three, there’s enough information on this page alone (both the post and the comments) to get a pretty good idea about how this works.
    I also needed a custom brush and a custom theme for my project and was able to do both. My plugin is for highlighting Arduino code in listings of the Arduino IDE sketches. It’s published here http://elabz.com/arduino-syntaxhighlighter/ and hope it will be available on WordPress.org soon, too. You’re more than welcome to peek inside and adapt to your own syntax if you like.

  28. Pingback: SyntaxHighlighter??Brush?????DOS ???????? | ???????????

  29. For some reason, I’m not getting any syntax highlight nor any sort of errors. Any thoughts?

    Plugin Code:

    <?php
    /*
    Plugin Name: SyntaxHighlighter Evolved: SAS Brush
    Description: Adds support for the SAS Language
    Author: ProcRun
    Version: 0.1
    Author URL: http://www.procrun.com
    */
     
    // SyntaxHighlighter Evolved doesn't do anything until early in the "init" hook, so best to wait until after that
    add_action( 'init', 'syntaxhighlighter_sas_regscript' );
     
    // Tell SyntaxHighlighter Evolved about this new language/brush
    add_filter( 'syntaxhighlighter_brushes', 'syntaxhighlighter_sas_addlang' );
     
    // Register the brush file with WordPress
    function syntaxhighlighter_sas_regscript() {
        wp_register_script( 'syntaxhighlighter-brush-sas', plugins_url( 'syntaxhighlighter-sas/shBrushSAS.js'), array('syntaxhighlighter-core'), '1.2.3' );
    }
     
    // Filter SyntaxHighlighter Evolved's language array
    function syntaxhighlighter_sas_addlang( $brushes ) {
        $brushes['sas'] = 'sas';
        $brushes['SAS'] = 'sas';
     
        return $brushes;
    }
     
    ?>
    

    Actual brush:

    SyntaxHighlighter.brushes.sas = function()
    {
    var keywords = 'proc run by data';
    
    };
     
    SyntaxHighlighter.brushes.sas.prototype = new SyntaxHighlighter.Highlighter();
    SyntaxHighlighter.brushes.sas.aliases = ['SAS', '.sas', 'sas'];
    

    shBrushSAS.js is inside the syntaxhighlter-sas directory with the .php file.

      • The page source looks like this:

        proc sort data = sample;
        by variable;
        run;

        It highlights Bash and some of the other syntaxes fine if I use those brushes. It’s just not finding the proc, sort or run to highlight for some reason.

        • I left the code bracket off the above comment, it looks like

          <pre class="brush: sas; title: ; notranslate" title="">
          proc sort data = sample;
          by variable;
          run;
          </pre>
          
  30. Pingback: Unable to perform Translation:Quota Exceeded. Please see http://code.google.com/apis/language/translate/overview.html - CyberMaster

  31. Pingback: Adding a new brush to the SyntaxHighlighter Evolved plugin | http://blog.hashbangweb.com

  32. Pingback: Wordpress – Syntax Highlighter – Add Custom Brush(es) | Me Like Dev

  33. Pingback: Adding a new brush to the SyntaxHighlighter Evolved plugin | noseyparka.me.uk

  34. Pingback: SyntaxHighlighter Evolved Biferno | Best Plugins - wordpress – widgets – plugin 2012

  35. Pingback: ??????? » SyntaxHighlighter Evolved?Haskell????

  36. Pingback: SyntaxHighlighter Evolved PHP5 | Best Plugins - wordpress – widgets – plugin 2012

  37. Pingback: SyntaxHighlighter Evolved | It??????????

  38. Pingback: TypeScript Syntax Highlighting for Wordpress « Ian Obermiller

  39. Pingback: DynStatic – Wordpress RouterOS Syntax Highlighting

  40. Pingback: Add SyntaxHighlighter Evolved Plugin Third Party Brushes To Your WordPress Installation - it.megocollector.com

  41. Pingback: SyntaxHighlighter Evolved ? lisp ??????? | CuP ????

  42. Pingback: SyntaxHighlighter Evolved : D Brush « azurenote

  43. Pingback: SyntaxHighlighter????????? | Crescent

  44. Pingback: SyntaxHighlighter Evolved | Tidy Repo

  45. Hi Alex,

    I could use a little help. I keep getting the SyntaxHighlighter message:
    Can’t find brush for: gms

    wp-content/plugins/gms-brush contains only:
    gms-brush.php
    shBrushGMS.js

    gms-brush.php:

    After seven hours of staring, poking and probing I’m at wits end.

    Thank you very much for any help.

    Kelly

  46. Pingback: WordPress Syntax Highlighting for YAML | tedious ramblings

  47. Pingback: carlynorama | SyntaxHighlighting Evolved WordPress Plugin and a Custom Arduino Brush

Leave a Reply