我拼凑了以下脚本,在主题演讲中的演讲者备注的第三段上设置了一个称为“ talkingPoints”的标记,然后将该标记替换为OmniOutliner记录的备注。 OmniOutliner的每一行都对应一个幻灯片编号(行1到幻灯片1,行2到幻灯片2,依此类推)。
问题是,当代码替换“ talkingPoints”标记时,它会更改整个“演讲者备注”的样式,从而更改为与第一行的样式匹配。如何修改脚本以保留每个段落的样式?
谢谢!
tell application "OmniOutliner"
activate
try
if not (exists document 1) then error number 10000
display dialog "This script will replace the marker (talkingPoints) within the presenter notes of the active slides of the frontmost Keynote presentation, with the contents of this outline." & return & return & "The contents of each row will replace the marker (talkingPoints) within the presenter notes of a corresponding Keynote slide." with icon 1
tell application "Keynote"
activate
if not (exists document 1) then error number 10001
tell front document
set the slideCount to the count of (slides whose skipped is false)
end tell
end tell
tell the front document
set theseOutlinerNotes to the topic of every row
end tell
if the (count of theseOutlinerNotes) is greater than the slideCount then
error number 10002
else if the (count of theseOutlinerNotes) is less than the slideCount then
error number 10003
end if
on error errorMessage number errorNumber
if errorNumber is 10000 then
set errorMessage to "No document is open."
else if errorNumber is 10001 then
set errorMessage to "No presentation is open."
else if errorNumber is 10002 then
set errorMessage to ¬
"There are more rows in this document than there are active slides in the presentation."
else if errorNumber is 10003 then
set errorMessage to ¬
"There are fewer rows in this document than there are active slides in the presentation."
end if
if errorNumber is not -128 then
display alert "PREPARATION ERROR" message errorMessage
end if
error number -128
end try
end tell
set targetMarker to "talkingPoints"
tell application "Keynote"
tell the front document
repeat with i from 1 to the count of slides
tell slide i
tell presenter notes
set (the third paragraph) to ¬
"talkingPoints"
end tell
if presenter notes contains targetMarker then
set targetNotes to (presenter notes as string)
tell application "System Events"
set AppleScript's text item delimiters to targetMarker
set presenterNoteParsed to every text item of targetNotes
set AppleScript's text item delimiters to ""
end tell
set presenterString to (item 1 of presenterNoteParsed) & (item i of theseOutlinerNotes) & (item 2 of presenterNoteParsed)
set presenter notes to presenterString
end if
end tell
end repeat
end tell
end tell