fcrespo82 / atom-markdown-table-formatter

A simple markdown plugin to format tables.
MIT License
21 stars 7 forks source link

Wrong formatting #17

Closed peter1000 closed 9 years ago

peter1000 commented 9 years ago

Hi,

I really like your package :+1:

I just noticed that some tables seem to get wrong formatted.

example: test.md

###  Character Group

| **Name**        | **Unicode**                           | **Unicode Name**                                      | **ASCII Dec**  |
|:----------------|:--------------------------------------|:------------------------------------------------------|:---------------|
| Digits          | The code points U+0030 through U+0039 | DIGIT ZERO through DIGIT NINE                         | 48 through 57  |
| CA­PI­TAL-LETTERS | The code points U+0041 through U+005A | LATIN CA­PI­TAL LET­TER A through LATIN CA­PI­TAL LET­TER Z | 65 through 90  |
| SMALL-LETTERS   | The code points U+0061 through U+007A | LATIN SMALL LET­TER A through LATIN SMALL LET­TER Z     | 97 through 122 |

After apply: atom-markdown-table-formatter

###  Character Group

| **Name**          | **Unicode**                           | **Unicode Name**                                            | **ASCII Dec**  |
|:------------------|:--------------------------------------|:------------------------------------------------------------|:---------------|
| Digits            | The code points U+0030 through U+0039 | DIGIT ZERO through DIGIT NINE                               | 48 through 57  |
| CA­PI­TAL-LETTERS | The code points U+0041 through U+005A | LATIN CA­PI­TAL LET­TER A through LATIN CA­PI­TAL LET­TER Z | 65 through 90  |
| SMALL-LETTERS     | The code points U+0061 through U+007A | LATIN SMALL LET­TER A through LATIN SMALL LET­TER Z         | 97 through 122 |

I'm not sure if that has to do with some setting of mine or just formats wrongly.

Cheers P

lierdakil commented 9 years ago

Interesting. Likely something changed in Atom. I'll see what I can do.

lierdakil commented 9 years ago

Okay, Atom is fine. Your input, however, is not. You've got a bunch of soft hyphens in your input, which mess up both Atom and this plugin. Zero-width unicode characters are generally a bad idea, since those are invisible. Now then, there are two options we have here. I could make table formatter sanitize input somewhat, or I could make it just ignore zero-width characters. Your call.

peter1000 commented 9 years ago

Thanks.

I just started using Atom a couple of weeks ago and the markdown-table-formatter even more recently. So, I'm not sure what would be best. I guess ignore zero-width characters might be the easier one for your side?

But I'm fine with whatever you think fit.

peter1000 commented 9 years ago

BTW: do you have any idea how to easily remove those soft hyphens in atom?

lierdakil commented 9 years ago

Okay, now this package ignores some more common zero-width characters for purposes of table cell width computation. Additional characters may be added to ignore list on user report (reason being, it's really hard to find them all, so I better wait until someone encounters one than spend a couple days reading through whole Unicode table)

lierdakil commented 9 years ago

As for removing those "in bulk", you have to know what unicode codepoint you want to remove. In your case, soft hyphen is 0x00AD. So you take Atom's find and replace utility (ctrl+F or something like that), enable regular expression search (.* button), and input \u00AD into search box. You can 'replace all' with empty string to remove them.

peter1000 commented 9 years ago

Thanks a lot for you help. You can close issue if you think fit to do so.

lierdakil commented 9 years ago

For reference, here is current ignore list (zero-width spaces and soft hyphen): [\u200B-\u200D\uFEFF\u00AD]