Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Three backtick block parsing is way too strict compared to other messengers, making element comparatively annoying to use #14898

Closed
ell1e opened this issue Aug 6, 2020 · 9 comments

Comments

@ell1e
Copy link

ell1e commented Aug 6, 2020

Description

Three backtick block parsing is too strict compared to other messengers, making element comparatively annoying to use in coding channels when sharing snippets. It just feels like element goes out of its way to make exchanging code snippets hard for the sake of wanting me to teach markdown, instead of just getting out of the way of painless conversation. Here are a few examples where the strictness is problematic:

Example 1

Input:

hello this is my code example: ```
test code line 1
test code line 2```

Telegram: ✔️

ex1telegram

Discord: ✔️

ex1discord

Element: 👎

ex1element

Example 2

Input:

```
test code line 1
test code line 2``` < see my code here

Telegram: ✔️

ex2telegram

Discord: ✔️

ex2discord

Element: 👎

ex2element

Example 3

Input:

more code:
```test code line 1
test code line 2```

(Note: I realize this one flies in the face of having the programming language specified in the first line. However, even this can be made to work without breaking legitimate markdown by just assuming anything with a space char or brackets or semicolons on the first line likely doesn't use the first line to specify a programming language. And this example happens more often for me than you'd think when not paying attention)

Telegram: ✔️

ex3telegram

Discord: ✔️

ex3discord

Element: 👎

ex3element

Steps to reproduce

Steps to reproduce:

  • Connect to matrix using Element
  • Copy the input for any of the examples above, make sure it copies as you see it (GitHub appears to like to insert empty lines in between which you will need to take out again)
  • Paste example into Element chat bar and hit send

Describe how what happens differs from what you expected:

As written above, when just exchanging some snippets really quick in a discussion I don't want to be judged as if I'm writing a readme, and this works in all other messengers. As messy and non-standard as this is, I think the user intent of all examples is very clear and this is a real annoyance in conversation. So I think all of these examples should work in element.

There woud also IMHO be no need to make these work in more complex scenarios, like inside a quote or an indented block. But at least the super plain examples like in an otherwise unformatted message as above should work.

Version information

  • Platform: web
  • Browser: Firefox Nightly
  • OS: Fedora Linux
  • URL: app.element.io

Tickets #4674 and element-hq/element-meta#330 might be connected to fixing this.

@t3chguy
Copy link
Member

t3chguy commented Aug 7, 2020

This is just how https://spec.commonmark.org/dingus/ works.
The only solution would be to change Markdown dialects.

@ell1e
Copy link
Author

ell1e commented Aug 7, 2020

@t3chguy I think a good solution might be to expand the currently used parser to handle this, might e.g. also work nicely with a pre-parser that only detects and finds and reformats these special cases. Switching the entire dialect possibly impacting lots of other things doesn't really seem like it's a good approach, unless the other changes that would bring also are beneficial of course.

@t3chguy
Copy link
Member

t3chguy commented Aug 7, 2020

That would mean running a custom dialect which is not going to happen due to maintainability and interoperability

@ell1e
Copy link
Author

ell1e commented Aug 7, 2020

If I had to guess, I would assume custom parser tweaks that is what all these other messengers are doing. And interoperability in what sense? Right now Element seems to be doing a worse job at that in practice by not recognizing things that work in almost all others. And what exactly do I gain if a really complicated markdown readme pastes perfectly fine as-is, but the short snippet stuff I actually type in daily use doesn't work? I think adhering perfectly to some widely shared variant down to every detail might be overrated in this context

@t3chguy
Copy link
Member

t3chguy commented Aug 7, 2020

Ever more reason to switch to something like GFM rather than making our own thing which is hard to maintain exactly between all the platforms and still won't match anything else exactly

@ell1e
Copy link
Author

ell1e commented Aug 7, 2020

GitHub doesn't seem to pass the examples above. So if GFM means it matches GitHub's behavior exactly then it won't do anything useful to solve this issue, so I'm not sure why you'd bring it up in that case. Edit: i saw the talks about switching to it and of course if that did solve it that'd be cool. but otherwise some custom work would still be necessary. The interesting question is probably with what parser that'd be the easiest to do.

Edit 2: I'm also realizing I was possibly unclear above. When I wrote the following:

I think adhering perfectly to some widely shared variant down to every detail might be overrated in this context

... I was referring to the entirety of the standard, especially things that are relevant for documentation, READMEs, and not at all for chat, you know like the nesting behavior of multiple lists inside each other, complicated indents being resolved right, stuff like that. I did not refer to the examples of this ticket, like the short weird corner cases people actually abuse and use in practice in modern messengers. Those should in my opinion definitely work - but those don't seem to match the "classic" more strict markdown standards too well. So that is why I think just trying to shoehorn in a documentation/readme-oriented markdown lib with zero adjustments may never do this justice. I might be wrong though, just a feeling.

@t3chguy
Copy link
Member

t3chguy commented May 26, 2022

Closing in favour of element-hq/element-meta#330 as the general markdown bug

@t3chguy t3chguy closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2022
@ell1e
Copy link
Author

ell1e commented May 27, 2022

Does GFM support all these weird chat-specific corner cases though? Otherwise I'm not sure it's an "equivalent" bug

@t3chguy
Copy link
Member

t3chguy commented May 27, 2022

Nope, that's why I turned it into the general markdown bug, to pick the right dialect, with the current suggestion of gfm, I'd suggest arguing against gfm there if you don't like it's back tick handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants