Repository: kotfu/marked-bonus-pack
Branch: main
Commit: 936350ff9d6f
Files: 17
Total size: 36.7 KB
Directory structure:
gitextract_9j2oj9ut/
├── AppleScript/
│ └── OpenInMarked.applescript
├── BBEdit/
│ └── Open in Marked.applescript
├── Emacs/
│ └── dot.emacs.txt
├── README.md
├── Services/
│ ├── Open Current File in Marked.workflow/
│ │ └── Contents/
│ │ ├── Info.plist
│ │ └── document.wflow
│ └── Preview Selection in Marked.workflow/
│ └── Contents/
│ ├── Info.plist
│ └── document.wflow
├── Sublime/
│ └── Marked 2.sublime-build
├── TextMate/
│ └── Marked 2.tmbundle/
│ ├── Commands/
│ │ ├── Open in Marked 2.tmCommand
│ │ ├── Preview Selection in Marked 2.tmCommand
│ │ └── Strip Header IDs.tmCommand
│ └── info.plist
├── Watchers/
│ ├── everwatch.rb
│ └── nvwatch.rb
├── iAWriter/
│ └── Open in Marked.applescript
└── install
================================================
FILE CONTENTS
================================================
================================================
FILE: AppleScript/OpenInMarked.applescript
================================================
-- Open in Marked 2
-- Attempts to open the currently-edited document in Marked 2 for previewing
-- Based on ideas by Lri <https://gist.github.com/1077745>
-- with contributions from Donald Curtis <https://github.com/milkypostman>
---NV/nvALT configuation---------------------------------------------------
-- * Set NV/nvALT to store text files to disk
-- * Enter the full UNIX/POSIX path to your notes folder in nvNoteFolder
-- * Enter your default file extension (.txt,.md,etc.) in nvNoteExtension
-- It won't always work, but it will try. It's a temporary hack;
-- nvALT will soon have an AppleScript command to access the file directly.
property nvNoteFolder : "/Users/username/pathtonotes/" -- include trailing slash
property nvNoteExtension : ".md" -- include leading dot
---------------------------------------------------------------------------on run {}
tell application "System Events"
set frontApp to (name of first process whose frontmost is true)
end tell
set f to false
set flist to {}
--Marked 2 (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 "Notational Velocity") or (frontApp is "nvALT") then
try
tell application "System Events" to tell process frontApp
-- Grab the text in the search field, hopefully this will be the filename
set p to value of text field 1 of group 1 of toolbar 1 of window 1
try -- look for it in nvNoteFolder with the nvNoteExtension suffix
set f to POSIX file (nvNoteFolder & p & nvNoteExtension) as alias
end try
if f is false then -- if we didn't get a bite...
try -- attempt with .txt
set f to POSIX file (nvNoteFolder & p & ".txt") as alias
end try
end if
if f is false then -- report the failure
set _res to display dialog "Couldn't open " & nvNoteFolder & p & nvNoteExtension & ". Check your property settings in the script." buttons {"OK"}
return
end if
end tell
on error errNO
set _res to display dialog "Couldn't open " & nvNoteFolder & p & nvNoteExtension & ". Check your property settings in the script." buttons {"OK"}
return
end try
--Finder (open selected file)
else if frontApp is "Finder" then
tell application "Finder" to set flist to (get selection)
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
--Fallback (attempt "path of document 1" and see if current app responds)
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 if frontApp is "TextWrangler" then
tell application frontApp to set f to file of document of window 1 as alias
else if frontApp is "DEVONthink Pro" then
tell application "DEVONthink Pro" to set f to path of content record of think window 1
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
================================================
FILE: BBEdit/Open in Marked.applescript
================================================
-- Place in ~/Library/Application Support/BBEdit/Scripts
-- Use from the Script menu bar item while editing a Markdown document (must be saved first)
-- Assign a shortcut key in BBEedit Preferences->Menu Items
tell application "BBEdit" to set mdFile to file of document of window 1
tell application "Marked 2"
activate
open mdFile
end tell
================================================
FILE: Emacs/dot.emacs.txt
================================================
(defun markdown-preview-file ()
"use Marked 2 to preview the current file"
(interactive)
(shell-command
(format "open -a 'Marked 2.app' %s"
(shell-quote-argument (buffer-file-name))))
)
(global-set-key "\C-cm" 'markdown-preview-file)
================================================
FILE: README.md
================================================
# Marked Bonus Pack
The Marked Bonus Pack is a collection of scripts, commands, services, and
documentation. Some work with multiple editors, some are specific to certain
editors. The Services will generally work with any editor that has the necessary
capabilities. The rest are organized in folders based on the application they
work with.
These items work with [Marked 2](http://marked2app.com). If you need support for
the original version of Marked, you will need to download [Marked Bonus Pack
1.5](https://github.com/kotfu/marked-bonus-pack/releases/tag/v1.5)
## Works With Marked
Some applications work with Marked out of the box and don't require you to
install anything else. These applications take advantage of the Marked
[Streaming Preview](https://marked2app.com/help/Streaming_Preview.html) feature.
This feature requires developers to implement Marked support in their
application. Some apps will have a Preview command to manually send updates to
Marked, others will automatically update without any interaction from the user.
### Drafts
[Drafts for Mac](https://getdrafts.com/) includes support for Streaming Preview,
but you must enable it:
- Open Drafts
- Click on the **Drafts > Preferences** menu (or press ⌘,)
- Click on the `General` tab
- Select the `Enable Marked App Streaming Preview support` checkbox.
- Click the `Open Marked` button to launch Marked and open the `Streaming Preview` window
- Close the Drafts Preferences window
Now you have a live Marked preview that updates as you type in Drafts.
Tip: You can re-open the `Streaming Preview` window in Marked by clicking the
**Preview > Streaming Preview** menu.
### nvALT
Enable the Streaming Preview in [nvALT](https://brettterpstra.com/projects/nvalt/)
by selecting the **Preview > Streaming Preview in Marked** menu option.
### The Archive
[The Archive](https://zettelkasten.de/the-archive/) includes support for
Streaming Preview. Choose the **Note > Stream Preview to Marked** menu option to
enable. The Marked preview updates as you type, no saving required.
## Installation and Usage
If you aren't familiar with GitHub, click on the green button that says `Code`
at the top of this page and then choose `Download Zip`. Unzip the file on your
computer.
If you are familiar with GitHub, you know what to do.
For some of the installation targets listed below — specifically
__Services__, __BBEdit__, __Sublime Text__, and __iA Writer__ — you can use
the provided
[install](./install) script.
### Services
Put the Services in `~/Library/Services`, where `~` is your user's home folder.
If you want hotkeys for the services, assign them in **System
Preferences > Keyboard > Shortcuts > Services**.
### BBEdit
Place `BBEdit/Open in Marked.applescript` in `~/Library/Application Support/BBEdit/Scripts/`.
Use from the Script menu bar item while editing a Markdown document (must be
saved first). You can assign a keyboard shortcut in BBEedit **Preferences > Menus
& Shortcuts**.
### TextMate
Double-click on the `Marked 2` bundle to open it in TextMate's Bundle Editor.
You can access the preview commands using the ⌃⌥M keyboard
shortcut. There are two of these commands, one previews the current document and
will watch the associated file for future changes, the other previews the
current selection using a temporary file. The latter will not update
automatically.
### Sublime Text
Copy the `Marked 2.sublime-build` file to `~/Library/Application Support/Sublime
Text 3/Packages/User/`. It will show up in the **Build Systems** section of the
**Tools** menu in Sublime. When selected, pressing ⌘B will open the current file
in Marked for preview. Once opened, changes to the file will be tracked
automatically by Marked.
(This extension will also work with Sublime Text 2. Just copy
`Marked 2.sublime-build` to
`~/Library/Application Support/Sublime Text 2/Packages/User/`.)
### Vim
Via [A Whole Lot of Bollocks](http://captainbollocks.tumblr.com/post/9858989188/linking-macvim-and-marked-app).
Add the following to your .vimrc file:
:nnoremap <leader>m :silent !open -a Marked\ 2.app '%:p'<cr>
**\m** (or your preferred leader) will now open the current file in Marked.
From [dixius99](https://github.com/dixius99):
You may prefer `:Marked` instead of using the leader key to launch Marked. To do that,
add the following to your .vimrc:
command Marked :silent !open -a Marked\ 2.app '%:p'
The word right after "command" is what triggers the action. It can be anything
you want, but has to start with a capital letter.
### iA Writer
Via [stephenhowells](https://gist.github.com/stephenhowells/4599997):
Copy `iAWriter/Open in Marked.applescript` to `~/Library/Scripts/Applications/iA
Writer/`. Run by clicking the **Script > iA Writer > Open in Marked** menu.
### Emacs
Via [Barry](http://spacebeast.com/blog/)
Install the `dot.emacs.txt` file in one of the following ways (depending on how
you have configured your emacs startup):
1. Append the contents of `dot.emacs.txt` to `~/.emacs`
2. Append the contents of `dot.emacs.txt` to `~/.emacs.d/init.el`
3. Copy `dot.emacs.txt` to `~/.emacs.d/marked2.el` and ensure it is loaded by `~/.emacs.d/init.el`
See
[The Emacs Initialization File](http://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html)
for more information about emacs startup.
Once installed, restart Emacs. Press **Control-C m** to preview the file
associated with the current buffer in Marked 2.
### Visual Studio Code
This project does not contain anything to help you integrate with [Visual Studio
Code](https://code.visualstudio.com/). However, Fabian Morón Zirfas has created
an [Open in Marked
Extension](https://marketplace.visualstudio.com/items?itemName=fmoronzirfas.open-in-marked).
Once the extension is installed, you can open the current file in Marked 2 by
typing ⇧⌘P and then typing `marked` to narrow the list of commands, and then
selecting "Open In Marked 2".
To bind it to a keyboard shortcut, select the **Code > Preferences > Keyboard Shortcuts**
menu to open the keyboard shortcuts editor. Type `marked` to narrow the list
of commands, and then double-click on "Open in Marked 2". Type the keyboard shortcut
you want, and press **Return**.
See [Key Bindings for Visual Studio Code](https://code.visualstudio.com/docs/getstarted/keybindings)
for more information on binding shortcuts to commands.
### AppleScript
There's one AppleScript included that performs essentially the same function as
the Open in Marked Service, but with some special accommodations for [Notational
Velocity](http://notational.net/) and
[nvALT](http://brettterpstra.com/project/nvalt/). In order to use it, two
configuration variables need to be edited at the top of the script. Open the
.applescript file in AppleScript Editor and modify the `property` lines at the
top, then save it as a compiled script (scpt) file. You can then run it from the
AppleScript menu (enabled in the AppleScript Editor preferences), or from a
hotkey-capable application like
[FastScripts](http://www.red-sweater.com/fastscripts/).
### Watchers
Marked version 1 required some watcher scripts to work with Scrivener and
MarsEdit. Marked 2 has built in support for these applications, and no watcher
scripts are required.
More info: <http://brettterpstra.com/marked-scripts-nvalt-evernote-marsedit-scrivener/>
### Notes:
The easiest way to use these scripts is to put them in a convenient folder (I
use `~/scripts`) and run `chmod a+x path/to/script.rb` to make them executable.
You can then just type the path and script name and hit Enter (e.g.
`~/scripts/everwatch.rb`). They will run and watch for changes in their specific
application until you cancel the command by typing `Control-c`.
The scripts will create a file in your home directory (modifiable in the script)
called 'Marked Preview.md'. Open that file in Marked; Marked will watch that
file for changes that the scripts make.
You can create LaunchAgents for any of these and run them automatically in the
background if you know what you're doing. If you don't, you can still use an app
like [Lingon](http://www.peterborgapps.com/lingon/) to do it.
#### Evernote
To keep the 'Marked Preview.md' file synced with whatever note you're currently
editing in Evernote, start the script by running `~/path/to/everwatch.rb` in
Terminal. The script watches for changes to timestamps on any directory in
Evernote's data folder. This shouldn't need to be adjusted. To update Marked,
you'll need to have "~/Marked Preview.md" open and then hit "Command-S" in your
Evernote note. The autosave on Evernote will work, but it takes longer.
The HTML of the note is captured via AppleScript and run through `textutil` to
remove the HTML formatting. This means that embedded images won't come through,
but those probably would have broken anyway. The script is specifically
expecting you to write your notes in Markdown. If you're not, I'm not sure why
you'd want a Marked preview anyway. Inline HTML works, but you have to watch
your quote marks very carefully. Evernote likes to convert the single and double
quote marks you type into "smart quotes", which Marked doesn't interpret as
HTML.
This watcher will not reliably if you have multiple Evernote user id's.
Even with "Command-S" there's still a 4-5 second delay on the update, as it
takes a bit for Evernote to write out to the file, the script to poll through
and notice the change, the content to be pulled via AppleScript and written to
the preview file and then for Marked to pick up on the change there. Considering
all of that, 4-5 seconds isn't too bad. If someone can think of a faster way,
I'm certainly open to it.
#### Notational Velocity/nvALT
If you store your notes as plain text files in NV/nvALT, you can just open the
notes folder in Marked 2 and it will always display a preview of the
most-recently edited file.
Watcher script:
If you're using [Notational Velocity][nv] (or my fork, [nvALT][nvalt]), you can
tell it to save your notes as text files on your drive. This script will watch
these text files for updates, then display the contents of the most
recently-edited note. It's a workable solution, at least until I get better
integration worked into nvALT directly.
You need to configure the script to point to your chosen folder for note
storage, and if you're using any unique extension, you'll need to add to or
modify the list in the script. It should be pretty obvious what needs to be set
if you look at the top of the script.
[nv]: http://notational.net
[nvalt]: http://brettterpstra.com/projects/nvalt
## Running multiple Custom Pre/Processors
If you use Marked's Custom Processor and/or Preprocessor functionality, you may want
to check out [Conductor](https://github.com/ttscoff/marked-conductor "ttscoff/marked-conductor"),
which allows you to run different processors based on natural language conditions. For example,
run one custom (pre)processor for Obsidian notes, a different one for blog posts, and
another one for GitHub READMEs. There's a sample config available at
[github.com/ttscoff/conductor-config/](https://github.com/ttscoff/conductor-config/).
================================================
FILE: Services/Open Current File in Marked.workflow/Contents/Info.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSServices</key>
<array>
<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>Open Current File in Marked</string>
</dict>
<key>NSMessage</key>
<string>runWorkflowAsService</string>
</dict>
</array>
</dict>
</plist>
================================================
FILE: Services/Open Current File in Marked.workflow/Contents/document.wflow
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AMApplicationBuild</key>
<string>381</string>
<key>AMApplicationVersion</key>
<string>2.4</string>
<key>AMDocumentVersion</key>
<string>2</string>
<key>actions</key>
<array>
<dict>
<key>action</key>
<dict>
<key>AMAccepts</key>
<dict>
<key>Container</key>
<string>List</string>
<key>Optional</key>
<true/>
<key>Types</key>
<array>
<string>com.apple.applescript.object</string>
</array>
</dict>
<key>AMActionVersion</key>
<string>1.0.2</string>
<key>AMApplication</key>
<array>
<string>Automator</string>
</array>
<key>AMParameterProperties</key>
<dict>
<key>source</key>
<dict/>
</dict>
<key>AMProvides</key>
<dict>
<key>Container</key>
<string>List</string>
<key>Types</key>
<array>
<string>com.apple.applescript.object</string>
</array>
</dict>
<key>ActionBundlePath</key>
<string>/System/Library/Automator/Run AppleScript.action</string>
<key>ActionName</key>
<string>Run AppleScript</string>
<key>ActionParameters</key>
<dict>
<key>source</key>
<string>-- 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</string>
</dict>
<key>BundleIdentifier</key>
<string>com.apple.Automator.RunScript</string>
<key>CFBundleVersion</key>
<string>1.0.2</string>
<key>CanShowSelectedItemsWhenRun</key>
<false/>
<key>CanShowWhenRun</key>
<true/>
<key>Category</key>
<array>
<string>AMCategoryUtilities</string>
</array>
<key>Class Name</key>
<string>RunScriptAction</string>
<key>InputUUID</key>
<string>BF1A33C8-AC86-4E27-BCDF-032E82335A97</string>
<key>Keywords</key>
<array>
<string>Run</string>
</array>
<key>OutputUUID</key>
<string>481CDC65-D777-4FBC-9404-11D2149BE37F</string>
<key>UUID</key>
<string>0D994D77-D1BA-48EB-82C3-F43CA91236E2</string>
<key>UnlocalizedApplications</key>
<array>
<string>Automator</string>
</array>
<key>arguments</key>
<dict>
<key>0</key>
<dict>
<key>default value</key>
<string>on run {input, parameters}
(* Your script goes here *)
return input
end run</string>
<key>name</key>
<string>source</string>
<key>required</key>
<string>0</string>
<key>type</key>
<string>0</string>
<key>uuid</key>
<string>0</string>
</dict>
</dict>
<key>isViewVisible</key>
<true/>
<key>location</key>
<string>254.500000:554.000000</string>
<key>nibPath</key>
<string>/System/Library/Automator/Run AppleScript.action/Contents/Resources/English.lproj/main.nib</string>
</dict>
<key>isViewVisible</key>
<true/>
</dict>
</array>
<key>connectors</key>
<dict/>
<key>workflowMetaData</key>
<dict>
<key>serviceInputTypeIdentifier</key>
<string>com.apple.Automator.nothing</string>
<key>serviceOutputTypeIdentifier</key>
<string>com.apple.Automator.nothing</string>
<key>serviceProcessesInput</key>
<integer>0</integer>
<key>workflowTypeIdentifier</key>
<string>com.apple.Automator.servicesMenu</string>
</dict>
</dict>
</plist>
================================================
FILE: Services/Preview Selection in Marked.workflow/Contents/Info.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSServices</key>
<array>
<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>Preview Selection in Marked</string>
</dict>
<key>NSMessage</key>
<string>runWorkflowAsService</string>
<key>NSSendTypes</key>
<array>
<string>public.utf8-plain-text</string>
</array>
</dict>
</array>
</dict>
</plist>
================================================
FILE: Services/Preview Selection in Marked.workflow/Contents/document.wflow
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AMApplicationBuild</key>
<string>381</string>
<key>AMApplicationVersion</key>
<string>2.4</string>
<key>AMDocumentVersion</key>
<string>2</string>
<key>actions</key>
<array>
<dict>
<key>action</key>
<dict>
<key>AMAccepts</key>
<dict>
<key>Container</key>
<string>List</string>
<key>Optional</key>
<true/>
<key>Types</key>
<array>
<string>com.apple.cocoa.string</string>
</array>
</dict>
<key>AMActionVersion</key>
<string>2.0.3</string>
<key>AMApplication</key>
<array>
<string>Automator</string>
</array>
<key>AMParameterProperties</key>
<dict>
<key>COMMAND_STRING</key>
<dict/>
<key>CheckedForUserDefaultShell</key>
<dict/>
<key>inputMethod</key>
<dict/>
<key>shell</key>
<dict/>
<key>source</key>
<dict/>
</dict>
<key>AMProvides</key>
<dict>
<key>Container</key>
<string>List</string>
<key>Types</key>
<array>
<string>com.apple.cocoa.string</string>
</array>
</dict>
<key>ActionBundlePath</key>
<string>/System/Library/Automator/Run Shell Script.action</string>
<key>ActionName</key>
<string>Run Shell Script</string>
<key>ActionParameters</key>
<dict>
<key>COMMAND_STRING</key>
<string>TMPFILE=`mktemp -t marked2-preview`
cat > $TMPFILE
open -a "Marked 2.app" $TMPFILE
osascript -e 'tell application "Marked 2" to activate'</string>
<key>CheckedForUserDefaultShell</key>
<true/>
<key>inputMethod</key>
<integer>0</integer>
<key>shell</key>
<string>/bin/bash</string>
<key>source</key>
<string></string>
</dict>
<key>BundleIdentifier</key>
<string>com.apple.RunShellScript</string>
<key>CFBundleVersion</key>
<string>2.0.3</string>
<key>CanShowSelectedItemsWhenRun</key>
<false/>
<key>CanShowWhenRun</key>
<true/>
<key>Category</key>
<array>
<string>AMCategoryUtilities</string>
</array>
<key>Class Name</key>
<string>RunShellScriptAction</string>
<key>InputUUID</key>
<string>4387D534-C179-4BE5-8868-B44C596823B0</string>
<key>Keywords</key>
<array>
<string>Shell</string>
<string>Script</string>
<string>Command</string>
<string>Run</string>
<string>Unix</string>
</array>
<key>OutputUUID</key>
<string>DC0483B4-0CD6-406B-A0C5-7AF3BE520A5C</string>
<key>UUID</key>
<string>B11DCC37-6B60-490A-9CC5-B1FCD08F7A85</string>
<key>UnlocalizedApplications</key>
<array>
<string>Automator</string>
</array>
<key>arguments</key>
<dict>
<key>0</key>
<dict>
<key>default value</key>
<integer>0</integer>
<key>name</key>
<string>inputMethod</string>
<key>required</key>
<string>0</string>
<key>type</key>
<string>0</string>
<key>uuid</key>
<string>0</string>
</dict>
<key>1</key>
<dict>
<key>default value</key>
<string></string>
<key>name</key>
<string>source</string>
<key>required</key>
<string>0</string>
<key>type</key>
<string>0</string>
<key>uuid</key>
<string>1</string>
</dict>
<key>2</key>
<dict>
<key>default value</key>
<false/>
<key>name</key>
<string>CheckedForUserDefaultShell</string>
<key>required</key>
<string>0</string>
<key>type</key>
<string>0</string>
<key>uuid</key>
<string>2</string>
</dict>
<key>3</key>
<dict>
<key>default value</key>
<string></string>
<key>name</key>
<string>COMMAND_STRING</string>
<key>required</key>
<string>0</string>
<key>type</key>
<string>0</string>
<key>uuid</key>
<string>3</string>
</dict>
<key>4</key>
<dict>
<key>default value</key>
<string>/bin/sh</string>
<key>name</key>
<string>shell</string>
<key>required</key>
<string>0</string>
<key>type</key>
<string>0</string>
<key>uuid</key>
<string>4</string>
</dict>
</dict>
<key>isViewVisible</key>
<true/>
<key>location</key>
<string>254.500000:554.000000</string>
<key>nibPath</key>
<string>/System/Library/Automator/Run Shell Script.action/Contents/Resources/English.lproj/main.nib</string>
</dict>
<key>isViewVisible</key>
<true/>
</dict>
</array>
<key>connectors</key>
<dict/>
<key>workflowMetaData</key>
<dict>
<key>serviceInputTypeIdentifier</key>
<string>com.apple.Automator.text</string>
<key>serviceOutputTypeIdentifier</key>
<string>com.apple.Automator.nothing</string>
<key>serviceProcessesInput</key>
<integer>0</integer>
<key>workflowTypeIdentifier</key>
<string>com.apple.Automator.servicesMenu</string>
</dict>
</dict>
</plist>
================================================
FILE: Sublime/Marked 2.sublime-build
================================================
{
"cmd": ["open","-a","/Applications/Marked 2.app","$file"],
"selector": "text.html.markdown"
}
================================================
FILE: TextMate/Marked 2.tmbundle/Commands/Open in Marked 2.tmCommand
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env bash
[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh"
open -a "Marked 2.app" "$TM_FILEPATH"
osascript -e 'tell application "Marked 2" to activate'
</string>
<key>input</key>
<string>none</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>^~m</string>
<key>name</key>
<string>Open in Marked 2</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>discard</string>
<key>scope</key>
<string>text.html.markdown, text.html.markdown.multimarkdown, text.html</string>
<key>uuid</key>
<string>74F0D07D-C2F7-4CDC-B08B-25024657AAF4</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
================================================
FILE: TextMate/Marked 2.tmbundle/Commands/Preview Selection in Marked 2.tmCommand
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>saveActiveFile</string>
<key>command</key>
<string>#!/usr/bin/env bash
[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh"
TMPFILE=`mktemp -t marked2-preview`
cat > $TMPFILE
open -a "Marked 2.app" $TMPFILE
osascript -e 'tell application "Marked 2" to activate'</string>
<key>input</key>
<string>selection</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>^~m</string>
<key>name</key>
<string>Preview Selection in Marked 2</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>discard</string>
<key>scope</key>
<string>text.html.markdown, text.html.markdown.multimarkdown, text.html</string>
<key>uuid</key>
<string>F0BD6911-FCB2-4B6B-AE72-19DB9F3F86D6</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
================================================
FILE: TextMate/Marked 2.tmbundle/Commands/Strip Header IDs.tmCommand
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby18 -wKU
input = STDIN.read
puts input.gsub(/(h\d) id=".*?"/,"\\1")
</string>
<key>input</key>
<string>document</string>
<key>inputFormat</key>
<string>text</string>
<key>name</key>
<string>Strip Header IDs</string>
<key>outputCaret</key>
<string>heuristic</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>replaceInput</string>
<key>scope</key>
<string>text.html</string>
<key>uuid</key>
<string>E66EE61A-0D66-44B0-899E-DA4DD9D1E20F</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
================================================
FILE: TextMate/Marked 2.tmbundle/info.plist
================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>contactEmailRot13</key>
<string>wnerq@xbgsh.arg</string>
<key>contactName</key>
<string>Jared Crapo</string>
<key>description</key>
<string>Preview markdown in [Marked 2](http://marked2app.com).</string>
<key>name</key>
<string>Marked 2</string>
<key>uuid</key>
<string>98FC9536-43B0-4A09-873E-DD7ED25C291B</string>
</dict>
</plist>
================================================
FILE: Watchers/everwatch.rb
================================================
#!/usr/bin/env ruby
# everwatch.rb by Brett Terpstra, 2011
# Watch Evernote for updates and put the current content of the editor into a preview file for Marked.app
# <http://markedapp.com>
trap("SIGINT") { exit }
watch_folder = File.expand_path("~/Library/Application Support/Evernote/data")
if not File.directory?(watch_folder)
# evernote from the app store uses a different path
# because of the sandbox rules
app_folder = File.expand_path("~/Library/Application Support/com.evernote.Evernote/accounts/www.evernote.com")
# inside app_folder, there is a folder with your evernote user id. If you
# have multiple evernote user id's this will probably break, but most
# people don't, so we should be good
watch_folder = Dir.glob("#{app_folder}/*").first
end
marked_note = File.expand_path("~/Marked Preview.md")
counter = 0
while true do # repeat infinitely
# read a list of files from the autosave folder
files = Dir.glob( File.join( watch_folder, "*") )
# build a hash of timestamps
new_hash = files.collect {|f| [ f, File.stat(f).mtime.to_i ] }
hash ||= new_hash
# check for timestamp changes since the last loop
diff_hash = new_hash - hash
if diff_hash.empty? # if there's no change
# if it's been less than 10 seconds, increment the counter
# otherwise, set it to zero and wait for new changes
counter = (counter < 10 && counter > 0) ? counter + 1 : 0
else
# store the new hash and start the 10 second change timer at 1
hash = new_hash
counter = 1
end
if counter > 0 # if the time is running
# get the contents of the post and continued editor screens
note = %x{ osascript <<APPLESCRIPT
tell application "Evernote"
if selection is not {} then
set the_selection to selection
return HTML content of item 1 of the_selection
else
return ""
end if
end tell
APPLESCRIPT}
unless note == '' # if we got something back from the AppleScript
# convert the contents to plain text
txtnote = %x{echo '<html><body>#{note}</body></html>'|textutil -stdin -convert txt -stdout}
# write the contents to the preview file
watch_note = File.new("#{marked_note}",'w')
watch_note.puts txtnote
watch_note.close
end
# sleep an extra second on changes because Marked only
# reads changes every 2 seconds
sleep 1
end
sleep 1
end
================================================
FILE: Watchers/nvwatch.rb
================================================
#!/usr/bin/env ruby
# watch.rb by Brett Terpstra, 2011
# Watch Notational Velocity notes folder for changes and
# update a preview file for Marked with most recently-modified file contents
# Requres that notes be stored as plain text and notes folder be customized below
trap("SIGINT") { exit }
watch_folder = "/Users/ttscoff/Dropbox/Notes/nvALT2.1"
watch_types = ['txt','md']
marked_note = File.expand_path("~/Marked Preview.md")
while true do # repeat infinitely
files = []
watch_types.each {|type|
files += Dir.glob( File.join( watch_folder, "**", "*.#{type}" ) )
} # collect a list of files of specified type
new_hash = files.collect {|f| [ f, File.stat(f).mtime.to_i ] } # create a hash of timestamps
hash ||= new_hash
diff_hash = new_hash - hash # check for changes
unless diff_hash.empty? # if changes were found in the timestamps
hash = new_hash
puts "changed"
note_file = File.new("#{diff_hash[0][0]}",'r') # read the latest changed file from the hash
note = note_file.read
note_file.close
watch_note = File.new("#{marked_note}",'w') # write its contents to the preview file
watch_note.puts note
watch_note.close
end
sleep 1
end
================================================
FILE: iAWriter/Open in Marked.applescript
================================================
-- Preview the currently active iA Writer document using Marked.
tell application "iA Writer"
activate
-- Ask iA Writer for it's active document.
set the_document to document 1
-- Save the document or prompt if not previously saved.
save the_document
-- If the file is saved, open it using Marked.
tell application "Marked"
set the_file to the_document's file
open the_file
-- Bring Marked forward so it becomes visible.
activate
end tell
end tell
================================================
FILE: install
================================================
#! /usr/bin/env bash
services() {
cp -r Services/* $HOME/Library/Services
}
bbedit() {
BBEDIT_DIR="$HOME/Library/Application Support/BBEdit/Scripts/"
mkdir -p "$BBEDIT_DIR"
cp "BBEdit/Open in Marked.applescript" "$BBEDIT_DIR"
}
st2() {
ST2_DIR="$HOME/Library/Application Support/Sublime Text 2/Packages/User"
mkdir -p "$ST2_DIR"
cp "Sublime/Marked 2.sublime-build" "$ST2_DIR"
}
st3() {
ST3_DIR="$HOME/Library/Application Support/Sublime Text 3/Packages/User"
mkdir -p "$ST3_DIR"
cp "Sublime/Marked 2.sublime-build" "$ST3_DIR"
}
iawriter() {
IAWRITER_DIR="$HOME/Library/Scripts/Applications/iA Writer/"
mkdir -p "$IAWRITER_DIR"
cp "iAWriter/Open in Marked.applescript" "$IAWRITER_DIR"
}
# TODO:
# Add vim support.
# Add emacs support.
if [[ -z $@ ]]
then
cat << EOF
This scriptlet automates installing *some* elements of the Marked
bonus pack. It currently supports the targets listed below, using the
corresponding keywords:
Target Keyword
-------------- --------
Services services
BBEdit. bbedit
Sublime Text 2 st2
Sublime Text 3 st3
iA Writer. iawriter
Invoke it with one or more of the keywords as arguments, e.g.
./install services st3
EOF
else
for i in $@
do
echo "Installing $i"
$i
done
fi
gitextract_9j2oj9ut/ ├── AppleScript/ │ └── OpenInMarked.applescript ├── BBEdit/ │ └── Open in Marked.applescript ├── Emacs/ │ └── dot.emacs.txt ├── README.md ├── Services/ │ ├── Open Current File in Marked.workflow/ │ │ └── Contents/ │ │ ├── Info.plist │ │ └── document.wflow │ └── Preview Selection in Marked.workflow/ │ └── Contents/ │ ├── Info.plist │ └── document.wflow ├── Sublime/ │ └── Marked 2.sublime-build ├── TextMate/ │ └── Marked 2.tmbundle/ │ ├── Commands/ │ │ ├── Open in Marked 2.tmCommand │ │ ├── Preview Selection in Marked 2.tmCommand │ │ └── Strip Header IDs.tmCommand │ └── info.plist ├── Watchers/ │ ├── everwatch.rb │ └── nvwatch.rb ├── iAWriter/ │ └── Open in Marked.applescript └── install
Condensed preview — 17 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (42K chars).
[
{
"path": "AppleScript/OpenInMarked.applescript",
"chars": 4534,
"preview": "-- Open in Marked 2\n-- Attempts to open the currently-edited document in Marked 2 for previewing\n-- Based on ideas by Lr"
},
{
"path": "BBEdit/Open in Marked.applescript",
"chars": 342,
"preview": "-- Place in ~/Library/Application Support/BBEdit/Scripts\n-- Use from the Script menu bar item while editing a Markdown d"
},
{
"path": "Emacs/dot.emacs.txt",
"chars": 252,
"preview": "(defun markdown-preview-file ()\n \"use Marked 2 to preview the current file\"\n (interactive)\n (shell-command \n (forma"
},
{
"path": "README.md",
"chars": 11169,
"preview": "# Marked Bonus Pack\n\nThe Marked Bonus Pack is a collection of scripts, commands, services, and\ndocumentation. Some work "
},
{
"path": "Services/Open Current File in Marked.workflow/Contents/Info.plist",
"chars": 432,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "Services/Open Current File in Marked.workflow/Contents/document.wflow",
"chars": 6098,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "Services/Preview Selection in Marked.workflow/Contents/Info.plist",
"chars": 525,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "Services/Preview Selection in Marked.workflow/Contents/document.wflow",
"chars": 5077,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "Sublime/Marked 2.sublime-build",
"chars": 97,
"preview": "{\n\t\"cmd\": [\"open\",\"-a\",\"/Applications/Marked 2.app\",\"$file\"],\n\t\"selector\": \"text.html.markdown\"\n}"
},
{
"path": "TextMate/Marked 2.tmbundle/Commands/Open in Marked 2.tmCommand",
"chars": 1051,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "TextMate/Marked 2.tmbundle/Commands/Preview Selection in Marked 2.tmCommand",
"chars": 1127,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "TextMate/Marked 2.tmbundle/Commands/Strip Header IDs.tmCommand",
"chars": 830,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "TextMate/Marked 2.tmbundle/info.plist",
"chars": 519,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "Watchers/everwatch.rb",
"chars": 2450,
"preview": "#!/usr/bin/env ruby\n# everwatch.rb by Brett Terpstra, 2011\n# Watch Evernote for updates and put the current content of t"
},
{
"path": "Watchers/nvwatch.rb",
"chars": 1201,
"preview": "#!/usr/bin/env ruby\n# watch.rb by Brett Terpstra, 2011\n# Watch Notational Velocity notes folder for changes and \n# updat"
},
{
"path": "iAWriter/Open in Marked.applescript",
"chars": 471,
"preview": "-- Preview the currently active iA Writer document using Marked.\ntell application \"iA Writer\"\n activate\n\t\n\t-- Ask iA Wr"
},
{
"path": "install",
"chars": 1372,
"preview": "#! /usr/bin/env bash\n\nservices() {\n cp -r Services/* $HOME/Library/Services\n}\n\nbbedit() {\n BBEDIT_DIR=\"$HOME/Libra"
}
]
About this extraction
This page contains the full source code of the kotfu/marked-bonus-pack GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 17 files (36.7 KB), approximately 11.6k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.