This is by no means as sophisticated as anything that @pete31 produces but a simple change or two to my transclusion script may give what you need:
(* This script creates a new markdown record in the chosen database
and group and then adds to that record transclusion item links for plain text,
markdown or HTML records you have selected in the database with a line drawn
between each item. It will prompt you for the name of the new record or
you can choose to use the default name. *)
-- the database to open
property pDatabase : "/Users/stapp/Documents/DevonThink/Diaries.dtBase2"
-- the group to use for tbe markdown file of transclusions
property pGroup : "F3E59383-23EF-4CAB-9912-369CF9CF45CC"
-- the valid types of record for transclusion
property validTypes : {"markdown", "txt", "html"}
tell application id "DNtp"
try
activate
-- open the database
set theDatabase to open database pDatabase
set myGroup to get record with uuid pGroup
--check that we have some records selected for transclusion
set theSelection to the selection
if (count of theSelection) is 0 then
error "Please select some markdown records for transclusion"
end if
--set up the new record for the transclusions
set dAnswer to "New document"
set userEntry to display dialog ¬
"Enter the name of the new document (without the extension) or accept the default: " default answer dAnswer with title "New document for the transclusions"
set dAnswer to text returned of userEntry
set theNewRecord to create record with {name:dAnswer, type:markdown} in myGroup
-- Set up an empty list to populate with new strings, etc.
set textUpdates to {}
repeat with theRecord in (selection as list)
-- Check the document type
if (type of theRecord as string) is in validTypes then
--Get the reference URLs of the selected records
set recURL to reference URL of theRecord
set recordName to the name of theRecord
-- Format the transclusions
set transcludedItem to my createTransclusion(recURL)
-- Copy the string to the list, noting a linefeed is added after each line
copy (recordName & linefeed & transcludedItem & linefeed) to end of textUpdates
else
error "Check selected records: only markdown, plain text and HTML records are suitable for transclusion"
end if
-- Keep adding to the list until the loop expires
end repeat
-- Update the text of the file in one move
set plain text of theNewRecord to (textUpdates as string)
set root of viewer window 1 to myGroup
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
return
end try
end tell
--The handler to format the transclusion links is separate simply to make it easy
--to change the formatting between items if you wish.
on createTransclusion(theURL)
set theLink to "{{" & theURL & "}}" & linefeed & linefeed & "---" & linefeed
return theLink
end createTransclusion
Stephen