obsidian-day-planner icon indicating copy to clipboard operation
obsidian-day-planner copied to clipboard

Bullet list with leading number parsed as a task

Open showaykerker opened this issue 11 months ago • 5 comments

Describe the bug As title, in a daily note, if a bullet list item contains leading number, it'll be considered a task, parsed and added to the timeline. Even for number bigger than 24.

To Reproduce In any daily note, add any of the lines below:

- 6 people were promoted today
- 15g salt
- 250g sugar

Expected behavior Formats like HH:MM or HH-HH (e.g. 10-12) are reasonable to parsed as time. 250g is no way to be treated in the same way.

Screenshots image

Additional context Possible solution:

  1. Use a pattern list to enumerate all possible format
  2. Use regex to match numbers, at least filtered out numbers bigger than 24 or numbers comes with appended characters.

showaykerker avatar Mar 07 '24 18:03 showaykerker

I believe I've identified a workaround for the issue at hand. However, given that implementing this workaround may impact the code structure, I propose discussing it with the author first to ensure alignment.

It appears that the issue stems from a compatibility issue with various time formats. The current regex limitation is quite broad, leading to most strings with numbers being parsed as time values.

To address this, I suggest removing some of the supported formats, see details in the picture attached. Implementing this solution will likely require using if-else conditions rather than relying solely on regex. I attempted to tackle this with pure regex initially, but it proved to be too complex.

image

Note that as a hour format, "03" should be used instead of "3".

I look forward to discussing this further and finding the most suitable approach to resolve the issue.

[Update] /\s([[0-1][0-9]|2[0-3]])\s?([apAP][mM])?\s(.+)|\s([0-1]?[0-9]\s?)([apAP][mM])\s(.+)|\s([0-1][0-9]|2[0-3])[\.\:]?([0-5][0-9])\s?([apAP][mM])?\s(.+)

This is so far the best I can get. It's hard to only considering time without context. image

showaykerker avatar Mar 11 '24 14:03 showaykerker

Hey, @showaykerker, could you submit a PR with the change?

If your approach with if-else statements is more readable than a huge regex, I'm all for it 😄

ivan-lednev avatar Mar 11 '24 17:03 ivan-lednev

I'll see what I can to.

showaykerker avatar Mar 12 '24 09:03 showaykerker

@showaykerker any progress on opening a PR?

aahventures avatar Jul 13 '24 12:07 aahventures

Sorry, I'm occupied by other projects since then, there's no much progress on this 😥

showaykerker avatar Jul 14 '24 02:07 showaykerker