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

Render Markdown lists correctly #434

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sk22
Copy link
Contributor

@sk22 sk22 commented Nov 29, 2022

Closes #152

@sk22
Copy link
Contributor Author

sk22 commented Nov 29, 2022

(ignore the bold thing that's actually meant to be rendered in italic – but not in this pull request)
Screenshot_2022-11-30-00-09-56-790-edit_org joinmastodon android
Screenshot_2022-11-30-00-09-46-304-edit_org joinmastodon android

@grishka
Copy link
Member

grishka commented Nov 29, 2022

Hm. But Markdown isn't an officially supported Mastodon feature 🤔

@sk22
Copy link
Contributor Author

sk22 commented Nov 29, 2022

well, people come across posts using "advanced" html tags, including lists, all the time.

mastodon for web renders this

LIST HEADER

* item 1
* item 2

LIST FOOTER
<p>LIST HEADER<p>
<ul>
  <li>item 1</li>
  <li>item 2</li>
</ul>
<p>LIST FOOTER</p>

like this:

image

…which is still readable.

mastodon for android renders it like this:

Screenshot_2022-11-30-00-15-57-061-edit_org joinmastodon android sk

@sk22
Copy link
Contributor Author

sk22 commented Nov 29, 2022

my pull request can be easily adapted to archive what you see on mastodon web; by

  • removing the "head" switch-case for "p" (which ensures the empty line after lists/non-paragraphs)
  • removing the "head" switch-case for "li"
  • moving the "tail" case for "li" outside the !openSpans.isEmpty() block

edit: i've simplified the implementation since

@sk22
Copy link
Contributor Author

sk22 commented Nov 29, 2022

Screenshot_2022-11-30-00-24-58-052-edit_org joinmastodon android sk debug

would look like this. you can add commits to this PR if you want to

@sk22 sk22 marked this pull request as draft November 30, 2022 00:25
@sk22
Copy link
Contributor Author

sk22 commented Nov 30, 2022

found an issue with my implementation: list items will always append a line break, even if there's nothing after them – resulting in an empty line at the end of the SpannableStringBuilder

@sk22 sk22 marked this pull request as ready for review November 30, 2022 09:51
@sk22
Copy link
Contributor Author

sk22 commented Nov 30, 2022

okay, fixed it – also, the implementation feels much cleaner now

@sk22
Copy link
Contributor Author

sk22 commented Nov 30, 2022

… and since #152 also applies to other block elements, like <blockquote>, it's probably smart to insert spaces (just like after <p> elements), so i changed the logic a bit.

@sk22
Copy link
Contributor Author

sk22 commented Mar 6, 2023

Hm. But Markdown isn't an officially supported Mastodon feature 🤔

it is now: mastodon/mastodon#23913

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.

Display MD lists correctly
2 participants