Daily Journal Smart Template question

Hello,
looking at the last executed applescript of that template, a simple bullet is pasted to the text of the RTF document:

tell text of myRecord
			set the last character to the last character & return & return
			make new paragraph at end with data ((theTime & return) as string)
			set properties of last paragraph to {font:"Helvetica Neue", size:16, alignment:left, superscript:2, color:headerColor}
			italicize last paragraph
			set properties of last character to {font:"Helvetica Neue", size:16, alignment:left, superscript:0, color:blackColor}
			set last character to last character & "â–  "
		end tell

I would apped something like this:

Private

  • Topic 1
  • Topic 2
  • Topic 3

Work

  • Topic 1
  • Topic 2
  • Topic 3

Whereas this should be a real list each below a header and use not the round list character but the little box instead. I have read to add paragraphs but i cannot find anything in the dictionary of DT3 how to set a style / list to the desired paragraphs, can somebody point me to where i missunderstand the concept? Or is this not possible?

For example, i can create a basic structure like this:

	make new paragraph at end with data "Privat" & return
			set properties of last paragraph to {font:"Helvetica Neue", size:16, alignment:left, paragraph spacing:5.0, color:blackColor}
			bold last paragraph
			
			make new paragraph at end with data "Topic 1" & return
			set properties of last paragraph to {font:"Helvetica Neue", size:16, alignment:left, paragraph spacing:3.0, color:blackColor, first line head indent:20.0}
			
			make new paragraph at end with data "Topic 2" & return
			set properties of last paragraph to {font:"Helvetica Neue", size:16, alignment:left, paragraph spacing:3.0, color:blackColor, first line head indent:20.0}
			
			make new paragraph at end with data "Topic 3" & return
			set properties of last paragraph to {font:"Helvetica Neue", size:16, alignment:left, paragraph spacing:3.0, color:blackColor, first line head indent:20.0}
			
			
			make new paragraph at end with data "Arbeit" & return
			set properties of last paragraph to {font:"Helvetica Neue", size:16, alignment:left, paragraph spacing:5.0, color:blackColor}
			bold last paragraph
			
			make new paragraph at end with data "Topic 1" & return
			set properties of last paragraph to {font:"Helvetica Neue", size:16, alignment:left, paragraph spacing:3.0, color:blackColor, first line head indent:20.0}
			
			make new paragraph at end with data "Topic 2" & return
			set properties of last paragraph to {font:"Helvetica Neue", size:16, alignment:left, paragraph spacing:3.0, color:blackColor, first line head indent:20.0}
			
			make new paragraph at end with data "Topic 3" & return
			set properties of last paragraph to {font:"Helvetica Neue", size:16, alignment:left, paragraph spacing:3.0, color:blackColor, first line head indent:20.0}

It will not have the list style, but looks already basically right… i know there are presumably smarter ways to do it:

Private

 Topic 1
 Topic 2
 Topic 3

Work

 Topic 1
 Topic 2
 Topic 3

I also tried to import a rtf file with the desired structure into the record. An import into the same group creates a rtf doc with the desired structure successfully , but when i try to import it from within the script of the smart template i get an error using the follwing line of code:

import "/Users/%username%/Library/Application Support/DEVONthink 3/Templates.noindex/Productivity/Daily Journal — Text.templatescriptd/Contents/Resources/listtemplate.rtf" to record myRecord

%username% is a placeholder for my real user, not used in script

An error occured when adding the document. „DEVONthink 3“ hat einen Fehler erhalten: „record (content id 11978 of database id 1) of every text of content id 11978 of database id 1“ kann nicht gelesen werden.

It seems i cannot identify the right way how to include the rtf file content into the text of that record. Is there some transformation needed? Do i have to do that later in a different place then the tell text area of the main.scpt of the smart template?
I thought also of controling the GUI directly after the record is opened in a new tab, but i would like to avoid that.

When changing the line to myGroup it creates on own document successfully in the same group as stated above:

import "/Users/%username%/Library/Application Support/DEVONthink 3/Templates.noindex/Productivity/Daily Journal — Text.templatescriptd/Contents/Resources/listtemplate.rtf" to myGroup

%username% is a placeholder, not used in real script.

When using just myRecord variable nothing happens, no error nor document created nor imported data that shows within the record:

import "/Users/%username%/Library/Application Support/DEVONthink 3/Templates.noindex/Productivity/Daily Journal — Text.templatescriptd/Contents/Resources/listtemplate.rtf" to myRecord

The imported and desired style looks like this:

This is a real list with automated indentation.

Lists or tables in rich text documents aren’t scriptable so far.

How about the import option to import a part of the rtf from another rtf? I seem to do something wrong here…

I assume here that markdown is not scriptable via classes as well but due to the md language itself, i could just pass the text as md to create the list… ?

Markdown is just plain text so you can process the raw text, if needed. However, it’s unclear what you’re thinking about doing.

I want to create some list structure that is automatically created and decided for RTF in the first place and wonder if i should maybe rethink, as i cannot script a list structure into the smart template according to @cgrunenberg. The list should be adapted to think about the days topics for the journal.

But i also asked above if i could not create a template.rtf that containst the structure and is imported at the end, when quote of the day and headlines are done already…

As @cgrunenberg mentioned, you can’t script the styling of lists in rich text. But your comment about Markdown gave me an idea.

Here is my offering…

(* Creates a rich text file with a proper list via a temporary Markdown file. *)

tell application id "DNtp"
	set dummyText to "**Private**  
- one
- two
- three

<br>

**Public**  
- apple
- orange
- banana

<!-- Styling -->
<style type=\"text/css\">
ul {
list-style-type: square;
}
</style> "
	set tmpRecord to create record with {source:dummyText, type:markdown, name:"myFile"} in current group
	set newRecord to convert record tmpRecord to rich
	delete record tmpRecord
end tell

While this may not fulfil your specific requirements, I think it’s a useful and viable approach, perhaps in other ways I haven’t imagined. :slight_smile:

PS: To my friend @chrillek, a pre-emptive “yeah, yeah, yeah” about the internal styling. :stuck_out_tongue_winking_eye: But in this case, it’s quick and clean and the file is also purged after conversion to rich text.

1 Like

Cool stuff.

1 Like

Yes i read that RTF is not scriptable (hopefully yet - somewhen there might be some time to implement it?) but what am i doing wrong with the import option? It would be sufficient to create a loadable part with all the stylings i want. Another way i could imaging is to have the template with placeholders and the needed styles and then let the script replace the placeholders with HEADLINES, QODT and DATE…

That reminds me that i would love native support for asciidoc within DT :wink:

Afaik, some aspects of RTF are scriptable (rich text suite), just not lists.

Did you try the script I posted?