Thank you.
A little update: now script can handle long filenames with almost any symbols and spaces in them (added quoting in shell script).
New version is here:
-- Convert Markdown documents to Pandoc PDFs (using XeTeX)
-- Created by Christian Grunenberg on Mon Dec 01 2008.
-- Copyright (c) 2008-2011. All rights reserved.
-- Slightly changed by Silverstone on March 18 2019,
-- All copyrights go to great DEVONtech Team ;)
tell application id "DNtp"
try
set theSelection to the selection
if theSelection is not {} then
show progress indicator "Converting..." steps (count of theSelection)
repeat with theRecord in theSelection
set theName to (name of theRecord) as string
step progress indicator theName
if cancelled progress then exit repeat
set theType to type of theRecord
if theType is not group and theType is not feed and theType is not smart group then
set Path_to_MD to path of theRecord
-- Setup Your Temporary Folder Here:
set theOutput to "/Users/ilya/Documents/00_Temp/" & theName & ".pdf"
-- Construct your personal command line options here:
do shell script "export PATH=/Library/TeX/texbin:$PATH && /usr/local/bin/pandoc \"" & Path_to_MD & "\" -s -o \"" & theOutput & "\" --pdf-engine=xelatex --toc"
try
set theParents to parents of theRecord
set thePDF to import theOutput to (item 1 of theParents) name theName
repeat with i from 2 to (count of theParents)
replicate record thePDF to (item i of theParents)
end repeat
set URL of thePDF to URL of theRecord
set creation date of thePDF to creation date of theRecord
set modification date of thePDF to modification date of theRecord
set comment of thePDF to comment of theRecord
set label of thePDF to label of theRecord
end try
tell application "Finder" to delete theOutput as POSIX file
end if
end repeat
hide progress indicator
end if
on error error_message number error_number
hide progress indicator
if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try
end tell
And here are some random PDFs, which are made using this script, after clipping web pages in a clutter-free markdown (without any formatting):
Quitting Evernote for DEVONthink – Yann Rousse – Medium.pdf (479.3 KB)
What is life really like in Africa? - Quora.pdf (5.1 MB)
What Is Long-Form Content and Why Does It Work?.pdf (765.1 KB)