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

Markdown code block rendering problem on Android #42

Open
bitmand opened this issue Jan 19, 2023 · 1 comment
Open

Markdown code block rendering problem on Android #42

bitmand opened this issue Jan 19, 2023 · 1 comment

Comments

@bitmand
Copy link

bitmand commented Jan 19, 2023

Problem

When I send a message where the first characters, in the first line, in a code block, is whitespaces, like this:

```
          Some Text
          More Test
```

Then the prepended whitespaces is removed from the first line, when displayed on Android and message looks like this:

Some Text
          More Test

On Discord Desktop and iOS app, the same message is rendered the way I would expect it:

          Some Text
          More Test

A Wild Guess Appears

I tested this markdown code block regex, but the matching seems to work correctly:

  • The first group (optionally) matches the language ( line 298 val language = ... )
  • The second group has all the lines in the code block, including all the prepended whitespaces ( line 299 val codeBody = ... )

So my suspicion is that codeBody is trimmed (removing all prepending- and appending whitespaces, newlines etc.) later on. That would explain why it only happens on the first line of the code block.

But the only use of trim() I can find is in MarkdownRules.kt in a override fun parse() function:

val classes = matcher.group(2)?.trim()?.split(' ')

..and I have zero idea if it's related in any way.

There is also the possibility that this bug is outside of SimpleAST .. ?

@Naitzirch
Copy link

Naitzirch commented Mar 13, 2024

I encountered the same issue. Additionally, in code blocks inside of embeds, tabs (\t) do not get rendered in-between text.

The above two messages are renditions of the same text, and there is also a leading space in front of the first character that doesn't get rendered.

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

No branches or pull requests

2 participants