obsidian-day-planner
obsidian-day-planner copied to clipboard
Bullet list with leading number parsed as a task
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
Additional context Possible solution:
- Use a pattern list to enumerate all possible format
- Use regex to match numbers, at least filtered out numbers bigger than 24 or numbers comes with appended characters.
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.
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.
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 😄
I'll see what I can to.
@showaykerker any progress on opening a PR?
Sorry, I'm occupied by other projects since then, there's no much progress on this 😥