Preview your Markdown notes using Marked

Have you ever wished you could write in Tinderbox, and preview your notes using Marked? Now you can!

This document demonstrates how. You can find the main action code in Preview in Marked.

To use it, make sure you have Marked installed on your machine. Then enable the MyBoolean checkbox above. This triggers an edict which does the following:

  1. It creates a temporary file and writes the note $Text to the file
  2. It checks to see if Marked is previewing the temp file. If not, it tells Marked to preview it.

Now change the note content. When the edict runs, Marked will refresh the note preview.

The simplest way to re-trigger the edict is to command-tab away from Tinderbox, and then command-tab back to it.

(It seems as though Tinderbox doesn’t trigger an edict run when the $Text changes)

Implementation notes

If you close the Marked preview window, it won’t come back automatically. This is because the action code uses lsof to determine whether the file is open, and Marked doesn’t release the file until it quits completely. So, to get the preview window back, you have to quit Marked.

I’ve used $MyString and $MyBoolean so that this example document will work out of the box (assuming you have Marked installed). You may want to change the attribute names.

The action code only writes $Text to the temp file, but you could get more sophisticated and use exportedString().

Try it out: marked preview.tbx (64.6 KB)

4 Likes

Thank you for this, Pat. Very nice :clap::clap::clap:

For several years I had published Clarify demo for an alternate way of using Marked with Tinderbox. Unfortunately Clarify is dead, but here is a .pdf explaining the method, which is simple.

This doc is written for Tinderbox 6 – nothing changed in Tinderbox 7 to modify the method. Merely export text that utilizes MultiMarkdown syntax (e.g., table markup is accepted) to a text file. Open that exported text file in Marked, and from that point forward any new export updates to the same file are reflected in Marked. The beauty of Marked is that it watches files and updates its preview accordingly. The usual approach is to put Marked and Tinderbox in side-by-side horizontal windows – Tinderbox on top, Marked on the bottom.

When I have a document that I need to get from Tinderbox to Word or Pages, I create it using MultiMarkdown in Tinderbox, preview in Marked, tweak as necessary, then export the preview from Marked to Word or Pages or PDF.

2 Likes

Awesome @pat That’s great and really does help getting closer to a streamlined writing workflow (at least for me). It’s a fine contribution to the things we’ve been already discussing here in this forum.

What do you think: Is it possible to go one step further and have Marked.app display several Tinderbox-notes at the same time?

We know of the method of including the text of child-notes through code-lines like ^text(notename01) and ^text(notename02). But that is not going to work here in this Markdown-Scenario.

So, @pat, could you think of a way of amending the code you kindly provided to do that?

Cheers!

The method I posted above, based on standard Tinderbox text exporting, can deal with one, a container, or a selection of notes. Merely select the notes you want to export (does not have to be a contiguous selection) and use File > Export > as Text and set the export as follows:

image

Export to a file whose extension is .md or .markdown, and drag that to Marked’s icon. From that point forward, you can continue to export the same select or others to the same file, and Marked will update its preview. No other coding, prototypes, or anything necessary.

So I guess there are two interpretations of “displaying several notes at the same time.” Fortunately, I have both covered.

First, to display several notes separately (in their own Marked windows), just check the $MyBoolean box on multiple notes. They’ll each open in separate windows in Marked – though on my machine they overlap, so I have to move one window out of the way to see them both.

Yep that one is a bit trickier. There’s a bit of incompatibility between Markdown formatting and $HTMLMarkupText (the thing that processes things like ^include^). So my solution was to enable $HTMLMarkupText for my notes – which means I lose Markdown preview inside of Tinderbox, but that’s okay because I’m using Marked to preview it anyway :slight_smile:

The changes are complex enough that think it warrants its own thread: