@gleick What if there are multiple juicy bits, each set off with the same markers?
It turns out that with runCommand
and egrep
Tinderbox can quite easily extract multiple instances of text between two markers.
Here is a demo file:
Excerpts demo.tbx (92.1 KB)
The action code in the stamps is like this:
// specify starting and ending markers -- must be different //
var startmarker="<i>";var endmarker="</i>";
// put marked up Tinderbox export string into a variable //
var str=exportedString(this,$HTMLExportTemplate);
// use regex in egrep to extract matches -- each will appear on a separate line //
$Text=$Text+"EXCERPTS \n"+runCommand("egrep -o " + "'"+ startmarker +".+"+endmarker+"'",str);
// remove starting and ending markers -- do longer one first //
$Text=$Text.replace(endmarker,"").replace(startmarker,"");
Select the container folder containing marked up notes and run a stamp. The excerpts from the children notes will be placed in the text of the container note. The stamps can also be run on an individual note, in which case the excerpts will be appended to the existing text of that note.
startmarker
and endmarker
can be changed as needed. In the demo file I’ve tried italics, bold, and arbitrary starting marker of &&
ending marker of &&&
. I find it much easier to select text and hit command-i (or command-b) than insert special markers.
This is more concise than the AppleScript upthread. But it was much fussier to debug. Plus AppleScript can be placed in the Script Menu and easily reused with other Tinderbox files without messing around with copying stamps, etc. AppleScript deserves more respect around here.
Both approaches require the built-in HTML template to be present (File > Built-in Templates > HTML).