• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Convert HTML Text to Plain Text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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:

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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

  • Follow-Ups:
    • Re: Convert HTML Text to Plain Text
      • From: Jim Underwood <email@hidden>
References: 
 >Convert HTML Text to Plain Text (From: Jim Underwood <email@hidden>)

  • Prev by Date: Convert HTML Text to Plain Text
  • Next by Date: Re: Script Debugger 6 Officially Released
  • Previous by thread: Convert HTML Text to Plain Text
  • Next by thread: Re: Convert HTML Text to Plain Text
  • Index(es):
    • Date
    • Thread