See my reply in a new thread: How to have a sequence of more than two newlines in a capture template? - #2 by wilya
TLDR: Only trailing whitespace are preserved.
To answer your question, if you comment out this line:
(defun org-roam-capture--fill-template (template &optional ensure-newline)
;; ... (other parts of the function) ...
;; Comment out or remove the following line to preserve newlines
;; (setq template (replace-regexp-in-string "[\n]*\\'" "" (org-capture-fill-template template)))
(when (and ensure-newline
(string-equal template-whitespace-content ""))
(setq template-whitespace-content "\n"))
(setq template (concat template template-whitespace-content))
template)
it should change the behavior of the function. However, I have no idea if this could have unpleasant second order effects (also called bugs).
You can redefine the org-roam-capture--fill-template
function in your Emacs configuration file.
(defun org-roam-capture--fill-template (template &optional ensure-newline)
;; ... (copy the original function definition here) ...
;; Comment out or remove the newline collapsing line
;; (setq template (replace-regexp-in-string "[\n]*\\'" "" (org-capture-fill-template template)))
;; ... (rest of the original function definition) ...
)
This approach effectively overrides the original function definition with your modified version. Keep in mind that when redefining functions from packages, it can lead to conflicts if the package’s implementation changes in the future.