Skip to content

Instantly share code, notes, and snippets.

@bsoist
Last active December 20, 2015 15:09
Show Gist options
  • Save bsoist/6152427 to your computer and use it in GitHub Desktop.
Save bsoist/6152427 to your computer and use it in GitHub Desktop.
One of my verbs for converting to TaskPaper format. See http://4a.bsoi.st/ for more information
/*
One of my verbs for use converting
OPML to TaskPaper
See http://4a.bsoi.st/ for more information
*/
taskThis: function(filename) {
var bsoist_ext = '.todo';
if (! filename ) {
filename = file.getCurrentFilePath().split('.')[0] + bsoist_ext;
}
var taskdata = "";
var bsoist_prefix = "";
var bsoist_suffix = ":\r\n";
op.visitSubs(
function(headline,levelnum) {
taskdata += bsoist_prefix + headline.getLineText() + bsoist_suffix;
},
function(levelnum) {
bsoist_prefix = "- ";
bsoist_suffix = "\r\n";
},
function(levelnum) {
bsoist_prefix = "";
bsoist_suffix = ":\r\n";
}
);
file.writeWholeFile(filename,taskdata);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment