BBEdit text factories

(Crossposted to the BBEdit mailing list.)

I’m having trouble getting BBEdit to apply a text factory to the document – I’m a bit of a newb to scripting, so it’s possible I’m making an obvious mistake.

The script grabs a wikipedia article and tries to clean it up (only the last part is relevant) :


-- get user input
property theArticleName : ""

repeat while theArticleName is ""
	display dialog "Enter exact name of article, case sensitive, substituting underscores for spaces" default answer theArticleName
	set theArticleName to text returned of result
end repeat

--retrieve wikisyntax article text
set theArticleText to do shell script "curl [url=http://en.wikipedia.org/wiki/Special:Export/]http://en.wikipedia.org/wiki/Special:Export/"[/url] & theArticleName

tell application "BBEdit"
	-- read in the datadump
	set BBDoc to make new document with properties {contents:theArticleText}
	
	set BBFactory to a reference to file "Macintosh HD:Users:old:WP automated:WP"
	
	-- clean up the text
	apply text factory BBFactory to document BBDoc
	
end tell

It always highlights that “apply text factory” line and pops up an error dialog telling me that the text factory file, called “WP”, doesn’t understand how to apply itslef:

‘BBEdit got an error: file “Macintosh HD:Users:old:WP automated:WP” doesn’t understand the apply text factory message.’

Argh. Any advice?

AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Awesome; thanks.