The Marked 2 URL Handler
There’s an update to Marked 2 almost ready for release which has an in-app purchase option for full spelling and grammar checking. It also includes completely rewritten memory management and background processing which improves speed and stability (that part will be free to all users). Look for that soon! In the meantime…
Recent versions of Marked 2 have included a URL handler. Rather than expanding the AppleScript library immediately, I’ve focused on allowing more inclusive inter-app operability with url commands that can easily be used with launchers such as LaunchBar and Alfred, called from the command line or any script with the open command, or used as links.
The url handler can load files, send text to temporary previews, force refreshes on a single window or all windows, change the preview style, and even reposition windows.
The initial documentation is on the Marked 2 site (and in the internal help). The protocol for the handler is marked://
, followed by the command you want to call. For example, to refresh every open window from the command line or a script, you can use:
open marked://refresh/all
If you pass a ?file=
parameter with that url, you can target a specific window. While the open
command requires a full path, commands that target a window (refresh, style, etc.) only need a partial match; Marked will refresh whichever window’s filename best matches the path given.
Points of interest:
- The
open
command can accept an additionalx-success
parameter, which can call any other app that has a url handler upon completion of the command open
uses a?file=
parameter, but calling it with just a path works as well:marked://open/~/nvALT2.2
(also note that because that path is a directory, Marked will open it as a folder watcher and show the most recent file, updating as that changes)- The
paste
andpreview
commands can be used to create temporary preview windows using text from the clipboard or passed in the?text=
parameter, respectively - Most commands can include a
frame
parameter (not documented yet) which accepts 4 numbers separated by commas (orNSStringFromRect()
), defining top left corner distance from left of display, top left corner distance from top of display, window width, and window height for the target preview window- A
display
parameter can be used to force multi-display setups to target a specific monitor, numbered beginning at 0 - If the parameters also include
&framePosition=left
or&framePosition=right
, the window will be positioned to the left or right of the given frame (if possible within screen dimensions), allowing you to pass the frame of another window and have Marked move its preview based on that window’s position
- A
As an example of the url handler in action, I’ve created two simple System Services you can download below. One for previewing the clipboard in Marked, and one for selected text. Both open a temporary preview window (which you can chose to save as a permanent file if needed), and if you set up keyboard shortcuts for them, they demonstrate the usefulness and flexibility of the handler.
There are additional handlers that will be documented soon. The do
command actually allows any JavaScript to be executed within a target preview window, and there’s a Marked JavaScript API available for just about every feature of the app. Once I determine exactly what I want to expose to this command, I’ll publish documentation for that as well.
I hope that opens up some automation ideas for some of you. See the Marked 2 help for more details. I’ll be adding additional AppleScript/JavaScript support over the next few releases. First on the docket, though, is finishing a complete rewrite of the RTF system, which will facilitate much (much, much) better output for Pages, Word, and email messages.
Check out Marked 2 at marked2app.com!
Marked Selection Services v1
Download Marked Selection Services v1
Services for opening selections and clipboard contents in Marked
Published 05/29/15.
Updated 05/29/15. Changelog