Skip to content

Commit dc78af1

Browse files
authored
Merge pull request #13 from hackmdio/bugfix/csv-mode
2 parents b5ef874 + c8b5527 commit dc78af1

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

addon/mode/simple.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,13 @@
9494

9595
function tokenFunction(states, config) {
9696
return function(stream, state) {
97-
if (state.pending) {
97+
if (state.pending && state.pending.length > 0) {
9898
var pend = state.pending.shift();
9999
if (state.pending.length == 0) state.pending = null;
100100
stream.pos += pend.text.length;
101101
return pend.token;
102+
} else if (state.pending && state.pending.length === 0) {
103+
console.warn('Regex capturing group is empty. Please check your regex')
102104
}
103105

104106
if (state.local) {

mode/csv/csv.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
CodeMirror.defineSimpleMode('csv', {
1111
start: [
1212
{
13-
regex: /((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?/,
13+
regex: /((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)/,
1414
token: [
1515
"variable",
16-
"variable-2",
17-
"variable-3",
18-
"operator",
1916
"keyword",
20-
"variable",
17+
"operator",
18+
"string",
19+
"number",
2120
"variable-2",
22-
"variable-3",
21+
"keyword",
2322
"operator",
24-
"keyword"
23+
"string",
24+
"number"
2525
]
2626
}
2727
]

0 commit comments

Comments
 (0)