csholmq / vscode-excel-to-markdown-table

VSCode extension to paste Excel copies to markdown table format
MIT License
30 stars 12 forks source link

Added ":" as prefix for left aligned headers #16

Closed Markus-Hanisch closed 3 years ago

Markus-Hanisch commented 4 years ago

fixes issue #12

csholmq commented 4 years ago

Nice!

csholmq commented 4 years ago

@Markus-Hanisch Normally default alignment (---) is identical to left alignment (:---). This fix clarifies that by making ^l explicit. That's good.

Problem is that it also removes the default alignment option where no ^[lcr] prefix defaults to explicit left alignment. I suggest you add a new default alignment and the corresponding logic to it before I merge it.

Markus-Hanisch commented 4 years ago

Hello @csholmq Unfortunately, I am not such a good developer as you obviously are. Long story short: I might revert my pull request because I don't know exactly how to adjust your code appropriately. I assume that it will require

Should I make a suggestion / pull request? Would you mind to review, test and adjust or refuse if prefered?

I think what confused me is the fact that in Markdown the header alignment seems to default to centered alignment whereas the alignment of data rows defaults to left alignment. However, using the colons ":" will adjust header and rows at the same time and there seems no way to align rows and headers separately (references: 1, 2). I try to illustrate with the following example:

explicit left / center / right data row alignment (both the same): Heeeeading1 Heeeeading2 Heeeeading3
row 1 row 2 row 3
explicit left / center / right header alignment (both the same): Heading1 Heading2 Heading3
rooooooooooooooow 1 rooooooooooooooow 2 rooooooooooooooow 3
implicit default datarow alignment (left): Heeeeading1 Heeeeading2 Heeeeading3
row 1 row 2 row 3
implicit default header alignment (centered): Heading1 Heading2 Heading3
rooooooooooooooow 1 rooooooooooooooow 2 rooooooooooooooow 3

Markdown:

*explicit left / center / right data row alignment (both the same)*:
| Heeeeading1 | Heeeeading2 | Heeeeading3 |
|:----------|:---------:|----------:|
| row 1     | row 2     | row 3      |

*explicit left / center / right header alignment (both the same)*:
| Heading1 | Heading2 | Heading3 |
|:----------|:---------:|----------:|
| rooooooooooooooow 1     | rooooooooooooooow 2     | rooooooooooooooow 3      |

*implicit default datarow alignment (left)*:
| Heeeeading1 | Heeeeading2 | Heeeeading3 |
|----------------|----------------|----------------|
| row 1     | row 2     | row 3      |

*implicit default header alignment (centered)*:
| Heading1 | Heading2 | Heading3 |
|----------|---------|----------|
| rooooooooooooooow 1     | rooooooooooooooow 2     | rooooooooooooooow 3      |
Markus-Hanisch commented 4 years ago

@csholmq I made two additional commit with regard to my suggested modifications. Please review accordingly. Thanks.