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

Support code blocks #4090

Merged
merged 2 commits into from
Nov 1, 2023
Merged

Support code blocks #4090

merged 2 commits into from
Nov 1, 2023

Conversation

connyduck
Copy link
Collaborator

before

after

return this.replace("<br> ", "<br>&nbsp;")
.replace("<br /> ", "<br />&nbsp;")
.replace("<br/> ", "<br/>&nbsp;")
.replace("\n", "<br/>")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to inject the nonbreaking space here? Or we only get \n when it's a code block?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a browser renders HTML, it ignores newlines as a default. The Android HTML parsing code does the same.
In a browser, you can override that behavior with the whitespace css property. Mastodon sets it for the whole status to pre-wrap. That difference did not matter, because Mastodon also replaces all newlines with <br/> so the Android parser would handle them correctly. But inside <code> blocks, newlines are not replaced by Mastodon, so that's what this replacement is for.

Tldr:

we only get \n when it's a code block?

yes

@Tak Tak merged commit 6773342 into develop Nov 1, 2023
3 checks passed
@Tak Tak deleted the support_code_and_lists branch November 1, 2023 08:22
@charlag charlag added this to the Tusky 24 milestone Nov 18, 2023
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

Successfully merging this pull request may close these issues.

3 participants