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.
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.