Tinderbox Forum

Exploding DEVONthink's Annotation Summary File

Here’s a minority opinion, providing an approach to breaking down a “Summarize Highlights” file produced by DEVONthink for a PDF annotated in that software. Specifically the markdown version of that file.

The suggested process of fiddling around with AppleScripts seemed complicated to me. Bolting 3rd pary automation onto Tinderbox just to accomplish a task that Tinderbox can already do is something I personally prefer avoiding whenever possible. I like to control action code entirely within Tinderbox.

Here’s a suggestion that uses Tinderbox’s Explode Note feature and the ability to apply actions to the exploded note:

  1. Drag the annotation summary file (markdown version) from DEVONthink to Tinderbox.
  2. Setup the Tinderbox file as shown in the attached sample:
    – add a prototype that will be applied (by the action code) to the exploded notes
    – add a “Code” note that will clean up the exploded notes, put the DEVONthink item link into the correct attribute ($ReferenceURL), put the page number into a user attribute $Page, set the $Name for each note and remove the extraneous data from the annotation note $Text.
  3. Here’s the configuration for “Explode”. Note that “Action” in the Explode dialog points to a “Code” note with the action code to do #2, above. This doesn’t have to be a Code note. The action code could be a stamp or it could be all spelled out in the Explode dialog. Or it could be a stamp called by the explode dialog with stamp("StampName");

  1. The action code is
$Page=runCommand("grep -o 'Page\s[0-9]*'",$Text);
$MyString=$Text.replace("\[.*\)"); 
$ReferenceURL=runCommand("grep -o 'x-devonthink-item://.*'",$Text).replace($MyString).replace("\)");
$Text=$Text.replace("\[Page.\d*\]\(.*");
$Text=$Text.replace("\[|\]");
$Text=$Text.replace("\(.*");
$Text=$Text.replace("# ");
if($Text.contains("\n\* ")) {$Name=$Text.substr(1,42).replace("\n\* ");} else {$Name=$Text.substr(0,50);};
$Name=$Name.replace("\n");
$Prototype="myProto";

The code works with the 10 or so Annotation Summary documents that I tested. Of course, disclaimer: not all PDFs are the same, DEVONtech could change their script at any time, and weird ASCII characters can show up in text and frustrate you.

Anyhow, as I said, this is a minority view on how to do this task. It’s not “cool” or “awesome” or whatever. Just happens to work good enough for me. Sample attached.

Test Explosion.tbx (3.4 MB)

4 Likes

This is awesome!

I wonder if it might be even simpler? grep -o looks for a regular expression and returns the line in which it occurs; I wonder if there’s a good way to do that with .contains()?

1 Like

No doubt there are dozens of regular expressions that could suffice. Simplification are always possible, and suggestions are welcome.

The “Action” in Explode is an excellent feature. Thank you for that.

1 Like