Last active
February 9, 2017 09:21
-
-
Save 62mkv/81a7757898f158b85cade9ddd4c911de to your computer and use it in GitHub Desktop.
Groovy script to copy FreePlane branch as Textile for easy creation of Redmine issues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.datatransfer.*; | |
import java.awt.Toolkit; | |
/* | |
* Export Freeplane mindmap branch to nested list in textile format e.g. for use in Redmine wiki | |
* - Save as <filename>.groovy in <freeplane directory>/scripts/ | |
- Select node and start script from menu: Tools -> Scripts -> <filename> | |
* | |
* (c) 2014 Fabian Kretzer https://dhf.sk/freeplane-mindmap-to-redmine-wiki/ | |
* (c) 2016 62mkv | |
*/ | |
def process(thisNode, childPosition) { | |
def result ="" | |
result = prefix(childPosition)+thisNode.getPlainText()+suffix(childPosition) | |
thisNode.children.each { | |
result += process(it, childPosition + 1) | |
} | |
return result | |
} | |
def prefix(position){ | |
if(position == 0){ | |
return "h1. " | |
} else { | |
return "*".multiply(position)+" " | |
} | |
} | |
def suffix(position){ | |
if(position == 0){ | |
return "\n\n" | |
} else { | |
return "\n" | |
} | |
} | |
def cbcopy(String text) { | |
StringSelection stringSelection = new StringSelection(text); | |
Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); | |
clpbrd.setContents(stringSelection, null); | |
} | |
def output = process(node, 0); | |
cbcopy(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Save it as %APPDATA%\Freeplane\1.5.x\scripts\copy_as_textile.groovy