Quantcast
Channel: David Orlo .com | Tag Archives: php
Viewing all articles
Browse latest Browse all 5

Syntax Highlighter Evolved AutoIT Brush Plugin

0
0

Here is my second Syntax Highlighter Brush attempt. This one was far more complex than the last Arduino / Wiring Brush I made. There are still a few things that need to be worked out such as multiline comments and there seems to be a bug in WordPress / Syntax Highlighter that adds a semicolon in various places where one didn’t exist before. I noticed this because the semicolon is used to denote comments in AutoIT and after adding that section of code to the highlighter I was able to easily spot this flaw.

I plan to do more work on the expressions used and colors for various themes but for now this is pretty good, much better than using the VB Brush as I was before. I used Scite script editor as a rough guide for the color scheme and if your using the default or another light theme the colors should be near identical. One exception is the  Preprocessor and Special Keywords which I just lumped together in the same category since there is only 3 special keywords and a handful of Preprocessor keywords which are as follows.

au3.keywords.preprocessor=#ce #comments-end #comments-start #cs #include #include-once \
#noautoit3execute #notrayicon #onautoitstartregister #requireadmin
au3.keywords.special=#endregion #forceref #region

Another change I made to help lighten up the code and keep the syntax checking fast was to remove the keywords and use regular expressions for Preprocessor, Special, Sendkeys and Macros which means the Highlighter may match some keywords that don’t actually exists if you put an @ symbol before a word or enclose it in {} brackets.

I made 2 different CSS color themes, one for dark and one for light themes. I will copy and paste the instructions from the last Brush I made for installation so excuse me for being lazy.

Screen shots of the before and after, before using VB as language and after using the AutoIT custom Brush.

Syntax Highlighter using VB for AutoIT Code

Syntax Highlighter using VB for AutoIT Code

Syntax Highlighter using AIT for AutoIT Code

Syntax Highlighter using AIT for AutoIT Code

 

I couldn’t find solid instruction on how to install these brushes so I just figured out a way to make it work on my own and I like the way this works so I don’ t plan to change it. First download the shBrushWiring.js file that I have attached to this post.

shBrushAutoIT

Next upload the file to the “/wp-content/plugins/syntaxhighlighter/third-party-brushes/” folder.

Now we need to edit a few files, you can either do this directly in WordPress by going to Plugins and then the editor and choosing the files or you can download them via FTP and edit them in an editor which I think is the better way to go because you will get more predictable results.

First we need to edit the main php file called “syntaxhighlighter.php” it’s located in ”/wp-content/plugins/syntaxhighlighter/
Find the line that reads ”// Register some popular third-party brushes” and after the last entry add the following line

wp_register_script( ‘syntaxhighlighter-brush-autoit’, plugins_url(‘syntaxhighlighter/third-party-brushes/shBrushAutoIT.js’), array(‘syntaxhighlighter-core’), ’20120504? );

Now find the line that reads “// Create list of brush aliases and map them to their real brushes” and at the top of the list before “‘as3′           => ‘as3′,” Add the following lines

‘ait’ => ‘autoit’,
‘AIT’ => ‘autoit’,
‘AutoIT’ => ‘autoit’,
‘Autoit’ => ‘autoit’,
‘autoit’ => ‘autoit’,

Save, Close and upload the file if you downloaded it via FTP

Next we need to go into the “/wp-content/plugins/syntaxhighlighter/syntaxhighlighter3/styles/” folder and edit the file which correlates to the theme you are using or you can edit all of the theme files which I recommend. The files we want to edit are the ones with THEME in the name, i.e. “shThemeDefault.css” At the end of the file we need to add the following lines. These lines control the colors so if you want to edit them you can do that here. If you think a specific word should be in a different category, i.e. function labeled as a keyword, just drop me a comment below and I will fix it.

LIGHT COLORED THEME FILES, i.e. Default Theme

.syntaxhighlighter .aitcomment {
color: #2e7b59 !important;
}
.syntaxhighlighter .aitvariables {
color: #7b1415 !important;
}
.syntaxhighlighter .aitfunctions {
color: #01042f !important;
}
.syntaxhighlighter .aitudfs {
color: #376fac !important;
}
.syntaxhighlighter .aitkeywords {
color: #1f1198 !important;
}
.syntaxhighlighter .aitmacros {
color: #d14ec0 !important;
}
.syntaxhighlighter .aitpreprocessor {
color: #9342a9 !important;
}
.syntaxhighlighter .aitspecial {
color: #6f4090 !important;
}
.syntaxhighlighter .aitsendkeys {
color: #000005 !important;
}

DARK COLORED THEME FILES, i.e. EMacs Theme

.syntaxhighlighter .aitcomment {
color: #00da17 !important;
}
.syntaxhighlighter .aitvariables {
color: #ff0106 !important;
}
.syntaxhighlighter .aitfunctions {
color: #0b25ff !important;
}
.syntaxhighlighter .aitudfs {
color: #0bccff !important;
}
.syntaxhighlighter .aitkeywords {
color: #0b76ff !important;
}
.syntaxhighlighter .aitmacros {
color: #ff49f8 !important;
}
.syntaxhighlighter .aitpreprocessor {
color: #b41fff !important;
}
.syntaxhighlighter .aitspecial {
color: #870fff !important;
}
.syntaxhighlighter .aitsendkeys {
color: #ffffff !important;
}

Save, Close and upload the files if you downloaded them via FTP

That’s it your all done, to use the new code you can use the following example in your post, you must enclose these in brackets and follow them up with /code in brackets [].

code lang=”AutoIT”
code lang=”AIT”


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images