Skip to content

Commit

Permalink
fix(roam-import): fix roam-date regex to match ordinal numbers in roa…
Browse files Browse the repository at this point in the history
…m dates more (athensresearch#1171)

strictly, removing the possibility of date
name conflicts.

closes athensresearch#1135

Co-authored-by: julio <jnavarro@webdoxclm.com>
Co-authored-by: jeff <tangj1122@gmail.com>
  • Loading branch information
3 people authored and korlaism committed Jul 19, 2021
1 parent 5a84437 commit b540523
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/cljc/athens/patterns.cljc
Expand Up @@ -24,12 +24,11 @@
(linked old-title)
(str "$1$3$4" new-title "$2$5")))


;; Positive Lookbehind: between 1 and 2 digits
;; One of an ordinal suffix, e.g. -st, -nd, -rd, -th, see https://en.wikipedia.org/wiki/Ordinal_indicator
;; Comma
;; Positive Lookahead: whitespace and 4 digits
(def roam-date #"(?<=\d{1,2})(st|nd|rd|th),(?=\s\d{4})")
;; Matches a date with an ordinal number (roam format), considering the correct ordinal
;; suffix based on the ending number of the date
;; Regular expression, with test cases can be found here https://regex101.com/r/vOzOl9/1
;; Any update to this should be done after testing it using the previous regex101 link
(def roam-date #"((?<=\s1\d)th|(?<=(\s|[023456789])\d)((?<=1)st|(?<=2)nd|(?<=3)rd|(?<=[4567890])th)),(?=\s\d{4})")


(defn date
Expand Down

0 comments on commit b540523

Please sign in to comment.