Applescript 使用rb appscript在页面或文本编辑中编写项目符号/编号列表

Applescript 使用rb appscript在页面或文本编辑中编写项目符号/编号列表,applescript,sourceforge-appscript,rb-appscript,Applescript,Sourceforge Appscript,Rb Appscript,我需要使用rb appscript创建一个新的页面文档,其中包含项目符号和编号列表。看看这里,我看到段落有一个名为list_style的属性,但我对rb-appscript或applescript还不太熟悉,不知道如何设置该属性。我已经阅读了ASDictionary生成的文档,但我对AppleScript的了解显然太少,无法理解它 如果您能帮助您理解如何使用文档中提供的信息,或者在页面中使用rb appscript编写列表,我们将不胜感激 编辑:我不是停留在页面上,文本编辑也是一个可行的选择。当

我需要使用rb appscript创建一个新的页面文档,其中包含项目符号和编号列表。看看这里,我看到段落有一个名为list_style的属性,但我对rb-appscript或applescript还不太熟悉,不知道如何设置该属性。我已经阅读了ASDictionary生成的文档,但我对AppleScript的了解显然太少,无法理解它

如果您能帮助您理解如何使用文档中提供的信息,或者在页面中使用rb appscript编写列表,我们将不胜感激


编辑:我不是停留在页面上,文本编辑也是一个可行的选择。

当前的苹果应用程序对脚本来说很奇怪。我不使用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
本质上,这是将每个列表项放在其自己的段落中(即列表项的所有意图和目的:缩进的段落加上项目符号),依次选择每个段落,然后将列表段落样式应用于选择。
段落
对象只返回给定段落的文本,由于某种原因,它本身不包含任何状态。这不是处理这种情况的最佳方法,但至少所有组件都可以满足您的需要。

rb-appscript:

require 'rubygems'
require 'appscript'; include Appscript

lst=["a", "b"]
doc = app('Pages').documents[0]
doc.selection.get.paragraph_style.set("Body Bullet")
doc.selection.set(lst.join("\n"))
AppleScript:

set lst to {"a", "b"}
set text item delimiters to linefeed
tell application "Pages" to tell document 1
    set paragraph style of (get selection) to "Body Bullet"
    set selection to (lst as text)
end tell