mirror of
https://github.com/correl/org-roam-export-backlinks.git
synced 2024-11-25 11:09:54 +00:00
Add basic excerpt support
This commit is contained in:
parent
964dc22c3a
commit
c9d17e8fbb
2 changed files with 22 additions and 0 deletions
|
@ -34,5 +34,14 @@
|
|||
"Get Org link to BACKLINK."
|
||||
(concat "id:" (org-roam-node-id (org-roam-backlink-source-node backlink))))
|
||||
|
||||
(defun org-roam-export-backlink-excerpt (backlink)
|
||||
"Get the Org element containing the link from BACKLINK as an excerpt."
|
||||
(with-temp-buffer
|
||||
(insert-file-contents-literally (org-roam-node-file (org-roam-backlink-source-node backlink)))
|
||||
(goto-char (org-roam-backlink-point backlink))
|
||||
(let ((element (org-element-at-point)))
|
||||
(s-trim (buffer-substring (org-element-property :contents-begin element)
|
||||
(org-element-property :contents-end element))))))
|
||||
|
||||
(provide 'org-roam-export)
|
||||
;;; org-roam-export.el ends here
|
||||
|
|
13
tests.el
13
tests.el
|
@ -28,5 +28,18 @@
|
|||
(should (equal '("Ipsum > II")
|
||||
(seq-map #'org-roam-export-backlink-title (org-roam-backlinks-get (org-roam-node-from-id "d12a1ce4-3199-42f4-b39b-b68c03458669") :unique t)))))
|
||||
|
||||
(ert-deftest lorem-backlink-excerpt ()
|
||||
(should (equal '("Aliquam [[id:d12a1ce4-3199-42f4-b39b-b68c03458669][lorem]] ante, suscipit a lorem molestie, aliquet elementum eros. Proin
|
||||
mattis lacus nec dapibus auctor. Donec lacinia finibus ex vitae tempor.
|
||||
Suspendisse blandit, justo vitae placerat lacinia, eros tortor convallis nisi,
|
||||
fermentum sodales lorem augue at ligula. Nulla facilisi. Curabitur vel convallis
|
||||
tellus, a luctus mi. Donec sollicitudin erat erat, vel condimentum mauris tempus
|
||||
eget. Pellentesque hendrerit suscipit risus eu fermentum. Vivamus non urna
|
||||
commodo, lacinia odio vitae, blandit metus. Nam et tempus ipsum. Aenean lobortis
|
||||
mauris sit amet lorem accumsan blandit. Fusce eleifend, tellus non tristique
|
||||
auctor, ligula justo varius dolor, id bibendum nulla elit ac dui. Vestibulum
|
||||
sodales enim eget tristique tempor.")
|
||||
(seq-map #'org-roam-export-backlink-excerpt (org-roam-backlinks-get (org-roam-node-from-id "d12a1ce4-3199-42f4-b39b-b68c03458669") :unique t)))))
|
||||
|
||||
(provide 'tests)
|
||||
;;; tests.el ends here
|
||||
|
|
Loading…
Reference in a new issue