Skip to content

Instantly share code, notes, and snippets.

@62mkv
Last active February 9, 2017 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 62mkv/81a7757898f158b85cade9ddd4c911de to your computer and use it in GitHub Desktop.
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
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)
@62mkv
Copy link
Author

62mkv commented Feb 9, 2017

Save it as %APPDATA%\Freeplane\1.5.x\scripts\copy_as_textile.groovy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment