Markdown to Omnifocus

I am trying to use the Taskpaper to OF or Send to OF actions that are part of @RosemaryOrchard Drafts Taskpaper action group.

I have a big markdown file that I am using for a project template, organized as below:

Project Name

## Phase 1

### Task Group that is part of Phase 1

- task 1
- task 2
- task 3

### Another task group that is part of Phase 1

- task 1
- task 2

## Phase 2

### Task Group that is part of Phase 2

- task 1
- task 2
	- subtask 1
	- subtask 2 
- task 3

What I am finding is that when I run the Send to OF (Project) or Taskpaper to OF actions, I end up with three projects,

One called Project Name
a second called ## Phase 1 with no items (including hashtags)
and a third called Phase 2 (including hashtags), which has a long list of the remaining tasks (only some of which appeared indented correctly)

I am including a screenshot of what I hope the project will ultimately look like in Omnifocus. What I am trying to do is maintain the project template in markdown and figure out how to go from markdown to Omnifocus. Would appreciate any feedback if I am going about this the wrong way!

With further testing… it looks like markdown doesn’t work, there is a taskpaper format I need to use. When I changed all my hashtags to various numbers of tabs and hyphens, it worked. If there is a route from markdown to Project management software (OmniFocus and asana in my dreams) please let me know!

Markdown and Taskpaper do not have any sort of defined equivalence. You could create something that converts how you want Markdown to be converted to Taskpaper, but it would be specific to your require, not generic.

The basic premise would be to carry out the same conversion that you did manually. If you can define what you want to do, then I expect you could automate the conversion using text replacement instructions, potentially. Using regular expressions may be beneficial depending upon the complexity.

Fundamentally, it should be possible.

However, would it be viable to switch your template to Taskpaper rather than Markdown? Is it serving some other purpose being in Markdown?

In my open source project I support mixing Markdown and Taskpaper. For the former’s bullets I only support asterisks. Taskpaper uses dashes. So putting such a document through a Markdown processor does make the tasks look SLIGHTLY funny but the funniness is the extra Taskpaper syntax - which is actually quite useful.

And Taskpaper has quite a nice syntax.

(If my code encounters dash-started lines they becomes tasks in a task table at the end of the generated (PowerPoint) document.

TaskPaper uses indenting for hierarchy, which you could, as Sylumer suggests, convert the markdown to somehow. But my action group was only designed for TaskPaper and is unlikely to support Markdown in the near future.

Thanks for the info!

I am hoping for others to be able to “consume” it. Markdown is more readable, IMHO. Several of my team members use Markdown.

Okay, your examples don’t match up exactly above (it goes from a Markdown example to a different example in OmniFocus), so this is my best guess at an action that will specifically convert the Markdown template style that you have presented into what I think the desired Taskpaper structure would be for use with the action group for OmniFocus.

The acton starts off by saving a version in Drafts (safety first!), strips blank lines, makes the title into a Taskpaper project, processes line by line indenting based on the header section (level 2 and 3 Markdown headings only), and finally replaces the content with the Taskpaper version.

If you want a separate version, you could modify the action to create a new Draft instead. Alternatively you could modify @RosemaryOrchard’s action group actions to operate on an in memory (as a string) converted to Taskpaper version of the drafts. It just depends on convenience and the effort to apply any updates Rosemary may make to the action group in the future.

Here is how the conversion looks based on the text example you provided:

Input (Left) - Markdown
Project Name

## Phase 1

### Task Group that is part of Phase 1

- task 1
- task 2
- task 3

### Another task group that is part of Phase 1

- task 1
- task 2

## Phase 2

### Task Group that is part of Phase 2

- task 1
- task 2
	- subtask 1
	- subtask 2 
- task 3
Output (Right) - Taskpaper
Project Name:
	- Phase 1
		- Task Group that is part of Phase 1
			- task 1
			- task 2
			- task 3
		- Another task group that is part of Phase 1
			- task 1
			- task 2
	- Phase 2
		- Task Group that is part of Phase 2
			- task 1
			- task 2
				- subtask 1
				- subtask 2 
			- task 3

Pasting the Taskpaper content into OmniFocus gives the following structure.

2022-03-23-17.24.43

As it stands, the conversion is quite strict in regards to what it will process in Markdown, and how. For example:

  • It is only looking for “-” as a bullet, and not “*” or “+”, which are also valid bullet characters.
  • It is only doing basic matching and prep for headings starting with octothorpes ("#"), ignoring any trailing octothorpes (i.e., they are not removed), or headings defined by underlines.
  • No unnecessary markup is removed, such as bold, italic, block quote, etc.

Hopefully, it is the sort of thing you are after, and at least gives you a starting point to take it further. But, do let me know how close, of far, it is.

1 Like

I’ve not tested this but it looks like things such as @due would survive the translation.

Yes, task notes is another Taskpaper feature that is accommodated but do keep in mind they are not Markdown, so they are not being converted but rather simply part of the destination syntax being left intact.

The point I wanted to try to make is that this action does not cope with all ways the example template could be expressed as valid Markdown in terms of what would then be converted; only a very specific subset/flavours of marking.

1 Like

This is so cool… thank you. I look forward to testing. I had started taking notes on what I was doing manually to convert and it looks similar:

Converting the project tracking list from markdown to taskpaper.

  • replace "#### " with \t\t\t
  • replace "### "with \t\t (note the space needs to be removed)
  • replace \n\n with \n
  • replace "- " with \t\t\t (not sure how many? are they all under level three headings?)
  • remove non task text

regex for URLs

\[(.*?)\]\((.*?)\)

I’m happy to share my test… I was trying to simplify for illustration purposes.

1 Like

Maybe you can reuse some of what I shared then?

If an example doesn’t cover all requirements then a specification is truly essential. An illustrative example consequently results in just an illustrative solution.

1 Like

Just wanted to share that the script that @sylumer provided worked wonderfully with my markdown project outline. I’m very grateful for the help.