mirror of
https://github.com/correl/org-roam-export-backlinks.git
synced 2024-11-22 03:00:12 +00:00
Add an export preprocessor
This commit is contained in:
parent
5cef9aa24d
commit
3998816f33
2 changed files with 21 additions and 4 deletions
|
@ -9,7 +9,7 @@
|
|||
;; Version: 0.0.1
|
||||
;; Keywords: abbrev bib c calendar comm convenience data docs emulations extensions faces files frames games hardware help hypermedia i18n internal languages lisp local maint mail matching mouse multimedia news outlines processes terminals tex tools unix vc wp
|
||||
;; Homepage: https://github.com/correlr/org-roam-export
|
||||
;; Package-Requires: ((emacs "24.4") (org-roam "2.2.1"))
|
||||
;; Package-Requires: ((emacs "25.1") (org-roam "2.2.1"))
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
|
@ -48,7 +48,7 @@
|
|||
(goto-char (org-roam-backlink-point backlink))
|
||||
(org-roam-export--excerpt)))
|
||||
|
||||
(defun org-roam-export-format-backlink (title 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)
|
||||
|
@ -57,5 +57,22 @@
|
|||
(insert excerpt))
|
||||
(buffer-string)))
|
||||
|
||||
(defun org-roam-export-format-backlink (backlink)
|
||||
"Format a BACKLINK for inclusion in an Org document."
|
||||
(org-roam-export--format-backlink
|
||||
(org-roam-export-backlink-title backlink)
|
||||
(org-roam-export-backlink-excerpt backlink)))
|
||||
|
||||
(defun org-roam-export-preprocessor (backend)
|
||||
"Append org-roam backlinks with content when applicable before
|
||||
passing to the org export BACKEND."
|
||||
(when-let ((node (org-roam-node-at-point)))
|
||||
(let ((backlinks (org-roam-backlinks-get node)))
|
||||
(when backlinks
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(insert (concat "\n* Backlinks\n"
|
||||
(string-join (mapcar #'org-roam-export-format-backlink backlinks)))))))))
|
||||
|
||||
(provide 'org-roam-export)
|
||||
;;; org-roam-export.el ends here
|
||||
|
|
4
tests.el
4
tests.el
|
@ -120,7 +120,7 @@ lobortis quam non eleifend. Pellentesque vitae imperdiet nisl.\n")
|
|||
|
||||
Paragraph text.
|
||||
"
|
||||
(org-roam-export-format-backlink
|
||||
(org-roam-export--format-backlink
|
||||
"Heading > Subheading"
|
||||
"Paragraph text.\n"))))
|
||||
|
||||
|
@ -137,7 +137,7 @@ Paragraph text.
|
|||
|
||||
Paragraph text.
|
||||
"
|
||||
(org-roam-export-format-backlink
|
||||
(org-roam-export--format-backlink
|
||||
"Heading"
|
||||
"** Subheading One
|
||||
|
||||
|
|
Loading…
Reference in a new issue