Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the '10.8: New Notes App Service' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.8: New Notes App Service
Authored by: Lri on Apr 14, '13 06:35:25AM

And apparently the body is always HTML, so you also need to escape characters like <. Just adding white-space:pre seems to preserve whitespace though.

on run {input, parameters}
	tell application "Notes"
		tell folder 1 of account 1
			make new note with properties {body:"<body style=white-space:pre>" & my amp(input) & "</body>"}
		end tell
	end tell
	tell application "System Events" to tell process "Notes"
		set selected of row 1 of table 1 of scroll area 1 of group 1 of splitter group 1 of window 1 to true
		set focused of group 1 of UI element 1 of scroll area 1 of group 2 of splitter group 1 of window 1 to true
	end tell
end run

on amp(input)
	my replace(input, "&", "&amp;")
	my replace(result, "<", "&lt;")
	my replace(result, ">", "&gt;")
end amp

on replace(input, x, y)
	set text item delimiters to x
	set ti to text items of input
	set text item delimiters to y
	ti as text
end replace

In the previous scripts you should use printf %s, <<<, or shopt -u xpg_echo; echo. echo interprets escape sequences by default in OS X's /bin/sh, so for example do shell script "echo " & quoted form of tab prints a literal tab.

[ Reply to This | # ]