apple   art   china   net culture   productivity   reading   shots/pics   stories   tech   work

Applescript to translate a markdown file into a textile file (for later use in Textpattern)
18 September 2011

Ever since I started using Writing Kit I wondered if there would be an easy way to transform its output (which is in Markdown) to Textile. Textile is the markup language used by Textpattern – which this site runs on. Also I’m much more used to it.

The following script will translate a selected Markdown file (sorry, only one) into a textile file with an “.textile” extension. To run this script you need to have Pandoc installed.

tell application "Finder"
set theItems to selection
set fileName to name of item 1 of theItems as text
set fileFolder to folder of item 1 of theItems as text
set folderPos to POSIX path of fileFolder
end tell

set pdCall to "/usr/local/bin/pandoc -f markdown -t textile "
set pdCall to pdCall & quoted form of folderPos
set pdCall to pdCall & quoted form of fileName
set pdCall to pdCall & " -o " & quoted form of folderPos & quoted form of fileName & ".textile"

do shell script pdCall

I use this script in conjunction with Spark, in order to start it with a keyboard shortcut.

ps. Learning a bit of Applescript has been the true value of this exercise for me.