mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(fix)capture: respect blank lines in capture templates (#2203)
This commit is contained in:
committed by
GitHub
parent
01843a6486
commit
f144941dfb
@ -788,7 +788,7 @@ When ENSURE-NEWLINE, always ensure there's a newline behind."
|
|||||||
;; template does not start with any whitespace, and only ends with a single newline
|
;; template does not start with any whitespace, and only ends with a single newline
|
||||||
;;
|
;;
|
||||||
;; Instead, we restore the whitespace in the original template.
|
;; Instead, we restore the whitespace in the original template.
|
||||||
(setq template (replace-regexp-in-string "\n$" "" (org-capture-fill-template template)))
|
(setq template (replace-regexp-in-string "[\n]*\\'" "" (org-capture-fill-template template)))
|
||||||
(when (and ensure-newline
|
(when (and ensure-newline
|
||||||
(string-equal template-whitespace-content ""))
|
(string-equal template-whitespace-content ""))
|
||||||
(setq template-whitespace-content "\n"))
|
(setq template-whitespace-content "\n"))
|
||||||
|
@ -48,6 +48,11 @@
|
|||||||
(org-roam-capture--fill-template "foo\n\t\n")
|
(org-roam-capture--fill-template "foo\n\t\n")
|
||||||
:to-equal "foo\n\t\n"))
|
:to-equal "foo\n\t\n"))
|
||||||
|
|
||||||
|
(it "fills template without deleting newlines in its body"
|
||||||
|
(expect
|
||||||
|
(org-roam-capture--fill-template "foo\n\n\nbar\n\n")
|
||||||
|
:to-equal "foo\n\n\nbar\n\n"))
|
||||||
|
|
||||||
(it "expands templates when it's a function"
|
(it "expands templates when it's a function"
|
||||||
(expect
|
(expect
|
||||||
(org-roam-capture--fill-template (lambda () "foo"))
|
(org-roam-capture--fill-template (lambda () "foo"))
|
||||||
|
Reference in New Issue
Block a user