Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ <h2>Input</h2>
<small id="table-selector-help" class="form-text text-muted">Default is "table.wikitable"</small>
</div>
</div>
<div class="form-group row">
<label for="table-selector" class="col-12 col-sm-3 col-xl-2 col-form-label">Output delimiter</label>
<div class="col-12 col-sm-9 col-xl-10">
<select class="table2csv-form__delimiter form-control">
<option value=",">Comma</option>
<option value=";">Semicolon</option>
<option value="&#9;">Tab</option>
</select>
</div>
</div>

<div class="table2csv-errors"></div>

Expand Down
8 changes: 5 additions & 3 deletions src/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ function parseCell (cellItem) {
}

// put line in double quotes
// if line break, comma or quote found in line
if (/\r|\n|\"|,/.test(line)) {
// if line break, comma or quote found in lines
var re = new RegExp(this.options.delimiter, "g");

if (/\r|\n|\"/.test(line) || re.test(line) ) {
line = '"' + line + '"';
}

Expand Down Expand Up @@ -111,7 +113,7 @@ parser.parseTable = function (element) {

}
}
result += csvLine.join() + '\n';
result += csvLine.join(this.options.delimiter) + '\n';
}
return result
}
Expand Down
1 change: 1 addition & 0 deletions src/ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ ui.submitClickCb = function (e) {
trim: document.querySelector('.table2csv-form__trim').checked,
remove_n: document.querySelector('.table2csv-form__remove-n').checked,
tableSelector: this.form.querySelector('.table2csv-form__table-selector').value,
delimiter: document.querySelector('.table2csv-form__delimiter').value,
url: queryUrl
};

Expand Down