How to convert Taskpaper projects/task text into a bulleted list?


#1

Has anyone come up with a script or workflow that would allow me to copy some projects/notes/tasks from taskpaper and paste them into my email client Apple Mail, Airmail, etc… and have the text be converted into a bulleted list?

I find myself using Taskpaper to capture meeting notes however it’s turning into a real PITA to try can share those notes out through email without having to convert the outline to a bulleted list and then manually fixing the indentation.


#2

I’m not sure how your email client will handle this, but try this script:

function SelectionToBMLTaskPaperContextScript(editor, options) {
  return ItemSerializer.serializeItems(editor.selection.selectedItems, { type: ItemSerializer.BMLType })
}

let taskPaperApp = Application("TaskPaper")
taskPaperApp.includeStandardAdditions = true
let selectionAsBML = taskPaperApp.documents[0].evaluate({
  script: SelectionToBMLTaskPaperContextScript.toString()
})
taskPaperApp.setTheClipboardTo(selectionAsBML)

It will convert the selected items in your TaskPaper document to BML (which is a subset of HTML) and put that text on the clipboard. So run the script and then paste into your email client and see if that works.


#3

Thanks for the quick reply Jesse!

I tried running your script but keep getting an error:

Is there something else I need to do?


#4

Ok, so I was able to get this to work by replacing “let” with “var”.

It seems to work although it still maintains the "- " before each task which I have to remove manually:

Project:

  • -Task one
  • -Task two

Is there anyway to remove the taskpaper formatting?

Thanks again for your help with this.


#5

Try this one instead:

function SelectionToBMLTaskPaperContextScript(editor, options) {
  var items = editor.selection.selectedItems.map(function(each) {
  	if (each.getAttribute('data-type') == 'task') {
	  	var clone = each.clone()
		clone.setAttribute('data-type', 'note')
		return clone
	}
	return each
  })
  return ItemSerializer.serializeItems(items, { type: ItemSerializer.BMLType })
}

var taskPaperApp = Application("TaskPaper")
taskPaperApp.includeStandardAdditions = true
var selectionAsBML = taskPaperApp.documents[0].evaluate({
  script: SelectionToBMLTaskPaperContextScript.toString()
})
taskPaperApp.setTheClipboardTo(selectionAsBML)

It converts any “task” item to a note before serializing as BML. The result is no leading dash.

Hum… what version of macOS are you using? I’m on 10.12 … might be that let isn’t supported on earlier versions.


#6

Is there a way to do the opposite when you have a bulleted list or hard return list from an email and convert them all to tasks? I just finally upgraded to TaskPaper 3 through the App Store hoping for that feature since it looked like it had so many more key commands.


#7

Nevermind, I just found it, “Item: Format As: Task” hooray!


#8

There is a list of different ways to do this in the Wiki. If this is something you are planning on doing ofter, I would recommend you to do it using the Ruby Library. This is because you can do that with a script that runs every whenever you want using “jobs”. There is an explanation on how to do that in one of the script pages in the wiki. If you are interesting on it, try reading those links and I can help along. Just create another post with your questions and tag me.