Skip to content

Commit

Permalink
reimplement idris highlighter as haskell extention
Browse files Browse the repository at this point in the history
  • Loading branch information
KeenS committed Feb 12, 2021
1 parent f21be61 commit e6a005d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 28 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion components.json
Expand Up @@ -525,7 +525,8 @@
"idris": {
"title": "Idris",
"alias": "idr",
"owner": "KeenS"
"owner": "KeenS",
"require": ["haskell"]
},
"ignore": {
"title": ".ignore",
Expand Down
29 changes: 5 additions & 24 deletions components/prism-idris.js
@@ -1,32 +1,13 @@
Prism.languages.idris = {
Prism.languages.idris = Prism.languages.extend('haskell', {
'comment': {
pattern: /(?:(?:--|\|\|\|).*$|{-[\s\S]*?-})/m,
},
'char': {
pattern: /'(?:[^\\']|\\(?:[abfnrtv\\"'&]|\^[A-Z@[\]^_]|NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|\d+|o[0-7]+|x[0-9a-fA-F]+))'/,
alias: 'string'
},
'string': {
pattern: /"(?:[^\\"]|\\(?:\S|\s+\\))*"/,
greedy: true
},
'keyword': /\b(?:Type|case|class|codata|constructor|corecord|data|do|dsl|else|export|if|implementation|implicit|import|impossible|in|infix|infixl|infixr|instance|interface|let|module|mutual|namespace|of|parameters|partial|postulate|private|proof|public|quoteGoal|record|rewrite|syntax|then|total|using|where|with)\b/,
'keyword': /\b(?:Type|case|class|codata|constructor|corecord|data|do|dsl|else|export|if|implementation|implicit|import|impossible|in|infix|infixl|infixr|instance|interface|let|module|mutual|namespace|of|parameters|partial|postulate|private|proof|public|quoteGoal|record|rewrite|syntax|then|total|using|where|with)\b/,
'import-statement': {
pattern: /(^\s*)import\s+(?:[A-Z][\w']*)(?:\.[A-Z][\w']*)*/m,
lookbehind: true,
lookbehind: true
},
// decimal integers and floating point numbers | octal integers | hexadecimal integers
'number': /\b(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?|0o[0-7]+|0x[0-9a-f]+)\b/i,
// Most of this is needed because of the meaning of a single '.'.
// If it stands alone freely, it is the function composition.
// It may also be a separator between a module name and an identifier => no
// operator. If it comes together with other special characters it is an
// operator too.
'operator': /\s\.\s|[-!#$%*+=?&@|~:<>^\\\/]*\.[-!#$%*+=?&@|~.:<>^\\\/]+|[-!#$%*+=?&@|~.:<>^\\\/]+\.[-!#$%*+=?&@|~:<>^\\\/]*|[-!#$%*+=?&@|~:<>^\\\/]+|`(?:[A-Z][\w']*\.)*[_a-z][\w']*`/,
// In Idris, nearly everything is a variable, do not highlight these.
'hvariable': /\b(?:[A-Z][\w']*\.)*[_a-z][\w']*\b/,
'constant': /\b(?:[A-Z][\w']*\.)*[A-Z][\w']*\b/,
'punctuation': /[{}[\];(),.:]/
};
'builtin': undefined
});

Prism.languages.idr = Prism.languages.idris;
2 changes: 1 addition & 1 deletion components/prism-idris.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions plugins/autoloader/prism-autoloader.js
Expand Up @@ -59,6 +59,9 @@
"handlebars": "markup-templating",
"haxe": "clike",
"hlsl": "c",
"idris": [
"haskell"
],
"java": "clike",
"javadoc": [
"markup",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e6a005d

Please sign in to comment.