SyntaxHighlighter Evolved - Version 3.6.2

Version Description

Download this release

Release Info

Developer aaronfc
Plugin Icon wp plugin SyntaxHighlighter Evolved
Version 3.6.2
Comparing to
See all releases

Code changes from version 3.6.1 to 3.6.2

readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: Viper007Bond, automattic, donncha
3
  Donate link: https://alex.blog/2019/03/13/in-memory-of-alex-donation-link-update/
4
  Tags: code, source, sourcecode, php, syntax highlighting, syntax, highlight, highlighting, highlighter, WordPress.com
5
- Requires at least: 5.6
6
- Tested up to: 5.8
7
- Stable tag: 3.6.1
8
 
9
  Easily post syntax-highlighted code to your site without having to modify the code at all. As seen on WordPress.com.
10
 
@@ -40,6 +40,10 @@ Try excluding this plugin's Javascript from any performance optimizations your s
40
 
41
  == ChangeLog ==
42
 
 
 
 
 
43
  = Version 3.6.1 =
44
 
45
  * New: Set code block language when pasting into editor. #215
2
  Contributors: Viper007Bond, automattic, donncha
3
  Donate link: https://alex.blog/2019/03/13/in-memory-of-alex-donation-link-update/
4
  Tags: code, source, sourcecode, php, syntax highlighting, syntax, highlight, highlighting, highlighter, WordPress.com
5
+ Requires at least: 5.7
6
+ Tested up to: 5.9
7
+ Stable tag: 3.6.2
8
 
9
  Easily post syntax-highlighted code to your site without having to modify the code at all. As seen on WordPress.com.
10
 
40
 
41
  == ChangeLog ==
42
 
43
+ = Version 3.6.2 =
44
+
45
+ * New: Add syntax highlight for Swift. #232
46
+
47
  = Version 3.6.1 =
48
 
49
  * New: Set code block language when pasting into editor. #215
syntaxhighlighter.php CHANGED
@@ -4,22 +4,22 @@
4
 
5
  Plugin Name: SyntaxHighlighter Evolved
6
  Plugin URI: https://alex.blog/wordpress-plugins/syntaxhighlighter/
7
- Version: 3.6.1
8
  Description: Easily post syntax-highlighted code to your site without having to modify the code at all. Uses Alex Gorbatchev's <a href="http://alexgorbatchev.com/SyntaxHighlighter/">SyntaxHighlighter</a>. Includes a new editor block.
9
  Author: Alex Mills (Viper007Bond)
10
  Author URI: https://alex.blog/
11
  Text Domain: syntaxhighlighter
12
  License: GPL2
13
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
14
- Requires at least: 5.6
15
- Tested up to: 5.8
16
  Requires PHP: 7.0
17
 
18
  **************************************************************************/
19
 
20
  class SyntaxHighlighter {
21
  // All of these variables are private. Filters are provided for things that can be modified.
22
- public $pluginver = '3.6.1'; // Plugin version
23
  public $agshver = false; // Alex Gorbatchev's SyntaxHighlighter version (dynamically set below due to v2 vs v3)
24
  public $shfolder = false; // Controls what subfolder to load SyntaxHighlighter from (v2 or v3)
25
  public $settings = array(); // Contains the user's settings
@@ -150,6 +150,7 @@ class SyntaxHighlighter {
150
  wp_register_script( 'syntaxhighlighter-brush-ruby', plugins_url( $this->shfolder . '/scripts/shBrushRuby.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
151
  wp_register_script( 'syntaxhighlighter-brush-scala', plugins_url( $this->shfolder . '/scripts/shBrushScala.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
152
  wp_register_script( 'syntaxhighlighter-brush-sql', plugins_url( $this->shfolder . '/scripts/shBrushSql.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
 
153
  wp_register_script( 'syntaxhighlighter-brush-vb', plugins_url( $this->shfolder . '/scripts/shBrushVb.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
154
  wp_register_script( 'syntaxhighlighter-brush-xml', plugins_url( $this->shfolder . '/scripts/shBrushXml.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
155
  wp_register_script( 'syntaxhighlighter-brush-yaml', plugins_url( $this->shfolder . '/scripts/shBrushYaml.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
@@ -232,6 +233,7 @@ class SyntaxHighlighter {
232
  'ruby' => 'ruby',
233
  'scala' => 'scala',
234
  'sql' => 'sql',
 
235
  'vb' => 'vb',
236
  'vbnet' => 'vb',
237
  'xml' => 'xml',
@@ -273,6 +275,7 @@ class SyntaxHighlighter {
273
  'r' => __( 'R', 'syntaxhighlighter' ),
274
  'ruby' => __( 'Ruby / Ruby on Rails', 'syntaxhighlighter' ),
275
  'scala' => __( 'Scala', 'syntaxhighlighter' ),
 
276
  'sql' => __( 'SQL', 'syntaxhighlighter' ),
277
  'vb' => __( 'Visual Basic', 'syntaxhighlighter' ),
278
  'xml' => __( 'HTML / XHTML / XML / XSLT', 'syntaxhighlighter' ),
4
 
5
  Plugin Name: SyntaxHighlighter Evolved
6
  Plugin URI: https://alex.blog/wordpress-plugins/syntaxhighlighter/
7
+ Version: 3.6.2
8
  Description: Easily post syntax-highlighted code to your site without having to modify the code at all. Uses Alex Gorbatchev's <a href="http://alexgorbatchev.com/SyntaxHighlighter/">SyntaxHighlighter</a>. Includes a new editor block.
9
  Author: Alex Mills (Viper007Bond)
10
  Author URI: https://alex.blog/
11
  Text Domain: syntaxhighlighter
12
  License: GPL2
13
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
14
+ Requires at least: 5.7
15
+ Tested up to: 5.9
16
  Requires PHP: 7.0
17
 
18
  **************************************************************************/
19
 
20
  class SyntaxHighlighter {
21
  // All of these variables are private. Filters are provided for things that can be modified.
22
+ public $pluginver = '3.6.2'; // Plugin version
23
  public $agshver = false; // Alex Gorbatchev's SyntaxHighlighter version (dynamically set below due to v2 vs v3)
24
  public $shfolder = false; // Controls what subfolder to load SyntaxHighlighter from (v2 or v3)
25
  public $settings = array(); // Contains the user's settings
150
  wp_register_script( 'syntaxhighlighter-brush-ruby', plugins_url( $this->shfolder . '/scripts/shBrushRuby.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
151
  wp_register_script( 'syntaxhighlighter-brush-scala', plugins_url( $this->shfolder . '/scripts/shBrushScala.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
152
  wp_register_script( 'syntaxhighlighter-brush-sql', plugins_url( $this->shfolder . '/scripts/shBrushSql.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
153
+ wp_register_script( 'syntaxhighlighter-brush-swift', plugins_url( $this->shfolder . '/scripts/shBrushSwift.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
154
  wp_register_script( 'syntaxhighlighter-brush-vb', plugins_url( $this->shfolder . '/scripts/shBrushVb.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
155
  wp_register_script( 'syntaxhighlighter-brush-xml', plugins_url( $this->shfolder . '/scripts/shBrushXml.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
156
  wp_register_script( 'syntaxhighlighter-brush-yaml', plugins_url( $this->shfolder . '/scripts/shBrushYaml.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
233
  'ruby' => 'ruby',
234
  'scala' => 'scala',
235
  'sql' => 'sql',
236
+ 'swift' => 'swift',
237
  'vb' => 'vb',
238
  'vbnet' => 'vb',
239
  'xml' => 'xml',
275
  'r' => __( 'R', 'syntaxhighlighter' ),
276
  'ruby' => __( 'Ruby / Ruby on Rails', 'syntaxhighlighter' ),
277
  'scala' => __( 'Scala', 'syntaxhighlighter' ),
278
+ 'swift' => __( 'Swift', 'syntaxhighlighter' ),
279
  'sql' => __( 'SQL', 'syntaxhighlighter' ),
280
  'vb' => __( 'Visual Basic', 'syntaxhighlighter' ),
281
  'xml' => __( 'HTML / XHTML / XML / XSLT', 'syntaxhighlighter' ),
syntaxhighlighter3/scripts/shBrushSwift.js ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Swift brush based on contributions by Alex Gorbatchev
2
+ // https://github.com/syntaxhighlighter/brush-swift/blob/master/brush.js
3
+
4
+ ;(function()
5
+ {
6
+ // CommonJS
7
+ SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
8
+
9
+ function Brush()
10
+ {
11
+ function getKeywordsPrependedBy(keywords, by) {
12
+ return '(?:' + keywords.replace(/^\s+|\s+$/g, '').replace(/\s+/g, '|' + by + '\\b').replace(/^/, by + '\\b') + ')\\b';
13
+ }
14
+
15
+ function stringAdd(match, regexInfo) {
16
+ var str = match[0],
17
+ result = [],
18
+ pos = 0,
19
+ matchStart = 0,
20
+ level = 0;
21
+
22
+ while (pos < str.length - 1) {
23
+ if (level === 0) {
24
+ if (str.substr(pos, 2) === "\\(") {
25
+ result.push(new SyntaxHighlighter.Match(str.substring(matchStart, pos + 2), matchStart + match.index, regexInfo.css));
26
+ level++;
27
+ pos += 2;
28
+ } else {
29
+ pos++;
30
+ }
31
+ } else {
32
+ if (str[pos] === "(") {
33
+ level++;
34
+ }
35
+ if (str[pos] === ")") {
36
+ level--;
37
+ if (level === 0) {
38
+ matchStart = pos;
39
+ }
40
+ }
41
+ pos++;
42
+ }
43
+ }
44
+ if (level === 0) {
45
+ result.push(new SyntaxHighlighter.Match(str.substring(matchStart, str.length), matchStart + match.index, regexInfo.css));
46
+ }
47
+
48
+ return result;
49
+ };
50
+
51
+ // "Swift-native types" are all the protocols, classes, structs, enums, funcs, vars, and typealiases built into the language
52
+ var swiftTypes = 'AbsoluteValuable Any AnyClass Array ArrayBound ArrayBuffer ArrayBufferType ' +
53
+ 'ArrayLiteralConvertible ArrayType AutoreleasingUnsafePointer BidirectionalIndex Bit ' +
54
+ 'BitwiseOperations Bool C CBool CChar CChar16 CChar32 CConstPointer CConstVoidPointer ' +
55
+ 'CDouble CFloat CInt CLong CLongLong CMutablePointer CMutableVoidPointer COpaquePointer ' +
56
+ 'CShort CSignedChar CString CUnsignedChar CUnsignedInt CUnsignedLong CUnsignedLongLong ' +
57
+ 'CUnsignedShort CVaListPointer CVarArg CWideChar Character CharacterLiteralConvertible ' +
58
+ 'Collection CollectionOfOne Comparable ContiguousArray ContiguousArrayBuffer DebugPrintable ' +
59
+ 'Dictionary DictionaryGenerator DictionaryIndex DictionaryLiteralConvertible Double ' +
60
+ 'EmptyCollection EmptyGenerator EnumerateGenerator Equatable ExtendedGraphemeClusterLiteralConvertible ' +
61
+ 'ExtendedGraphemeClusterType ExtensibleCollection FilterCollectionView FilterCollectionViewIndex ' +
62
+ 'FilterGenerator FilterSequenceView Float Float32 Float64 Float80 FloatLiteralConvertible ' +
63
+ 'FloatLiteralType FloatingPointClassification FloatingPointNumber ForwardIndex Generator ' +
64
+ 'GeneratorOf GeneratorOfOne GeneratorSequence Hashable HeapBuffer HeapBufferStorage ' +
65
+ 'HeapBufferStorageBase ImplicitlyUnwrappedOptional IndexingGenerator Int Int16 Int32 Int64 ' +
66
+ 'Int8 IntEncoder IntMax Integer IntegerArithmetic IntegerLiteralConvertible IntegerLiteralType ' +
67
+ 'Less LifetimeManager LogicValue MapCollectionView MapSequenceGenerator MapSequenceView ' +
68
+ 'MaxBuiltinFloatType MaxBuiltinIntegerType Mirror MirrorDisposition MutableCollection ' +
69
+ 'MutableSliceable ObjectIdentifier OnHeap Optional OutputStream PermutationGenerator ' +
70
+ 'Printable QuickLookObject RandomAccessIndex Range RangeGenerator RawByte RawOptionSet ' +
71
+ 'RawRepresentable Reflectable Repeat ReverseIndex ReverseRange ReverseRangeGenerator ' +
72
+ 'ReverseView Sequence SequenceOf SignedInteger SignedNumber Sink SinkOf Slice SliceBuffer ' +
73
+ 'Sliceable StaticString Streamable StridedRangeGenerator String StringElement ' +
74
+ 'StringInterpolationConvertible StringLiteralConvertible StringLiteralType UInt UInt16 ' +
75
+ 'UInt32 UInt64 UInt8 UIntMax UTF16 UTF32 UTF8 UWord UnicodeCodec UnicodeScalar Unmanaged ' +
76
+ 'UnsafeArray UnsafePointer UnsignedInteger Void Word Zip2 ZipGenerator2 abs advance alignof ' +
77
+ 'alignofValue assert bridgeFromObjectiveC bridgeFromObjectiveCUnconditional bridgeToObjectiveC ' +
78
+ 'bridgeToObjectiveCUnconditional c contains count countElements countLeadingZeros debugPrint ' +
79
+ 'debugPrintln distance dropFirst dropLast dump encodeBitsAsWords enumerate equal false filter ' +
80
+ 'find getBridgedObjectiveCType getVaList indices insertionSort isBridgedToObjectiveC ' +
81
+ 'isBridgedVerbatimToObjectiveC isUniquelyReferenced join lexicographicalCompare map max ' +
82
+ 'maxElement min minElement nil numericCast partition posix print println quickSort reduce ' +
83
+ 'reflect reinterpretCast reverse roundUpToAlignment sizeof sizeofValue sort split startsWith ' +
84
+ 'strideof strideofValue swap swift toString transcode true underestimateCount unsafeReflect ' +
85
+ 'withExtendedLifetime withObjectAtPlusZero withUnsafePointer withUnsafePointerToObject ' +
86
+ 'ßwithUnsafePointers withVaList ' +
87
+ 'fatalError assert assertionFailure precondition preconditionFailure ' +
88
+ 'Set AnyPublisher AnyCancellable sink store compactMap flatMap ObservableObject ';
89
+
90
+ var keywords = 'as break catch case class continue default deinit do dynamicType else enum ' +
91
+ 'extension fallthrough for forEach func if import in init is let new protocol ' +
92
+ 'return self Self static struct subscript super switch Type typealias ' +
93
+ 'var where while __COLUMN__ __FILE__ __FUNCTION__ __LINE__ associativity ' +
94
+ 'didSet get infix inout left mutating none nonmutating operator override required ' +
95
+ 'postfix precedence prefix right set try unowned unowned(safe) unowned(unsafe) weak willSet ' +
96
+ 'guard convenience defer dynamic final fileprivate private internal open public repeat throw throws rethrows unowned lazy ' +
97
+ 'isolated nonisolated safe unsafe some optional assignment indirect ' +
98
+ // Precedence group
99
+ 'precedencegroup higherThan lowerThan ' +
100
+ // Swift concurrency
101
+ 'actor associatedtype async await ';
102
+
103
+ var attributes = 'assignment class_protocol exported noreturn escaping NSCopying NSManaged objc nonobjc optional required auto_closure IBAction IBDesignable IBInspectable IBOutlet infix prefix postfix unknown available ' +
104
+ 'resultBuilder propertyWrapper autoclosure convention ' +
105
+ // SwiftUI property wrappers
106
+ 'Binding State StateObject ObservedObject EnvironmentObject ViewBuilder Environment ScaledMetric main ' +
107
+ // Swift concurrency
108
+ 'MainActor Sendable globalActor ';
109
+
110
+ var datatypes = 'char bool BOOL double float int long short id instancetype void ' +
111
+ ' Class IMP SEL _cmd';
112
+
113
+ this.regexList = [
114
+ // HTML entities
115
+ {
116
+ regex: new RegExp('\&[a-z]+;', 'gi'),
117
+ css: 'plain'
118
+ },
119
+ // Single line comments
120
+ {
121
+ regex: SyntaxHighlighter.regexLib.singleLineCComments,
122
+ css: 'comments'
123
+ },
124
+ // Multiline comments in Swift
125
+ {
126
+ regex: SyntaxHighlighter.regexLib.multiLineCComments,
127
+ css: 'comments'
128
+ },
129
+ // Nested comments are supported up to 2 levels
130
+ {
131
+ regex: new RegExp(/(^|[^\\:])(?:\/\/.*|\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\*\/)/, 'gs'),
132
+ css: 'comments'
133
+ },
134
+ // Multiline strings in Swift
135
+ {
136
+ regex: new RegExp(/"""(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|[^#])|[^\\])*?"""/, 'gm'),
137
+ css: 'string'
138
+ },
139
+ // Types in Swift foundation
140
+ {
141
+ regex: new RegExp(this.getKeywords(datatypes), 'gm'),
142
+ css: 'datatypes'
143
+ },
144
+ // Handle string interpolation in Swift
145
+ {
146
+ regex: SyntaxHighlighter.regexLib.doubleQuotedString,
147
+ css: 'string',
148
+ func: stringAdd
149
+ },
150
+ // Numeric literals in Swift
151
+ {
152
+ regex: new RegExp('\\b([\\d_]+(\\.[\\de_]+)?|0x[a-f0-9_]+(\\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\\b', 'gi'),
153
+ css: 'value'
154
+ },
155
+ // Keywords in Swift
156
+ {
157
+ regex: new RegExp(this.getKeywords(keywords), 'gm'),
158
+ css: 'keyword'
159
+ },
160
+ // Common declaration and type attributes in Swift
161
+ {
162
+ regex: new RegExp(getKeywordsPrependedBy(attributes, '@'), 'gm'),
163
+ css: 'color1'
164
+ },
165
+ // Common native types in Swift
166
+ {
167
+ regex: new RegExp(this.getKeywords(swiftTypes), 'gm'),
168
+ css: 'color2'
169
+ },
170
+ // UIKit/NS/Core Graphics/Core Animation/MapKit/XCFrameworks types
171
+ {
172
+ regex: new RegExp(/\b(?:UI|NS|CG|CA|MK|XC)[a-zA-Z0-9_]+\b/, 'g'),
173
+ css: 'color2'
174
+ },
175
+ // Compiler directives
176
+ {
177
+ regex: new RegExp(/^ *#[a-zA-Z0-9_]+/, 'gm'),
178
+ css: 'preprocessor'
179
+ },
180
+ // Any variables
181
+ {
182
+ regex: new RegExp('\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b', 'gi'),
183
+ css: 'variable'
184
+ }
185
+ ];
186
+ }
187
+
188
+ Brush.prototype = new SyntaxHighlighter.Highlighter();
189
+ Brush.aliases = ['swift'];
190
+
191
+ SyntaxHighlighter.brushes.Swift = Brush;
192
+
193
+ // CommonJS
194
+ typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
195
+ })();