Skip to content

Commit

Permalink
Add support for ARFF (Fix #653) (#1327)
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote authored Mar 7, 2018
1 parent 926f6f8 commit 0bc98ac
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 2 deletions.
4 changes: 4 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ var components = {
"require": "cpp",
"owner": "eisbehr-"
},
"arff": {
"title": "ARFF",
"owner": "Golmote"
},
"asciidoc": {
"title": "AsciiDoc",
"owner": "Golmote"
Expand Down
10 changes: 10 additions & 0 deletions components/prism-arff.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Prism.languages.arff = {
'comment': /%.*/,
'string': {
pattern: /(["'])(?:\\.|(?!\1)[^\\\r\n])*\1/,
greedy: true
},
'keyword': /@(?:attribute|data|end|relation)\b/i,
'number': /\b\d+(?:\.\d+)?\b/,
'punctuation': /[{},]/
};
1 change: 1 addition & 0 deletions components/prism-arff.min.js

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

49 changes: 49 additions & 0 deletions examples/prism-arff.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<h1>ARFF</h1>
<p>To use this language, use the class "language-arff".</p>

<h2>Comments</h2>
<pre><code>%
% Some comments
%
%</code></pre>

<h2>Keywords</h2>
<pre><code>@attribute
@data
@relation</code></pre>

<h2>Numbers</h2>
<pre><code>42
0.14</code></pre>

<h2>Strings</h2>
<pre><code>'Single \'quoted\' string'
"Double \"quoted\" string"</code></pre>

<h2>Full example</h2>
<pre><code>% 1. Title: Iris Plants Database
%
% 2. Sources:
% (a) Creator: R.A. Fisher
% (b) Donor: Michael Marshall (MARSHALL%PLU@io.arc.nasa.gov)
% (c) Date: July, 1988
%
@RELATION iris

@ATTRIBUTE sepallength NUMERIC
@ATTRIBUTE sepalwidth NUMERIC
@ATTRIBUTE petallength NUMERIC
@ATTRIBUTE petalwidth NUMERIC
@ATTRIBUTE class {Iris-setosa,Iris-versicolor,Iris-virginica}

@DATA
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
5.4,3.9,1.7,0.4,Iris-setosa
4.6,3.4,1.4,0.3,Iris-setosa
5.0,3.4,1.5,0.2,Iris-setosa
4.4,2.9,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa</code></pre>
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (!Prism.plugins.toolbar) {
}

// The languages map is built automatically with gulp
var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","asciidoc":"AsciiDoc","asm6502":"6502 Assembly","aspnet":"ASP.NET (C#)","autohotkey":"AutoHotkey","autoit":"AutoIt","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","csp":"Content-Security-Policy","css-extras":"CSS Extras","django":"Django/Jinja2","fsharp":"F#","glsl":"GLSL","graphql":"GraphQL","http":"HTTP","hpkp":"HTTP Public-Key-Pins","hsts":"HTTP Strict-Transport-Security","ichigojam":"IchigoJam","inform7":"Inform 7","json":"JSON","latex":"LaTeX","livescript":"LiveScript","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","n4js":"N4JS","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","opencl":"OpenCL","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","properties":".properties","protobuf":"Protocol Buffers","jsx":"React JSX","tsx":"React TSX","renpy":"Ren'py","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vbnet":"VB.Net","vhdl":"VHDL","vim":"vim","wiki":"Wiki markup","xojo":"Xojo (REALbasic)","yaml":"YAML"}/*]*/;
var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","arff":"ARFF","asciidoc":"AsciiDoc","asm6502":"6502 Assembly","aspnet":"ASP.NET (C#)","autohotkey":"AutoHotkey","autoit":"AutoIt","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","csp":"Content-Security-Policy","css-extras":"CSS Extras","django":"Django/Jinja2","fsharp":"F#","glsl":"GLSL","graphql":"GraphQL","http":"HTTP","hpkp":"HTTP Public-Key-Pins","hsts":"HTTP Strict-Transport-Security","ichigojam":"IchigoJam","inform7":"Inform 7","json":"JSON","latex":"LaTeX","livescript":"LiveScript","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","n4js":"N4JS","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","opencl":"OpenCL","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","properties":".properties","protobuf":"Protocol Buffers","jsx":"React JSX","tsx":"React TSX","renpy":"Ren'py","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vbnet":"VB.Net","vhdl":"VHDL","vim":"vim","wiki":"Wiki markup","xojo":"Xojo (REALbasic)","yaml":"YAML"}/*]*/;
Prism.plugins.toolbar.registerButton('show-language', function(env) {
var pre = env.element.parentNode;
if (!pre || !/pre/i.test(pre.nodeName)) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

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

15 changes: 15 additions & 0 deletions tests/languages/arff/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%
% Some comment
% Comment " with ' quotes

----------------------------------------------------

[
["comment", "%"],
["comment", "% Some comment"],
["comment", "% Comment \" with ' quotes"]
]

----------------------------------------------------

Checks for comments.
17 changes: 17 additions & 0 deletions tests/languages/arff/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@attribute
@data
@end
@relation

----------------------------------------------------

[
["keyword", "@attribute"],
["keyword", "@data"],
["keyword", "@end"],
["keyword", "@relation"]
]

----------------------------------------------------

Checks for all keywords.
13 changes: 13 additions & 0 deletions tests/languages/arff/number_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
42
0.14

----------------------------------------------------

[
["number", "42"],
["number", "0.14"]
]

----------------------------------------------------

Checks for numbers.
13 changes: 13 additions & 0 deletions tests/languages/arff/string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"double quoted\"' % string"
'single quoted"\' % string'

----------------------------------------------------

[
["string", "\"double quoted\\\"' % string\""],
["string", "'single quoted\"\\' % string'"]
]

----------------------------------------------------

Checks for strings.

0 comments on commit 0bc98ac

Please sign in to comment.