Skip to content

Commit

Permalink
Merge pull request #55 from AndrewLane/add-feature-trim-input-lines
Browse files Browse the repository at this point in the history
Add a checkbox that allows input lines to be automatically trimmed before parsing
  • Loading branch information
ozh committed Apr 5, 2021
2 parents dd875de + eea3770 commit a551bbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function createTable() {

var headerStyle = $('#hdr-style').val();
var autoFormat = $('#auto-format').is(':checked');
var trimInput = $('#trim-input').is(':checked');
var hasHeaders = headerStyle == "top";
var spreadSheetStyle = headerStyle == "ssheet";
var input = $('#input').val();
Expand Down Expand Up @@ -58,6 +59,9 @@ function createTable() {
var colLengths = [];
var isNumberCol = [];
for (var i = 0; i < rows.length; i++) {
if (trimInput) {
rows[i] = rows[i].trim();
}
if (separator == "\t") {
rows[i] = rows[i].replace(/( )/g, "\t");
} else {
Expand Down
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ <h2>Input</h2>
<div class="row">
<label for="auto-format" class="control-label" title="Center the headers and right-align numbers in the output table">Auto-Format:
<input id="auto-format" checked="true" type="checkbox" title="Center the headers and right-align numbers in the output table" onchange="createTable()"></label>
<label for="trim-input" class="control-label" title="Trim the input lines before parsing">Trim Input Lines:
<input id="trim-input" checked="true" type="checkbox" title="Trim the input lines before parsing" onchange="createTable()"></label>
</div>
<div class="row">
<label for="separator" class="control-label" title="Identify character for custom separator, default is the tab character">Custom Separator:
Expand Down

0 comments on commit a551bbd

Please sign in to comment.