I woud like to automate the formatting of code in Swift copied from Xcode and pasted into a text field in Keynote. Format is indeed carried over, but I want to change the font size (this I have done) and further I would like to add line numbers (this can be done manually with Bullets and Lists of type Number).
I have written an AppleScript program that just changes the size of the font.
My code looks like this:
tell application "Keynote"
activate
set ts to the current slide of the front document
tell ts
set theTextItem to its first text item
tell theTextItem
set the size of its object text to 32
end tell
end tell
end tell
This code changes the size of the text object to 32, but I have found no way to activate line numbering (that is, to activate Numbers format in Bullets and Lists.
TI turns out that Bullets and Numbering in iWork are part of the rich text format, which AppleScript does not have direct access to. However, you can accomplish this through GUI-scripting with a bit of effort, like so:
It ain't pretty, but it gets the job done.