Created
December 19, 2025 15:21
-
-
Save brokosz/82487557f355d7666c5f773f43c78008 to your computer and use it in GitHub Desktop.
JXA script to convert Markdown back to TaskPaper format. Preserves date tags, project tags, and task completion status.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env osascript -l JavaScript | |
| function run(argv) { | |
| const app = Application.currentApplication(); | |
| app.includeStandardAdditions = true; | |
| let content; | |
| if (argv.length > 0) { | |
| // Use file from command line | |
| content = app.read(Path(argv[0])); | |
| } else { | |
| // Use clipboard | |
| content = app.theClipboard(); | |
| } | |
| const lines = content.split(/\r\n|\r|\n/); | |
| let taskpaper = ''; | |
| for (let line of lines) { | |
| if (line.trim() === '') { | |
| taskpaper += '\n'; | |
| } else if (line.startsWith('## ')) { | |
| taskpaper += `${line.slice(3)}:\n`; | |
| } else if (line.includes('- [x]')) { | |
| let task = line.replace(/.*-\s*\[x\]\s*/, '').trim(); | |
| const doneDateMatch = task.match(/#done-(\d{4}-\d{2}-\d{2})/); | |
| const doneDate = doneDateMatch ? doneDateMatch[1] : new Date().toISOString().split('T')[0]; | |
| if (doneDateMatch) { | |
| task = task.replace(/#done-\d{4}-\d{2}-\d{2}/, '').trim(); | |
| } | |
| task = task.replace(/#due-(\d{4}-\d{2}-\d{2})/g, '@due($1)') | |
| .replace(/#start-(\d{4}-\d{2}-\d{2})/g, '@start($1)') | |
| .replace(/#([A-Z][a-zA-Z]*)/g, '@project($1)') | |
| .replace(/#(\w+)/g, '@$1').trim(); | |
| taskpaper += `\t- ${task} @done(${doneDate})\n`; | |
| } else if (line.includes('- [ ]')) { | |
| let task = line.replace(/.*-\s*\[\s*\]\s*/, '').trim(); | |
| task = task.replace(/#due-(\d{4}-\d{2}-\d{2})/g, '@due($1)') | |
| .replace(/#start-(\d{4}-\d{2}-\d{2})/g, '@start($1)') | |
| .replace(/#([A-Z][a-zA-Z]*)/g, '@project($1)') | |
| .replace(/#(\w+)/g, '@$1').trim(); | |
| taskpaper += `\t- ${task}\n`; | |
| } else { | |
| taskpaper += `${line}\n`; | |
| } | |
| } | |
| app.setTheClipboardTo(taskpaper); | |
| console.log("Converted Markdown to TaskPaper and copied to clipboard"); | |
| return taskpaper; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
Markdown → TaskPaper:
Conversions
Project:## Project- task- [ ] task- task @done- [x] task@due(2025-12-18)#due-2025-12-18@start(2025-12-18)#start-2025-12-18@project(Name)#Name(capitalized)@tag#tagOutput goes to clipboard for easy pasting between apps.