mirror of
https://github.com/correl/org-roam-export-backlinks.git
synced 2025-03-27 01:11:46 -09:00
Backlink Formatting
This commit is contained in:
parent
841202288a
commit
5cef9aa24d
2 changed files with 44 additions and 0 deletions
|
@ -48,5 +48,14 @@
|
|||
(goto-char (org-roam-backlink-point backlink))
|
||||
(org-roam-export--excerpt)))
|
||||
|
||||
(defun org-roam-export-format-backlink (title excerpt)
|
||||
"Format a backlink with TITLE and EXCERPT for inclusion in an Org document."
|
||||
(with-temp-buffer
|
||||
(org-mode)
|
||||
(insert "** " title "\n\n")
|
||||
(if (string-match-p "^\*+ " excerpt) (org-paste-subtree 3 excerpt)
|
||||
(insert excerpt))
|
||||
(buffer-string)))
|
||||
|
||||
(provide 'org-roam-export)
|
||||
;;; org-roam-export.el ends here
|
||||
|
|
35
tests.el
35
tests.el
|
@ -115,5 +115,40 @@ venenatis eget. Proin laoreet nulla a enim bibendum finibus. Proin mattis
|
|||
lobortis quam non eleifend. Pellentesque vitae imperdiet nisl.\n")
|
||||
(mapcar #'org-roam-export-backlink-excerpt (org-roam-backlinks-get (org-roam-node-from-id "e6c17c1a-6b05-40d2-a01f-b147633c51b1") :unique t)))))
|
||||
|
||||
(ert-deftest format-backlink-test ()
|
||||
(should (equal "** Heading > Subheading
|
||||
|
||||
Paragraph text.
|
||||
"
|
||||
(org-roam-export-format-backlink
|
||||
"Heading > Subheading"
|
||||
"Paragraph text.\n"))))
|
||||
|
||||
(ert-deftest format-backlink-with-subheadings ()
|
||||
(should (equal "** Heading
|
||||
|
||||
*** Subheading One
|
||||
|
||||
Paragraph text.
|
||||
|
||||
**** Subheading Two
|
||||
|
||||
***** Subheading Two A
|
||||
|
||||
Paragraph text.
|
||||
"
|
||||
(org-roam-export-format-backlink
|
||||
"Heading"
|
||||
"** Subheading One
|
||||
|
||||
Paragraph text.
|
||||
|
||||
*** Subheading Two
|
||||
|
||||
**** Subheading Two A
|
||||
|
||||
Paragraph text.
|
||||
"))))
|
||||
|
||||
(provide 'tests)
|
||||
;;; tests.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue