Search code examples
htmlmailcore2

flatten HTML to text object-c with mailcore2


I am using mailcore2 and I have below Scenario.

I want to display html and summary but only want to download the content 1 time, so I decide to load the HTML content and flatten (remove html tags) html to text:

  1. Get the HTML content using htmlBodyRenderingOperationWithMessage
  2. I don't want to use plainTextBodyRenderingOperationWithMessage to load the textbody, I want to flatten HTML from the htmlBodyRenderingOperationWithMessage.

Do we have any export function from mailcore2 to flatten HTML to text.


Solution

  • There's a method available in MailCore 2 to "flatten" HTML. You can use:

    -[NSString mco_flattenHTML]
    

    It will remove all the html tags and non-visible text from the string.