From 8854c26be71e8e86ef089e5617b9735307146dec Mon Sep 17 00:00:00 2001 From: James Turk Date: Sat, 27 Jul 2024 00:36:27 -0400 Subject: [PATCH] improve styling --- README.md | 12 ++++++++++++ src/maddog/app.py | 15 +++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index db0fe4b..cddb021 100644 --- a/README.md +++ b/README.md @@ -1 +1,13 @@ # maddog + +A suite of tools for dealing with a directory of markdown files. + +IDEA: just markdown? todo logic might be useful outside that? + +TODO: decide on a more permanent name, maddog/md/mddir + +TODO: this is an example of a todo due in the past {by:2024-07} + +TODO: this is an example of a todo with other tags {tag:example} + +DONE: this is an example of a todo with other tags {tag:example} {by:2024-01} diff --git a/src/maddog/app.py b/src/maddog/app.py index 6755a7e..4e96d74 100644 --- a/src/maddog/app.py +++ b/src/maddog/app.py @@ -10,7 +10,7 @@ console = Console() now = datetime.datetime.now() ALL_TODO_RE = re.compile(r"^(TODO|IDEA|DONE):?\s*([^\{\n]+)(\{.*\})?", re.MULTILINE) -TODO_TODO_RE = re.compile(r"(TODO):?\s*") +TODO_TODO_RE = re.compile(r"^(TODO):?\s*") def parse_todo_tag(tag) -> tuple[str, str]: @@ -23,7 +23,7 @@ def parse_todo_tag(tag) -> tuple[str, str]: if name == "by": dval = parser.parse(val) days_left = dval - now - style = "red" if days_left.days <= 0 else "" + style = "red" if days_left.days <= 0 else "yellow" return f"by {dval.date()} ({days_left.days})", style else: return f"{name}:{val}", "" @@ -39,14 +39,17 @@ def pull_todos(file: pathlib.Path): text = file.read_text() todos = ALL_TODO_RE.findall(text) for t in todos: - style = {"TODO": "yellow", "DONE": "#999999"}[t[0]] - tags, style_override = parse_todo_tag(t[2]) + tags, style = parse_todo_tag(t[2]) + if t[0] == "DONE": + style = "#999999" + elif t[0] == "IDEA": + style = "blue" yield { "file": file.name, "status": t[0], "description": t[1], "tags": tags, - "style": style_override or style, + "style": style, } @@ -85,7 +88,7 @@ def cli(): def get_files(dirname): if not dirname: dirname = "~/wiki/" - p = pathlib.Path(dirname).expanduser() + p = pathlib.Path(dirname[0]).expanduser() return p.rglob("*.md")