mirror of
https://github.com/correl/org-roam-export-backlinks.git
synced 2024-11-21 19:18:36 +00:00
Fix subtree excerpts
Subtrees should include their initial heading and full body.
This commit is contained in:
parent
c104206c91
commit
e0b67c4396
2 changed files with 12 additions and 6 deletions
|
@ -37,10 +37,13 @@
|
|||
"Extract an excerpt from ELEMENT in BUFFER."
|
||||
(with-current-buffer (or buffer (current-buffer))
|
||||
(let ((element (or element (org-element-at-point))))
|
||||
(if (eq 'headline (org-element-type element))
|
||||
(progn (org-mark-subtree)
|
||||
(buffer-substring (point) (mark)))
|
||||
(if-let ((begin (org-element-property :contents-begin element))
|
||||
(end (org-element-property :contents-end element)))
|
||||
(buffer-substring begin end)
|
||||
""))))
|
||||
"")))))
|
||||
|
||||
(defun org-roam-export-backlink-excerpt (backlink)
|
||||
"Get the Org element containing the link from BACKLINK as an excerpt."
|
||||
|
|
7
tests.el
7
tests.el
|
@ -79,18 +79,21 @@ Opening paragraph.
|
|||
(ert-deftest excerpt-heading-with-subheadings-test ()
|
||||
(with-test-document
|
||||
(goto-line 8)
|
||||
(should (equal " Heading one paragraph.
|
||||
(should (equal "* Heading One
|
||||
|
||||
Heading one paragraph.
|
||||
|
||||
** Subheading One A
|
||||
|
||||
- List item 1
|
||||
- List item 2
|
||||
|
||||
" (org-roam-export--excerpt)))))
|
||||
|
||||
(ert-deftest excerpt-simple-heading-test ()
|
||||
(with-test-document
|
||||
(goto-line 17)
|
||||
(should (equal " Heading two paragraph.\n" (org-roam-export--excerpt)))))
|
||||
(should (equal "* Heading Two\n\n Heading two paragraph.\n" (org-roam-export--excerpt)))))
|
||||
|
||||
(ert-deftest lorem-backlink-excerpt ()
|
||||
(should (equal '("Aliquam [[id:d12a1ce4-3199-42f4-b39b-b68c03458669][lorem]] ante, suscipit a lorem molestie, aliquet elementum eros. Proin
|
||||
|
|
Loading…
Reference in a new issue