1
0
Fork 0
mirror of https://github.com/marty-oehme/scripts.git synced 2024-06-25 21:27:58 +00:00

Added header parsing (no need to use "project:" statement anymore for project definition)

This commit is contained in:
Filip Makowski 2017-06-05 12:19:09 +02:00
parent dc114d1e4f
commit 4a2e61d61b
2 changed files with 4 additions and 3 deletions

View file

@ -6,5 +6,5 @@
"minAppVersion": "17.06.1",
"authors": ["@fmakowski"],
"platforms": ["linux", "macos"],
"description" : "This script creates menu items and buttons to import and export Taskwarrior tasks.\n\n<b>Dependencies</b>\n\nUnix-like OSes only!\n<a href=\"http://taskwarrior.org\">Taskwarrior</a>\n\n<b>Usage</b>\n\n<i>Export:</i>\nThe script takes selected text from your note and parse it to create task entries based on it. The following rules currently apply for the test to be parsed correctly:\n * the project is defined by writing \"project:\" (case-insensitive) immediately followed by the project name; the rest of the line content is skipped\n * the task is defined by making a list item, using either - (minus) or * (asterisk) at the beginning; the task description taken will be used with the most recently detected project name to create a new task\n\n<i>Import:</i>\nThe script takes selected text from your note, parsing it into the project names you want to fetch from Taskwarrior into the note. The tasks will be written as a list right below the selection. The project names will be appended before the lists As \"Project: [projectName]\" to separate lists.<b>To Do</b>\n\n * foolproof used regexps\n * make project nesting easier\n * use headers to determine project name and nesting\n * Windows support\n * Taskwarrior parameter parsing (like tags, dates, priority, etc.)"
"description" : "This script creates menu items and buttons to import and export Taskwarrior tasks.\n\n<b>Dependencies</b>\n\nUnix-like OSes only!\n<a href=\"http://taskwarrior.org\">Taskwarrior</a>\n\n<b>Usage</b>\n\n<i>Export:</i>\nThe script takes selected text from your note and parse it to create task entries based on it. The following rules currently apply for the test to be parsed correctly:\n * the project is defined by writing \"project:\" (case-insensitive) immediately followed by the project name; the rest of the line content is skipped\n * the headers (lines starting with #) are also considered as project names - no nesting available yet\n * the task is defined by making a list item, using either - (minus) or * (asterisk) at the beginning; the task description taken will be used with the most recently detected project name to create a new task\n\n<i>Import:</i>\nThe script takes selected text from your note, parsing it into the project names you want to fetch from Taskwarrior into the note. The tasks will be written as a list right below the selection. The project names will be appended before the lists As \"Project: [projectName]\" to separate lists.<b>To Do</b>\n\n * foolproof used regexps\n * make project nesting easier\n * Windows support\n * Taskwarrior parameter parsing (like tags, dates, priority, etc.)"
}

View file

@ -45,10 +45,11 @@ QtObject {
function getProjectNameAndRun(str, func) {
// We are trying to get the name of the project.
// To do so, we are getting the substring of a line by using regexp group.
var projectRegExp = /project:[\s*]?(.+)?[\s*]?/i;
var projectRegExp = /(project:[\s*]?(.+)?[\s*]?)|(#+[\s*]?(.+)?[\s*]?)/i;
var isProjectName = projectRegExp.exec(str);
if (isProjectName) {
func(isProjectName[1]);
var projectName = isProjectName[2] ? isProjectName[2] : isProjectName[4];
func(projectName);
return true;
}
}