Loading ...
Sorry, an error occurred while loading the content.

Script for viewing markdown in Marked

Expand Messages
  • Michael
    I wrote a little AppleScript to open Markdown documents in the Marked previewer, and thought some others might find it useful. It needs to be saved as a
    Message 1 of 2 , Jul 20 10:50 AM
    • 0 Attachment
      I wrote a little AppleScript to open Markdown documents in the Marked previewer, and thought some others might find it useful. It needs to be saved as a compiled script in the Scripts folder within the Markdown mode (while you're there, take advantage and remove the silly rot13 script that's included for some inexplicable reason).

      tell application "SubEthaEdit"
      if not (exists path of front document) then
      error "You have to save the document first"
      end if
      set docpath to the path of the front document
      end tell

      set mdFile to POSIX file docpath
      tell application "Marked" to open mdFile

      on seescriptsettings()
      return {displayName:"Preview with Marked", shortDisplayName:"Preview", keyboardShortcut:"@O", toolbarIcon:"ToolbarIconRun", inDefaultToolbar:"yes", toolbarTooltip:"Preview current document with Marked", inContextMenu:"no"}
      end seescriptsettings
    • Michael
      For reasons not entirely clear to me, the script will hang on some files (naturally, none I tested before posting about it!), with SubEthaEdit waiting for a
      Message 2 of 2 , Aug 2, 2011
      • 0 Attachment
        For reasons not entirely clear to me, the script will hang on some files (naturally, none I tested before posting about it!), with SubEthaEdit waiting for a response from Marked. Adding an <code>ignoring application responses</code> takes care of that. Sorry for any inconvenience.

        Here's the revised script:

        tell application "SubEthaEdit"
        if not (exists path of front document) then
        error "You have to save the document first"
        end if
        set docpath to the path of the front document
        end tell

        set mdFile to POSIX file docpath
        ignoring application responses
        tell application "Marked" to open mdFile
        end ignoring

        on seescriptsettings()
        return {displayName:"Preview with Marked", shortDisplayName:"Preview", keyboardShortcut:"@O", toolbarIcon:"ToolbarIconRun", inDefaultToolbar:"yes", toolbarTooltip:"Preview current document with Marked", inContextMenu:"no"}
        end seescriptsettings
      Your message has been successfully submitted and would be delivered to recipients shortly.