-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial repo created from Marked Bonus Pack 1.5 in response to thread at http://support.markedapp.com/discussions/problems/52571-textmate-bundle-no-longer-works
- Loading branch information
Showing
26 changed files
with
1,448 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
-- Open in Marked | ||
-- Attempts to open the currently-edited document in Marked 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 (if Marked is foreground, hide Marked and end script) | ||
if frontApp is "Marked" then | ||
tell application "System Events" to set visible of process "Marked" 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 tool bar 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 | ||
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" | ||
activate | ||
repeat with afile in flist | ||
open (afile as alias) | ||
end repeat | ||
end tell | ||
else if f is not false then | ||
tell application "Marked" | ||
activate | ||
open f | ||
end tell | ||
end if | ||
end run |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(defun markdown-preview-file () | ||
"run Marked on the current file and revert the buffer" | ||
(interactive) | ||
(shell-command | ||
(format "open -a /Applications/Marked.app %s" | ||
(shell-quote-argument (buffer-file-name)))) | ||
) | ||
(global-set-key "\C-cm" 'markdown-preview-file) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,97 @@ | ||
marked-bonus-pack | ||
================= | ||
# Marked Bonus Pack # | ||
|
||
Helpful scripts, commands, and services that make the Marked app for OSX more useful | ||
The Marked Bonus Pack is a collection of scripts, commands and services. 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. | ||
|
||
## Installation and Usage | ||
|
||
### 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**. | ||
|
||
### TextMate | ||
|
||
Double-click on the Marked bundle to open it in TextMate's Bundle Editor. You can access the preview commands using Control-Command-M. 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. | ||
|
||
There's a third command for stripping header id's out of HTML documents. This can be done by setting "Compatibility Mode" in Marked Preferences, but this also causes other MultiMarkdown features to be disabled. To keep MultiMarkdown features and remove the auto-generated header ID's from the HTML output, use this command. | ||
|
||
### Sublime Text 2 | ||
|
||
Copy the Marked.sublime-build file to `~/Library/Application Support/Sublime Text 2/Packages/User/`. It will show up in the "Build Systems" section of the **Tools** menu in Sublime. When selected, pressing Command-B will open the current file in Marked for preview. Once opened, changes to the file will be tracked automatically by Marked. | ||
|
||
### 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.app '%:p'<cr> | ||
|
||
**\m** (or your preferred leader) will now open the current file in Marked. | ||
|
||
### Emacs ### | ||
|
||
Via [Barry](http://spacebeast.com/blog/) | ||
|
||
Add the following to your .emacs file | ||
|
||
(defun markdown-preview-file () | ||
"run Marked on the current file and revert the buffer" | ||
(interactive) | ||
(shell-command | ||
(format "open -a /Applications/Marked.app %s" | ||
(shell-quote-argument (buffer-file-name)))) | ||
) | ||
(global-set-key "\C-cm" 'markdown-preview-file) | ||
|
||
Command key is **Control-c m** | ||
|
||
### 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/). | ||
|
||
The nvALT scripts do their best to figure out the file, but don't always work. The next version of nvALT should make this a lot easier. | ||
|
||
### Watchers ### | ||
|
||
|
||
More info: <http://brettterpstra.com/marked-scripts-nvalt-evernote-marsedit-scrivener/> | ||
|
||
### Notes: | ||
|
||
For all of these scripts (except for the Scrivener Droplet app), the easiest way to use them is to put them in a convenient folder (I use `~/scripts`) and run `chmod a+x path/to/script.rb` to make them executable. With the exception of the Scrivener script (`scrivwatch.rb`), 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 (except, again, Scrivener) 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][en], 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... | ||
|
||
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. | ||
|
||
#### Scrivener | ||
|
||
This script creates a folder in your home directory called "ScrivWatcher" which contains separate previews for each document opened. There is a cache directory for conversion speedup containing text versions of all of the sections in your document. The rendered Markdown file will open on its own in Marked when the script or droplet is run, and if it's not already open in Scrivener, Scrivener will launch and open that project as well. | ||
|
||
The [Scrivener][scriv] script watches the RTF and XML files that Scrivener keeps within the project as you write. If you set Scrivener's preferences to auto-save 1 second after you stop typing, Marked will stay pretty snappy on the updates without any further intervention. The full document is compiled and displayed in the order set in the Scrivener binder. | ||
|
||
To launch the script (assuming you made the script executable as detailed at the beginning of this section), open Terminal and type `path/to/scrivwatcher.rb /path/to/YourDocument.scriv`. Example: `~/scripts/scrivwatcher.rb ~/Documents/Thesis.scriv`. The script will take it from there and run until you interrupt with `Control-c`. | ||
|
||
There is also a droplet bundled in the same folder. Running it will give you a small drop area to which you can drag a Scrivener project file (.scriv) and it will handle the rest. | ||
|
||
The files Scrivener stores are Rich Text Format, so Marked can't view their contents directly. The script runs the most recently-edited file through `textutil` to convert from RTF to text. The converted files are cached and only updated when changed, allowing large documents to preview quickly on save. | ||
|
||
#### MarsEdit | ||
|
||
Thanks to Daniel Jalkut for an assist with this one. It watches the [MarsEdit][mars] autosave folder for any changes, and then uses AppleScript to get the full contents of the editor (post *and* continued) when one is detected. Because the autosave can be a bit slow on the draw, it continues updating every second for 10 seconds, whether there's a change or not. If no more changes are detected within 10 seconds, it chills out in the background until the next one is detected. | ||
|
||
Run `marswatch.rb` to start polling for changes, open 'Marked Preview.md` from your home folder and Marked should start updating the preview automatically as you make changes in a MarsEdit post. | ||
|
||
#### Notational Velocity/nvALT | ||
|
||
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. |
18 changes: 18 additions & 0 deletions
18
Services/Open Current File in Marked.workflow/Contents/Info.plist
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?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> |
Binary file added
BIN
+68.4 KB
Services/Open Current File in Marked.workflow/Contents/QuickLook/Thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 130 additions & 0 deletions
130
Services/Open Current File in Marked.workflow/Contents/document.wflow
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
Oops, something went wrong.