matterhorn-chat / matterhorn

A feature-rich Unix terminal client for the Mattermost chat system
BSD 3-Clause "New" or "Revised" License
1.05k stars 77 forks source link

quoted code block markdown renders different than I expected #782

Closed setharnold closed 2 years ago

setharnold commented 2 years ago

Hello, I sent a message that combined both markdown > quoted content as well as ``` triple-quoted code block and I think matterhorn may have rendered it differently than the web version, and also differently than I expected.

I'm not actually sure it matters, since it's all monospaced anyway, but it is a difference. (The yank code command grabbed the URL rather than the text, so it's not entirely about the color and vertical bar.)

GitHub is making it difficult to attach markdown in a comment or in the main body of the issue. Here it is in base64:

PmBgYAogICogc2NwKDEpOiBkbyBub3Qgbm90IGZ0cnVuY2F0ZSgzKSBmaWxlcyBlYXJseSB3aGVu
IGluIHNmdHAgbW9kZS4gVGhlCiAgIHByZXZpb3VzIGJlaGF2aW91ciBvZiB1bmNvbmRpdGlvbmFs
bHkgdHJ1bmNhdGluZyB0aGUgZGVzdGluYXRpb24KICAgZmlsZSB3b3VsZCBjYXVzZSAic2NwIH4v
Zm9vIGxvY2FsaG9zdDpmb28iIGFuZCB0aGUgcmV2ZXJzZQogICAic2NwIGxvY2FsaG9zdDpmb28g
fi9mb28iIHRvIGRlbGV0ZSBhbGwgdGhlIGNvbnRlbnRzIG9mIHRoZWlyCiAgIGRlc3RpbmF0aW9u
LiBiejM0MzEKYGBgCgpodHRwczovL3d3dy5vcGVud2FsbC5jb20vbGlzdHMvb3NzLXNlY3VyaXR5
LzIwMjIvMTAvMDQvMQo=

Thanks

markdown mattermost matterhorn

jtdaugherty commented 2 years ago

Thanks for opening this. Looking at the screenshots, it appears that Matterhorn's difference is that it actually parses the block quote as a bulleted list and renders it accordingly, which I find surprising. Is that the behavior you are wanting to point out?

jtdaugherty commented 2 years ago

Oh! I missed the > at the start of the message. So Matterhorn is seeing a blockquote but somehow missing the verbatim markings, it seems. I have no idea whether that's even valid Markdown; I'd have to look. The parser we use should be conformant to the CommonMark spec.

jtdaugherty commented 2 years ago

If I use the reference implementation's testing tool and provide the input above, I get the same thing that Matterhorn parses (which I expect). It would seem that the web client's parser is treating the single > as adequate to demarcate the entire verbatim block as a block quote. To get the same result in Matterhorn, > needs to be prepended to each line (which I think is probably a better behavior anyway).

I'm inclined to say that the Markdown input text here is not well-formed, but it almost doesn't matter what I think because we don't control the Markdown implementation that we use at a low enough level to make an exception for a behavior like this. For what it's worth, at some point in the past I asked the server developers for Mattermost about whether they'd ever consider using CommonMark as their Markdown implementation in their official clients and I believe the answer was something like "yes, we'd like to get around to that at some point." :/

setharnold commented 2 years ago

Hello, thanks for taking a look. After https://github.com/matterhorn-chat/matterhorn/issues/752 I figured it was enough to just mark one line as a quote, and I've been very lazy since then in how I format my messages. :)

(I'd forgotten the reference testing tool from the other issue. That might have saved some time.)

In any event, I can easily understand "it's not worth the trouble to modify the markdown parser" as a motivator to move on. Here's hoping the Mattermost team can migrate to something more .. common .. soon.

Thanks