Brett on 20 Apr, 2015 10:00 PM
No, Marked watches for changes in the filesystem and reads the
file that exists on the disk, not the text in memory for an unsaved
window. You could assign a keyboard shortcut to the
Markup->Preview in... command, but if the current file isn't
saved it will create a new temp window, which isn't ideal for
However, if you had the skills, there is a "streaming preview"
as well as a 'marked://preview?text='
URL handler that lets you pass text directly to a temporary window.
Everything below is advanced, and I don't know your skill level, so
if you're not a coder you'll have to accept the above as the
If you found a way to "stream" text to the url handler while
editing, you could create a more "live" preview. I haven't
experimented with this in BBEdit, but I mention it just in case
you're familiar with building BBEdit plugins...
The streaming preview can be opened from the Marked "Preview"
menu item, or by using the marked://stream/ url. It
watches a named clipboard for changes and updates instantly. This
would be the ideal solution. On changes in the document, you'd
collect the contents of the current view and post them:
NSString *rawString = @"the text to be processed";
// pasteboard *must* be named 'mkStreamingPreview'
NSPasteboard* pb = [NSPasteboard pasteboardWithName:@"mkStreamingPreview"];
[pb setString:rawString forType:(NSString*)kUTTypeUTF8PlainText];
That's ideal, but requires Cocoa API access, and I don't know if
there's an easy way to do that in BBEdit. I have this integrated in
my local dev version of nvALT and it's beautiful, but really
something that has to be incorporated by the app's dev, rather than
The issue is that opening this url will bring Marked to the
foreground. There's an 'x-success' parameter that will open a url
scheme after update, but I'm not sure if BBEdit currently has one.
It used to handle txmt: urls, but it seems to be
breaking on those now.
The required parameter for marked://preview is
'text', which creates a temporary window. Sending the same command
again creates a new temp window, but you can create a reusable
window by including 'window' and 'id' parameters. You can also
optionally specify a 'base' parameter so it knows where to find
included files and images. All values just need to be HTML
This is all new, and probably not helpful, but feel free to
open 'marked://preview/?text=[markdown content]&window=BBEdit%20Preview&id=com.bbedit.preview&base=[base dir for current file]'