AshKyd / tabsalad

🥗 Paste cells from your spreadsheet and convert them into HTML table markup.
https://tabsalad.kyd.au/
2 stars 1 forks source link

Strip multiline strings #1

Open marklawlor opened 9 years ago

marklawlor commented 9 years ago

If the source spreadsheet contains a cell with a multiline string (includes a carriage return, not word wrapping), the generated Markdown will be incorrect. Carriage returns don't make sense in markdown and should be stripped from the input. Cells with multiple line strings are surrounded by double quotes when copied from excel & google docs.

Example Spreadsheet

https://docs.google.com/spreadsheets/d/1PtbPUHGrRY1P8Blv1E9CMuObq5lpyN2bGJoq0SjhKGw/edit?usp=sharing

Resulting markup

Heading 1 Heading 2

"I am a
multiline string" | I am a single line string

Expected

Heading 1 Heading 2
I am a multiline string I am a single line string
AshKyd commented 9 years ago

Good call. I'll look into it (unless you beat me to it.)

It will introduce some inconsistency between formats that support it and those which don't, but I can live with that.

Format Supports newlines
HTML :thumbsup:
MediaWiki :thumbsup:
JSON :thumbsup:
Github markdown :thumbsdown:
Atlassian JIRA :thumbsdown:
AshKyd commented 9 years ago

Oops. Didn't mean to close this one.

marklawlor commented 9 years ago

I didn't realise there would be an inconsistency between the formats. Instead of reformatting your data, I think a warning should popup and provide you the option to reformat your input. Something along the lines of:

"Warning: Github markdown does not support multiline strings, click here to convert these cells to single lines"

garrows commented 4 years ago

Hello friends. I'd also like this feature.

AshKyd commented 4 years ago

What a great feature request! I'm not committing to do anything, but I was curious how this works.

  1. Multi-line string
    1. starts with a quotation mark (").
    2. Must contain one or more newlines (a single-line column may contain a quoted value such as "false", which must retain the quotation marks.)
    3. Quotation marks in the value of the cell are represented as double quotation marks ("")
    4. Ends with a quotation mark and the row continues as normal (i.e. with a tab character leading to the next column, or a newline character if this is the last column)

With that in mind, here are a couple of variants of these cases: https://docs.google.com/spreadsheets/d/14ryiyI9Os4MW-mPN4qsCyXvM8YS4W2Klh0A3XsfEP3s/edit#gid=0

And the copied output:

Heading 1   Heading 2
I am a single line string   -
"I am a 
multiline string"   -
"i am a string with quotation marks"    -
"I am a string that starts with quotation marks but doesn't end with them   -
"""I am a multiline string that starts with quo-
tation marks but doesn't end with them" -
"I am a 
multiline string in the first column"   "I am a 
multiline string in the second column"

Edit: turns out Github converts pasted spreadsheet cells into markdown table syntax now too