Allow graph output filetype to be configurable, currently SVG is hardcoded

Hi friends. I love the ability to generate a graph of my org-roam nodes. Yesterday I tried out a new technique – I printed out a small graph of a book I’m reading, and took notes on that graph as I read. At the end, I went to Emacs and created nodes etc as needed to capture what I drew.

In the process, I learned that if you want to ‘posterize’ a large document in MacOS, the easiest way to do this is by making it a PDF file, and then using Acrobat to split your document up over multiple sheets of paper.

In order to get org-roam to generate a PDF rather than an SVG, I needed to change these two lines in org-roam-graph–build:

(temp-graph (make-temp-file "graph." nil ".svg")))

:command (,org-roam-graph-executable ,temp-dot “-Tsvg” “-o” ,temp-graph)`

When I changed the svgs to pdfs, everything worked just fine, and the org-protocol links back to Emacs all still worked too.

I haven’t tried doing this yet, but was curious to know if people thought this would be a reasonable PR to submit, along with changing the code above to use this new variable:

(defcustom org-roam-graph-filetype "svg"
  "Type of image file to create.
It may be one of the following:
  - svg
  - pdf"
  :type '(choice
          (const    :tag "svg")
          (const    :tag "pdf"))
  :group 'org-roam)

I would ideally propose this change for both the v1 and v2 branches.

p.s. of course we could add whatever other suffixes we want, and/or make it so the suffix is just a string and people can change it to whatever they think might work in dot

p.p.s. Is this a reasonable post to make here on discourse or should I have just posted this as an issue on github?

If I understand what you’re proposing (that the output format be configurable), your title is a bit misleading :wink:

I must need an editor – what title would be better? :slight_smile:

Maybe “allow graph output format to be configurable”?

1 Like

Open to a PR here.

I removed the graphing support temporarily in v2, because it needs a rewrite for the new database schema anyway. The code should be simplified a little. You’re welcome to try to add it back!

OK, here’s my first org-roam PR :slight_smile:

1 Like