Creating markdown documents?

Hello,

the following code creates a document test.md, which is shown with the wrong icon but with a type “Markdown” and which opens in the configured external Markdown editor. However, the icon is wrong and the content is not displayed in Devonthink. I looked in the Applescript library but there does not seem to be a special type “Markdown” which I can use for creating Markdown documents.

What is the correct way to create a Markdown document via Applescript?

tell application id "com.devon-technologies.thinkpro2"
	
	set theDatabase to inbox -- the global inbox
	set theDestination to incoming group of theDatabase
	set newDoc to create record with {name:"Note.md", type:unknown, source:"#"} in theDestination
	set newPath to the path of newDoc
	set newFile to POSIX file newPath as string
	tell application "Finder" to open newFile
	
end tell

Bye,
Oliver

There’s no AppleScript support for Markdown yet, another approach is this one:

tell application id "com.devon-technologies.thinkpro2"
	set theRecord to create record with {name:"Test", type:txt, content:""}
	set name of theRecord to "Test.markdown"
end

Note: Renaming a plain text item updates the file’s extension too if the new name has a valid extension.