Skip to content

Format for rich text messages (SPEC-48) #471

Closed
@matrixbot

Description

@matrixbot

Currently, m.text just supports a raw string. Whilst we have solved the attachment use case (via m.image, m.video and so on), we have no current way to specify markup for raw text.

After doing some research, there are a handful of options here:

  • Roll our own format e.g.
  spans: [ 
    { type: bold, start: 4, end: 9 }, 
    { type: italic, start: 15, end: 21 } 
  ]

  • Use XHTML tags (and strip the nasty ones)
  • Use BBCode
  • Use Markdown
  • Use reStructured Text (RST)

I would prefer that we didn't re-invent the wheel on this, so I'm against rolling our own format. Using XHTML tags would be fine, but the kicker is that there are unsafe tags which we'd want to strip (akin to XEP-0071). Clients may be lazy and not strip bad tags, and everything goes into a mess. For these reasons, I'm against using XHTML as the markup for this.

This leave BBCode and Markdown/RST. BBCode has been around for a long time, has easy regex parsing to map directly to HTML, though there are odd quirks with it such as ambiguous markup syntax. Markdown/RST have a lot of libraries for different languages to map to HTML, and provide a richer feature set than BBCode. As such, I'd prefer either Markdown or RST.

Without getting into the holy war of RST vs Markdown, RST is more mature at the moment since there is a well-defined spec http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html and not many different fragmented versions (unlike Markdown). That being said, this will be fixed in the future http://commonmark.org/ - I hold no real preference as to which we should use. It seems Markdown has a slightly nicer syntax and is geared more towards generating HTML possibly, which I feel may be more aligned with what we actually want from a markup language.

Thoughts welcome.

(Imported from https://matrix.org/jira/browse/SPEC-48)

(Reported by @kegsay)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions