From 8eaf7009ee813449eaf2b0ab15ee80e9e1613553 Mon Sep 17 00:00:00 2001 From: Andrew Bell Date: Fri, 21 Oct 2016 02:49:57 +0100 Subject: [PATCH] Added support for haskell --- haskell.js | 32 +++++++++++++ styles/haskell.css | 115 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 haskell.js create mode 100644 styles/haskell.css diff --git a/haskell.js b/haskell.js new file mode 100644 index 0000000..362178a --- /dev/null +++ b/haskell.js @@ -0,0 +1,32 @@ +CodeHighlighter.addStyle("haskell",{ + comments : { + exp : /(--[^\n]*(\n|$))|(\{-[^-]*-+([^\}][^-]*-+)*\})/ + }, + brackets : { + exp : /\(|\)/ + }, + lists : { + exp : /\[|\]/ + }, + stringexp : { + exp : /"[^"]*"/ + }, + keywords : { + exp : /\b(as|case|of|class|data|default|deriving|do|forall|hiding|if|then|else|import|infix|infixl|infixr|instance|let|in|module|newtype|qualified|type|where')\b/ + }, + mainlibs : { + exp : /\b(Foreign|Numeric|Prelude)\b/ + }, + preludefuncs : { + exp : /\b(not|otherwise|maybe|either|fst|snd|curry|uncurry|compare|max|min|succ|pred|toEnum|fromEnum|enumFrom|enumFromThen|enumFromTo|enumFromThenTo|minBound|maxBound|negate|abs|signum|fromInteger|toRational|quot|rem|div|mod|quotRem|divMod|toInteger|recip|fromRational|pi|exp|log|sqrt|logBase|sin|cos|tan|asin|acos|atan|sinh|cosh|tanh|asinh|acosh|atanh|properFraction|truncate|round|ceiling|floor|floatRadix|floatDigits|floatRange|decodeFloat|encodeFloat|exponent|significand|scaleFloat|isNaN|isInfinite|isDenomalized|isNegativeZero|isIEEE|atan2|subtract|even|odd|gcd|lcm|fromIntegral|realToFrac|return|fail|fmap|mapM|mapM_|sequence|sequence_|id|const|flip|until|asTypeOf|error|undefined|seq|map|filter|head|last|tail|init|null|length|reverse|foldl|foldl1|foldr|foldr1|and|or|any|all|sum|product|concat|concatMap|maximum|minimum|scanl|scanl1|scanr|scanr1|iterate|repeat|cycle|take|drop|splitAt|teakWhile|dropWhile|span|break|elem|notElem|lookup|zip|zip3|zipWith|zipWith3|unzip|unzip3|unzip|unzip3|lines|words|unlines|unwords|showPrec|show|showList|shows|showChar|showString|showParen|readsPrec|readList|reads|readParen|read|lex|putChar|putStr|putStrLn|print|getChar|getLine|getContents|interact|readFile|writeFile|appendFile|readIO|readLn|ioError|userError|catch)\b/ + }, + preludetypes : { + exp : /\b(Bool|Maybe|Either|Ord|Ordering|Char|String|Eq|Enum|Bounded|Int|Integer|Float|Double|Rational|Num|Real|Integral|Fractional|Floating|RealFrac|RealFloat|Monad|Functor|Show|ShowS|Read|ReadS|IO)\b/ + }, + preludeexceptions : { + exp : /\b(IOError|IOException)\b/ + }, + symbols : { + exp : /\||->|<-|@|!|::|_|~|=|&&|\|\||==|\/=|<|<=|>|>=|\+|-|\*|\/|\*\*|^|^^|>>=|>>|=<<|\$|\.|\$!|\+\+|!!/ + } +}); diff --git a/styles/haskell.css b/styles/haskell.css new file mode 100644 index 0000000..e805008 --- /dev/null +++ b/styles/haskell.css @@ -0,0 +1,115 @@ + pre { + border: 1px solid black; + border-color: #BBB #DDD #DDD #BBB; + margin : 2em; + padding : 1em; + line-height: 1.5; + background: black !important; + overflow: auto; + color: silver !important; + } + + code { + font-size: 1.2em; + } + + .javascript .comment, .ruby .comment { + color : green; + } + + .javascript .string, .ruby .string { + color : teal; + } + + .javascript .keywords, .ruby .keywords { + color : purple; + } + + .javascript .global { + color : blue; + } + + .javascript .brackets, .ruby .brackets { + color : navy; + } + + .css .comment { + color : gray; + } + + .css .properties { + color : navy; + } + + .css .selectors { + color : maroon; + font-weight : bold; + } + + .css .units { + color :red; + } + + .css .urls { + color :green; + } + + .html .tag { + color : purple; + } + + .html .comment { + color : gray; + font-style: italic; + } + + .html .string { + color : navy; + } + + .html .doctype { + color : teal; + } + + .haskell .comments { + color: blue; + } + + .haskell .brackets { + color : teal; + } + + .haskell .lists { + color : olive; + } + + .haskell .stringexp { + color : yellow; + } + + .haskell .keywords { + color : green; + } + + .haskell .mainlibs { + color : gray; + } + + .haskell .preludefuncs { + color : white; + } + + .haskell .preludetypes { + color : fuchsia; + } + + .haskell .preludeexceptions { + color : maroon; + } + + .haskell .symbols { + color : red; + } + + +