Skip to content
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

Message Composition: Parse Markdown and send HTML #282

Open
kiliankoe opened this issue Mar 24, 2021 · 8 comments
Open

Message Composition: Parse Markdown and send HTML #282

kiliankoe opened this issue Mar 24, 2021 · 8 comments

Comments

@kiliankoe
Copy link
Member

See #281.

@kloenk
Copy link
Member

kloenk commented Aug 5, 2021

This library seems like it could do the job quite well: https://github.com/JohnSundell/Ink

@helje5
Copy link
Contributor

helje5 commented Aug 5, 2021

Or this one, probably makes more sense than an arbitrary custom parser: https://github.com/apple/swift-cmark

@kloenk
Copy link
Member

kloenk commented Aug 5, 2021

Also AttributedString, but it does not seem to have anything to output html, only to render markdown

@helje5
Copy link
Contributor

helje5 commented Aug 5, 2021

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).

@helje5
Copy link
Contributor

helje5 commented Aug 5, 2021

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".

@kloenk
Copy link
Member

kloenk commented Aug 5, 2021

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).

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.

@helje5
Copy link
Contributor

helje5 commented Aug 5, 2021

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 :-)

@kloenk
Copy link
Member

kloenk commented Aug 5, 2021

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants