Streaming Tinderbox Note to Marked2?

I’ve no KeyboardMaestro expertise, but a quick Google found this: Menu item selecting - #2 by kcwhat - Questions & Suggestions - Keyboard Maestro Discourse. As all Tinderbox stamps are listed in the Stamps menu, you can make a stamp called “Set HTMLMarkdown” with the code:

$HTMLMarkdown=true

Now, use the above KM forum instructions to make a KM action to click the Tinderbox Stamps menu item ‘Set HTMLMarkdown’. You could use AppleScript but it seems overkill writing a custom script to replicate an interaction type already in the KM app, plus it requires no AppleScript smarts.

If this works, do let us know as validation of the idea would likely help other users.

HTH

3 Likes

As Mark says, all you need to do is assign the KM macro to the relevant menu item.

This one triggers a stamp called MD: ToggleMarkdownPreview. (It then calls another macro, but you can ignore that — it’s an old one from previous versions when there wasn’t a shortcut for the preview pane.)

You’re probably aware that a : in a Stamp name creates a submenu (here MD), so in KM you have to explicitly recognise that by choosing the submenu, then the rest of the stamp name will appear for you to select.

HTH.

4 Likes

@PaulWalters
Interesting. Do you know, is there any way to pass an exportString to Marked2?
I would like to be able to send the $Title of a note to Marked2, as well as the results of a TBX template, rather thank having to hardcode structure and expressions in the body of a note, which is appears what you’d need to do it you want to do something more complex than simply pushing out a few notes.

Also, I have one other observation: if you have notes in a container, the container needs to be epxanded. The selected notes in the outline will all show up in Marked at the same level, regardless of their heading depth.

Again, I’d be very interested if we can stream a template output, not just the selected note.

Here’s an AppleScript to act on selected notes so you don’t need to set up a stamp if you don’t want one:

tell application "Tinderbox 9"
	tell front document
		repeat with aNote in selections
			tell aNote to set value of attribute "HTMLMarkdown" to true
		end repeat
	end tell
end tell

And the equivalent in (probably bad, but it works) JavaScript for Automation:

var app = Application("Tinderbox 9");

var frontDocument = app.documents[0];

for (var i = 0; i < frontDocument.selections.length; i++) {
    var aNote = frontDocument.selections[i];
    aNote.attributes["HTMLMarkdown"].value = true;
}

This thread, in particular the explanation by @PaulWalters, has been an eye-opener!

1 Like

For Streaming Preview to work, the selected note(s) must at minimum have $HTMLMarkdown set to true. Happily the latter ensures inline export code is evaluated *i.e. not just parsing Markdown syntax. Som in $Text—not this method does not use an explicit template—`value(exportedString(…))^ would the the returned value of the action code into the $Text and thus into the (HTML/Markdown) render seen in Markdown.

Well it should: busy ATM so I’ve not run an actual test.

I don’t know about the streaming. Here it seems to work only on a note or, as @PaulWalters has illustrated, multiple selected notes (!) visible in the Text pane.

But I see Marked has Preview > Clipboard Preview. So at the very least you can direct your exported string to the clipboard to quickly get it into Marked for onward export, etc.

1 Like

Wow, Sumner, you are a genius too!
(same comment to MarkA on another thread! same kudos to many many other people: MichaelB, PaulW, Detlef and the grandmaster MarkB) :slight_smile:

It even works within container. I had 2 notes at root level and 1 note within a container and the streaming preview in Marked 2 was pppeeerrrfect

Thanks buddy.
Tom

Just tested. This works. :slight_smile:

1 Like

Actually, I was not looking for Marked to do the work, but to find a way for TBX to and to send Marked the appropriate stream. I don’t know enough about the tools to make this work. I thoroughly love the thread and your contributions here!!! Has stimulated a ton of great thought.

Anyway, @mwra’s idea above about using exportedString worked great!

1 Like

Many thanks for the confirmation.

1 Like

Could you explain briefly? Say I’ve got text in notes already. What do I do? Is the original text replaced?

Sure, see this:
TBX L - Marked and exportedString.tbx (192.9 KB)

You create a streamed report note and put this in text ^value(exportedString(tbx:Bk4JB5,"HTML page"))^. The first argument is the $Name (in quotes), $ID, or $IDString of the target document you want to stream.

See Exported String aTbRef.

As above the notes need $Markdown==true.

2 Likes

Thanks! Got it working.

In your example the exported string appears to be HTML, which Marked happily accepts.

I “markdownified” the page and item templates, disabled HTML Preview Command, and was able to stream Markdown (though then the Preview pane in Tinderbox is no longer useful).

I can select the Stream Report note to include note names as headers in the Markdown. Or just select the notes themselves if I don’t want the note names as headers in the Markdown. Nice!

Though this is not unexpected. Markdown ‘Stream Parsing’ is a different discrete form of Markdown use where you work in the main Text pane, and preview the Markdown outside Tinderbox.

Markdown support brought a lot of (unintended) complexity to Markdown and I’m working on some more detailed documentation in aTbRef on Markdown use within Tinderbox. For clarity, I don’t think Markdown is bad—indeed, this post is typed/styled using Markdown syntax—it’s just that for many Markdown doesn’t do what/how they think it does. To use Tinderbox effectively with Tinderbox, it thus helps to have correct starting assumptions—which I hope to provide in due course.

2 Likes

Ooh, thanks for this tidbit. The question was brewing in my mind and you answered it for me. I spend a lot of my time in multi-note editing these days.

1 Like

just a small cosmetic change for the AppleScript…

use:
tell application id "Cere"

instead of

tell application "Tinderbox 9"

in AppleScript. The script will then work with a version 10 of TBX too :wink:

1 Like

This is how rumours get started :wink:

2 Likes

Sure, if you wanted to have a pure markdown output, just create another template, see:
TBX L - Marked and exportedStringR2.tbx (188.6 KB)

What does “Cere” mean? Is this something specfiic to TBX?

“Cere” is the static 4-letter Apple Application identifier for (all versions of) Tinderbox.

2 Likes