matrix-spec-proposals icon indicating copy to clipboard operation
matrix-spec-proposals copied to clipboard

MSC2427: Proposal for JSON-based message formatting

Open tulir opened this issue 5 years ago • 3 comments

Rendered

tulir avatar Jan 24 '20 19:01 tulir

This is very similar to how Minecraft does its chat https://wiki.vg/Chat

Though I'm not sure why this makes tables and lists are impossible, wouldn't something like

{
  "m.formatted.version": "0.1",
  "m.formatted": [
    {"m.text": "Hello, here's a table:\n"},
    {"m.table": [
        [
             [{"m.text": "Row 0 "}, {"m.text": "Column 0"}],
             [{"m.text": "Row 0 Column 1"}]
        ],
        [
            [{"m.text": "Row 1 Column 0"}],
            [{"m.text": "Row 1 Column 1"}]
        ]
    ]},
    {"m.text": "And This is a list:\n"},
    {"m.list": [
        [{"m.text": "List Item 1"}],
        [{"m.text": "List Item 2"}],
        [{"m.width": 128, "m.height": 64, "m.alt_text": "Could even be an image", "m.image": "mxc://example.org/ABCDEF"}]
    ]},
  ]
}

Be fine?

Of course this would require non-string primary types and would complicate the renderer quite a bit. (and I guess it kinda looks like something extensible-eventsy at this point)

D4ndellion avatar Jan 25 '20 01:01 D4ndellion

This also looks similar to https://github.com/portabletext/portabletext, which might be nice since there's already a few libraries built around it. It's spec would have to be expanded for things like mentions, though.

KB1RD avatar Mar 09 '20 21:03 KB1RD

The spec details the real problem of a html renderer being quite heavy and the html spec itself naturally being a huge thing to depend opon in matrix renderers.

Moving over to JSON, however, is something that looks a bit weird to my eyes. It solves a different problem, it essentially re-invents serialization without talking about the initial issue of standardizing text/image-rendering.

Using XML (lets assume html is xml for just a moment) has one big advantage in that any renderer can simply remove tags it doesn't understand and still have a good text that it can render. That is to say, XML is much better suited for markup of human readable text than JSON is. JSON is much better for structures and data.

My suggestion is to look at the ODF spec and copy those parts that will fit in the matrix need. This avoid re-inventing serialization and even giving the opportunity for software to reuse existing support for this ISO-specified format. Naturally a very strict subset is needed to be specified to avoid repeating the html renderer issue where people can just add tags that a browser understands and it works for some clients and not for others.

Because at the end of the day the point of this MSC is to avoid HTML and specify exactly what tags are supported. And if this can be done without inventing the serialization itself, that is just a bonus.

zander avatar Jun 26 '22 21:06 zander