fix: Support ol, pre, and code elements in content#2241
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
codepreol/liul/liProvide a
MastodonTagHandlerthat handles these, by creating appropriate spans in the content.In particular, a new
LeadingMarginWithTextSpanis used to create spans with a leading margin that can contain text -- typically either bullets forulor numbers forol.The margin is sized to allow space for an
lilabeled99., 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 thetypeorstartattributes 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 tocore.ui.taghandlerand adjust as necessary.Fixes #2217