Markdown text file to MindNode on macOS

I read Rose’s article at, because I have a Markdown-formatted list (with all the correct indenting) that I want to convert to a mindmap in MindNode. However, it looks like the MindNode URL scheme only works on iOS, since running the Drafts action doesn’t seem to do anything.

Consequently, how should I go about converting a Markdown file into a MindNode mindmap on macOS? I can always copy and paste the text from the Markdown file into MindNode, but this is slow and manual. I’d love a shell script or AppleScript like

md2mindnode --input --output tmp.mindnode


I’m curious about this, too. Surprising that Mindnode would have different URL scheme support on the two platforms, though.

I would love it markdown mind mapping was two-way. That is, you could open a markdown file in Mindnode, edit it there, and have the results change the underlying markdown text. Sure, it would require a simpler feature set than Mindnode’s styles and connections, but I think it’d make for a nice, nimble experience.

1 Like

In terms of URL schemes working one platform and not another, that isn’t that uncommon. Different development teams and code bases that aren’t as shared as people would like (usually thanks to a history of separate development) are factors that can lead to this.

I’m not sure what action was being used on iOS that wasn’t being used on Drafts, but I had a look in the MindNode manual for the Mac and created this single step Drafts action that just uses the Mac URL scheme.

Looking through the MindNode AppleScript dictionary there’s no import option, only open, and while that works on importing OPML files (see the AppleScript example for this in the manual, or on GitHub), it doesn’t work on Markdown files from my brief testing. Therefore for a scripted solution, we could either look at first converting Markdown to OPML, or resigning ourselves to automating just the open via URL scheme (this leaves a confirmation dialog open, so without then calling in something like Keyboard Maestro to deal with that I just ended up banging my head on how to get past that to control MindNode to do the saving.

This example AppleScript allows you to select a folder, picks out all of the files with a file extension of md (that’s what I use as my default markdown extension as it’s nice and short), grabs the content of each file in turn, URL encodes it, and then opens it using the URL scheme’s import option via the command line.

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set folderPath to choose folder
set fileExtension to "md"

tell application "Finder"
		set fileNames to name of every file of folderPath whose name extension is fileExtension
	end try
end tell

repeat with name in fileNames
	set mdFile to alias ((folderPath as text) & name)
	set mdContent to (read mdFile)
	do shell script "open 'mindnode:///import?format=md&content=" & urlEncode(mdContent) & "&name='" & urlEncode(name)
end repeat

on urlEncode(theText)
	set theTextEnc to ""
	repeat with eachChar in characters of theText
		set useChar to eachChar
		set eachCharNum to ASCII number of eachChar
		if eachCharNum = 32 then
			set useChar to "+"
		else if (eachCharNum ≠ 42) and (eachCharNum ≠ 95) and (eachCharNum < 45 or eachCharNum > 46) and (eachCharNum < 48 or eachCharNum > 57) and (eachCharNum < 65 or eachCharNum > 90) and (eachCharNum < 97 or eachCharNum > 122) then
			set firstDig to round (eachCharNum / 16) rounding down
			set secondDig to eachCharNum mod 16
			if firstDig > 9 then
				set aNum to firstDig + 55
				set firstDig to ASCII character aNum
			end if
			if secondDig > 9 then
				set aNum to secondDig + 55
				set secondDig to ASCII character aNum
			end if
			set numHex to ("%" & (firstDig as string) & (secondDig as string)) as string
			set useChar to numHex
		end if
		set theTextEnc to theTextEnc & useChar as string
	end repeat
	return theTextEnc
end urlEncode

If you’re happy with the point of just creating and not saving, and you really do want to pass a file and a name in, you could do something simpler with a shell script; and probably even re-do the above, but I was so far in to trying to get the save working as well I figured I’d share anyway.

This script takes a file path and a name for the mind map as its arguments.

contents=`cat $1`

alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
encodedContents=`urlencode $contents`

open "mindnode:///import?format=md&content=$encodedContents&name=$name"

An example call from my testing looked like this:

~/scripts/ "/Users/stephen/Desktop/" "temporary"

Hopefully, there’s something of at least limited use to you in those examples.

MindNode can import Freemind XML, BTW. I was experimenting with it yesterday. (I have a python programming project I hope to be able to open source soon that, among other things, converts Markdown bulleted lists to Freemind XML. (Also iThoughts-compatible CSV.)

Freemind XML is pretty simple and could be brute-forced with a text editor from Markdown bulleted lists.

What Markdown elements are you using? Headings? Nested bulleted lists? (Right now I only handle the latter but think I should handle the former. too.)