Jump to content

Workflow to convert selected markdown file to PDF


Recommended Posts

I'm using lots of markdown files and it would be great if I could:

  • select a markdown file in finder
  • trigger Alfred
  • select "convert file to PDF"

And eventually end up with a converted markdown file to PDF on -for example- my desktop. Would something be possible? I have marked2 installed, but I don't think a marked2-export can be started form the console, right?

Link to comment

And eventually end up with a converted markdown file to PDF on -for example- my desktop. Would something be possible? I have marked2 installed, but I don't think a marked2-export can be started form the console, right?

 

That's really a question for the Marked support page.

Pandoc can probably do it from the command line, although you might have to use pandoc to convert Markdown -> XXX and some other tool to convert XXX -> PDF.

Link to comment

I use some automator workflows that run Pandoc and xelatex (so you need BasicTeX and Pandoc installed). A script like this should work (it does in automator anyway):

#!/bin/zsh
debug=0
export PATH=/Library/TeX/texbin:$PATH
cd "$( dirname "$1" )"
filename=$(basename "$1")

if [[ $debug -gt 0 ]]; then
	/usr/local/bin/pandoc --verbose --latex-engine=xelatex "$filename" -o "$filename.pdf" > $$.log 2>&1 &
        open $$.log
else
	/usr/local/bin/pandoc --latex-engine=xelatex "$filename" -o "$filename.pdf"
fi
Edited by iandol
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...