Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am very much a novice at this, so please bear with me.

I'm intrigued by the idea of using Markdown. I want to be able to write my stuff in a plaintext editor on OS X and iOS and save it in Dropbox in .txt format using a Markdown syntax. I don't want to save my files in markdown format but as plain text. I need support for footnotes, so the Multimarkdown syntax seems like an obvious option.

What tools can I use on OS X and iOS to convert my .txt files, marked up with a Markdown syntax, to .pdf format? Is this even possible?

Thanks for reading.

share|improve this question
    
Isn't markdown format plain text? –  mouviciel Mar 28 '13 at 13:37
    
I don't know. Is it? I so, that would clear up a lot of confusion I've been having. I tend to compose in WriteRoom which can't save files in .md format. –  DrGuyBH Mar 28 '13 at 14:21
2  
The whole idea of markdown is that it is plain text and you can use any text editor you like. The .md suffix is just a convention, there is no difference to .txt files. –  patrix Mar 28 '13 at 14:27

3 Answers 3

up vote 7 down vote accepted

I use Marked to process text files to pdf routinely.

No matter what editor you use, Marked will open and re-save a PDF generated from the plain text input by opening and re-saving the file.

It also saves to HTML or RDF output from markdown.

In reality, any program that renders markdown could print to PDF using OS X core services (File -> Print -> PDF -> Save as PDF), but I much prefer having Marked for it's multitude of handy and flexible processing options and it's ability to live preview markdown files as I edit them in another editor:

  • Printing: TOC, suppressing link underline colors, better page breaks
  • Multiple styles of markdown rendering
  • Support for custom processors, all manner of smart (and dumb) typography
  • overall clean, fast, robust, elegant software for a very reasonable price
share|improve this answer
    
"No matter what editor you use, it has easy save options to generate PDF, HTML, RDF output from a given text format input file of markdown content." If I convert a file in .txt format, which is marked up with MD syntax, to .pdf using a simple text editor, I just get a .pdf file with all the syntax in it. Does Marked turn the syntax into formatting? Some apps I've looked at say LaTex is needed to convert to .pdf. Where does LaTex come in? –  DrGuyBH Mar 28 '13 at 14:10
1  
Marked does one stop save. foo.txt -> foo.pdf with PDF being a beautifully rendered. Here is an example using a revision of my answer above. answer.txt is UTF-8 text file and answer.pdf is what Marked saved as PDF. –  bmike Mar 28 '13 at 14:19
    
Thanks. One last question: does it support footnotes? –  DrGuyBH Mar 28 '13 at 14:25
    
Yes. Markdown doesn't differentiate between normal links and citations, but multimarkdown style syntax works out of the box. I've slapped that on the end of answer.txt above. The author of Marked is prolifically active, blogging, improving, adding features and squashing bugs as well. You can compare how cloudily renders markdown with this link of the same source above - cl.ly/Nuq1 –  bmike Mar 28 '13 at 14:40
    
Many thanks indeed. Just downloaded it now and it does exactly what I want. Daedalus Touch does much the same on iOS but without footnotes. –  DrGuyBH Mar 28 '13 at 15:33

install markdown (which is a perl script) from here: http://daringfireball.net/projects/markdown/

(Alternately you can use homebrew (http://mxcl.github.com/homebrew/) to install markdown, or one of the many enhanced markdown utilities)

Then once you have your markdown text file (say it's text.md) you can simply run:

$ perl *pathto*/markdown.pl text.md > text.html in the terminal

then open the resulting text.html in Safari (or any other web browser) and Print to PDF.

If you are extensively converting markdown to pdf you can simplify this by using pandoc: http://johnmacfarlane.net/pandoc/

Better yet, there are a number of text editors designed specifically for Markdown that seem to do the job for you. (Though you may want to check for pdf export... for example iA Writer only exports to RTF or HTML... the conversion of one of those to PDF is trivial, but it's an extra step).

Many general purpose text editors (TextMate, BBEdit) can be used well for Markdown. (For example in the latest TextMate 2 Beta you can select Preview from the Markdown bundle and then export the formatted document to PDF from the Print dialog.)

share|improve this answer
  • brew install pandoc
  • Install MacTex and add /usr/local/texlive/2012/bin/universal-darwin/ to the path
  • pandoc input.md -o output.pdf

I don't know how to change the styles. pdflatex also gave me errors for some non-ASCII characters.

  • --strict acts like Markdown.pl
  • -p preserves tabs
  • -s --toc adds a TOC (-s / standalone adds headers and footers)
  • -S enables smart punctuation

You could also convert to HTML and then to PDF:

sudo gem install wkpdf
pandoc --strict -p input.md -c style.css -o temp.html
wkpdf -s temp.html -m 10 -o output.pdf
  • -s = source
  • -m 10 reduces the default margins
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.