Creating html document notes with org-roam-bibtex

Hi @zaeph ,

A question of the evening. I have a lot of references from websites and blogs in my zotero… so in my biblio.bib file like :

@online{kuan_how_2020,
  title = {How {{To Take Smart Notes With Org}}-Mode -},
  author = {Kuan, Jethro},
  date = {2020-02-14},
  url = {https://blog.jethro.dev/posts/how_to_take_smart_notes_org/}
  urldate = {2020-06-16},
  file = {/home/manu/Zotero/storage/3C34ZK85/how_to_take_smart_notes_org.html},
  keywords = {emacs,org-mode,org-roam}
}

My question : Is it possible to create a note via orb-note-action? That would mean a configuration in org-ref but which one?
And more generally how do you manage web documents in zotero AND org-roam?
Have a nice evening.

org-note-actions is not for creating notes, but for running helm/ivy-like actions on the note.

ORB patches the Open notes action in org-ref and the Edit notes in helm-/ivy-bibtex, which are the commands you’re supposed to use to create your notes. ORB is mostly about helping you create your bibliographic notes by providing access to BibTeX fields during the template-expansion. Check our manual for details.

I know that we’re doing a bad job at explaining what ORB is doing, but this is something that I’m hoping to address soon with #830.

1 Like

Hi @zaeph,

If I wanted to modify orb-templates to be able to edit notes for pdf but also html documents how should I adapt it?

Hi @bepolymathe,

I don’t understand what you mean by being “able to edit notes for pdf and html documents”. Could you please elaborate?

Hi @mshevchuk ,

Yes, my explanations may not be very clear.

I use Zotero (with betterbibtex extension) to generate my bibliography in .bib file. It contains references to articles and books but also to many online documents (blog, press, etc) of which I only have an html copy. I would like to be able to use org-roam and org-roam-bibtex to take notes related to these html documents as I already do for pdf articles.

So I’m wondering how to modify my configuration (probably my template) to do this. Is it clearer?

@bepolymathe, not really, sorry.

First of all let’s fix up the terminology, this is often the reason why people misunderstand each other. So, BibTeX files do not contain references, they instead contain entries in the form of bibliographic records that follow a special BibTeX syntax. BibTeX records contain fields in the form of key = value pairs. A typical BibTeX record looks like this (examples are taken from here):

N.B. A BibTeX record starts with the "at" symbol and runs until the outermost 
balanced "}" symbol, everything else are comments

A BibTeX record
entry type: "article"
BibTeX key:  "einstein1905"
"author" is the name of a field (its key)
"Albert Einstein" is the the value of the filed "author"
------------------------------------
@article{einstein1905,
    author =       "Albert Einstein",
    title =        "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
        [{On} the electrodynamics of moving bodies]",
    journal =      "Annalen der Physik",
    volume =       "322",
    number =       "10",
    pages =        "891--921",
    year =         "1905",
    DOI =          "http://dx.doi.org/10.1002/andp.19053221004"
}

another BibTeX record
entry type: "book"
BibTeX key:  "latexcompanion1993"
------------------------------------
@book{latexcompanion1993,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The \LaTeX\ Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}

yet another BibTeX record
entry type: "misc"
BibTeX key:  "knuthwebsite"
------------------------------------
@misc{knuthwebsite,
    author    = "Donald Knuth",
    title     = "Knuth: Computers and Typesetting",
    url       = "http://www-cs-faculty.stanford.edu/\~{}uno/abcde.html"
}

Now, Org Roam package doesn’t care about BibTeX at all, it even doesn’t know BibTeX exists. With Org Roam you can take notes about anything you like.

Org Roam BibTeX package, however, offers some integration of BibTeX into Org Roam. It is able to read your bibliography .bib file or files and put the retrieved information into an Org Roam template when a note is created. This can be achieved if you have placed special placeholders into your org-roam-capture-templates or orb-templates. When you create a note from helm-bibtex or org-ref, before the note’s template is expanded by org-roam, org-roam-bibtex reads the corresponding BibTeX record (helm-bibtex or org-ref have told it which exactly record to read) and “preformats” the placeholders with the values of the corresponding fields. Typically, a placeholder contains the field name, e.g. ${author} will be replaced with “Albert Einstein”, ${journal} will be replaced with “Annalen der Physik” and so on. This is how you get #+ROAM_KEY: einstein1905 from #+ROAM_KEY: ${citekey}.

But Org Roam BibTeX is completely agnostic with regard to what entry types you have, e.g @article, @book or @misc. It also doesn’t care about field keys and values. It works equally well for all of them. It also doesn’t know and doesn’t care about PDFs or HTML when creating a note.

After you’ve created a note, it is possible to run orb-note-actions to access such commands as “open PDF file” or “open URL link”. When you call such an action, Org Roam BibTeX looks for the entry key stored in #+ROAM_KEY: property, looks for the BibTeX record with this key and retrieves the values from file or url fields. If these values are retrievable, i.e. present in the particular record, Org Roam BibTeX will run the commands to open the PDF or URL.

There theoretically can be bugs in Org Roam BibTeX or the packages it depends on that will cause it to fail or produce some errors if you have non-conventional BibTeX entry types, but none that I’m aware of.

If you happen to explain your workflow in more detail, like “first I run this command, then I run this command and finally I run this command and this is my configuration file together with the relevant BibTeX record”, and also explain what prevents you from creating notes from your "html documents ", I’ll be happy to help you.

Thank you for this detailed and educational response. I appreciate it.

Let’s try it step by step.

  1. I have this entry.

    @online{zotero-2512,
    title = {L’écrivain Philippe Besson nommé consul de France à Los Angeles},
    journaltitle = {Le Monde.fr},
    url = {https://www.lemonde.fr/politique/article/2018/08/29/l-ecrivain-philippe-besson-nomme-consul-de-france-a-los-angeles_5347732_823448.html},
    urldate = {2018-08-29},
    abstract = {L’auteur d’«~Un personnage de roman~», consacré à Emmanuel Macron, hérite d’une place très convoitée par les diplomates.},
    file = {/home/manu/Zotero/storage/KNM8UG8H/L’écrivain Philippe Besson nommé consul de France .html},
    langid = {french}
    }

  2. I find it in my bibliography thanks to helm-bibtex.

  1. I try to edit note

image

  1. I have a error message “Cannot resolve a template to values”

And for information, my template looks like :

(setq org-roam-capture-ref-templates
      '(("r" "ref" plain (function org-roam-capture--get-point)
         "%?"
         :file-name "${slug}"
         :head "#+TITLE: ${title}
#+ROAM_KEY: ${ref}
#+ROAM_ALIAS:
#+ROAM_TAGS: \"web\"
#+CREATED: %u
#+LAST_MODIFIED: %U
- tags :: \n\n"
         :unnarrowed t)))

Thank you! This is what I was asking for.

Could you please paste the value of orb-templates and org-roam-capture-templates. The first one is responsible for creating notes, but if its value is nil, then the second one is used.

Are you sure the error message reads “Cannot resolve a template to values”? I could not find this error message neither in our packages nor in the associated ones.

@bepolymathe, ok, I found what’s producing the error. I think the problem’s in your orb-templates or org-roam-capture-templates whichever you use.

Hi,

My orb-template

(setq orb-templates
      '(("r" "ref" plain (function org-roam-capture--get-point)
         ""
         :file-name "${slug}"
         :head "#+TITLE: ${=key=}: ${title}\n#+ROAM_KEY: ${ref}

- tags ::
- keywords :: ${keywords}

\n* ${title}\n  :PROPERTIES:\n  :Custom_ID: ${=key=}\n  :URL: ${url}\n  :AUTHOR: ${author-or-editor}\n  :NOTER_DOCUMENT: %(orb-process-file-field \"${=key=}\")\n  :NOTER_PAGE: \n  :END:\n\n"

 :unnarrowed t)))

My org-roam-capture-templates

(setq org-roam-capture-templates
  '(("d" "default" plain (function org-roam-capture--get-point)
     "%?"
     :file-name "${slug}"
     :head "#+TITLE: ${title}
#+ROAM_ALIAS:
#+ROAM_TAGS:
#+CREATED: %U
#+LAST_MODIFIED: %U\n
- tags :: \n\n"
     :unnarrowed t)))

@bepolymathe The problem here is that you have author-or-editor field set for pre-formatting in your template and in orb-preformat-keywords, but your BibTeX entry contains neither author nor editor fields. As far as I can see it, the article and book entries you get from PDF files in Zotero have the author field set, while the online entries you get from websites do not contain the author field, making an impression that “PDF documents” work and “HTML” do not work.

This is clearly a bad behaviour of org-roam-bibtex that should be fixed. Please, file a bug issue at org-roam-bibtex.

Meanwhile as a workaround, either populate your online entries with the author field, or remove "author-or-editor" from orb-preformat-keywords, or remove ${author-or-editor} placeholder from your template.

Thanks for that :+1:

DONE --» https://github.com/org-roam/org-roam-bibtex/issues/83

1 Like

Thank you!