Passing protocol capture text with quotations inside

Greetings

I have an org-roam-capture-ref template that mostly works great for capturing selections of web pages via org-protocol.

  (setq org-roam-capture-ref-templates
        '(("r" "ref" entry
           "* ${title}\n#+created: %U\n\n** Item\n#+BEGIN_QUOTE\n%(replace-regexp-in-string \"^\" \" \" \"${body}\")\n#+END_QUOTE\n"
           :if-new (file+head "webrefs/%<%Y%m%d%H%M%S>-webref.org"
                              "\n#+FILETAGS: %?\n#+ROAM_TAGS: \n")
            :unnarrowed t :empty-lines 1)))

This works well in taking the ${body} of selected text in my browser and placing it the above template.

The problem I have is when some of the text I select contains a quotation-mark ("), emacs tries to parse the quoted word as a variable and gives me an undefined var error.

I’ve even tried creating a wrapper function to strip quotation marks but that too gets parsed and throws the same error.

I am pretty new to emacs/elisp so don’t if there’s an easy way to prevent ${body} from being parsed or if this is a bug in org-roam.

I have a similar template for org-capture that does work fine with quotation marks and doesn’t have this difficulty.

Thanks!
-Boodle

1 Like