Skip to content

Commit f9b6952

Browse files
Added support for CSV (#2794)
1 parent f84c49c commit f9b6952

File tree

8 files changed

+120
-2
lines changed

8 files changed

+120
-2
lines changed

components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

+4
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@
287287
"modify": "css",
288288
"owner": "milesj"
289289
},
290+
"csv": {
291+
"title": "CSV",
292+
"owner": "RunDevelopment"
293+
},
290294
"cypher": {
291295
"title": "Cypher",
292296
"owner": "RunDevelopment"

components/prism-csv.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// https://tools.ietf.org/html/rfc4180
2+
3+
Prism.languages.csv = {
4+
'value': /[^\r\n,"]+|"(?:[^"]|"")*"(?!")/,
5+
'punctuation': /,/
6+
};

components/prism-csv.min.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Prism.languages.csv={value:/[^\r\n,"]+|"(?:[^"]|"")*"(?!")/,punctuation:/,/};

examples/prism-csv.html

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<h2>Full example</h2>
2+
<pre><code>Year,Make,Model,Description,Price
3+
1997,Ford,E350,"ac, abs, moon",3000.00
4+
1999,Chevy,"Venture ""Extended Edition""","",4900.00
5+
1999,Chevy,"Venture ""Extended Edition, Very Large""",,5000.00
6+
1996,Jeep,Grand Cherokee,"MUST SELL!
7+
air, moon roof, loaded",4799.00</code></pre>

plugins/show-language/prism-show-language.js

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"conc": "Concurnas",
6060
"csp": "Content-Security-Policy",
6161
"css-extras": "CSS Extras",
62+
"csv": "CSV",
6263
"dataweave": "DataWeave",
6364
"dax": "DAX",
6465
"django": "Django/Jinja2",

plugins/show-language/prism-show-language.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/csv/value.test

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
aaa,bbb,ccc
2+
zzz,yyy,xxx
3+
4+
"aaa","bbb","ccc"
5+
6+
"aaa","b
7+
bb","ccc"
8+
9+
"aaa","b""bb","ccc"
10+
11+
Year,Make,Model,Description,Price
12+
1997,Ford,E350,"ac, abs, moon",3000.00
13+
1999,Chevy,"Venture ""Extended Edition""","",4900.00
14+
1999,Chevy,"Venture ""Extended Edition, Very Large""",,5000.00
15+
1996,Jeep,Grand Cherokee,"MUST SELL!
16+
air, moon roof, loaded",4799.00
17+
18+
----------------------------------------------------
19+
20+
[
21+
["value", "aaa"],
22+
["punctuation", ","],
23+
["value", "bbb"],
24+
["punctuation", ","],
25+
["value", "ccc"],
26+
27+
["value", "zzz"],
28+
["punctuation", ","],
29+
["value", "yyy"],
30+
["punctuation", ","],
31+
["value", "xxx"],
32+
33+
["value", "\"aaa\""],
34+
["punctuation", ","],
35+
["value", "\"bbb\""],
36+
["punctuation", ","],
37+
["value", "\"ccc\""],
38+
39+
["value", "\"aaa\""],
40+
["punctuation", ","],
41+
["value", "\"b\r\nbb\""],
42+
["punctuation", ","],
43+
["value", "\"ccc\""],
44+
45+
["value", "\"aaa\""],
46+
["punctuation", ","],
47+
["value", "\"b\"\"bb\""],
48+
["punctuation", ","],
49+
["value", "\"ccc\""],
50+
51+
["value", "Year"],
52+
["punctuation", ","],
53+
["value", "Make"],
54+
["punctuation", ","],
55+
["value", "Model"],
56+
["punctuation", ","],
57+
["value", "Description"],
58+
["punctuation", ","],
59+
["value", "Price"],
60+
61+
["value", "1997"],
62+
["punctuation", ","],
63+
["value", "Ford"],
64+
["punctuation", ","],
65+
["value", "E350"],
66+
["punctuation", ","],
67+
["value", "\"ac, abs, moon\""],
68+
["punctuation", ","],
69+
["value", "3000.00"],
70+
71+
["value", "1999"],
72+
["punctuation", ","],
73+
["value", "Chevy"],
74+
["punctuation", ","],
75+
["value", "\"Venture \"\"Extended Edition\"\"\""],
76+
["punctuation", ","],
77+
["value", "\"\""],
78+
["punctuation", ","],
79+
["value", "4900.00"],
80+
81+
["value", "1999"],
82+
["punctuation", ","],
83+
["value", "Chevy"],
84+
["punctuation", ","],
85+
["value", "\"Venture \"\"Extended Edition, Very Large\"\"\""],
86+
["punctuation", ","],
87+
["punctuation", ","],
88+
["value", "5000.00"],
89+
90+
["value", "1996"],
91+
["punctuation", ","],
92+
["value", "Jeep"],
93+
["punctuation", ","],
94+
["value", "Grand Cherokee"],
95+
["punctuation", ","],
96+
["value", "\"MUST SELL!\r\nair, moon roof, loaded\""],
97+
["punctuation", ","],
98+
["value", "4799.00"]
99+
]

0 commit comments

Comments
 (0)