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

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.

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.

Thanks for the quick reply Jesse!

I tried running your script but keep getting an error:

Is there something else I need to do?

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.

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.

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.

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

1 Like

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.

I just posted a thread asking to create numbers or bulleted lists in TaskPaper. My current workaround is to copy what I want to put in a list in TaskPaper, paste into Notes, format the list, copy it again and paste it back into my TaskPaper document.

Should this still work? When I run this script and paste into Drafts or Bear, it gives me gobbledegook. I’m using the current version of MacOS. Thanks!

The script is still working for me, but it is intended to generate HTML code, which probably Bear doesn’t handle specially, and the end result is gobbledegook.

In the case of Bear I think just copy/paste TaskPaper lists is probably your best bet? If you can explain a bit more on what exactly you want your list to look like in Bear I can try offering other ideas.

I’d like to be able to copy a list like this:
TaskPaper
And paste it into Bear or Drafts (either) and have it look like this:Bear
or this:Drafts

Is that possible?

1 Like

@jessegrosjean Circling back on this request. Is there a simple way to do this that I’m missing? Being able to do my initial writing/outlining in TaskPaper and then being able to copy that work and paste it into another plain text-based program for easy sharing with others would be really handy. Thanks.

Here’s a script that I think will do what you want.

If you run that from Script Editor it should copy the current item (and all contained items) to the clipboard in the format that you want. I “think”.

More info on using scripts is here:

https://guide.taskpaper.com/using-taskpaper/using-scripts.html

var TaskPaper = Application('TaskPaper')

function TaskPaperContext(editor, options) {
	let outline = editor.outline
	let selection = editor.selection
	let currentItem = selection.startItem
	let result = ""
	for (each of currentItem.branchItems) {
		result += "\t".repeat(each.depth - 1)
	
		let type = each.getAttribute("data-type")
		if (type == "task") {
			result += "- [ ] " + each.bodyString.substring(2)
		} else if (type == "note") {
			result += "- " + each.bodyString
		} else {
			result += each.bodyString
		}

		result += "\n"
	}
	return result

}

var text = TaskPaper.documents[0].evaluate({
  script: TaskPaperContext.toString()
});

TaskPaper.includeStandardAdditions = true
TaskPaper.setTheClipboardTo(text)
2 Likes

This is fantastic! It works as long as my cursor is at the top of the TaskPaper page (assuming I want the entire list to be copied). I don’t really know what I’m doing with scripting and workflows, but I made an Alfred workflow that will use a hotkey (in this case it involves my caps lock remapped to Shift+control+option+command), move the cursor to the top of the TaskPaper page, run your script, open a new Bear note, and paste the list into Bear, formatted perfectly. Thanks so much!
Taskpaper to Bear.zip (2.2 KB)

1 Like