Markdown code block rendering problem on Android
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 382
- Forks
- 33
- Avg merge
- 18h 8m
- Merged PRs (30d)
- 1
Description
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 .. ?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with CodeRules.kt around the codeBody extraction at lines 298-299, then inspect MarkdownRules.kt around the parse() call at line 146 and trace the value into Android rendering. Reproduce the example on Android and confirm that leading whitespace on the first code-block line is preserved, while matching behavior on Desktop and iOS remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100