Skip to content

Commit 503e579

Browse files
authored
Merge pull request #136 from Siytek/master
2 parents 4e7a6b7 + cbceb95 commit 503e579

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

syntaxhighlighter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function_exists( 'parse_blocks' ) // WordPress 5.0+
123123
// Register brush scripts
124124
wp_register_script( 'syntaxhighlighter-core', plugins_url( $this->shfolder . '/scripts/shCore.js', __FILE__ ), array(), $this->agshver );
125125
wp_register_script( 'syntaxhighlighter-brush-as3', plugins_url( $this->shfolder . '/scripts/shBrushAS3.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
126+
wp_register_script( 'syntaxhighlighter-brush-arduino', plugins_url( $this->shfolder . '/scripts/shBrushArduino.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
126127
wp_register_script( 'syntaxhighlighter-brush-bash', plugins_url( $this->shfolder . '/scripts/shBrushBash.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
127128
wp_register_script( 'syntaxhighlighter-brush-coldfusion', plugins_url( $this->shfolder . '/scripts/shBrushColdFusion.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
128129
wp_register_script( 'syntaxhighlighter-brush-cpp', plugins_url( $this->shfolder . '/scripts/shBrushCpp.js', __FILE__ ), array('syntaxhighlighter-core'), $this->agshver );
@@ -172,6 +173,7 @@ function_exists( 'parse_blocks' ) // WordPress 5.0+
172173
$this->brushes = (array) apply_filters( 'syntaxhighlighter_brushes', array(
173174
'as3' => 'as3',
174175
'actionscript3' => 'as3',
176+
'arduino' => 'arduino',
175177
'bash' => 'bash',
176178
'shell' => 'bash',
177179
'coldfusion' => 'coldfusion',
@@ -232,6 +234,7 @@ function_exists( 'parse_blocks' ) // WordPress 5.0+
232234

233235
$this->brush_names = (array) apply_filters( 'syntaxhighlighter_brush_names', array(
234236
'as3' => __( 'ActionScript', 'syntaxhighlighter' ),
237+
'arduino' => __( 'Arduino', 'syntaxhighlighter' ),
235238
'bash' => __( 'BASH / Shell', 'syntaxhighlighter' ),
236239
'coldfusion' => __( 'ColdFusion', 'syntaxhighlighter' ),
237240
'clojure' => __( 'Clojure', 'syntaxhighlighter' ),
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* SyntaxHighlighter
3+
* http://alexgorbatchev.com/SyntaxHighlighter
4+
*
5+
* SyntaxHighlighter is donationware. If you are using it, please donate.
6+
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
7+
*
8+
* @version
9+
* 3.0.83 (Wed, 16 Apr 2014 03:56:09 GMT)
10+
*
11+
* @copyright
12+
* Copyright (C) 2004-2013 Alex Gorbatchev.
13+
*
14+
* @license
15+
* Dual licensed under the MIT and GPL licenses.
16+
*
17+
* Original brush carlynorama/wp-syntaxhighlighter-arduino updated April 2020 by https://siytek.com
18+
*/
19+
;(function()
20+
{
21+
// CommonJS
22+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
23+
24+
function Brush()
25+
{
26+
27+
var datatypes = 'boolean char byte int long float double void unsigned volatile word string static const';
28+
29+
var keywords = 'setup loop if else for switch case default while do break continue return';
30+
31+
var functions = 'pinMode digitalWrite digitalRead analogRead analogWrite shiftOut pulseIn ' +
32+
'millis micros delay delayMicroseconds min max abs constrain ' +
33+
'map pow sq sqrt sin cos tan randomSeed random ' +
34+
'sizeof lowByte highByte bitRead bitWrite bitSet bitClear bit tone noTone' +
35+
'attachInterrupt detachInterrupt interrupts noInterrupts ' +
36+
'Serial\\.begin Serial\\.available Serial\\.read Serial\\.flush ' +
37+
'Serial\\.print Serial\\.println Serial\\.write ';
38+
39+
var constants = 'HIGH LOW INPUT OUTPUT true false CHANGE RISING FALLING';
40+
41+
42+
this.regexList = [
43+
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' } // one line comments
44+
,{ regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' } // multiline comments
45+
,{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' } // strings
46+
,{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' } // strings
47+
,{ regex: /^ *#(.)+?\b/gm, css: 'preprocessor' } // preprocessor directives
48+
,{ regex: new RegExp(this.getKeywords(datatypes), 'gm'), css: 'color1 bold' } // datatypes
49+
,{ regex: new RegExp(this.getKeywords(functions), 'gm'), css: 'functions' } // functions
50+
,{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword bold' } // control flow
51+
,{ regex: new RegExp(this.getKeywords(constants), 'gm'), css: 'constants bold' } // predefined constants
52+
,{ regex: /\b(\d*\.\d+([Ee]-?\d{1,3})?)|(\d+[Ee]-?\d{1,3})\b/gm, css: 'constants'} // numeric constants (floating point)
53+
,{ regex: /\b\d+[uU]?[lL]?\b/gm, css: 'constants'} // numeric constants (decimal)
54+
,{ regex: /\b0x[0-9A-Fa-f]+[uU]?[lL]?\b/gm, css: 'constants'} // numeric constants (hexidecimal)
55+
,{ regex: /\bB[01]{1,8}\b/gm, css: 'constants'} // numeric constants (binary)
56+
,{ regex: /\+|\-|\*|\/|\%|!|\||\&|=|\?|\^|~/gm, css: 'plain bold' } // operators
57+
];
58+
};
59+
60+
Brush.prototype = new SyntaxHighlighter.Highlighter();
61+
Brush.aliases = ['arduino', 'arduinolite'];
62+
63+
SyntaxHighlighter.brushes.Arduino = Brush;
64+
65+
// CommonJS
66+
typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
67+
})();

0 commit comments

Comments
 (0)