emacs-citar / citar-org-roam

citar/org-roam integration
GNU General Public License v3.0
101 stars 9 forks source link

Add optional filter function to `citar-org-roam-template-fields` #43

Open bdarcus opened 1 year ago

bdarcus commented 1 year ago

This is an example that suggests perhaps it might be worth enhancing citar-org-roam-template-fields to allow an optional filter function to be associated with a template field, as we do already in the citar template language. Here, we'd just want to pre-filter it.

In this case, the example filter might be ex-latex-to-org.

So maybe:

 (:citar-note   ("note")   'ex-latex-to-org)

Or, alternately, somehow hook this up to citar-display-transform-functions?


This says Better BibTeX exports these as LaTeX notes.

Here's an (untested) example adapted from https://github.com/org-roam/org-roam-bibtex/issues/178#issuecomment-798898300 that should work, to convert those notes to org.

(defun ex/latex-note-to-org (citekey)
  "Convert Better BibTeX exported LaTeX notes to org." ; Zotero annotations
  (let* ((note (citar-get-value "note" citekey))
         (pandoc-command "pandoc --from latex --to org")
         result)
    (with-temp-buffer
      (shell-command (format "echo \"%s\" | %s" note pandoc-command)
                     (current-buffer))
      (setq result (buffer-substring-no-properties (point-min) (point-max))))))

Just need to figure out how to hook it up with some specific output (insert into buffer, integrate into capture template, etc.).

Effectively, this is a sort of filter run on some content. It may be possible to adapt something like this to the new citar-org-roam capture template support.

Originally posted by @bdarcus in https://github.com/emacs-citar/citar/discussions/774#discussioncomment-5542563

bdarcus commented 1 year ago

Just need to hook this up to core citar.