├── Sublime └── Marked 2.sublime-build ├── Services ├── Open Current File in Marked.workflow │ └── Contents │ │ ├── QuickLook │ │ └── Thumbnail.png │ │ ├── Info.plist │ │ └── document.wflow └── Preview Selection in Marked.workflow │ └── Contents │ ├── QuickLook │ └── Thumbnail.png │ ├── Info.plist │ └── document.wflow ├── Emacs └── dot.emacs.txt ├── BBEdit └── Open in Marked.applescript ├── iAWriter └── Open in Marked.applescript ├── TextMate └── Marked 2.tmbundle │ ├── info.plist │ └── Commands │ ├── Strip Header IDs.tmCommand │ ├── Open in Marked 2.tmCommand │ └── Preview Selection in Marked 2.tmCommand ├── Watchers ├── nvwatch.rb └── everwatch.rb ├── install ├── AppleScript └── OpenInMarked.applescript └── README.md /Sublime/Marked 2.sublime-build: -------------------------------------------------------------------------------- 1 | { 2 | "cmd": ["open","-a","/Applications/Marked 2.app","$file"], 3 | "selector": "text.html.markdown" 4 | } -------------------------------------------------------------------------------- /Services/Open Current File in Marked.workflow/Contents/QuickLook/Thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ttscoff/marked-bonus-pack/master/Services/Open Current File in Marked.workflow/Contents/QuickLook/Thumbnail.png -------------------------------------------------------------------------------- /Services/Preview Selection in Marked.workflow/Contents/QuickLook/Thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ttscoff/marked-bonus-pack/master/Services/Preview Selection in Marked.workflow/Contents/QuickLook/Thumbnail.png -------------------------------------------------------------------------------- /Emacs/dot.emacs.txt: -------------------------------------------------------------------------------- 1 | (defun markdown-preview-file () 2 | "use Marked 2 to preview the current file" 3 | (interactive) 4 | (shell-command 5 | (format "open -a 'Marked 2.app' %s" 6 | (shell-quote-argument (buffer-file-name)))) 7 | ) 8 | (global-set-key "\C-cm" 'markdown-preview-file) 9 | -------------------------------------------------------------------------------- /BBEdit/Open in Marked.applescript: -------------------------------------------------------------------------------- 1 | -- Place in ~/Library/Application Support/BBEdit/Scripts 2 | -- Use from the Script menu bar item while editing a Markdown document (must be saved first) 3 | -- Assign a shortcut key in BBEedit Preferences->Menu Items 4 | tell application "BBEdit" to set mdFile to file of document of window 1 5 | tell application "Marked 2" 6 | activate 7 | open mdFile 8 | end tell 9 | -------------------------------------------------------------------------------- /Services/Open Current File in Marked.workflow/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSServices 6 | 7 | 8 | NSMenuItem 9 | 10 | default 11 | Open Current File in Marked 12 | 13 | NSMessage 14 | runWorkflowAsService 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /iAWriter/Open in Marked.applescript: -------------------------------------------------------------------------------- 1 | -- Preview the currently active iA Writer document using Marked. 2 | tell application "iA Writer" 3 | activate 4 | 5 | -- Ask iA Writer for it's active document. 6 | set the_document to document 1 7 | 8 | -- Save the document or prompt if not previously saved. 9 | save the_document 10 | 11 | -- If the file is saved, open it using Marked. 12 | tell application "Marked" 13 | set the_file to the_document's file 14 | open the_file 15 | -- Bring Marked forward so it becomes visible. 16 | activate 17 | end tell 18 | 19 | end tell -------------------------------------------------------------------------------- /TextMate/Marked 2.tmbundle/info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | contactEmailRot13 6 | wnerq@xbgsh.arg 7 | contactName 8 | Jared Crapo 9 | description 10 | Preview markdown in [Marked 2](http://marked2app.com). 11 | name 12 | Marked 2 13 | uuid 14 | 98FC9536-43B0-4A09-873E-DD7ED25C291B 15 | 16 | 17 | -------------------------------------------------------------------------------- /Services/Preview Selection in Marked.workflow/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSServices 6 | 7 | 8 | NSMenuItem 9 | 10 | default 11 | Preview Selection in Marked 12 | 13 | NSMessage 14 | runWorkflowAsService 15 | NSSendTypes 16 | 17 | public.utf8-plain-text 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /TextMate/Marked 2.tmbundle/Commands/Strip Header IDs.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env ruby18 -wKU 9 | input = STDIN.read 10 | puts input.gsub(/(h\d) id=".*?"/,"\\1") 11 | 12 | input 13 | document 14 | inputFormat 15 | text 16 | name 17 | Strip Header IDs 18 | outputCaret 19 | heuristic 20 | outputFormat 21 | text 22 | outputLocation 23 | replaceInput 24 | scope 25 | text.html 26 | uuid 27 | E66EE61A-0D66-44B0-899E-DA4DD9D1E20F 28 | version 29 | 2 30 | 31 | 32 | -------------------------------------------------------------------------------- /TextMate/Marked 2.tmbundle/Commands/Open in Marked 2.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env bash 9 | [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh" 10 | 11 | open -a "Marked 2.app" "$TM_FILEPATH" 12 | osascript -e 'tell application "Marked 2" to activate' 13 | 14 | input 15 | none 16 | inputFormat 17 | text 18 | keyEquivalent 19 | ^~m 20 | name 21 | Open in Marked 2 22 | outputCaret 23 | afterOutput 24 | outputFormat 25 | text 26 | outputLocation 27 | discard 28 | scope 29 | text.html.markdown, text.html.markdown.multimarkdown, text.html 30 | uuid 31 | 74F0D07D-C2F7-4CDC-B08B-25024657AAF4 32 | version 33 | 2 34 | 35 | 36 | -------------------------------------------------------------------------------- /TextMate/Marked 2.tmbundle/Commands/Preview Selection in Marked 2.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | saveActiveFile 7 | command 8 | #!/usr/bin/env bash 9 | [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh" 10 | 11 | TMPFILE=`mktemp -t marked2-preview` 12 | cat > $TMPFILE 13 | open -a "Marked 2.app" $TMPFILE 14 | osascript -e 'tell application "Marked 2" to activate' 15 | input 16 | selection 17 | inputFormat 18 | text 19 | keyEquivalent 20 | ^~m 21 | name 22 | Preview Selection in Marked 2 23 | outputCaret 24 | afterOutput 25 | outputFormat 26 | text 27 | outputLocation 28 | discard 29 | scope 30 | text.html.markdown, text.html.markdown.multimarkdown, text.html 31 | uuid 32 | F0BD6911-FCB2-4B6B-AE72-19DB9F3F86D6 33 | version 34 | 2 35 | 36 | 37 | -------------------------------------------------------------------------------- /Watchers/nvwatch.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # watch.rb by Brett Terpstra, 2011 3 | # Watch Notational Velocity notes folder for changes and 4 | # update a preview file for Marked with most recently-modified file contents 5 | # Requres that notes be stored as plain text and notes folder be customized below 6 | 7 | trap("SIGINT") { exit } 8 | 9 | watch_folder = "/Users/ttscoff/Dropbox/Notes/nvALT2.1" 10 | watch_types = ['txt','md'] 11 | marked_note = File.expand_path("~/Marked Preview.md") 12 | 13 | while true do # repeat infinitely 14 | files = [] 15 | watch_types.each {|type| 16 | files += Dir.glob( File.join( watch_folder, "**", "*.#{type}" ) ) 17 | } # collect a list of files of specified type 18 | new_hash = files.collect {|f| [ f, File.stat(f).mtime.to_i ] } # create a hash of timestamps 19 | hash ||= new_hash 20 | diff_hash = new_hash - hash # check for changes 21 | 22 | unless diff_hash.empty? # if changes were found in the timestamps 23 | hash = new_hash 24 | puts "changed" 25 | note_file = File.new("#{diff_hash[0][0]}",'r') # read the latest changed file from the hash 26 | note = note_file.read 27 | note_file.close 28 | watch_note = File.new("#{marked_note}",'w') # write its contents to the preview file 29 | watch_note.puts note 30 | watch_note.close 31 | end 32 | 33 | sleep 1 34 | end -------------------------------------------------------------------------------- /install: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | services() { 4 | cp -r Services/* $HOME/Library/Services 5 | } 6 | 7 | bbedit() { 8 | BBEDIT_DIR="$HOME/Library/Application Support/BBEdit/Scripts/" 9 | mkdir -p "$BBEDIT_DIR" 10 | cp "BBEdit/Open in Marked.applescript" "$BBEDIT_DIR" 11 | } 12 | 13 | st2() { 14 | ST2_DIR="$HOME/Library/Application Support/Sublime Text 2/Packages/User" 15 | mkdir -p "$ST2_DIR" 16 | cp "Sublime/Marked 2.sublime-build" "$ST2_DIR" 17 | } 18 | 19 | st3() { 20 | ST3_DIR="$HOME/Library/Application Support/Sublime Text 3/Packages/User" 21 | mkdir -p "$ST3_DIR" 22 | cp "Sublime/Marked 2.sublime-build" "$ST3_DIR" 23 | } 24 | 25 | iawriter() { 26 | IAWRITER_DIR="$HOME/Library/Scripts/Applications/iA Writer/" 27 | mkdir -p "$IAWRITER_DIR" 28 | cp "iAWriter/Open in Marked.applescript" "$IAWRITER_DIR" 29 | } 30 | 31 | # TODO: 32 | # Add vim support. 33 | # Add emacs support. 34 | 35 | if [[ -z $@ ]] 36 | then 37 | cat << EOF 38 | This scriptlet automates installing *some* elements of the Marked 39 | bonus pack. It currently supports the targets listed below, using the 40 | corresponding keywords: 41 | 42 | Target Keyword 43 | -------------- -------- 44 | Services services 45 | BBEdit. bbedit 46 | Sublime Text 2 st2 47 | Sublime Text 3 st3 48 | iA Writer. iawriter 49 | 50 | Invoke it with one or more of the keywords as arguments, e.g. 51 | 52 | ./install services st3 53 | EOF 54 | else 55 | for i in $@ 56 | do 57 | echo "Installing $i" 58 | $i 59 | done 60 | fi 61 | -------------------------------------------------------------------------------- /Watchers/everwatch.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # everwatch.rb by Brett Terpstra, 2011 3 | # Watch Evernote for updates and put the current content of the editor into a preview file for Marked.app 4 | # 5 | 6 | trap("SIGINT") { exit } 7 | 8 | watch_folder = File.expand_path("~/Library/Application Support/Evernote/data") 9 | if not File.directory?(watch_folder) 10 | # evernote from the app store uses a different path 11 | # because of the sandbox rules 12 | app_folder = File.expand_path("~/Library/Application Support/com.evernote.Evernote/accounts/www.evernote.com") 13 | # inside app_folder, there is a folder with your evernote user id. If you 14 | # have multiple evernote user id's this will probably break, but most 15 | # people don't, so we should be good 16 | watch_folder = Dir.glob("#{app_folder}/*").first 17 | end 18 | marked_note = File.expand_path("~/Marked Preview.md") 19 | counter = 0 20 | 21 | while true do # repeat infinitely 22 | 23 | # read a list of files from the autosave folder 24 | files = Dir.glob( File.join( watch_folder, "*") ) 25 | # build a hash of timestamps 26 | 27 | new_hash = files.collect {|f| [ f, File.stat(f).mtime.to_i ] } 28 | hash ||= new_hash 29 | # check for timestamp changes since the last loop 30 | diff_hash = new_hash - hash 31 | 32 | if diff_hash.empty? # if there's no change 33 | # if it's been less than 10 seconds, increment the counter 34 | # otherwise, set it to zero and wait for new changes 35 | counter = (counter < 10 && counter > 0) ? counter + 1 : 0 36 | else 37 | # store the new hash and start the 10 second change timer at 1 38 | hash = new_hash 39 | counter = 1 40 | end 41 | 42 | if counter > 0 # if the time is running 43 | # get the contents of the post and continued editor screens 44 | note = %x{ osascript <#{note}'|textutil -stdin -convert txt -stdout} 57 | # write the contents to the preview file 58 | watch_note = File.new("#{marked_note}",'w') 59 | watch_note.puts txtnote 60 | watch_note.close 61 | end 62 | # sleep an extra second on changes because Marked only 63 | # reads changes every 2 seconds 64 | sleep 1 65 | end 66 | 67 | sleep 1 68 | 69 | end -------------------------------------------------------------------------------- /AppleScript/OpenInMarked.applescript: -------------------------------------------------------------------------------- 1 | -- Open in Marked 2 2 | -- Attempts to open the currently-edited document in Marked 2 for previewing 3 | -- Based on ideas by Lri 4 | -- with contributions from Donald Curtis 5 | 6 | ---NV/nvALT configuation--------------------------------------------------- 7 | -- * Set NV/nvALT to store text files to disk 8 | -- * Enter the full UNIX/POSIX path to your notes folder in nvNoteFolder 9 | -- * Enter your default file extension (.txt,.md,etc.) in nvNoteExtension 10 | -- It won't always work, but it will try. It's a temporary hack; 11 | -- nvALT will soon have an AppleScript command to access the file directly. 12 | property nvNoteFolder : "/Users/username/pathtonotes/" -- include trailing slash 13 | property nvNoteExtension : ".md" -- include leading dot 14 | ---------------------------------------------------------------------------on run {} 15 | tell application "System Events" 16 | set frontApp to (name of first process whose frontmost is true) 17 | end tell 18 | 19 | set f to false 20 | set flist to {} 21 | 22 | --Marked 2 (if Marked 2 is foreground, hide Marked 2 and end script) 23 | if frontApp is "Marked 2" then 24 | tell application "System Events" to set visible of process "Marked 2" to false 25 | return 26 | --Notational Velocity/nvALT 27 | else if (frontApp is "Notational Velocity") or (frontApp is "nvALT") then 28 | try 29 | tell application "System Events" to tell process frontApp 30 | -- Grab the text in the search field, hopefully this will be the filename 31 | set p to value of text field 1 of group 1 of toolbar 1 of window 1 32 | try -- look for it in nvNoteFolder with the nvNoteExtension suffix 33 | set f to POSIX file (nvNoteFolder & p & nvNoteExtension) as alias 34 | end try 35 | if f is false then -- if we didn't get a bite... 36 | try -- attempt with .txt 37 | set f to POSIX file (nvNoteFolder & p & ".txt") as alias 38 | end try 39 | end if 40 | if f is false then -- report the failure 41 | set _res to display dialog "Couldn't open " & nvNoteFolder & p & nvNoteExtension & ". Check your property settings in the script." buttons {"OK"} 42 | return 43 | end if 44 | end tell 45 | on error errNO 46 | set _res to display dialog "Couldn't open " & nvNoteFolder & p & nvNoteExtension & ". Check your property settings in the script." buttons {"OK"} 47 | return 48 | end try 49 | --Finder (open selected file) 50 | else if frontApp is "Finder" then 51 | tell application "Finder" to set flist to (get selection) 52 | else if frontApp is "Emacs" then 53 | set emacsclient to false 54 | tell application "Finder" 55 | if exists POSIX file "/usr/local/bin/emacsclient" then 56 | set emacsclient to "/usr/local/bin/emacsclient" 57 | end if 58 | end tell 59 | if emacsclient is not false then 60 | set f to do shell script emacsclient & " -e '(first (delete nil (mapcar (function buffer-file-name) (buffer-list))))' | sed 's/^\"//' | sed 's/\"$//'" as string 61 | if f is not "nil" then 62 | set f to f as POSIX file as alias 63 | else 64 | set f to false 65 | end if 66 | end if 67 | --Byword (open current document) 68 | else if frontApp is "Byword" then 69 | tell application frontApp to set f to file of document of window 1 as alias 70 | else if frontApp is "TextEdit" then 71 | tell application frontApp to set f to path of document of window 1 as POSIX file 72 | --Fallback (attempt "path of document 1" and see if current app responds) 73 | else if frontApp is "Mou" then 74 | tell application "System Events" 75 | set f to text 17 thru -1 of (value of attribute "AXDocument" of first window of process "Mou" as text) 76 | end tell 77 | else if frontApp is "TextWrangler" then 78 | tell application frontApp to set f to file of document of window 1 as alias 79 | else if frontApp is "DEVONthink Pro" then 80 | tell application "DEVONthink Pro" to set f to path of content record of think window 1 81 | else 82 | tell application "System Events" 83 | tell process frontApp 84 | try 85 | set isScriptable to has scripting terminology 86 | on error 87 | set isScriptable to false 88 | end try 89 | end tell 90 | end tell 91 | if isScriptable then 92 | try 93 | tell application frontApp to set f to POSIX file (path of document 1 of window 1) as alias 94 | end try 95 | if f is false then 96 | try 97 | tell application frontApp to set f to POSIX file (path of first document) as alias 98 | end try 99 | end if 100 | if f is false then 101 | try 102 | tell application frontApp to set f to POSIX file (text 17 thru -1 of (get URL of document 1)) as alias -- BBEdit 103 | end try 104 | end if 105 | end if 106 | end if 107 | 108 | if f is false and flist is not {} then 109 | tell application "Marked 2" 110 | activate 111 | repeat with afile in flist 112 | open (afile as alias) 113 | end repeat 114 | end tell 115 | else if f is not false then 116 | tell application "Marked 2" 117 | activate 118 | open f 119 | end tell 120 | end if 121 | end run -------------------------------------------------------------------------------- /Services/Preview Selection in Marked.workflow/Contents/document.wflow: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AMApplicationBuild 6 | 381 7 | AMApplicationVersion 8 | 2.4 9 | AMDocumentVersion 10 | 2 11 | actions 12 | 13 | 14 | action 15 | 16 | AMAccepts 17 | 18 | Container 19 | List 20 | Optional 21 | 22 | Types 23 | 24 | com.apple.cocoa.string 25 | 26 | 27 | AMActionVersion 28 | 2.0.3 29 | AMApplication 30 | 31 | Automator 32 | 33 | AMParameterProperties 34 | 35 | COMMAND_STRING 36 | 37 | CheckedForUserDefaultShell 38 | 39 | inputMethod 40 | 41 | shell 42 | 43 | source 44 | 45 | 46 | AMProvides 47 | 48 | Container 49 | List 50 | Types 51 | 52 | com.apple.cocoa.string 53 | 54 | 55 | ActionBundlePath 56 | /System/Library/Automator/Run Shell Script.action 57 | ActionName 58 | Run Shell Script 59 | ActionParameters 60 | 61 | COMMAND_STRING 62 | TMPFILE=`mktemp -t marked2-preview` 63 | cat > $TMPFILE 64 | open -a "Marked 2.app" $TMPFILE 65 | osascript -e 'tell application "Marked 2" to activate' 66 | CheckedForUserDefaultShell 67 | 68 | inputMethod 69 | 0 70 | shell 71 | /bin/bash 72 | source 73 | 74 | 75 | BundleIdentifier 76 | com.apple.RunShellScript 77 | CFBundleVersion 78 | 2.0.3 79 | CanShowSelectedItemsWhenRun 80 | 81 | CanShowWhenRun 82 | 83 | Category 84 | 85 | AMCategoryUtilities 86 | 87 | Class Name 88 | RunShellScriptAction 89 | InputUUID 90 | 4387D534-C179-4BE5-8868-B44C596823B0 91 | Keywords 92 | 93 | Shell 94 | Script 95 | Command 96 | Run 97 | Unix 98 | 99 | OutputUUID 100 | DC0483B4-0CD6-406B-A0C5-7AF3BE520A5C 101 | UUID 102 | B11DCC37-6B60-490A-9CC5-B1FCD08F7A85 103 | UnlocalizedApplications 104 | 105 | Automator 106 | 107 | arguments 108 | 109 | 0 110 | 111 | default value 112 | 0 113 | name 114 | inputMethod 115 | required 116 | 0 117 | type 118 | 0 119 | uuid 120 | 0 121 | 122 | 1 123 | 124 | default value 125 | 126 | name 127 | source 128 | required 129 | 0 130 | type 131 | 0 132 | uuid 133 | 1 134 | 135 | 2 136 | 137 | default value 138 | 139 | name 140 | CheckedForUserDefaultShell 141 | required 142 | 0 143 | type 144 | 0 145 | uuid 146 | 2 147 | 148 | 3 149 | 150 | default value 151 | 152 | name 153 | COMMAND_STRING 154 | required 155 | 0 156 | type 157 | 0 158 | uuid 159 | 3 160 | 161 | 4 162 | 163 | default value 164 | /bin/sh 165 | name 166 | shell 167 | required 168 | 0 169 | type 170 | 0 171 | uuid 172 | 4 173 | 174 | 175 | isViewVisible 176 | 177 | location 178 | 254.500000:554.000000 179 | nibPath 180 | /System/Library/Automator/Run Shell Script.action/Contents/Resources/English.lproj/main.nib 181 | 182 | isViewVisible 183 | 184 | 185 | 186 | connectors 187 | 188 | workflowMetaData 189 | 190 | serviceInputTypeIdentifier 191 | com.apple.Automator.text 192 | serviceOutputTypeIdentifier 193 | com.apple.Automator.nothing 194 | serviceProcessesInput 195 | 0 196 | workflowTypeIdentifier 197 | com.apple.Automator.servicesMenu 198 | 199 | 200 | 201 | -------------------------------------------------------------------------------- /Services/Open Current File in Marked.workflow/Contents/document.wflow: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AMApplicationBuild 6 | 381 7 | AMApplicationVersion 8 | 2.4 9 | AMDocumentVersion 10 | 2 11 | actions 12 | 13 | 14 | action 15 | 16 | AMAccepts 17 | 18 | Container 19 | List 20 | Optional 21 | 22 | Types 23 | 24 | com.apple.applescript.object 25 | 26 | 27 | AMActionVersion 28 | 1.0.2 29 | AMApplication 30 | 31 | Automator 32 | 33 | AMParameterProperties 34 | 35 | source 36 | 37 | 38 | AMProvides 39 | 40 | Container 41 | List 42 | Types 43 | 44 | com.apple.applescript.object 45 | 46 | 47 | ActionBundlePath 48 | /System/Library/Automator/Run AppleScript.action 49 | ActionName 50 | Run AppleScript 51 | ActionParameters 52 | 53 | source 54 | -- Open in Marked 2 -- Attempts to open the currently-edited document in Marked 2 for previewing -- By Brett Terpstra <http://brettterpstra.com> -- for Marked 2 <http://marked2app.com> -- Based on ideas by Lri <https://gist.github.com/1077745> -- with contributions from Donald Curtis <https://github.com/milkypostman> on run {} tell application "System Events" set frontApp to (name of first process whose frontmost is true) end tell tell application frontApp to activate set f to false set flist to {} --Marked (if Marked 2 is foreground, hide Marked 2 and end script) if frontApp is "Marked 2" then tell application "System Events" to set visible of process "Marked 2" to false return --Notational Velocity/nvALT else if frontApp is "Finder" then tell application "Finder" to set flist to (get selection) -- Emacs? else if frontApp is "Emacs" then set emacsclient to false tell application "Finder" if exists POSIX file "/usr/local/bin/emacsclient" then set emacsclient to "/usr/local/bin/emacsclient" end if end tell if emacsclient is not false then set f to do shell script emacsclient & " -e '(first (delete nil (mapcar (function buffer-file-name) (buffer-list))))' | sed 's/^\"//' | sed 's/\"$//'" as string if f is not "nil" then set f to f as POSIX file as alias else set f to false end if end if --Byword (open current document) else if frontApp is "Byword" then tell application frontApp to set f to file of document of window 1 as alias else if frontApp is "TextEdit" then tell application frontApp to set f to path of document of window 1 as POSIX file else if frontApp is "Mou" then tell application "System Events" set f to text 17 thru -1 of (value of attribute "AXDocument" of first window of process "Mou" as text) end tell else tell application "System Events" tell process frontApp try set isScriptable to has scripting terminology on error set isScriptable to false end try end tell end tell if isScriptable then try tell application frontApp to set f to POSIX file (path of document 1 of window 1) as alias end try if f is false then try tell application frontApp to set f to POSIX file (path of first document) as alias end try end if if f is false then try tell application frontApp to set f to POSIX file (text 17 thru -1 of (get URL of document 1)) as alias -- BBEdit end try end if end if end if if f is false and flist is not {} then tell application "Marked 2" activate repeat with afile in flist open (afile as alias) end repeat end tell else if f is not false then tell application "Marked 2" activate open f end tell end if end run 55 | 56 | BundleIdentifier 57 | com.apple.Automator.RunScript 58 | CFBundleVersion 59 | 1.0.2 60 | CanShowSelectedItemsWhenRun 61 | 62 | CanShowWhenRun 63 | 64 | Category 65 | 66 | AMCategoryUtilities 67 | 68 | Class Name 69 | RunScriptAction 70 | InputUUID 71 | BF1A33C8-AC86-4E27-BCDF-032E82335A97 72 | Keywords 73 | 74 | Run 75 | 76 | OutputUUID 77 | 481CDC65-D777-4FBC-9404-11D2149BE37F 78 | UUID 79 | 0D994D77-D1BA-48EB-82C3-F43CA91236E2 80 | UnlocalizedApplications 81 | 82 | Automator 83 | 84 | arguments 85 | 86 | 0 87 | 88 | default value 89 | on run {input, parameters} 90 | 91 | (* Your script goes here *) 92 | 93 | return input 94 | end run 95 | name 96 | source 97 | required 98 | 0 99 | type 100 | 0 101 | uuid 102 | 0 103 | 104 | 105 | isViewVisible 106 | 107 | location 108 | 254.500000:554.000000 109 | nibPath 110 | /System/Library/Automator/Run AppleScript.action/Contents/Resources/English.lproj/main.nib 111 | 112 | isViewVisible 113 | 114 | 115 | 116 | connectors 117 | 118 | workflowMetaData 119 | 120 | serviceInputTypeIdentifier 121 | com.apple.Automator.nothing 122 | serviceOutputTypeIdentifier 123 | com.apple.Automator.nothing 124 | serviceProcessesInput 125 | 0 126 | workflowTypeIdentifier 127 | com.apple.Automator.servicesMenu 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Marked Bonus Pack 2 | 3 | The Marked Bonus Pack is a collection of scripts, commands, services, and 4 | documentation. Some work with multiple editors, some are specific to certain 5 | editors. The Services will generally work with any editor that has the necessary 6 | capabilities. The rest are organized in folders based on the application they 7 | work with. 8 | 9 | These items work with [Marked 2](http://marked2app.com). If you need support for 10 | the original version of Marked, you will need to download [Marked Bonus Pack 11 | 1.5](https://github.com/kotfu/marked-bonus-pack/releases/tag/v1.5) 12 | 13 | ## Works With Marked 14 | 15 | Some applications work with Marked out of the box and don't require you to 16 | install anything else. These applications take advantage of the Marked 17 | [Streaming Preview](https://marked2app.com/help/Streaming_Preview.html) feature. 18 | This feature requires developers to implement Marked support in their 19 | application. Some apps will have a Preview command to manually send updates to 20 | Marked, others will automatically update without any interaction from the user. 21 | 22 | ### Drafts 23 | 24 | [Drafts for Mac](https://getdrafts.com/) includes support for Streaming Preview, 25 | but you must enable it: 26 | 27 | - Open Drafts 28 | - Click on the **Drafts > Preferences** menu (or press ⌘,) 29 | - Click on the `General` tab 30 | - Select the `Enable Marked App Streaming Preview support` checkbox. 31 | - Click the `Open Marked` button to launch Marked and open the `Streaming Preview` window 32 | - Close the Drafts Preferences window 33 | 34 | Now you have a live Marked preview that updates as you type in Drafts. 35 | 36 | Tip: You can re-open the `Streaming Preview` window in Marked by clicking the 37 | **Preview > Streaming Preview** menu. 38 | 39 | ### nvALT 40 | 41 | Enable the Streaming Preview in [nvALT](https://brettterpstra.com/projects/nvalt/) 42 | by selecting the **Preview > Streaming Preview in Marked** menu option. 43 | 44 | ### The Archive 45 | 46 | [The Archive](https://zettelkasten.de/the-archive/) includes support for 47 | Streaming Preview. Choose the **Note > Stream Preview to Marked** menu option to 48 | enable. The Marked preview updates as you type, no saving required. 49 | 50 | 51 | ## Installation and Usage 52 | 53 | If you aren't familiar with GitHub, click on the green button that says `Code` 54 | at the top of this page and then choose `Download Zip`. Unzip the file on your 55 | computer. 56 | 57 | If you are familiar with GitHub, you know what to do. 58 | 59 | For some of the installation targets listed below — specifically 60 | __Services__, __BBEdit__, __Sublime Text__, and __iA Writer__ — you can use 61 | the provided 62 | [install](./install) script. 63 | 64 | ### Services 65 | 66 | Put the Services in `~/Library/Services`, where `~` is your user's home folder. 67 | If you want hotkeys for the services, assign them in **System 68 | Preferences > Keyboard > Shortcuts > Services**. 69 | 70 | ### BBEdit 71 | 72 | Place `BBEdit/Open in Marked.applescript` in `~/Library/Application Support/BBEdit/Scripts/`. 73 | Use from the Script menu bar item while editing a Markdown document (must be 74 | saved first). You can assign a keyboard shortcut in BBEedit **Preferences > Menus 75 | & Shortcuts**. 76 | 77 | ### TextMate 78 | 79 | Double-click on the `Marked 2` bundle to open it in TextMate's Bundle Editor. 80 | You can access the preview commands using the ⌃⌥M keyboard 81 | shortcut. There are two of these commands, one previews the current document and 82 | will watch the associated file for future changes, the other previews the 83 | current selection using a temporary file. The latter will not update 84 | automatically. 85 | 86 | ### Sublime Text 87 | 88 | Copy the `Marked 2.sublime-build` file to `~/Library/Application Support/Sublime 89 | Text 3/Packages/User/`. It will show up in the **Build Systems** section of the 90 | **Tools** menu in Sublime. When selected, pressing ⌘B will open the current file 91 | in Marked for preview. Once opened, changes to the file will be tracked 92 | automatically by Marked. 93 | 94 | (This extension will also work with Sublime Text 2. Just copy 95 | `Marked 2.sublime-build` to 96 | `~/Library/Application Support/Sublime Text 2/Packages/User/`.) 97 | 98 | ### Vim 99 | 100 | Via [A Whole Lot of Bollocks](http://captainbollocks.tumblr.com/post/9858989188/linking-macvim-and-marked-app). 101 | Add the following to your .vimrc file: 102 | 103 | :nnoremap m :silent !open -a Marked\ 2.app '%:p' 104 | 105 | **\m** (or your preferred leader) will now open the current file in Marked. 106 | 107 | From [dixius99](https://github.com/dixius99): 108 | 109 | You may prefer `:Marked` instead of using the leader key to launch Marked. To do that, 110 | add the following to your .vimrc: 111 | 112 | command Marked :silent !open -a Marked\ 2.app '%:p' 113 | 114 | The word right after "command" is what triggers the action. It can be anything 115 | you want, but has to start with a capital letter. 116 | 117 | ### iA Writer 118 | 119 | Via [stephenhowells](https://gist.github.com/stephenhowells/4599997): 120 | 121 | Copy `iAWriter/Open in Marked.applescript` to `~/Library/Scripts/Applications/iA 122 | Writer/`. Run by clicking the **Script > iA Writer > Open in Marked** menu. 123 | 124 | ### Emacs 125 | 126 | Via [Barry](http://spacebeast.com/blog/) 127 | 128 | Install the `dot.emacs.txt` file in one of the following ways (depending on how 129 | you have configured your emacs startup): 130 | 131 | 1. Append the contents of `dot.emacs.txt` to `~/.emacs` 132 | 2. Append the contents of `dot.emacs.txt` to `~/.emacs.d/init.el` 133 | 3. Copy `dot.emacs.txt` to `~/.emacs.d/marked2.el` and ensure it is loaded by `~/.emacs.d/init.el` 134 | 135 | See 136 | [The Emacs Initialization File](http://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html) 137 | for more information about emacs startup. 138 | 139 | Once installed, restart Emacs. Press **Control-C m** to preview the file 140 | associated with the current buffer in Marked 2. 141 | 142 | ### Visual Studio Code 143 | 144 | This project does not contain anything to help you integrate with [Visual Studio 145 | Code](https://code.visualstudio.com/). However, Fabian Morón Zirfas has created 146 | an [Open in Marked 147 | Extension](https://marketplace.visualstudio.com/items?itemName=fmoronzirfas.open-in-marked). 148 | Once the extension is installed, you can open the current file in Marked 2 by 149 | typing ⇧⌘P and then typing `marked` to narrow the list of commands, and then 150 | selecting "Open In Marked 2". 151 | 152 | To bind it to a keyboard shortcut, select the **Code > Preferences > Keyboard Shortcuts** 153 | menu to open the keyboard shortcuts editor. Type `marked` to narrow the list 154 | of commands, and then double-click on "Open in Marked 2". Type the keyboard shortcut 155 | you want, and press **Return**. 156 | 157 | See [Key Bindings for Visual Studio Code](https://code.visualstudio.com/docs/getstarted/keybindings) 158 | for more information on binding shortcuts to commands. 159 | 160 | ### AppleScript 161 | 162 | There's one AppleScript included that performs essentially the same function as 163 | the Open in Marked Service, but with some special accommodations for [Notational 164 | Velocity](http://notational.net/) and 165 | [nvALT](http://brettterpstra.com/project/nvalt/). In order to use it, two 166 | configuration variables need to be edited at the top of the script. Open the 167 | .applescript file in AppleScript Editor and modify the `property` lines at the 168 | top, then save it as a compiled script (scpt) file. You can then run it from the 169 | AppleScript menu (enabled in the AppleScript Editor preferences), or from a 170 | hotkey-capable application like 171 | [FastScripts](http://www.red-sweater.com/fastscripts/). 172 | 173 | ### Watchers 174 | 175 | Marked version 1 required some watcher scripts to work with Scrivener and 176 | MarsEdit. Marked 2 has built in support for these applications, and no watcher 177 | scripts are required. 178 | 179 | More info: 180 | 181 | ### Notes: 182 | 183 | The easiest way to use these scripts is to put them in a convenient folder (I 184 | use `~/scripts`) and run `chmod a+x path/to/script.rb` to make them executable. 185 | You can then just type the path and script name and hit Enter (e.g. 186 | `~/scripts/everwatch.rb`). They will run and watch for changes in their specific 187 | application until you cancel the command by typing `Control-c`. 188 | 189 | The scripts will create a file in your home directory (modifiable in the script) 190 | called 'Marked Preview.md'. Open that file in Marked; Marked will watch that 191 | file for changes that the scripts make. 192 | 193 | You can create LaunchAgents for any of these and run them automatically in the 194 | background if you know what you're doing. If you don't, you can still use an app 195 | like [Lingon](http://www.peterborgapps.com/lingon/) to do it. 196 | 197 | #### Evernote 198 | 199 | To keep the 'Marked Preview.md' file synced with whatever note you're currently 200 | editing in Evernote, start the script by running `~/path/to/everwatch.rb` in 201 | Terminal. The script watches for changes to timestamps on any directory in 202 | Evernote's data folder. This shouldn't need to be adjusted. To update Marked, 203 | you'll need to have "~/Marked Preview.md" open and then hit "Command-S" in your 204 | Evernote note. The autosave on Evernote will work, but it takes longer. 205 | 206 | The HTML of the note is captured via AppleScript and run through `textutil` to 207 | remove the HTML formatting. This means that embedded images won't come through, 208 | but those probably would have broken anyway. The script is specifically 209 | expecting you to write your notes in Markdown. If you're not, I'm not sure why 210 | you'd want a Marked preview anyway. Inline HTML works, but you have to watch 211 | your quote marks very carefully. Evernote likes to convert the single and double 212 | quote marks you type into "smart quotes", which Marked doesn't interpret as 213 | HTML. 214 | 215 | This watcher will not reliably if you have multiple Evernote user id's. 216 | 217 | Even with "Command-S" there's still a 4-5 second delay on the update, as it 218 | takes a bit for Evernote to write out to the file, the script to poll through 219 | and notice the change, the content to be pulled via AppleScript and written to 220 | the preview file and then for Marked to pick up on the change there. Considering 221 | all of that, 4-5 seconds isn't too bad. If someone can think of a faster way, 222 | I'm certainly open to it. 223 | 224 | #### Notational Velocity/nvALT 225 | 226 | If you store your notes as plain text files in NV/nvALT, you can just open the 227 | notes folder in Marked 2 and it will always display a preview of the 228 | most-recently edited file. 229 | 230 | Watcher script: 231 | 232 | If you're using [Notational Velocity][nv] (or my fork, [nvALT][nvalt]), you can 233 | tell it to save your notes as text files on your drive. This script will watch 234 | these text files for updates, then display the contents of the most 235 | recently-edited note. It's a workable solution, at least until I get better 236 | integration worked into nvALT directly. 237 | 238 | You need to configure the script to point to your chosen folder for note 239 | storage, and if you're using any unique extension, you'll need to add to or 240 | modify the list in the script. It should be pretty obvious what needs to be set 241 | if you look at the top of the script. 242 | 243 | [nv]: http://notational.net 244 | [nvalt]: http://brettterpstra.com/projects/nvalt 245 | 246 | ## Running multiple Custom Pre/Processors 247 | 248 | If you use Marked's Custom Processor and/or Preprocessor functionality, you may want 249 | to check out [Conductor](https://github.com/ttscoff/marked-conductor "ttscoff/marked-conductor"), 250 | which allows you to run different processors based on natural language conditions. For example, 251 | run one custom (pre)processor for Obsidian notes, a different one for blog posts, and 252 | another one for GitHub READMEs. There's a sample config available at 253 | [github.com/ttscoff/conductor-config/](https://github.com/ttscoff/conductor-config/). 254 | --------------------------------------------------------------------------------