Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

Custom strategies #6

Open
regexident opened this issue May 3, 2020 · 1 comment
Open

Custom strategies #6

regexident opened this issue May 3, 2020 · 1 comment
Labels
question Further information is requested

Comments

@regexident
Copy link

regexident commented May 3, 2020

Hi @mattt,

I'm currently working on integrating CommonMarkAttributedString into Nio, a Matrix client.

Since Matrix supports rich-text messages using common-mark markdown it would be great if the app could preview the formatting of one's message before sending, similar to how WhatsApp does it:

whatsapp

It basically parses the message body and applies the corresponding attributes to the raw markdown input, while reserving the markup characters.

I wonder if a migration to CommonMark's upcoming visitor API could make custom strategies like this possible?

I'm not exactly sure what would be the best API for this, but one should be able to customize both, the output strings and corresponding attributes.

@mattt mattt added the enhancement New feature or request label May 4, 2020
@mattt
Copy link
Owner

mattt commented May 4, 2020

I'm really glad to hear that you're considering CommonMarkAttributedString for Nio, @regexident!

The feature you're describing looks really cool. My first reaction is to say that this is likely outside the scope of this library, and that making this work correctly — that is, performantly and correctly wrt/input methods — will require thoughtful coordination between NSTextStorage and NSLayoutManager. To that end, I suspect you'll have to drop down to using CommonMark for parsing and AST manipulation (for which the visitor API may be quite helpful).

If you haven't already, you should take a look at the excellent WWDC session from 2018 "TextKit Best Practices". Not only does it provide a great overview, but it uses a WYSIWYG-style Markdown editor as an example!

Beyond that, you might also take a look at projects like Marklight, which implement similar functionality.

@mattt mattt added question Further information is requested and removed enhancement New feature or request labels May 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants