I made this for school and there’s one part that’s upsetting because its looks quite ugly. The script itself takes Skim annotations and creates an OmniOutliner document based on the color of the highlight. The ugliness is as follows…
I would like to pull out the “add style_” line, but its makes the script editor angry when I do.
if exists named styles of style of row_last then
set head_three to make new row with properties {topic:note_text, note:note_url} at end of last row's children of doc
add style_three to named styles of style of head_three
else if level of parent of last row of doc ≤ 2 then
set head_three to make new row with properties {topic:note_text, note:note_url} at end of rows of parent of last row of doc
add style_three to named styles of style of head_three
else
set head_three to make new row with properties {topic:note_text, note:note_url} at end of parent of last row's parent of doc
add style_three to named styles of style of head_three
end if
All of it
tell application "System Events"
if not (exists process "OmniOutliner") then
do shell script "open -a \"OmniOutliner\""
end if
end tell
tell application "Finder" to set dtb to bounds of window of desktop
tell application "Skim"
set all_notes to every note of front document
set pdf_name to (name of front document)
tell application id "OOut"
make new document with properties {name:pdf_name}
set (bounds of windows where visible is true) to dtb
tell application "System Events" to set frontmost of process "OmniOutliner" to true
set status visible of front document to false
tell style of front document
set value of attribute "font-size" to 16
set value of attribute "font-family" to "Avenir Next"
--set value of attribute "font-family" to "M+ 1p"
set value of attribute "font-fill" to {21047, 21047, 21047, 65535}
set value of attribute "item-to-note-space(com.omnigroup.OmniOutliner)" to "4.0"
set value of attribute "item-child-indentation(com.omnigroup.OmniOutliner)" to "30.0"
set value of attribute "shadow-color" to {57729, 57729, 57729, 65535}
--set value of attribute "shadow-offset" to "-1.0" --Why doesn't this work?
set value of attribute "shadow-radius" to "1.2"
end tell
tell column title style of front document
set value of attribute "font-fill" to {57729, 57729, 57729, 65535}
set value of attribute "underline-style" to "none"
set value of attribute "font-weight" to 1.0
end tell
make new row with properties {topic:pdf_name} at end of rows of front document
tell front document
set style_one to make new named style with properties {name:"Heading 1"}
set value of attribute "font-fill" of style_one to {16587, 28329, 55163, 65535}
set style_two to make new named style with properties {name:"Heading 2"}
set value of attribute "font-fill" of style_two to {39981, 38846, 25155, 65535}
set style_three to make new named style with properties {name:"Heading 3"}
set value of attribute "font-fill" of style_three to {23514, 43610, 18771, 65535}
set style_five to make new named style with properties {name:"Green Highlight"}
set value of attribute "text-background-color" of style_five to {59367, 61166, 56540, 65535}
set style_six to make new named style with properties {name:"Red Highlight"}
set value of attribute "text-background-color" of style_six to {63479, 59110, 58339, 65535}
end tell
end tell
repeat with i from 1 to count of all_notes
set _note to item i of all_notes
set _page to "pg. " & index of page of _note
set note_text to text of _note
set rgba to color of _note
set {fav1, fav2, fav3, fav4, fav5, fav6} to favorite colors
tell application id "OOut"
set doc to front document
set row_last to last row of doc
if rgba is fav1 then
set head_one to make new row with properties {topic:note_text, note:_page} at end of rows of doc
add style_one to named styles of style of head_one
else if rgba is fav2 then
try
set head_two to make new row with properties {topic:note_text, note:_page} at end of last child of doc
on error
set head_two to make new row with properties {topic:note_text, note:_page} at end of rows of doc
end try
add style_two to named styles of style of head_two
else if rgba is fav3 then
if exists named styles of style of row_last then
set head_three to make new row with properties {topic:note_text, note:_page} at end of last row's children of doc
add style_three to named styles of style of head_three
else if level of parent of last row of doc ≤ 2 then
set head_three to make new row with properties {topic:note_text, note:_page} at end of rows of parent of last row of doc
add style_three to named styles of style of head_three
else
set head_three to make new row with properties {topic:note_text, note:_page} at end of parent of last row's parent of doc
add style_three to named styles of style of head_three
end if
else if rgba is fav4 then
if exists named styles of style of row_last then
make new row with properties {topic:note_text} at end of last row's children of doc
else if level of row_last > 1 and has subtopics of preceding sibling of row_last contains {} or {false} then
make new row with properties {topic:note_text} at end of parent of last row of doc
else
make new row with properties {topic:note_text} at end of last child of doc
end if
else if rgba is fav5 then
if exists named styles of style of row_last then
set head_five to make new row with properties {topic:note_text} at end of last row's children of doc
add style_five to named styles of style of head_five
else if level of row_last > 1 and has subtopics of preceding sibling of row_last contains {} or {false} then
set head_five to make new row with properties {topic:note_text} at end of parent of last row of doc
add style_five to named styles of style of head_five
else
set head_five to make new row with properties {topic:note_text} at end of last child of doc
add style_five to named styles of style of head_five
end if
else if rgba is fav6 then
if exists named styles of style of row_last then
set head_six to make new row with properties {topic:note_text} at end of last row's children of doc
add style_six to named styles of style of head_six
else if level of row_last > 1 and has subtopics of preceding sibling of row_last contains {} or {false} then
set head_six to make new row with properties {topic:note_text} at end of parent of last row of doc
add style_six to named styles of style of head_six
else
set head_six to make new row with properties {topic:note_text} at end of last child of doc
add style_six to named styles of style of head_six
end if
end if
end tell
end repeat
tell application id "OOut" to expandAll rows of front document
end tell