Loop through the events only once to detect both whether there is markdown and whether the markdown is inline. Fix more cases of false negatives in markdown detection, like whitespaces that are removed or the string beginning by a backslash escape.
Serializable types for the events in the Matrix specification that can be shared by client and server code.