CyberShadow / DFeed

D news aggregator, newsgroup client, web newsreader and IRC bot
http://forum.dlang.org/help#about
380 stars 35 forks source link

Markdown tables spuriously fail #127

Closed dkorpel closed 3 years ago

dkorpel commented 3 years ago

Reduced to:

| A                                | B                            | C  |
|----------------------------------|-------------------------------|----|
| A                                | B                             | C  |
| A                                | B                             | C  |

Which should render as:

A B C
A B C
A B C

But on the forum preview it shows:

image

And if you align the last column:

| A                                | B                             | C  |
|----------------------------------|-------------------------------|----|
| A                                | B                             | C  |
| A                                | B                             | C  |

It fails completely and shows this:

A B C
A B
C
A B
C

If you tighten it up:

| A | B | C |
|---|---|---|
| A | B | C |
| A | B | C |

It works correctly. I have no idea what's happening.

CyberShadow commented 3 years ago

Argh. It's a bad interaction with RFC 2822 wrapping.

Standard Markdown fits and works well with hard-wrapped text, however, that does not extend to GitHub's extensions.

So, we need to heuristically detect and exempt lines containing Markdown tables from wrapping.

Edit: Hmm. No, that's not it.

We already unwrap lines before passing them on to the Markdown renderer:

https://github.com/CyberShadow/DFeed/blob/7985f38f835d8e4d054a32e288e7f79f5cf15c60/src/dfeed/web/web/part/postbody.d#L48

I think there's a problem with the unwrapping algorithm.

dkorpel commented 3 years ago

So it's simply word wrapping around 74 characters before converting to markdown? At least I can work around that for now by making my table smaller.

CyberShadow commented 3 years ago

Should be fixed now.

https://github.com/CyberShadow/ae/commit/5982fbdf6859f2ec6f0b13e114cb1e03c4cf6b24

dkorpel commented 3 years ago

Thanks for your swift action!