Last active
April 8, 2020 00:14
-
-
Save fractaledmind/6214151 to your computer and use it in GitHub Desktop.
REQUIRED PROGRAMS: -- Skim -- TextMate (I have alternate code for TextEdit as well) -- DEVONthink This script is a modification of a script by John Sidiropoulos at http://organognosi.blogspot.com. This script offers you a dialog box with two options: (1) insert a Markdown formatted Inline Link to the current page of the pdf you are viewing in Sk…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* INSERT MARKDOWN LINKS OF CURRENT PAGE OF SKIM PDF INTO TEXTMATE | |
-- created by Stephen Margheim | |
-- 06 July 2013 | |
-- open source | |
*) | |
tell application "Skim" | |
(* PART ONE: | |
Choose your Link | |
*) | |
set number_of_Note3 to (get text for note 3 of page 1 of document 1) as string | |
--display the dialog box with handler at end of script | |
set LinkType to my chooseLinkType({"Reference Link", "Inline Link"}) | |
if LinkType is 0 then return | |
(* PART TWO: | |
Insert your Chosen Link | |
*) | |
tell document 1 | |
--get Skim p# | |
set notePage to get index of current page | |
--get DEVON p#, since DEVONthink and Skim index pages differently | |
set DEVONpage to notePage - 1 | |
set DEVONpage_text to DEVONpage as text | |
--get p# printed on the pdf (requires you to manually alter Note 3) | |
set theRealPage to notePage + number_of_Note3 as string | |
--get DEVONthink URL and Title of the pdf | |
set DevonThinkLink to get text of note 1 of page 1 | |
set pdfTitle to (get extended text of note 1 of page 1) as string | |
--create Reference Link if chosen | |
if LinkType is 1 then | |
set FinalText to "[" & pdfTitle & " (p. " & theRealPage & ")]: " & DevonThinkLink & DEVONpage_text | |
--create Inline Link if chosen | |
else if LinkType is 2 then | |
set FinalText to "[" & pdfTitle & " (p. " & theRealPage & ")]" & "(" & DevonThinkLink & DEVONpage_text & ")" | |
end if | |
--insert whichever link type you selected into TextMate | |
tell application "TextMate" | |
activate | |
insert FinalText | |
end tell | |
(* If you don't have TextMate, here's the script for the universal Mac program TextEdit. To alter the code, merely delete or comment-out the TextMate tellblock and uncomment this block: | |
*) | |
-- tell application "TextEdit" | |
-- activate | |
-- make new word at end of text of document 1 with data FinalText | |
-- end tell | |
end tell | |
end tell | |
(* HANDLER *) | |
on chooseLinkType(typeList) | |
display dialog "Insert Inline or Reference link to currently viewed page of pdf?" buttons {"Inline", "Reference"} default button {"Inline"} | |
if result = {button returned:"Inline"} then | |
return 2 | |
else if result = {button returned:"Reference"} then | |
return 1 | |
end if | |
return LinkType | |
end chooseLinkType |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment