diff --git a/doc/org-roam.org b/doc/org-roam.org index 6777081..139592b 100644 --- a/doc/org-roam.org +++ b/doc/org-roam.org @@ -711,6 +711,16 @@ citation key: :END: #+end_src +or + +#+begin_src org +,* Probabilistic Robotics +:PROPERTIES: +:ID: 51b7b82c-bbb4-4822-875a-ed548cffda10 +:ROAM_REFS: [cite:@thrun2005probabilistic] +:END: +#+end_src + for ~org-cite~, or: #+begin_src org diff --git a/doc/org-roam.texi b/doc/org-roam.texi index b408bc9..553e64e 100644 --- a/doc/org-roam.texi +++ b/doc/org-roam.texi @@ -1091,6 +1091,16 @@ citation key: :END: @end example +or + +@example +* Probabilistic Robotics +:PROPERTIES: +:ID: 51b7b82c-bbb4-4822-875a-ed548cffda10 +:ROAM_REFS: [cite:@@thrun2005probabilistic] +:END: +@end example + for @code{org-cite}, or: @example diff --git a/org-roam-db.el b/org-roam-db.el index 198bd98..efe5be4 100644 --- a/org-roam-db.el +++ b/org-roam-db.el @@ -482,9 +482,24 @@ INFO is the org-element parsed buffer." (let (rows) (dolist (ref refs) (save-match-data - (cond ((string-prefix-p "@" ref) + (cond (;; @citeKey + (string-prefix-p "@" ref) (push (vector node-id (substring ref 1) "cite") rows)) - ((string-match org-link-plain-re ref) + (;; [cite:@citeKey] + (string-prefix-p "[cite:" ref) + (condition-case nil + (let ((cite-obj (org-cite-parse-objects ref))) + (org-element-map cite-obj 'citation-reference + (lambda (cite) + (let ((key (org-element-property :key cite))) + (push (vector node-id key "cite") rows))))) + (error + (lwarn '(org-roam) :warning + "%s:%s\tInvalid cite %s, skipping..." (buffer-file-name) (point) ref)))) + (;; https://google.com, cite:citeKey + ;; Note: we use string-match here because it matches any link: e.g. [[cite:abc][abc]] + ;; But this form of matching is loose, and can accept invalid links e.g. [[cite:abc] + (string-match org-link-plain-re ref) (let ((link-type (match-string 1 ref)) (path (match-string 2 ref))) (if (and (boundp 'org-ref-cite-types)