tag:support.markedapp.com,2011-09-11:/discussions/questions/8321-bbedit-refreshMarked: Discussion 2015-04-20T22:02:19Ztag:support.markedapp.com,2011-09-11:Comment/366292502015-04-20T21:13:04Z2015-04-20T21:13:05Zbbedit refresh <div><p>Greetings is it possible to have the marked window of a open
file in bbedit refresh without the need to save the file in
bbedit?</p>
<p>Edz..</p></div>Edzardtag:support.markedapp.com,2011-09-11:Comment/366292502015-04-20T22:00:11Z2015-04-20T22:02:19Zbbedit refresh <div><p>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
this.</p>
<p>However, if you had the skills, there is a "streaming preview"
as well as a '<a>marked://preview?text=&#39</a>;
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
answer.</p>
<hr>
<p>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...</p>
<p>The streaming preview can be opened from the Marked "Preview"
menu item, or by using the <code>marked://stream/</code> 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:</p>
<pre>
<code>NSString *rawString = @"the text to be processed";
// pasteboard *must* be named 'mkStreamingPreview'
NSPasteboard* pb = [NSPasteboard pasteboardWithName:@"mkStreamingPreview"];
[pb clearContents];
[pb setString:rawString forType:(NSString*)kUTTypeUTF8PlainText];</code>
</pre>
<p>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
plugin creators.</p>
<p>The url handler is more accessible, but faulty in this case.
Docs are at <a href="http://marked2app.com/help/URL_Handler.html">http://marked2app.com/help/URL_Handler.html</a>.
The current documentation is incomplete for this command, as
elaborated below.</p>
<p>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 <code>txmt:</code> urls, but it seems to be
breaking on those now.</p>
<p>The required parameter for <code>marked://preview</code> 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
escaped.</p>
<p>This is all new, and probably not helpful, but feel free to
report issues.</p>
<p>Example command:</p>
<pre>
<code>open 'marked://preview/?text=[markdown content]&window=BBEdit%20Preview&id=com.bbedit.preview&base=[base dir for current file]'</code>
</pre>
<p>-Brett</p></div>Brett