diff --git a/src/index.html b/src/index.html index b1a33fb..f3f79b0 100644 --- a/src/index.html +++ b/src/index.html @@ -66,6 +66,16 @@

Input

Default is "table.wikitable" +
+ +
+ +
+
diff --git a/src/parser/index.js b/src/parser/index.js index 92eb65e..9f8dfa6 100644 --- a/src/parser/index.js +++ b/src/parser/index.js @@ -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 + '"'; } @@ -111,7 +113,7 @@ parser.parseTable = function (element) { } } - result += csvLine.join() + '\n'; + result += csvLine.join(this.options.delimiter) + '\n'; } return result } diff --git a/src/ui/index.js b/src/ui/index.js index 50aba91..841780e 100644 --- a/src/ui/index.js +++ b/src/ui/index.js @@ -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 };