ganesshkumar / obsidian-excel-to-markdown-table

An Obsidian plugin to paste data from Microsoft Excel, Google Sheets, Apple Numbers and LibreOffice Calc as Markdown tables in Obsidian editor.
MIT License
202 stars 7 forks source link

[BUG] Pipe characters in excel cells are not escaped when pasted into Obsidian. #11

Closed reticulator closed 2 years ago

reticulator commented 2 years ago

Describe the bug Pipe | characters in excel cells are not escaped when pasted into Obsidian.

To Reproduce Steps to reproduce the behavior:

  1. Create table in excel and enter a pipe | character somewhere inside the cell image
  2. Copy and paste the table into Obsidian
  3. Source code looks like
    | Column 1        | Column2 |
    |-----------------|---------|
    | Value1a|Value1b | Value2  |

Expected behavior The pipe character should be escaped.

| Column 1         | Column2 |
|------------------|---------|
| Value1a\|Value1b | Value2  |

Desktop (please complete the following information):

Additional context According to https://www.markdownguide.org/extended-syntax/#escaping-pipe-characters-in-tables

You can display a pipe (|) character in a table by using its HTML character code (\|).

But it also doesn't specifically say you should not use the \ escape character which is a valid escape code and using \| does seem to render the table correctly which would be my preferred method as it's easier to remember. Perhaps this should be a configurable user option in case other users have a different preference.

ganesshkumar commented 2 years ago

@reticulator Please verify the fix in the latest version

reticulator commented 2 years ago

I upgraded to 0.4.0 and pasting in data with a pipe character is now correctly escaped, though I noticed the header padding is short by one character. I guess this would only be a problem if your value with the escaped pipe is the longest value.

This is what I see now

| Column 1        | Column2 |
|-----------------|---------|
| Value1a\|Value1b | Value2  |

and this is what I would expect

| Column 1         | Column2 |
|------------------|---------|
| Value1a\|Value1b | Value2  |