Message Composition: Parse Markdown and send HTML
See #281.
This library seems like it could do the job quite well: https://github.com/JohnSundell/Ink
Or this one, probably makes more sense than an arbitrary custom parser: https://github.com/apple/swift-cmark
Also AttributedString, but it does not seem to have anything to output html, only to render markdown
The HTML generated by NSAttributedString isn't any good anyways, IIRC. I use CMark in SwiftPM Catalog to display the READMEs, and it works really well for that purpose (and is very easy to use).
Finally, for editing, the message composition field should probably be a rich text field as well, so that users can also just bold/italic the text. So the HTML renderer is (should be) not just "Markdown to HTML", but "Markdown + AttributedString attributes to HTML".
The HTML generated by
NSAttributedStringisn't any good anyways, IIRC. I use CMark in SwiftPM Catalog to display the READMEs, and it works really well for that purpose (and is very easy to use).
Do you have api doc for cmark-swift (or a link to a project which uses it)?
I did not yet figure out if we can add the mx-* custom html tags. This is as far as I saw possible in Ink.
The AttributedString is new in iOS 15 IIRC.
AttributedString is new in iOS 15. NSAttributedString was new in NeXTstep.
Presumably those "mx" tags would be produced by typing @user and #channel and such? Not sure whether such things can be added to CMark.
In Nio however, one should deal with those in the UI anyways. I.e. if you type @, a completion panel should pop up and then store the result as an attributed string key (and turn the text into a proper "pill"/badge).
I say "should", because this is quite a bit of work to get right :-)
It's also there for Blockquote > . This is AFAIK defined in the markdown spec, but resulting html is changed for matrix.
Stuff like @user #channel is IIRC just an a tag, with a link (usually matrix.to)