Skip to content

Commit 788ecca

Browse files
authored
Merge pull request #210 from Automattic/add/haskell
Add syntax highlight for Haskell
2 parents 3b268ab + 12b27ef commit 788ecca

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

syntaxhighlighter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ function_exists( 'parse_blocks' ) // WordPress 5.0+
138138
wp_register_script( 'syntaxhighlighter-brush-erlang', plugins_url( $this->shfolder . '/scripts/shBrushErlang.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
139139
wp_register_script( 'syntaxhighlighter-brush-go', plugins_url( $this->shfolder . '/scripts/shBrushGo.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
140140
wp_register_script( 'syntaxhighlighter-brush-groovy', plugins_url( $this->shfolder . '/scripts/shBrushGroovy.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
141+
wp_register_script( 'syntaxhighlighter-brush-haskell', plugins_url( $this->shfolder . '/scripts/shBrushHaskell.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
141142
wp_register_script( 'syntaxhighlighter-brush-java', plugins_url( $this->shfolder . '/scripts/shBrushJava.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
142143
wp_register_script( 'syntaxhighlighter-brush-javafx', plugins_url( $this->shfolder . '/scripts/shBrushJavaFX.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
143144
wp_register_script( 'syntaxhighlighter-brush-jscript', plugins_url( $this->shfolder . '/scripts/shBrushJScript.js', __FILE__ ), array( 'syntaxhighlighter-core' ), $this->agshver );
@@ -201,6 +202,7 @@ function_exists( 'parse_blocks' ) // WordPress 5.0+
201202
'go' => 'go',
202203
'golang' => 'go',
203204
'groovy' => 'groovy',
205+
'haskell' => 'haskell',
204206
'java' => 'java',
205207
'jfx' => 'javafx',
206208
'javafx' => 'javafx',
@@ -256,6 +258,7 @@ function_exists( 'parse_blocks' ) // WordPress 5.0+
256258
'fsharp' => __( 'F#', 'syntaxhighlighter' ),
257259
'go' => __( 'Go', 'syntaxhighlighter' ),
258260
'groovy' => __( 'Groovy', 'syntaxhighlighter' ),
261+
'haskell' => __( 'Haskell', 'syntaxhighlighter' ),
259262
'java' => __( 'Java', 'syntaxhighlighter' ),
260263
'javafx' => __( 'JavaFX', 'syntaxhighlighter' ),
261264
'jscript' => __( 'JavaScript', 'syntaxhighlighter' ),
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Haskell Brushes for SyntaxHighlighter 3.0
3+
*/
4+
(function () {
5+
// CommonJS
6+
SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
7+
8+
function Brush() {
9+
var keywords = 'as case of class data default deriving do forall foreign hiding ' +
10+
'if then else import instance let in mdo module newtype qualified type where';
11+
12+
this.regexList = [
13+
{ regex: /{-#[\s\S]*?#-}/g, css: 'preprocessor' },
14+
{ regex: /--.*/g, css: 'comments' }, // one line comments
15+
{ regex: /{-(?!\$)[\s\S]*?-}/gm, css: 'comments' }, // multiline comments
16+
{ regex: /'.'/g, css: 'string' }, // chars
17+
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
18+
{ regex: /(-|!|#|\$|%|&|\*|\+|\/|<|=|>|\?|@|\^|\||~|:|\.|\\)+/g, css: 'keyword bold' },
19+
{ regex: /`[a-z][a-z0-9_']*`/g, css: 'keyword bold' }, // infix operators
20+
{ regex: /\b(\d+|0x[0-9a-f]+)\b/gi, css: 'value' }, // integer
21+
{ regex: /\b\d+(\.\d*)?([eE][+-]?\d+)?\b/gi, css: 'value' }, // floating number
22+
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword bold' }
23+
];
24+
25+
this.forHtmlScript({
26+
left : /(&lt;|<)%[@!=]?/g,
27+
right : /%(&gt;|>)/g
28+
});
29+
}
30+
31+
Brush.prototype = new SyntaxHighlighter.Highlighter();
32+
Brush.aliases = ['haskell'];
33+
34+
SyntaxHighlighter.brushes.Haskell = Brush;
35+
36+
// CommonJS
37+
typeof exports != 'undefined' ? (exports.Brush = Brush) : null;
38+
})();

0 commit comments

Comments
 (0)