Skip to content

Repository files navigation

taskmark

Parse taskmark-spec markdown files into Python.

Installation

pip install taskmark

Parse

importtaskmark# Parse stringstore=taskmark.loads("""# TODO +project## Features- [ ] (A) Build parser @alice #urgent due:2024-03-15 ~2h - [ ] Write tests - [ ] Document API- [ ] Weekly review planned:2024-03-15 repeat:weekly""")
# Parse file (follows [text](file.md) links)store=taskmark.load("path/to/todo.md")
# Iterate tasksfortaskinstore:
print(task["title"])
# Check for warningsstore.check() # raises ParseError if any warnings# Access frontmatter (timezone, locale)ifstore.frontmatter:
print(store.frontmatter.timezone) # e.g., "America/New_York"

Mutate

importtaskmarkfromtaskmarkimportTaskChanges, REMOVEstore=taskmark.load("tasks.md")
# Update taskresult=taskmark.update(
store,
title="Build parser",
project="project",
changes=TaskChanges(state="done", priority=REMOVE),
)
# Write changes to disktaskmark.write_updates(store)

Recurrence

When a recurring task is marked done, a new task is automatically created for the next occurrence:

# Input: - [ ] Standup planned:2024-03-15 repeat:daily# After marking done:# - [x] 2024-03-15 Standup planned:2024-03-15# - [ ] Standup planned:2024-03-16 repeat:daily

Supported patterns:

  • Simple: daily, weekly, monthly, yearly
  • Multiplied: 2weeks, 3days, 2months, 2d, 3w
  • Day of month: 15th, 1st, 31st (clamps to month end)
  • Nth weekday: 2nd-tuesday, last-friday, 1st-monday
  • Natural language: "every other week", "every 2 weeks" (requires quotes for spaces)

Task Access

task=store[0]
# Dict access (content fields)task["title"] # "Build parser"task["state"] # "open"task["priority"] # "A"dict(task) # all content fields# Attribute access (all fields)task.title# same as task["title"]task.file# Path to source filetask.inherited_tags# tags from headings

Date Fields

FieldDescription
due_dateWhen task is due
planned_dateWhen task is planned to start
done_dateWhen task was completed (auto-set)
created_dateWhen task was created
started_dateWhen task was started
paused_dateWhen task was blocked (auto-set)

API

FunctionInputOutput
loads(s)Markdown stringTaskStore
load(fp)File path/objectTaskStore
update(store, title, project, changes)Task identifier + changesUpdateResult
batch_update(store, updates)List of updatesBatchUpdateResult
write_updates(store)Store with changesWriteResult

Types

TypePurpose
TaskDict-like task with attribute access
TaskStoreIterable collection with warnings and frontmatter
TaskChangesChanges for update()
FrontmatterFile-level metadata (timezone, locale)
REMOVESentinel to remove field
ParseErrorRaised by check()
UpdateResultResult of single update with status
BatchUpdateResultResult of batch update
WriteResultResult of writing updates to files
TaskUpdateSpecSpecification for batch updates
RejectedChangeDetails of a rejected change
FileInfoSource file metadata
WarningParse warning details
TaskStateEnum: open, done, cancelled, blocked
UpdateStatusEnum: updated, not_found, etc.
StateMachineCustomizable state transition machine
StateTransitionSingle state transition definition
DEFAULT_STATE_MACHINEDefault state machine instance

Spec

See taskmark-spec for format details.

License

MIT

About

Python parser for taskmark-spec markdown task files

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages