蘋果應用程序的當前作物是奇怪的腳本。我不使用RB-appscript,但這裏是AppleScript的工作代碼,你應該能夠改變味道和端口:
property dummyList : {"Tyler Durden", "Marla Singer", "Robert Paulson"}
tell application "Pages"
set theDocument to make new document
tell theDocument
set bulletListStyle to ""
set lastListStyle to (count list styles)
repeat with thisListStyle from 1 to lastListStyle
set theListStyle to item thisListStyle of list styles
if name of theListStyle is "Bullet" then
set bulletListStyle to theListStyle
end if
end repeat
repeat with thisItem from 1 to (count dummyList)
set body text to body text & item thisItem of dummyList & return
end repeat
set paraCount to count paragraphs of theDocument
repeat with thisPara from 1 to paraCount
select paragraph thisPara
set theSelection to selection
set paragraph style of theSelection to "Body Bullet"
end repeat
end tell
end tell
這個做什麼,基本上是發生在自己的段每個列表項(這就是所有意圖和目的的列表項目:帶有項目符號的縮進段落),依次選擇每個paragrah,然後將列表段落樣式應用於選擇。 paragraph
對象只是返回給定段落的文本,並且由於某些原因本身並不保持任何狀態。這不是處理這種情況的最佳方式,但至少所有組件都可以滿足您的需求。