I need to be able to convert RTF or HTML to Markdown-syntaxed plain text for uploading to my server. I need to achieve this in Cocoa/Obj-C 2.0. Does anyone know how to do this?
Thanks so much —» Alex.
Edited Thu 4:53 PM
Umm. In answer to Yuji’s comment, I’m trying to make an NSStatusItem droplet that accepts text. It doesn’t matter what format the text is in, but I need to be able to format it either as plain text or plain text formatted with Markdown. I guess since I don’t know what kind of text I’ll be receiving…
Oooph, this is going to be tricky. As Yuji said, you can express a lot more in HTML/RTF than in markdown. That being the case…
I’d convert the content into an
NSAttributedString. You can easily construct anNSAttributedStringfrom RTF data; HTML will be much more difficult. Once you do that, however, it’ll be a matter of inspecting all the attributes on the string and applying the equivalent markdown to a plaintext version of the content.Researching a bit more: