PoiScript / orgize

A Rust library for parsing org-mode files.
https://poiscript.github.io/orgize/
MIT License
278 stars 34 forks source link

FR: Timestamps: Accept timestamps with DAYNAME, repeater, and delay in any order #28

Closed calmofthestorm closed 7 months ago

calmofthestorm commented 4 years ago

The Org spec requires the order be DAYNAME, then repeater-or-delay up to twice, but org-mode and org-element are robust, and will parse them in any order. So for example, these would all be accepted identically:

[2020-01-01 5:05 .+1w Fri --2d] [2020-01-01 5:05 .+1w --2d Fri] [2020-01-01 5:05 Fri .+1w --2d]

also valid is [2020-01-01 5:05 .+1w --2d]; covered under #27 .

calmofthestorm commented 4 years ago

32 partially fixes this by accepting repeater and delay in either order. Dayname still must precede them, however.

PoiScript commented 7 months ago

I just checked the implementation of parsing timestamp in org-elements api and find out it's quite flexible. The org-element parser will first accepts any string that starts with [yyyy-mm-dd and ends with ] as valid timestamp, then try to extract time/repeater/delay out of it.

It's possible for orgize to follow the same logic as org-elements, but I think it's more like implementation details instead of edge cases we need to handle. People would not write [2003-09-16 09:09-a 09:09-10:09] or [2003-09-16 abc abc bac 07:09-08:09]--[2003-09-16 09:09-09:09-09] and expect there're valid timestamps.