Suggestions on Extracting Highlights + Bold Text + Italic Text from $Text of a note

Ah! I’m a Google Chrome user. The popup you show above only triggers when you are using Safari, it turns out. You learn something new every day. Thanks!

Didn’t know that! Anyway, it seems as if Shortcuts can be a useful tool for inter-app integration with Tinderbox.

Hi @sumnerg Sorry to bother you, I tried to figure this out myself. If I wanted to add the values of the attribute $Contact to the highlight output how would I do this? Also, how would I have TBX produce a note with the selected highlighted values? I could not figure out how to successfully modify our action code. Finally, if I wanted each highlight individually separated by a ### so that I could parse them into individual notes, how would I do this?

@satikusala This shortcut demonstrates one way to do the things you are trying to do. For simplicity it handles yellow highlights only.

One advantage of doing this in a Shortcut instead of internally within a Tinderbox document is that it can easily be used for other Tinderbox documents too. You can, for example, pin it in the Menu Bar or elsewhere.

Screen Shot 2022-06-03 at 11.29.46 PM

3 Likes

This is VERY cool. I got it working. Do you have some recommendations on how to learn apple script and this new shortcut method? Now that I see this, I see the potential. What I want to do is to have Tinderbox create a new child note for each highlighted element in the text.

I’ve figured out that I don’t need the Contact after all, as I can add that through an $OnAdd when the new note is created.

What I can’t figure out is how to pass the value of the highlighted note’s color, e.g., “yellow” back to a Tinderbox attribute “$HLcolor” and to have the script create an individual child for each of the highlights. Let’s just stick with yellow for now. The same pattern can work for other colors.

-- in your general script
set theHighlight to "yellow" 

tell application "Tinderbox 9"
   tell front document -- assumes target TBX is active TB doc 
      set value of (attribute of myNote named "HLColor") to theHighlight
   end tell
end tell

For the wider point, you want to pass a list of highlight colours to your TBX and store that—perhaps in your TBXConfig note. Then in in action code (or via AppleScript) you iterate that list to make a child per list value.

Here’s a link to a simple demo. My test results looks something like this:

Using Shortcuts to string together little bits of AppleScript (or JavaScript), some calling little bits of Tinderbox Action Code, looks to have a lot of potential.

There are tons of Shortcuts examples online and of course AppleScript examples. But documentation specific to Tinderbox doesn’t exist. Examples like this are the documentation. There is no substitute for just trying different things. It turns out to be a lot easier than I would have thought.

1 Like

You, sir, are Amazing! This is perfect. I got it working with all three colors and am now passing the color back to the attribute. I’ve also figured out how to only create notes for the colors that exist. Very cool! here is the shortcut (NOTE: You have to use Safari to download the shortcut; the link won’t work in Chrome). The shortcut creates a new note with the name “new note.” I then have an edict that updates that note name:

if($Name="new note"){$Name="HL "+$Text.substr(0,25)+"...";};
$EdictDisabled=true;

Agreed. I’ve tried to start some here but I’ve no idea what a complete set of docs for this would look like and I’m hardly expert with AppleScript.

In Apple’s ‘Script Editor’ app, File ▸ Open Dictionary command (⌘+⇧+O) offers a access to per-app dictionaries, those not the macOS tends to not update it’s help datacase when the app is updated:

Opening Tinderbox v9.2.1’s AppleScript dictionary we get this:

There’s lots of info, but in truth of least use to those in most need of it. IOW, it’s more use of a reference once you know what you are doing.

Documenting everything one can do in AppleScript is an endless task, and almost as much for AppleScript + Tinderbox. Like action script a task is a combination of various operators and some understanding of data types, type coercion and variables. My understanding is AppleScript was intended to allow the user to write in ‘plain English’ and the OS would sort out the ‘code’ implied. Indeed, action code in Tinderbox had something of a similar aim (q.v. optional quoting of strings, optional attribute $-prefixes, etc.). The Achilles hell of this approach is written English is anything but unambiguous in meaning. Thus regularly ‘hilarity ensues’ when AppleScript tries to compile code.

I do feel this aTbRef page could be improved. As its author, I’m open to practical, actionable, suggestions (not “better documentation”) for such an improvement. For instance, what are the key Tinderbox-related actions that are missing or are insufficiently detailed? By all means address that in a new, separate, forum thread

†. Sorry, this is an English-language-centric trope, originating at least back in the 16C, being added to plays and stories as an ending, i.e. implying humours events then occur as/after the curtain falls. The nature of irony in (British) English means that it now also means an unexpected, as in unwanted, outcome occurs. [Humour doesn’t often translate well]

1 Like