Skip to content

MSC4313: Require HTML <ol> start Attribute support #4313

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions proposals/4313-require_html_ol_start_attribute.md
Copy link
Member

Choose a reason for hiding this comment

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

Implementation requirements:

  • Client (ideally several)

Copy link
Contributor Author

@HarHarLinks HarHarLinks Jul 15, 2025

Choose a reason for hiding this comment

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

  • I know this is already implemented in Element-Web, Element X iOS, Element classic iOS, Fractal, FluffyChat 2.0. There are likely more. What do you need as confirmation?

  • Implementations meeting this proposal but with limited issues (such as not rendering the number when the item has no content) exist, e.g. Nheko 0.12.0-9571d811, NeoChat, Element/SchildiChat classic, FluffyChat 1.25.

  • A counter-example would be Element X Android.

Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# MSC4313: Require HTML `<ol>` `start` Attribute support

The Matrix specification allows text messages to optionally contain a HTML-formatted version over the plain text
body.
A set of "safe" tags is recommended, along with a set of "safe" attributes for some of the tags that
support them.
Additional Matrix-specific attributes are also introduced. However, all of this is optional on any level:
Clients may choose for example to
- not implement sending or showing or HTML-formatting at all
- only implement some tags
- implement additional tags outside of the existing recommendation

This can lead to problems in terms of interoperability:
If a sending client sends certain markup that implies some information, and a receiving client does
not support that markup, removing it as it displays the message, then the received message is not
complete and thus has possibly altered meaning.

Specifically, over the last decade of Matrix, clients have repeatedly had issues with ordered lists.


## Proposal

Imagine the following conversation to illustrate:

Alice asks:
1. \<a very long option\>
2. \<another very long description\>
3. \<a huge third description\>

Bob replies:
2.

Let's assume Bob's client takes the option to translate the plain text `2.` to HTML.
Copy link
Member

Choose a reason for hiding this comment

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

arguably this is the bug, not the lack of start

Copy link
Member

Choose a reason for hiding this comment

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

(also, why aren't they using polls?)

Copy link
Contributor Author

@HarHarLinks HarHarLinks Jul 15, 2025

Choose a reason for hiding this comment

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

The spec says I may use start in my HTML body. If I use it and my conversational partner cannot interpret it correctly, then the spec does not adequately prevent communication from breaking there. How we get into this situation is irrelevant imo, unless we want to start speccing how the formatted_body must be constructed, which I hope is widely out of scope of Matrix.

(Whether to use polls or not is also not the question.)

Copy link

Choose a reason for hiding this comment

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

err, all that you need to do to invoke this issue is typing in EXA that you like the
4. of July.

Assuming further that Bob's client has full support to the extent recommended by the spec, then Bob's
message becomes `"formatted_body": "<ol start=\"2\"><li></li></ol>"`, i.e. an ordered ("numbered") list with a single,
empty entry, that starts at an index of two.

Let's assume Alice's client also implements HTML markup in a configuration allowed by the spec:
Her client supports `ol` tags, but not the `start` attribute.
A common implementation is to parse the HTML and simply remove any tags not implemented by the client.
After safely ingesting the message, Alice's client ends up with `"formatted_body": "<ol><li></li></ol>"`.
Rendering this, Alices screen shows:

Bob said:
1.
Comment on lines +44 to +45
Copy link
Contributor Author

@HarHarLinks HarHarLinks Jul 16, 2025

Choose a reason for hiding this comment

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

For evidence, this is the case in Element X as of 25.07.0.

Further evidence: nheko 0.12.0-9571d811 and SchildiChat ("classic") will show only whitespace here.


This is a clear break in communication, since this message has an entirely different meaning not only
from Bob's intended meaning, but also as it is viewed from different client implementations.

This MSC proposes to alter the spec such that a client implementing rendering of the `ol` HTML tag
in `formatted_body`s is also required ("MUST") to implement its `start` attribute, in order to prevent
loss of meaning of a message.


## Potential issues

This proposal increases the load on client developers, though presumable only a tiny bit,
which could mean that fewer clients could choose to implement `ol` at all.


## Alternatives
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you prevent the sending client from turning 2. into an <ol> in the first place?

Copy link

Choose a reason for hiding this comment

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

Independent of where this MSC goes I feel like this ("better logic for when to convert X. (numbers) into <ol>) is an issue report that should be opened against clients that currently do not do that in a sane way ?
I even remember seeing such issues iirc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I change my example, because apparently many reviewers are missing the issue I am trying to point out for another issue.

It is currently legal and intended within the Matrix spec for Alice to type:

3. A
4. B
5. C

and Alice's client to send this as "formatted_body": "<ol start=\"3\"><li>A</li><li>B</li><li>C</li>".

The above is a legal message, and there are valid use cases to get there. This formatted_body legally existing is the basis for this MSC. It is not concerned with how to get there, as long as you are allowed to get there.

Then the issue is that Bob's client missing support for start might render it as

1. A
2. B
3. C

What I at this point regard as out of scope of this MSC (convince me otherwise?) is prescribing to clients how to and how not to generate their HTML. Possible ways for clients to construct formatted_bodys could be:

  • interpret "plain text" as some markdown dialect (yes this is inconsistent across different clients), as most clients do today
  • users enter custom HTML straight in the input box, e.g. using Element Web's /html command
  • parse Org mode
  • a bot doing STT and heuristically applying formatting
  • any custom input language
  • AI generating formatted_body from a user signing sign language into their webcam
  • anything you can think of

So to get rid of erratic behavior, the spec could try to come up with rules trying to cover a million edge and corner cases that prevent a simple answer of 2. (current MSC example) or 4. of July (from spaetz) from being converted to an ol. But still the problem is not solved, see example above.

An easy alternative would be to disallow start from the spec, i.e. only allow ordered lists starting at 1, and leaving it up to clients to not mistakenly convert numbered lists starting not at 1 (incl misinterpretations like 4. of July) to ols.

Can anyone find a reference as to when start support was added to the spec, ideally the MSC and reasoning for it?

Copy link
Contributor

@Johennes Johennes Jul 16, 2025

Choose a reason for hiding this comment

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

I think fixing the start issue as per this proposal definitely makes sense in any case.

I was just thinking that when I type "4. Juli", I actually wouldn't want it to become an ordered list starting at 4. Even if it's displayed similarly, semantically it's something very different from what I intended. Agree that this is a different problem though and should be solved in another proposal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was just thinking that when I type "4. Juli", I actually wouldn't want it to become an ordered list starting at 4. Even if it's displayed similarly, semantically it's something very different from what I intended. Agree that this is a different problem though and should be solved in another proposal.

To be clear, I agree that this is annoying and suboptimal, and clients should do better. I am not sure though if this even falls into the area of concern of the spec.


- Define a list of all HTML tags whose displaying must be supported if `formatted_body` is used to display
messages at all, based on whether tags can replace characters such as in the demonstrated example.
This could apply recursively also for all attributes.
- Find a way for clients to determine whether the `body` matches its supported interpretation of the
`formatted_body`.
This could end up very similar to the previous alternative and additionally lead to inconsistent
behavior on clients where `formatted_body` is only sometimes used for display as a result.
- Remove HTML from the spec entirely. Possibly replace it with another markup language that prevents
this issue.


## Security considerations

No potential security issues are known to the author.
Only options already allowed are being defined more precisely.


## Unstable prefix

Not required, since implementations of this MSC would only allow an existing subclass of the currently legal
HTML-formatted messages.

## Dependencies

None.