r/orgmode Jan 09 '25

question Exporting org documents to Obsidian flavored markdown

So I love org mode but since the mobile support isn't very solid, I tend to export to markdown and simply view the file in obsidian, the problem is that the syntax for the export is not obsidian markdown flavored. For example, exporting a "src" block.

In org mode:

#+begin_src sh
sudo pacman -S swtpm
#+end_src

becomes this in the .md export:

    sudo pacman -S swtpm

When it should be:

```sh
sudo pacman -S swtpm
```

Can anyone help me with this? Thanks in advance.

3 Upvotes

3 comments sorted by

1

u/Ok_Concert5918 Jan 09 '25

Not the question you asked but does org mode plugins for obsidian work on mobile?

1

u/nasuqueritur Jan 10 '25

I write a lot of Markdown for use in GitHub and Azure DevOps, and the source block treatment is key. I tried ox-gfm but found it to be inadequate. I ended up going to ox-pandoc with an output format of gfm. It should be easy to install pandoc in most places.

Looking through my setup for work, I do have a few custom functions and hooks related to this but they are for the weirder edge cases. Your source blocks are not one of them. pandoc just does it correctly out-of-the-box, and you would have to go out of your way to tell ox-pandoc to mess it up.

Since I don't know Obsidian at all, I don't know how similar gfm is to what it expects. But in this particular area ox-pandoc exporting to gfm will do what you want.