Re: Convert HTML Text to Plain Text
Re: Convert HTML Text to Plain Text
- Subject: Re: Convert HTML Text to Plain Text
- From: Shane Stanley <email@hidden>
- Date: Fri, 17 Jun 2016 11:56:00 +1000
On 17 Jun 2016, at 11:12 AM, Jim Underwood <email@hidden> wrote:
I'm looking for a faster, better method of converting HTML text to plain text. I'm hoping ASObjC can come to the rescue. 😄
I have an Evernote script that might process thousands of Notes, and for each Note I need the plain text.
Any ideas/suggestions?
I don't know how much faster this will be; it uses the same process in the end:
use AppleScript version "2.4" -- Yosemite (10.10) or later use framework "Foundation" use framework "AppKit" use scripting additions
on HTMLDecode:HTMLString -- make it an NSString set theString to current application's NSString's stringWithString:HTMLString -- get raw data set theData to theString's dataUsingEncoding:(current application's NSUTF8StringEncoding) -- convert to attributed string set attStr to current application's NSAttributedString's alloc()'s initWithHTML:theData documentAttributes:(missing value) -- extract just the text return attStr's |string|() as text end HTMLDecode:
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden