I want to ask this question even though I am guessing the answer is probably a “not available in the near future.”
Would DT consider to release the “Summarize Highlights” function as a standard script in the script menu, or to add a function in DT library to get the list of highlighted texts and its page/paragraph links?
We can do a lot of useful stuff by working on those highlighted texts if such a script function is available in the DT dictionary or if we can fork from a standard script.
We’ll consider this for future releases. But you could actually already perform a script in a smart rule that is triggered On Creation and uses the conditions…
After choosing Tools > Summarize Highlights the smart rule should be triggered and could perform any actions including scripts. However, I just noticed that it doesn’t work, the menu item doesn’t trigger smart rules. 3.0.2 will fix this.
Therefore instead of executing a script to create a summary, the creation of a summary would execute a script.
The major obstacle is that I know of no way (by script or by other ways in DT) to get the highlighted texts block by block in one-go.
Summarize function produces a RTF of all highlighted texts, but if I need to split each block, I’ll need to manually add a separator between each block (the link and the cited text) in that single RTF file before using the “Split Document” function to produce the individual files in which each file is containing one block.
Anyway, this is not a pressing need, just think that it’s good to have the ability to get all blocks, in separate files, in one-go.
I have a similar suggestion in my recent post which would help this DT users working with individual blocks of text (see Improvements to Summarize Highlights)
The two key suggestions are i) a way to distinguish individual highlights and associated notes (I’ve suggested a double blank line) and ii) the inclusion of the page link for each text block rather than only in cases where the page changes number.
My understanding is that attribute runs in Apple Script parses the text steam into chunks of text with the same properties e.g. highlighted, URLs etc… which can then be used to reshape the file. What would happen with two paragraphs of text (say highlighted text from a PDF) back to back within the summary file. Are these treaded as one chunk or two ?
If you only enumerate the attribute runs, then it’s one block. But you could enumerate the paragraphs first and within each paragraph the attribute runs.
I see the corresponding paragraph Applescript function in the dictionary. I’m assuming that the properties
paragraph spacing (real) : Paragraph spacing of the text.
can be used to delimit the separations between blocks of text. Adding two spaces or other distinction between blocks would help here in the processing of the summary files as per Improvements to Summarize Highlights
It would be interesting to see a script version of Summarize Highlights. I’d love to be able to rearrange some of the elements (e.g. move the line numbers to the end the highlighted text, removing the “line” prefix).
I agree that custom formatting is an important feature.
As a stop gap, I threw together a script that converts summaries to my particular format. Editing the outputHighlight subroutine should allow you to customise the format.
As a note, the script supports joining highlights across pages by creating a highlight note with the text “JOIN”
Hope this script starts the conversation towards adding a feature to the software somehow.
If converting the function into a script is not possible, one suggestion is to add a dictionary item such as “get highlights” to get a list of highlighted texts within a selection of files (pdf+text and rtf) . However, a record-type list is perhaps more desirable: for each record in the list, the first field is the individual piece of highlighted text the second field is the current page/paragraph URL of that text. This data structure will allow users to script the list for different purposes, such as breaking down the list into multiple rtf files for simple qualitative analysis, or to approximate the function of the wonderful script “annotation and pane v3.0” without needing to worry about the future compatibility.
Just an idea. I don’t think this is a high priority request.
OK, I got curious, and had to see if I could script this! I started out with the idea to re-create the “summarize highlight” command, but make it work for any bolded text (since I use that for my headings). I ended up making a “jump to heading” script instead. It looks for all paragraphs that are bolded, and makes a list of them. You can then select one of the headings and your cursor will jump to it.
It’s a pretty clunky code, and a slow script, so I don’t know how useful it is. But it was fun to figure out! Maybe someone else can do better…?
-- Test script: Jump to headings (bolded text) in document
-- Daniel Sroka, 2019-11-01
tell application id "DNtp"
try
set itemURL to get the reference URL of (item 1 of (selection as list))
tell text of think window 1
set theList to {}
set thePos to {}
set paraCount to 0
repeat with thisParagraph in every paragraph
set len to the number of characters of thisParagraph
if (font of thisParagraph contains "Bold" and len > 1) then --only finds paragraphs that start bold
if len > 30 then
set thisHeading to characters 0 thru 30 of thisParagraph
else
set thisHeading to thisParagraph
end if
set end of theList to thisHeading as text
set end of thePos to paraCount
end if
set paraCount to paraCount + 1
end repeat
end tell
set theChoice to (choose from list theList with prompt {"Choose which heading to jump to: "} default items "" OK button name "Go To") as string
set choiceNum to my list_position(theChoice, theList)
set choicePos to item choiceNum of thePos as text
set itemURL to itemURL & "?reveal=1&line=" & choicePos as string
open location itemURL
end try
end tell
on list_position(this_item, this_list)
repeat with i from 1 to the count of this_list
if item i of this_list is this_item then return i
end repeat
return 0
end list_position