"Tom Alexander" <t...@fizz.buzz> writes: > Potentially related, org-mode is accepting this malformed timestamp from[1]: > ``` > <2016-02-14 Sun ++y> > ``` > > The org-mode documentation[2] only includes REST with TIME, defining TIME as > "H:MMREST". The above does not have any TIME but it accepts the timestamp > anyway: > ... > Perhaps that grammar is wrong and REST needs to be separated from TIME?
We have no internal consistency here, AFAIR. The actual matching is done with (defconst org-element--timestamp-regexp (concat org-ts-regexp-both "\\|" "\\(?:<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[dwmy]>\\)" "\\|" "\\(?:<%%\\(?:([^>\n]+)\\)>\\)") "Regexp matching any timestamp type object.") with org-ts-regexp-both matching (rx (seq (= 4 digit) "-" (= 2 digit) "-" (= 2 digit) (optional " " (*? nonl)))) (and also brackets) Then, `org-element-timestamp-parser' looks for DATE/TIME/REPEATERS/etc inside the above match, disregarding any order: (string-match "[012]?[0-9]:[0-5][0-9]\\(-\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)" date-start) (string-match "\\([.+]?\\+\\)\\([0-9]+\\)\\([hdwmy]\\)" raw-value) (string-match "\\(-\\)?-\\([0-9]+\\)\\([hdwmy]\\)" raw-value) However, not all the Org code is using org-element parser yet. Certain parts of Org are matching manually using a separate, more strict regexps, like org-ts-regexp0, org-ts-regexp1, ... So, we chose to use a more strict definition in org-syntax for the time being, before we consolidate things together in more uniform ways. As for the problem with REST you raised, I am inclined to remove it from syntax doc for the time being - it only creates more confusion, unfortunately. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>