hackish ways of using pandoc instead of mmd

I use pandoc rather than multimarkdown, primarily because of its robust ODT support (including footnotes) and its direct export to LaTeX and ConTeX.

It is easy enough to export to mmd, convert the meta-data to pandoc’s format, and then use pandoc to convert the file. But it would be nice to be able to use the drop down menu in Scrivener to directly export to the pandoc format or convert to other formats via pandoc.

If you are willing to hack around, you can do this by replacing the scripts in /Scrivener.app/Contents/MacOS/MultiMarkdown/bin (or, perhaps better, place alternate scripts with the same names in ~/Library/Application\ Support/MultiMarkdown/bin). (Obviously the first thing that has to be done is to convert the meta-data, but that is fairly trivial.)

And you can edit the strings for the pop up menu using by editing the following file in Interface Builder:


(this will presumably be overwritten when the software updates, so make a backup of your changes or just plan to do it again after the update.)

Some gotchas:

  • you are restricted to no more than 4 output scripts. (I only use three: pandoc, pandoc–>PDF, pandoc–>ODT)
  • I don’t see any way to change the file extensions for the exported files. If I try to enter in some alternative extension in the save dialog, it doesn’t allow it. This is okay so long as you are replacing MMD–>HTML (say) with pandoc–>HTML. But my most common desire is to export via pandoc to PDF or ODT, and that means I have to say that I’m saving it as “filename.rtf” (or whatever) even though the real output is PDF or ODT.
  • Either you replace the scripts in the application bundle, in which case (a) they are overwritten when the application is updated and (b) they are overridden by any scripts in Library/Application Support/MultiMarkdown; or you replace the scripts in Library/Application Support/MultiMarkdown, in which case you have to damage your mmd installation in order to use pandoc with Scrivener. Neither of these is ideal.

I have to admit that I know nothing about Pandoc, but it sounds interesting. If I had time, I’d research it a bit more, but I’m up to my ears in code as it is. So would you mind explaining a bit more about what it is and what it does. I found this page:


But haven’t the time to explore much right now. If it really is as simple as MMD then I might be able to provide ways of exporting directly in the future.

Incidentally, Scrivener looks in ~/Library/Application Support/MultiMarkdown before it looks inside its own package, so you could replace files there and that way updates to Scrivener wouldn’t replace them.

All the best,

Pandoc is a command line tool like MultiMarkdown. Like MultiMarkdown, it implements an extended flavor of Markdown. For many common markdown extensions, like footnotes, they share the same syntax.

For converting to html and LaTeX, both are probably equally good—in fact, MMD offers a few more options and a bit more control. Where Pandoc excels is in converting to other formats—ODT, RTF, ConTeXt, S5 html-based slideshows, reStructuredText, man pages (!) It also converts from some formats (html, uncomplicated LaTeX, …) to markdown. And, like MultiMarkdown, it comes with a script that converts from markdown to PDF by making use of LaTeX.

MMD converts markdown to xhtml, and then xhtml to other formats using XSLT files. In theory this might not impose many limitations, and provides a great deal of flexibility. In practice, it means that support for output formats other than html, LaTeX, and PDF isn’t great. For example, there is no proper support for footnotes in RTF. More generally, I don’t know of any route from markdown to ODT or DOC using MMD that supports footnotes correctly.

For the formats it supports, Pandoc converts directly from one format to the other. In particular, it generates properly structured ODT files. Footnotes are converted to real footnotes; titles, headers, blockquotes, etc. are each assigned their appropriate “style”. Once you’ve got a properly structured ODT file, you can use OpenOffice to convert it to a DOC file.

Pandoc also has experimental support for processing citations given a MODS xml database of publications and a CSL style file (the same style files that Zotero uses).

All of that said, Pandoc has one big problem: it is written in Haskell, and it is only available as source, so users have to compile it themselves, and before they can do that, they have to install the Haskell Compiler and a handful of other packages. And getting the compiler and packages to work on Snow Leopard requires—at the moment, at least—tweaking various packages in ways described on various forums. Grrr.

So I suspect that, for now, your efforts are best focused elsewhere. :frowning: Anyone able to setup Pandoc can probably also figure out how to implement the sort of workaround I described above.

But if there were an easy way for users to add additional export scripts without overwriting the existing MMD scripts, I’d be happy to try to produce a suite of such scripts for use with Pandoc. Maybe a folder in Application Support/Scrivener/ for users to drop Applescripts, modeled after the PDF Services folder? Each script could specify whether it wanted plain text, markdown, or RTF.

That would be neat. But I was happy to discover my hackish workaround, too. :slight_smile:

I was just digging around to see if there was a plugin facility for generating outputs from scrivener, as well as to see if this tool might be suitable for holding (say) latex (or some other formatting text in the source).

I guess I’ll download a trial, and play around in the meantime.

  • Yarko

An alternative approach which avoids hacking the internal files at the expense of adding a second step:

add a new page at the top of your document containing the pandoc title block.

% title
% author
% date

Now use the markdown output target, removing all the metadata from the metadata compile section.

This should generate a .markdown file suitible for calling from the terminal, e.g.
pandoc novel.markdown -o novel.odt
(or whatever).

Also, pandoc binaries are now availiable on the webpage for osx, so you don’t need to faff with cabal and ghc.

Pandoc rocks! Please offer it as mmd-alternative!

There is also a wysisyg editor for pandoc (Texts) - makes a beautiful couple with scrivener

+1 for Pandoc integration in Scrivener :slight_smile: