mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2025-12-06 02:30:46 -08:00
Add support for text/tab-separated-values mimetype (#9445)
* Add support for `text/tab-separated-values` mimetype * Fix eslint issues * Add the release note for CSV parser change
This commit is contained in:
parent
298508c104
commit
f16c0d769b
2 changed files with 17 additions and 3 deletions
|
|
@ -11,10 +11,13 @@ The CSV text parser processes CSV files into a table wrapped in a scrollable wid
|
|||
|
||||
var CsvParser = function(type,text,options) {
|
||||
// Special handler for tab-delimited files
|
||||
if (type === 'text/tab-delimited-values' && !options.separator) {
|
||||
if(
|
||||
!options.separator &&
|
||||
(type === "text/tab-delimited-values" || type === "text/tab-separated-values")
|
||||
) {
|
||||
options.separator = "\t";
|
||||
}
|
||||
|
||||
|
||||
// Table framework
|
||||
this.tree = [{
|
||||
"type": "scrollable", "children": [{
|
||||
|
|
@ -32,7 +35,7 @@ var CsvParser = function(type,text,options) {
|
|||
$tw.utils.each(lines, function(columns) {
|
||||
maxColumns = Math.max(columns.length, maxColumns);
|
||||
});
|
||||
|
||||
|
||||
for(var line=0; line<lines.length; line++) {
|
||||
var columns = lines[line];
|
||||
var row = {
|
||||
|
|
@ -55,3 +58,4 @@ var CsvParser = function(type,text,options) {
|
|||
|
||||
exports["text/csv"] = CsvParser;
|
||||
exports["text/tab-delimited-values"] = CsvParser;
|
||||
exports["text/tab-separated-values"] = CsvParser;
|
||||
|
|
|
|||
10
editions/tw5.com/tiddlers/releasenotes/5.4.0/#9445.tid
Normal file
10
editions/tw5.com/tiddlers/releasenotes/5.4.0/#9445.tid
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
title: $:/changenotes/5.4.0/#9445
|
||||
description: Add the prevailing mimetype for CSV parser
|
||||
release: 5.4.0
|
||||
tags: $:/tags/ChangeNote
|
||||
change-type: enhancement
|
||||
change-category: internal
|
||||
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9445
|
||||
github-contributors: EvidentlyCube
|
||||
|
||||
CSV parser used to support only the very obscure `text/tab-delimited-values` mimetype so this change adds the more common `text/tab-separated-values`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue