Mardown rendering options

I asked support for the possibility to use non-standard Markdown formatting like tables, references etc. via the use of extended Markdown syntaxes like MultiMarkdown or Pandoc (to name two).

I would really like the possibility to select a rendering machine and possibly a template in the preferences to render my Markdown files.

What do you think? Would you like such a feature?

I suggested this during testing of DEVONthink 2.6. I also would like to specify a Markdown template to use, just as is the option for RSS feeds. If the temple format was 100% compatible with’s templates, that would be even better still.

I’m less interested in the Markdown extensions, although if that were an option I expect that MultiMarkdown would be a logical choice.

One more vote for proposals from Januz and Greg.

I’d love to see Devonthink support Multimarkdown. For what it is worth, I’ve used the C libraries for this and found them pretty easy to work with. (They can be found here: )

The support of footnotes in particular is my concern. I use this everyday, and would find it great if I could read and edit these files in Devonthink without firing up a separate editor.

I also would find it useful to be able to specify the default template for the css would be a great addition. (And/or to specify a template for each document in, say, the final line of the file, or by some simple convention.)

Kudos of course for putting this in. Markdown is part of my workflow now…and it’s useful not just for html but for writing text with notes. I imagine it will continue to be, given that there seems to be no better standard for formatted text emerging in the mobile space, or through any kind of syncing algorithms. Seems like 1985 all over again, lol….and progress at the same time!


You can include standard HTML in most Markdown documents, so if you included code like this you should be able to invoke custom css:

<link rel="stylesheet" type="text/css" href="file://Users/Me/Documents/MyCSS/personal.css">

The code will not display when the document is rendered in the “Best Alternative” view.

Given that there are a lot of different markdown implementations, I’d really like being able to specify a custom Markdown Processor like allows me to do. Personally I use pandoc to handle my markdown conversions.

The developers seem to have opted for Multimarkdown only – how easy would it be to let the user decide how the .md file is processed (I am switching more and more to pandoc because it offers better citations options etc.)?!

Pandoc has so many parameters and permutations for input, and is non-Apple code, that I find it hard to imagine how the developers could (or would) include it in DEVONthink and satisfy all users. However, write your own routines with your favorite scripting language and create the feature you want.

For example, It is possible to install scripts as toolbar icons. Place the script in

~/Library/Application Support/DEVONthink Pro 2/Scripts/Toolbar

and then use View > Customize Toolbar to drag the script onto the tool bar.

  1. This is a toolbar script to open the current document in Marked
tell application id "DNtp"
		if selection is {} then error "Please select a document"
		set theItem to (the first item of (the selection as list))
		set theKind to kind of theItem
		if the theKind is not in {"mkdown", "markdown", "md", "mmd", "multimarkdown", "Text"} then error "Please select a plain text document"
		set thePath to the path of the theItem
		-- Marked
		tell application id "com.brettterpstra.marky"
			open thePath
		end tell
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink had an error" message error_message as warning
	end try
end tell
  1. Using techniques similar to the above, it is simple to create a toolbar script to call a command line routine to render the document in Pandoc. There are starting points for shell script, Perl script, and AppleScript examples shipped with DEVONthink.

I have a shortcut to view my markdown files in Marked which provides the possibility to render Markdown using a custom command (e.g., pandoc).

I thought the same possibility could be implemented in DEVONthink, i.e., let the user decide how Markdown is rendered by providing a (visible or invisible) option to choose a custom processor, ideally even on a per-document basis (see.;

FWIW here’s one sketch of an Applescript call to Pandoc from DevonThink

(to make a MultiMarkdown copy of the selected HTML or docx record)

property pTitle : "Convert html/docx DT record to MMD"
property pVer : "0.1"

property pRequirements : "


property pstrPandocPath : "/usr/local/bin" -- this is the path to pandoc used by the default OSX installer 
-- if, after successful installation, `which pandoc` in returns any alternative to /usr/local/bin/pandoc then
-- adjust above as necessary
property pstrOutFormat : "markdown_mmd" -- In, see output of `pandoc -h` for other Markdown and plain text output formats

tell application id "DNtp"
	set oRec to content record of front window
	if oRec is missing value then return
	set strKind to kind of oRec
	if strKind is not "HTML" and strKind is not "docx" then
		display dialog "Select an .html or .docx record for conversion to MD" buttons {"OK"} default button "OK" with title pTitle & "  ver. " & pVer
	end if
	set strInFormat to "html"
	-- The Bourne shell used by Applescripts doesn't inherit settings from the Bash, so we manually set a temporary
	-- UTF-8 version of the locale. (Doesn't persist across calls, or affect the Bash settings).
	-- We then pass the HTML source to Pandoc, and retrieve any Markdown which it generates
	set strCMD to "LANGSTATE=\"$(defaults read -g AppleLocale).UTF-8\"; if [[ \"$LC_CTYPE\" != *\"UTF-8\"* ]]; then export LC_ALL=\"$LANGSTATE\" ; fi; PATH=" & ¬
		pstrPandocPath & ":$PATH; MDOUT=$(pandoc -r " & strInFormat & " -w " & pstrOutFormat & " << BRKT_HTML" & linefeed & source of oRec & linefeed & ¬
		"BRKT_HTML); echo \"$MDOUT\""
	set strMD to (do shell script strCMD)
	if strMD is not "" then
		set strPath to (location of oRec) as string
		set oLocn to create location strPath in current database
		set recMD to create record with {name:name of oRec & ".md", type:markdown, plain text:strMD} in oLocn
	end if
	return strMD
end tell