Skip to content

fix: Support ol, pre, and code elements in content#2241

Merged
nikclayton merged 1 commit into
pachli:mainfrom
nikclayton:2217-ordered-lists
Apr 17, 2026
Merged

fix: Support ol, pre, and code elements in content#2241
nikclayton merged 1 commit into
pachli:mainfrom
nikclayton:2217-ordered-lists

Conversation

@nikclayton

@nikclayton nikclayton commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Mastodon extended the list of supported HTML elements in 4.2.0, but didn't mention it in the release notes.

https://docs.joinmastodon.org/spec/activitypub/#sanitization has the list of supported elements.

Most of them are handled by Android, but a few are not, or are handled badly. They are:

  • code
  • pre
  • ol / li
  • ul / li

Provide a MastodonTagHandler that handles these, by creating appropriate spans in the content.

In particular, a new LeadingMarginWithTextSpan is used to create spans with a leading margin that can contain text -- typically either bullets for ul or numbers for ol.

The margin is sized to allow space for an li labeled 99. , which should hopefully be enough for use on Mastodon and similar servers. The labels respect LTR and RTL locales, but do not allow setting custom labels (e.g., through the type or start attributes on the content) because Android's tag handler system does not pass the attributes down.

This duplicates some of the code in the pre-existing PachliTagHandler, so move that code to core.ui.taghandler and adjust as necessary.

Fixes #2217

Mastodon extended the list of supported HTML elements in 4.2.0, but
didn't mention it in the release notes.

https://docs.joinmastodon.org/spec/activitypub/#sanitization) has the
list of supported elements.

Most of them are handled by Android, but a few are not, or are handled
badly. They are:

- `code`
- `pre`
- `ol` / `li`
- `ul` / `li`

Provide a `MastodonTagHandler` that handles these, by creating appropriate
spans in the content.

In particular, a new `LeadingMarginWithTextSpan` is used to create spans
with a leading margin that can contain text -- typically either bullets
for `ul` or numbers for `ol`.

The margin is sized to allow space for an `li` labeled `99. `, which
should hopefully be enough for use on Mastodon and similar servers. The
labels respect LTR and RTL locales, but do not allow setting custom labels
(e.g., through the `type` or `start` attributes on the content) because
Android's tag handler system does not pass the attributes down.

This duplicates some of the code in the pre-existing `PachliTagHandler`,
so move that code to `core.ui.taghandler` and adjust as necessary.

Fixes pachli#2217
@nikclayton nikclayton merged commit abfbf2c into pachli:main Apr 17, 2026
29 checks passed
@nikclayton nikclayton deleted the 2217-ordered-lists branch April 17, 2026 08:44
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.

For Markdown posts: ordered lists are rendered as unordered lists

1 participant