WordPress.org

Ready to get started?Download WordPress

Forums

SyntaxHighlighter Evolved
Applescript install (3 posts)

  1. johneday
    Member
    Posted 3 years ago #

    Will someone please walk me through how to install the brush, theme and background image as detailed on

    davidchambersdesign.com

    If I am not supposed to put the brush in the third-party-brushes directory, where do I put it?
    Do I place the AppleScript theme and background image in the styles directory of syntaxhighlighter2 or syntaxhighlighter3? Or somewhere else?

    Am I supposed to do step 5? Where?

    <script type="text/javascript" src="/path/to/scripts/shCore.js"></script>
    <script type="text/javascript" src="/path/to/scripts/shBrushAppleScript.js"></script>
    <script type="text/javascript">
        SyntaxHighlighter.all();
    </script>

    An example including the file structure (using the 3 files provided) and the corresponding register script would be much appreciated.

    Thanks for the time.

    http://wordpress.org/extend/plugins/syntaxhighlighter/

  2. johneday
    Member
    Posted 3 years ago #

    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?

  3. Scott Selikoff
    Member
    Posted 3 years ago #

    I wrote a plugin that extends SyntaxHighlight Evolved and adds support for AppleScript:

    SyntaxHighlighter Evolved Applescript

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic