A note's text ($Text) can be 'exploded' (split) into a container holding a number of discrete smaller notes by specifying where Tinderbox should divide the current text. The newly created notes contain an appropriate segment of the original note, using part of the same text as the note title. The basic default behaviour is to split the source by paragraph, using the paragraph of text as the note's text and the first sentence of the paragraph as the note's title. However, there are a number of option, described below that control the title and content of the new notes. There will (should!) be no empty notes, such as those that might arise where two hard line returns are used as faux paragraph breaks, as these unwanted 'empty' outputs are automatically deleted as part of the Explode process. Empty notes will not be emitted for sequences of multiple paragraph breaks, i.e. sequences of greater than two breaks.
This process can be used to help with the import of data as well as for existing notes. For imports, drag, a plain text format file into an Outline or Map view, so as to create a new note. Note with that, or with a large existing note, selected in the view pane, choose Explode… from the Note menu. The option is available regardless of which pane has focus (prior to this, be aware that the Explode menu option is disabled if the input cursor is in the text pane).
Calling Note ▸ Explode presents the Explode pop-over. There are essentially three discrete sets of options to set before committing the explode.
- Defining how/where the source is split. This is defined by the top two radio buttons:
- Break at paragraphs. Breaks each paragraph into a new note (default option).
- Break at delimiter. Break on a delimiter. The input box for the delimiter is hidden when this option is not selected. The delimiter is a string of character(s) or a regular expression pattern that immediately precede the break point. Tinderbox remembers the last-used custom delimiter until the end of the current session. Use of delimiter patterns is described in more detail further below.
- Delete Delimiter. If the custom option is chosen, there is a further option to delete the delimiter string, otherwise it is retained as the end of each new note's text (as the end of the delimiter string is the per-note break). When importing date for explode and using a deliberate string for delimiter purposes it is usually best to use this sub-option to avoid importing unnecessary data.
- Selecting source of new note $Name and $Text. The Title panel settings give control of what part of each newly split note's $Text is used to form the note's title ($Name). This is done at sentence or paragraph scope. A 'sentence' is delimited by a terminating period, exclamation mark or question mark. A 'paragraph' is delimited by a line break. By default, an explode-generated note uses the whole exploded section of the source note as its own $Text and that text's first sentence as the note title.
- The scope of a new note's title can be altered:
- First Sentence. Only the first sentence of the note text forms the new title (default). From v8.8.0, when running under macOS 10.14.x or later, Explode is substantially smarter about recognising sentences. It now understands, for example, that "Dr. Perkins paid $10.00 to the U.S. Treasury." is one sentence, not five. However, if the user's current language locale doesn’t support the new sentence neural net, Tinderbox falls back to use the older sentence-end detection logic.
- First Two Sentences. The first two sentences form the new title.
- First Paragraph. Only the first paragraph is used for the new title. When importing custom data, such as lists of papers that often contain punctuation marks, this is usually the best option to choose.
- When Explode constructs a note title, the title may now extend up to 512 characters, and will include either the first line or the first $Text sentence of the new note—whichever is the best fit. If still over 512 characters the title is truncated at that point with an ellipsis. In some earlier versions pre-v5, truncation occurred at about 64 characters.
- Two tick boxes give additional control the $Text of the newly created notes. By default, both are un-ticked:
- Remove title from text. If ticked, the text used for the above choice is deleted from the new note's body text.
- Omit text. If ticked, this results in only a $Name being set for new notes and no $Text. If importing a list of data consisting only of data to form the title of new notes, this box should be ticked.
- The scope of a new note's title can be altered:
- Actions to apply to newly created notes. The Action box allows action code to be inserted that is applied to each newly exploded note by setting an $OnAdd for the 'exploded notes' container created by the process. If it is desired to apply a prototype other than the default (described above), simply set the action to set the desired prototype's name. Essentially, the default OnAdd action of the 'exploded notes' container is
$Prototype+"Exploded Notes"
unless the user adds code to the Action box. - Example preview. This panel Gives a preview of the $Name and $Text of the first exploded note. A control below the preview allows cycling through a preview of successive exploded notes.
Finally, the Explode button closes the pop-over and starts the Explode process using the choices set above. Focus remains on the exploded note. The Return keypress will act like a button press and start the Explode.
Custom delimiters
This is a either a literal string (i.e. the actual characters to match) or a regular expression pattern. For instance:
-
####
A newly exploded note will begin after each occurrence of the string'####'. The text matching is case-sensitive. -
\n
A newly exploded note will begin after new line feed character. This is also the default for this option, it is essentially the same as 'break at paragraphs' overall explode default. [More on line end character codes.] -
\r
A newly exploded note will begin after each carriage return or hard line break. -
\t
A newly exploded note will begin after each tab, e.g. for tab-delimited content pasted into a note. -
\,
A newly exploded note will begin after each comma, e.g. use for CSV content pasted into a note. -
^\d{1,4}\ ?
A newly exploded note will begin after each line starting with a sequence of between 1 and 4 numerical characters followed by zero or 1 space characters.- Delete delimiter. Only available if the 'Delimiter' option is set (default = not ticked). Tick this to remove the specified delimiter from the new exploded notes. When the delimiter is a complete line/paragraph, ensure the string used includes the line return character at the end or some output notes will have text starting with a blank line.
What results from an Explode?
The exploded (source) note itself remains unchanged and a new child container of the selected note is created, called 'exploded notes', and which contains the resulting new notes (i.e. the individual exploded notes are grandchildren of the source note). Each note contains as its text a section of the original text with the notes being titled according to the choices (described above) made before exploding. Using a secondary container for the notes might seem odd until realising this allows for the fact, more so for exploding existing notes than for new import, that the note being exploded might already have children; thus the new notes are separated from existing children of the exploded note.
Also notice that the 'exploded notes' container is added to the outline order after any pre-existing child notes for the exploded note, i.e. it is the last child (and thus easily accessible via the lastChild designator, amongst others).
The 'exploded notes' container does not inherit anything from the source note. However, the Action box allows the 'exploded notes' $OnAdd to be set afresh for each explode. Also, the 'Exploded Notes' prototype (see below) is added to the 'exploded notes' child container of the exploded source note. Either the action or the prototype can be used to read values from the parent note or to set values in the newly exploded notes.
'Exploded Notes' prototype
When a note is exploded the 'exploded notes' container has a prototype added and applied from '/Prototypes/Exploded Notes' (The /Prototypes container is created if needed before the new prototype is aded to it). Note the case sensitive spelling of the post explode container's title vs. that of the prototype's; this avoids naming collisions. By default, the only customisation of this prototype is to add $ChildCount as a Displayed Attribute. The prototype make it easy to set up things like counts and such if doing repeat explodes in the same document. This prototype can be added manually, for instance to customise it before doing an explode. By contrast, to 're-install' the default version, simply delete the any existing version of the prototype and do another explode.
Working with exploded notes
Of course, the constant name of the container holding the new notes ('exploded notes') makes it easy for agents to find and work on the new notes' actions. Be aware that unless the 'exploded notes' is cleaned up or renamed after an explode, there may be more than one container of that name. A benison of this is that it is possible to write a generic agent to act on the contents of all explode results using an $AgentQuery:
$Name(parent)=="exploded notes"
By adding a preceding descendedFrom() query argument to the above query, the scope of action can be reduced to items descended from a given container.
descendedFrom(To Do) & ($Name(parent)=="exploded notes")
This might be done because of the nature of the resulting agent action to be applied or simply to reduce agent update cycle time.
In summary:
- 'exploded notes' receives all the source note's attribute values except $Rule and $OnAdd. If the 'Exploded Notes' prototype has been altered to locally set attribute values these will be used in preference.
- Individual exploded notes do not inherit attribute values.
- Agents or manual editing of 'Exploded Text' actions should be used to apply attribute values to exploded text.
The explode action is applied after the text of the newly-created note is set, allowing the action to modify or depend on the exploded text. Explode also remembers the most recently-used delimiter, which can be convenient when using complicated regular expression delimiters.