Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Idris #2755

Merged
merged 6 commits into from Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions components.json
Expand Up @@ -522,6 +522,12 @@
"title": "Icon",
"owner": "Golmote"
},
"idris": {
"title": "Idris",
"alias": "idr",
"owner": "KeenS",
"require": ["haskell"]
KeenS marked this conversation as resolved.
Show resolved Hide resolved
},
"ignore": {
"title": ".ignore",
"owner": "osipxd",
Expand Down
13 changes: 13 additions & 0 deletions components/prism-idris.js
@@ -0,0 +1,13 @@
Prism.languages.idris = Prism.languages.extend('haskell', {
'comment': {
pattern: /(?:(?:--|\|\|\|).*$|{-[\s\S]*?-})/m,
},
'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
},
'builtin': undefined
});

Prism.languages.idr = Prism.languages.idris;
1 change: 1 addition & 0 deletions components/prism-idris.min.js

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

56 changes: 56 additions & 0 deletions examples/prism-idris.html
@@ -0,0 +1,56 @@
<h2>Comments</h2>
<pre><code>-- Single line comment
{- Multi-line
comment -}</code></pre>

<h2>Strings and characters</h2>
<pre><code>'a'
'\n'
'\^A'
'\^]'
'\NUL'
'\23'
'\o75'
'\xFE'</code></pre>

<h2>Numbers</h2>
<pre><code>42
123.456
123.456e-789
1e+3
0o74
0XAF</code></pre>

<h2>Larger example</h2>
<pre><code>module Main

import Data.Vect

-- this is comment
record Person where
constructor MkPerson2
age : Integer
name : String

||| identity function
id : a -> a
id x = x

{-
Bool type can be defined in
userland
-}
data Bool = True | False

implementation Show Bool where
show True = "True"
show False = "False"

not : Bool -> Bool
not b = case b of
True => False
False => True

vect3 : Vect 3 Int
vect3 = with Vect (1 :: 2 :: 3 :: Nil)
</code></pre>
4 changes: 4 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 Expand Up @@ -184,6 +187,7 @@
"xls": "excel-formula",
"gamemakerlanguage": "gml",
"hs": "haskell",
"idr": "idris",
"gitignore": "ignore",
"hgignore": "ignore",
"npmignore": "ignore",
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.

1 change: 1 addition & 0 deletions plugins/show-language/prism-show-language.js
Expand Up @@ -87,6 +87,7 @@
"hpkp": "HTTP Public-Key-Pins",
"hsts": "HTTP Strict-Transport-Security",
"ichigojam": "IchigoJam",
"idr": "Idris",
"ignore": ".ignore",
"gitignore": ".gitignore",
"hgignore": ".hgignore",
Expand Down